This commit is contained in:
Matteo Pagliazzi
2020-05-07 16:15:11 +02:00
parent 613895e294
commit ebd22296df
2 changed files with 30 additions and 22 deletions

View File

@@ -23,12 +23,16 @@ forOwn(backgrounds, (value, key) => {
const appearances = { const appearances = {
hair, hair, NO appearances.hair.{bangs|base|beard|color|flower|mustache}[key].set.setPrice and .key
shirt: shirts, shirt: shirts, appearances.shirt[key].set.setPrice and .key
size: sizes, size: sizes, NO, does not have cost
skin: skins, skin: skins, OK, appearances.skin[key].set.setPrice and .key
chair: chairs, chair: chairs, NO, does not have cost
background: reorderedBgs, background: reorderedBgs, OK appearances.backgroud[key].set.setPrice and .key
}; };
^ check with get(path) after validating name because hair are nested for example
^ if item.set exist -> use item.setPrice
^ what about other items in set?
export default appearances; export default appearances;

View File

@@ -7,11 +7,12 @@ import { removeItemByPath } from './pinnedGearUtils';
import getItemInfo from '../libs/getItemInfo'; import getItemInfo from '../libs/getItemInfo';
import content from '../content/index'; import content from '../content/index';
function determineCost (setType, isFullSet, set) { /**
if (isBackground) { * Splits `items.gear.owned.headAccessory_wolfEars` into `items.gear.owned`
return isFullSet ? 3.75 : 1.75; * and `headAccessory_wolfEars`
} */
return isFullSet ? 1.25 : 0.5; function splitPathItem (path) {
return path.match(/(.+)\.([^.]+)/).splice(1);
} }
/** /**
@@ -43,37 +44,38 @@ function getSet (setType, firstPath) {
: content.appearance[setType][itemKey]; : content.appearance[setType][itemKey];
if (!item) return invalidSet(); if (!item) return invalidSet();
// Only animal gear sets are unlockable
if (setType === 'gear' && item.gearSet !== 'animal') return invalidSet();
if (setType === 'gear') { if (setType === 'gear') {
// Only animal gear sets are unlockable
if (item.gearSet !== 'animal') return invalidSet();
} else { } else {
return item.set return item.set
} }
} }
//Add comment
function determineCost (setType, isFullSet, set) {
if (isBackground) {
return isFullSet ? 3.75 : 1.75;
}
return isFullSet ? 1.25 : 0.5;
}
//Add comment
function alreadyUnlocked (user, path) { function alreadyUnlocked (user, path) {
return isGear(path) return isGear(path)
? get(user, path) !== undefined ? get(user, path) !== undefined
: get(user, `purchased.${path}`); : get(user, `purchased.${path}`);
} }
//Add comment
function setAsObject (target, key, value) { function setAsObject (target, key, value) {
// Using Object so path[1] won't create an array but an object {path: {1: value}} // Using Object so path[1] won't create an array but an object {path: {1: value}}
setWith(target, key, value, Object); setWith(target, key, value, Object);
} }
/**
* Splits `items.gear.owned.headAccessory_wolfEars` into `items.gear.owned`
* and `headAccessory_wolfEars`
*/
function splitPathItem (path) {
return path.match(/(.+)\.([^.]+)/).splice(1);
}
/** /**
* `markModified` does not exist on frontend users * `markModified` does not exist on frontend users
*/ */
@@ -81,6 +83,7 @@ function markModified (user, path) {
if (user.markModified) user.markModified(path); if (user.markModified) user.markModified(path);
} }
//Add comment
function purchaseItem (path, user) { function purchaseItem (path, user) {
if (isGear(path)) { if (isGear(path)) {
setAsObject(user, path, true); setAsObject(user, path, true);
@@ -93,6 +96,7 @@ function purchaseItem (path, user) {
} }
} }
//Add comment
function buildResponse ({ purchased, preference, items }, ownsAlready, language) { function buildResponse ({ purchased, preference, items }, ownsAlready, language) {
const response = [ const response = [
{ purchased, preference, items }, { purchased, preference, items },