diff --git a/website/common/script/content/appearance/index.js b/website/common/script/content/appearance/index.js index 2c65beb9ce..3ffe67e57c 100644 --- a/website/common/script/content/appearance/index.js +++ b/website/common/script/content/appearance/index.js @@ -23,12 +23,16 @@ forOwn(backgrounds, (value, key) => { const appearances = { - hair, - shirt: shirts, - size: sizes, - skin: skins, - chair: chairs, - background: reorderedBgs, + hair, NO appearances.hair.{bangs|base|beard|color|flower|mustache}[key].set.setPrice and .key + shirt: shirts, appearances.shirt[key].set.setPrice and .key + size: sizes, NO, does not have cost + skin: skins, OK, appearances.skin[key].set.setPrice and .key + chair: chairs, NO, does not have cost + 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; diff --git a/website/common/script/ops/unlock.js b/website/common/script/ops/unlock.js index aafa10aa14..c318ed600d 100644 --- a/website/common/script/ops/unlock.js +++ b/website/common/script/ops/unlock.js @@ -7,11 +7,12 @@ import { removeItemByPath } from './pinnedGearUtils'; import getItemInfo from '../libs/getItemInfo'; import content from '../content/index'; -function determineCost (setType, isFullSet, set) { - if (isBackground) { - return isFullSet ? 3.75 : 1.75; - } - return isFullSet ? 1.25 : 0.5; +/** + * Splits `items.gear.owned.headAccessory_wolfEars` into `items.gear.owned` + * and `headAccessory_wolfEars` + */ +function splitPathItem (path) { + return path.match(/(.+)\.([^.]+)/).splice(1); } /** @@ -43,37 +44,38 @@ function getSet (setType, firstPath) { : content.appearance[setType][itemKey]; if (!item) return invalidSet(); - // Only animal gear sets are unlockable - if (setType === 'gear' && item.gearSet !== 'animal') return invalidSet(); - if (setType === 'gear') { + // Only animal gear sets are unlockable + if (item.gearSet !== 'animal') return invalidSet(); } else { 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) { return isGear(path) ? get(user, path) !== undefined : get(user, `purchased.${path}`); } +//Add comment function setAsObject (target, key, value) { // Using Object so path[1] won't create an array but an object {path: {1: value}} 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 */ @@ -81,6 +83,7 @@ function markModified (user, path) { if (user.markModified) user.markModified(path); } +//Add comment function purchaseItem (path, user) { if (isGear(path)) { setAsObject(user, path, true); @@ -93,6 +96,7 @@ function purchaseItem (path, user) { } } +//Add comment function buildResponse ({ purchased, preference, items }, ownsAlready, language) { const response = [ { purchased, preference, items },