wip: fix setting (some) items values in the hall of heroes (#11133)

This commit is contained in:
Matteo Pagliazzi
2019-04-25 22:41:43 +02:00
committed by GitHub
parent 99dec2eb0c
commit 9d473cc92e
3 changed files with 71 additions and 2 deletions

View File

@@ -54,4 +54,24 @@ export function validateItemPath (itemPath) {
if (itemPath.indexOf('items.quests') === 0) {
return Boolean(shared.content.quests[key]);
}
}
// When passed a value of an item in the user object it'll convert the
// value to the correct format.
// Example a numeric string like "5" applied to a food item (expecting an interger)
// will be converted to the number 5
// TODO cast the correct value for `items.gear.owned`
export function castItemVal (itemPath, itemVal) {
if (
itemPath.indexOf('items.pets') === 0 ||
itemPath.indexOf('items.eggs') === 0 ||
itemPath.indexOf('items.hatchingPotions') === 0 ||
itemPath.indexOf('items.food') === 0 ||
itemPath.indexOf('items.mounts') === 0 ||
itemPath.indexOf('items.quests') === 0
) {
return Number(itemVal);
}
return itemVal;
}