Hall Fixes (#11403)

* fix(hall): correctly casts owned gear and mounts

* typo
This commit is contained in:
Matteo Pagliazzi
2019-10-06 17:08:11 +02:00
committed by GitHub
parent ca7399f6c1
commit 16c8825b2b
2 changed files with 22 additions and 5 deletions

View File

@@ -60,18 +60,26 @@ export function validateItemPath (itemPath) {
// 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);
}
if (
itemPath.indexOf('items.mounts') === 0 ||
itemPath.indexOf('items.gear.owned') === 0
) {
if (itemVal === 'true') return true;
if (itemVal === 'false') return false;
return Boolean(itemVal);
}
return itemVal;
}