mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 07:37:25 +01:00
WIP(shops): fixes and Hall of Heroes update
This commit is contained in:
@@ -88,7 +88,8 @@ export function castItemVal (itemPath, itemVal) {
|
||||
if (itemPath.indexOf('items.mounts') === 0) {
|
||||
// Mounts are true when you own them and null when you have used Keys to the Kennel
|
||||
// to release them.
|
||||
// They are never false but allow 'false' to be null in case of user error.
|
||||
// Empty string or undefined means "unset" i.e. never owned.
|
||||
if (['', 'undefined'].includes(itemVal)) return undefined;
|
||||
if (itemVal === 'null' || itemVal === 'false') return null;
|
||||
if (itemVal) return true; // any truthy value
|
||||
return null; // any false value
|
||||
@@ -96,8 +97,8 @@ export function castItemVal (itemPath, itemVal) {
|
||||
|
||||
if (itemPath.indexOf('items.gear.owned') === 0) {
|
||||
// Gear is true when you own it and false if you previously owned it but lost it (e.g., Death)
|
||||
// It is never null but allow 'null' to be false in case of user error.
|
||||
if (itemVal === 'false' || itemVal === 'null') return false;
|
||||
// Null, empty string, or undefined are taken to mean "unset" i.e. never owned.
|
||||
if (['null', '', 'undefined'].includes(itemVal)) return undefined;
|
||||
return Boolean(itemVal);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user