diff --git a/website/client/src/store/actions/shops.js b/website/client/src/store/actions/shops.js index e79beb187f..c0ee965045 100644 --- a/website/client/src/store/actions/shops.js +++ b/website/client/src/store/actions/shops.js @@ -60,7 +60,10 @@ async function buyArmoire (store, params) { const isExperience = item.type === 'experience'; if (item.type === 'gear') { - store.state.user.data.items.gear.owned[item.dropKey] = true; + store.state.user.data.items.gear.owned = { + ...store.state.user.data.items.gear.owned, + [item.dropKey]: true, + }; } if (item.type === 'food') { diff --git a/website/common/script/content/loginIncentives.js b/website/common/script/content/loginIncentives.js index c63b8b4fdd..4a53cd22d4 100644 --- a/website/common/script/content/loginIncentives.js +++ b/website/common/script/content/loginIncentives.js @@ -9,7 +9,10 @@ export default function getLoginIncentives (api) { rewardKey: ['armor_special_bardRobes'], reward: [api.gear.flat.armor_special_bardRobes], assignReward: function assignReward (user) { - user.items.gear.owned.armor_special_bardRobes = true; // eslint-disable-line camelcase + user.items.gear.owned = { + ...user.items.gear.owned, + armor_special_bardRobes: true, + }; // eslint-disable-line camelcase if (user.markModified) user.markModified('items.gear.owned'); }, }, @@ -30,7 +33,10 @@ export default function getLoginIncentives (api) { rewardKey: ['head_special_bardHat'], reward: [api.gear.flat.head_special_bardHat], assignReward: function assignReward (user) { - user.items.gear.owned.head_special_bardHat = true; // eslint-disable-line camelcase + user.items.gear.owned = { + ...user.items.gear.owned, + head_special_bardHat: true, + }; // eslint-disable-line camelcase if (user.markModified) user.markModified('items.gear.owned'); }, }, @@ -39,7 +45,10 @@ export default function getLoginIncentives (api) { reward: [api.hatchingPotions.RoyalPurple], assignReward: function assignReward (user) { if (!user.items.hatchingPotions.RoyalPurple) user.items.hatchingPotions.RoyalPurple = 0; - user.items.hatchingPotions.RoyalPurple += 1; + user.items.hatchingPotions = { + ...user.items.hatchingPotions, + RoyalPurple: user.items.hatchingPotions.RoyalPurple + 1, + }; if (user.markModified) user.markModified('items.hatchingPotions'); }, }, @@ -48,11 +57,20 @@ export default function getLoginIncentives (api) { reward: [api.food.Chocolate, api.food.Meat, api.food.CottonCandyPink], assignReward: function assignReward (user) { if (!user.items.food.Chocolate) user.items.food.Chocolate = 0; - user.items.food.Chocolate += 1; + user.items.food = { + ...user.items.food, + Chocolate: user.items.food.Chocolate + 1, + }; if (!user.items.food.Meat) user.items.food.Meat = 0; - user.items.food.Meat += 1; + user.items.food = { + ...user.items.food, + Meat: user.items.food.Meat + 1, + }; if (!user.items.food.CottonCandyPink) user.items.food.CottonCandyPink = 0; - user.items.food.CottonCandyPink += 1; + user.items.food = { + ...user.items.food, + CottonCandyPink: user.items.food.CottonCandyPink + 1, + }; if (user.markModified) user.markModified('items.food'); }, }, @@ -61,7 +79,10 @@ export default function getLoginIncentives (api) { reward: [api.quests.moon1], assignReward: function assignReward (user) { if (!user.items.quests.moon1) user.items.quests.moon1 = 0; - user.items.quests.moon1 += 1; + user.items.quests = { + ...user.items.quests, + moon1: user.items.quests.moon1 + 1, + }; if (user.markModified) user.markModified('items.quests'); }, }, @@ -70,7 +91,10 @@ export default function getLoginIncentives (api) { reward: [api.hatchingPotions.RoyalPurple], assignReward: function assignReward (user) { if (!user.items.hatchingPotions.RoyalPurple) user.items.hatchingPotions.RoyalPurple = 0; - user.items.hatchingPotions.RoyalPurple += 1; + user.items.hatchingPotions = { + ...user.items.hatchingPotions, + RoyalPurple: user.items.hatchingPotions.RoyalPurple + 1, + }; if (user.markModified) user.markModified('items.hatchingPotions'); }, }, @@ -79,11 +103,20 @@ export default function getLoginIncentives (api) { reward: [api.food.Strawberry, api.food.Potatoe, api.food.CottonCandyBlue], assignReward: function assignReward (user) { if (!user.items.food.Strawberry) user.items.food.Strawberry = 0; - user.items.food.Strawberry += 1; + user.items.food = { + ...user.items.food, + Strawberry: user.items.food.Strawberry + 1, + }; if (!user.items.food.Potatoe) user.items.food.Potatoe = 0; - user.items.food.Potatoe += 1; + user.items.food = { + ...user.items.food, + Potatoe: user.items.food.Potatoe + 1, + }; if (!user.items.food.CottonCandyBlue) user.items.food.CottonCandyBlue = 0; - user.items.food.CottonCandyBlue += 1; + user.items.food = { + ...user.items.food, + CottonCandyBlue: user.items.food.CottonCandyBlue + 1, + }; if (user.markModified) user.markModified('items.food'); }, }, @@ -91,7 +124,10 @@ export default function getLoginIncentives (api) { rewardKey: ['weapon_special_bardInstrument'], reward: [api.gear.flat.weapon_special_bardInstrument], assignReward: function assignReward (user) { - user.items.gear.owned.weapon_special_bardInstrument = true; // eslint-disable-line camelcase + user.items.gear.owned = { + ...user.items.gear.owned, + weapon_special_bardInstrument: true, + }; // eslint-disable-line camelcase if (user.markModified) user.markModified('items.gear.owned'); }, }, @@ -100,7 +136,10 @@ export default function getLoginIncentives (api) { reward: [api.quests.moon2], assignReward: function assignReward (user) { if (!user.items.quests.moon2) user.items.quests.moon2 = 0; - user.items.quests.moon2 += 1; + user.items.quests = { + ...user.items.quests, + moon2: user.items.quests.moon2 + 1, + }; if (user.markModified) user.markModified('items.quests'); }, }, @@ -109,7 +148,10 @@ export default function getLoginIncentives (api) { reward: [api.hatchingPotions.RoyalPurple], assignReward: function assignReward (user) { if (!user.items.hatchingPotions.RoyalPurple) user.items.hatchingPotions.RoyalPurple = 0; - user.items.hatchingPotions.RoyalPurple += 1; + user.items.hatchingPotions = { + ...user.items.hatchingPotions, + RoyalPurple: user.items.hatchingPotions.RoyalPurple + 1, + }; if (user.markModified) user.markModified('items.hatchingPotions'); }, }, @@ -118,13 +160,25 @@ export default function getLoginIncentives (api) { reward: [api.food.Fish, api.food.Milk, api.food.RottenMeat, api.food.Honey], assignReward: function assignReward (user) { if (!user.items.food.Fish) user.items.food.Fish = 0; - user.items.food.Fish += 1; + user.items.food = { + ...user.items.food, + Fish: user.items.food.Fish + 1, + }; if (!user.items.food.Milk) user.items.food.Milk = 0; - user.items.food.Milk += 1; + user.items.food = { + ...user.items.food, + Milk: user.items.food.Milk + 1, + }; if (!user.items.food.RottenMeat) user.items.food.RottenMeat = 0; - user.items.food.RottenMeat += 1; + user.items.food = { + ...user.items.food, + RottenMeat: user.items.food.RottenMeat + 1, + }; if (!user.items.food.Honey) user.items.food.Honey = 0; - user.items.food.Honey += 1; + user.items.food = { + ...user.items.food, + Honey: user.items.food.Honey + 1, + }; if (user.markModified) user.markModified('items.food'); }, }, @@ -133,7 +187,10 @@ export default function getLoginIncentives (api) { reward: [api.hatchingPotions.RoyalPurple], assignReward: function assignReward (user) { if (!user.items.hatchingPotions.RoyalPurple) user.items.hatchingPotions.RoyalPurple = 0; - user.items.hatchingPotions.RoyalPurple += 1; + user.items.hatchingPotions = { + ...user.items.hatchingPotions, + RoyalPurple: user.items.hatchingPotions.RoyalPurple + 1, + }; if (user.markModified) user.markModified('items.hatchingPotions'); }, }, @@ -142,7 +199,10 @@ export default function getLoginIncentives (api) { reward: [api.quests.moon3], assignReward: function assignReward (user) { if (!user.items.quests.moon3) user.items.quests.moon3 = 0; - user.items.quests.moon3 += 1; + user.items.quests = { + ...user.items.quests, + moon3: user.items.quests.moon3 + 1, + }; if (user.markModified) user.markModified('items.quests'); }, }, @@ -151,7 +211,10 @@ export default function getLoginIncentives (api) { reward: [api.hatchingPotions.RoyalPurple], assignReward: function assignReward (user) { if (!user.items.hatchingPotions.RoyalPurple) user.items.hatchingPotions.RoyalPurple = 0; - user.items.hatchingPotions.RoyalPurple += 1; + user.items.hatchingPotions = { + ...user.items.hatchingPotions, + RoyalPurple: user.items.hatchingPotions.RoyalPurple + 1, + }; if (user.markModified) user.markModified('items.hatchingPotions'); }, }, @@ -160,7 +223,10 @@ export default function getLoginIncentives (api) { reward: [api.food.Saddle], assignReward: function assignReward (user) { if (!user.items.food.Saddle) user.items.food.Saddle = 0; - user.items.food.Saddle += 1; + user.items.food = { + ...user.items.food, + Saddle: user.items.food.Saddle + 1, + }; if (user.markModified) user.markModified('items.food'); }, }, @@ -169,7 +235,10 @@ export default function getLoginIncentives (api) { reward: [api.hatchingPotions.RoyalPurple], assignReward: function assignReward (user) { if (!user.items.hatchingPotions.RoyalPurple) user.items.hatchingPotions.RoyalPurple = 0; - user.items.hatchingPotions.RoyalPurple += 1; + user.items.hatchingPotions = { + ...user.items.hatchingPotions, + RoyalPurple: user.items.hatchingPotions.RoyalPurple + 1, + }; if (user.markModified) user.markModified('items.hatchingPotions'); }, }, @@ -177,7 +246,10 @@ export default function getLoginIncentives (api) { rewardKey: ['slim_armor_special_pageArmor'], reward: [api.gear.flat.armor_special_pageArmor], assignReward: function assignReward (user) { - user.items.gear.owned.armor_special_pageArmor = true; // eslint-disable-line camelcase + user.items.gear.owned = { + ...user.items.gear.owned, + armor_special_pageArmor: true, + }; // eslint-disable-line camelcase if (user.markModified) user.markModified('items.gear.owned'); }, }, @@ -186,7 +258,10 @@ export default function getLoginIncentives (api) { reward: [api.hatchingPotions.RoyalPurple], assignReward: function assignReward (user) { if (!user.items.hatchingPotions.RoyalPurple) user.items.hatchingPotions.RoyalPurple = 0; - user.items.hatchingPotions.RoyalPurple += 1; + user.items.hatchingPotions = { + ...user.items.hatchingPotions, + RoyalPurple: user.items.hatchingPotions.RoyalPurple + 1, + }; if (user.markModified) user.markModified('items.hatchingPotions'); }, }, @@ -194,7 +269,10 @@ export default function getLoginIncentives (api) { rewardKey: ['head_special_pageHelm'], reward: [api.gear.flat.head_special_pageHelm], assignReward: function assignReward (user) { - user.items.gear.owned.head_special_pageHelm = true; // eslint-disable-line camelcase + user.items.gear.owned = { + ...user.items.gear.owned, + head_special_pageHelm: true, + }; // eslint-disable-line camelcase if (user.markModified) user.markModified('items.gear.owned'); }, }, @@ -203,7 +281,10 @@ export default function getLoginIncentives (api) { reward: [api.hatchingPotions.RoyalPurple], assignReward: function assignReward (user) { if (!user.items.hatchingPotions.RoyalPurple) user.items.hatchingPotions.RoyalPurple = 0; - user.items.hatchingPotions.RoyalPurple += 1; + user.items.hatchingPotions = { + ...user.items.hatchingPotions, + RoyalPurple: user.items.hatchingPotions.RoyalPurple + 1, + }; if (user.markModified) user.markModified('items.hatchingPotions'); }, }, @@ -211,7 +292,10 @@ export default function getLoginIncentives (api) { rewardKey: ['weapon_special_pageBanner'], reward: [api.gear.flat.weapon_special_pageBanner], assignReward: function assignReward (user) { - user.items.gear.owned.weapon_special_pageBanner = true; // eslint-disable-line camelcase + user.items.gear.owned = { + ...user.items.gear.owned, + weapon_special_pageBanner: true, + }; // eslint-disable-line camelcase if (user.markModified) user.markModified('items.gear.owned'); }, }, @@ -220,7 +304,10 @@ export default function getLoginIncentives (api) { reward: [api.hatchingPotions.RoyalPurple], assignReward: function assignReward (user) { if (!user.items.hatchingPotions.RoyalPurple) user.items.hatchingPotions.RoyalPurple = 0; - user.items.hatchingPotions.RoyalPurple += 1; + user.items.hatchingPotions = { + ...user.items.hatchingPotions, + RoyalPurple: user.items.hatchingPotions.RoyalPurple + 1, + }; if (user.markModified) user.markModified('items.hatchingPotions'); }, }, @@ -228,7 +315,10 @@ export default function getLoginIncentives (api) { rewardKey: ['shield_special_diamondStave'], reward: [api.gear.flat.shield_special_diamondStave], assignReward: function assignReward (user) { - user.items.gear.owned.shield_special_diamondStave = true; // eslint-disable-line camelcase + user.items.gear.owned = { + ...user.items.gear.owned, + shield_special_diamondStave: true, + }; // eslint-disable-line camelcase if (user.markModified) user.markModified('items.gear.owned'); }, }, @@ -237,7 +327,10 @@ export default function getLoginIncentives (api) { reward: [api.hatchingPotions.RoyalPurple], assignReward: function assignReward (user) { if (!user.items.hatchingPotions.RoyalPurple) user.items.hatchingPotions.RoyalPurple = 0; - user.items.hatchingPotions.RoyalPurple += 1; + user.items.hatchingPotions = { + ...user.items.hatchingPotions, + RoyalPurple: user.items.hatchingPotions.RoyalPurple + 1, + }; if (user.markModified) user.markModified('items.hatchingPotions'); }, }, @@ -246,7 +339,10 @@ export default function getLoginIncentives (api) { reward: [api.food.Saddle], assignReward: function assignReward (user) { if (!user.items.food.Saddle) user.items.food.Saddle = 0; - user.items.food.Saddle += 1; + user.items.food = { + ...user.items.food, + Saddle: user.items.food.Saddle + 1, + }; if (user.markModified) user.markModified('items.food'); }, }, @@ -255,7 +351,10 @@ export default function getLoginIncentives (api) { reward: [api.hatchingPotions.RoyalPurple], assignReward: function assignReward (user) { if (!user.items.hatchingPotions.RoyalPurple) user.items.hatchingPotions.RoyalPurple = 0; - user.items.hatchingPotions.RoyalPurple += 1; + user.items.hatchingPotions = { + ...user.items.hatchingPotions, + RoyalPurple: user.items.hatchingPotions.RoyalPurple + 1, + }; if (user.markModified) user.markModified('items.hatchingPotions'); }, }, @@ -268,23 +367,50 @@ export default function getLoginIncentives (api) { rewardName: 'oneOfAllPetEggs', assignReward: function assignReward (user) { if (!user.items.eggs.BearCub) user.items.eggs.BearCub = 0; - user.items.eggs.BearCub += 1; + user.items.eggs = { + ...user.items.eggs, + BearCub: user.items.eggs.BearCub + 1, + }; if (!user.items.eggs.Cactus) user.items.eggs.Cactus = 0; - user.items.eggs.Cactus += 1; + user.items.eggs = { + ...user.items.eggs, + Cactus: user.items.eggs.Cactus + 1, + }; if (!user.items.eggs.Dragon) user.items.eggs.Dragon = 0; - user.items.eggs.Dragon += 1; + user.items.eggs = { + ...user.items.eggs, + Dragon: user.items.eggs.Dragon + 1, + }; if (!user.items.eggs.FlyingPig) user.items.eggs.FlyingPig = 0; - user.items.eggs.FlyingPig += 1; + user.items.eggs = { + ...user.items.eggs, + FlyingPig: user.items.eggs.FlyingPig + 1, + }; if (!user.items.eggs.Fox) user.items.eggs.Fox = 0; - user.items.eggs.Fox += 1; + user.items.eggs = { + ...user.items.eggs, + Fox: user.items.eggs.Fox + 1, + }; if (!user.items.eggs.LionCub) user.items.eggs.LionCub = 0; - user.items.eggs.LionCub += 1; + user.items.eggs = { + ...user.items.eggs, + LionCub: user.items.eggs.LionCub + 1, + }; if (!user.items.eggs.PandaCub) user.items.eggs.PandaCub = 0; - user.items.eggs.PandaCub += 1; + user.items.eggs = { + ...user.items.eggs, + PandaCub: user.items.eggs.PandaCub + 1, + }; if (!user.items.eggs.TigerCub) user.items.eggs.TigerCub = 0; - user.items.eggs.TigerCub += 1; + user.items.eggs = { + ...user.items.eggs, + TigerCub: user.items.eggs.TigerCub + 1, + }; if (!user.items.eggs.Wolf) user.items.eggs.Wolf = 0; - user.items.eggs.Wolf += 1; + user.items.eggs = { + ...user.items.eggs, + Wolf: user.items.eggs.Wolf + 1, + }; if (user.markModified) user.markModified('items.eggs'); }, }, @@ -293,7 +419,10 @@ export default function getLoginIncentives (api) { reward: [api.hatchingPotions.RoyalPurple], assignReward: function assignReward (user) { if (!user.items.hatchingPotions.RoyalPurple) user.items.hatchingPotions.RoyalPurple = 0; - user.items.hatchingPotions.RoyalPurple += 1; + user.items.hatchingPotions = { + ...user.items.hatchingPotions, + RoyalPurple: user.items.hatchingPotions.RoyalPurple + 1, + }; if (user.markModified) user.markModified('items.hatchingPotions'); }, }, @@ -309,29 +438,59 @@ export default function getLoginIncentives (api) { rewardName: 'oneOfAllHatchingPotions', assignReward: function assignReward (user) { if (!user.items.hatchingPotions.Base) user.items.hatchingPotions.Base = 0; - user.items.hatchingPotions.Base += 1; + user.items.hatchingPotions = { + ...user.items.hatchingPotions, + Base: user.items.hatchingPotions.Base + 1, + }; if (!user.items.hatchingPotions.CottonCandyBlue) { user.items.hatchingPotions.CottonCandyBlue = 0; } - user.items.hatchingPotions.CottonCandyBlue += 1; + user.items.hatchingPotions = { + ...user.items.hatchingPotions, + CottonCandyBlue: user.items.hatchingPotions.CottonCandyBlue + 1, + }; if (!user.items.hatchingPotions.CottonCandyPink) { user.items.hatchingPotions.CottonCandyPink = 0; } - user.items.hatchingPotions.CottonCandyPink += 1; + user.items.hatchingPotions = { + ...user.items.hatchingPotions, + CottonCandyPink: user.items.hatchingPotions.CottonCandyPink + 1, + }; if (!user.items.hatchingPotions.Desert) user.items.hatchingPotions.Desert = 0; - user.items.hatchingPotions.Desert += 1; + user.items.hatchingPotions = { + ...user.items.hatchingPotions, + Desert: user.items.hatchingPotions.Desert + 1, + }; if (!user.items.hatchingPotions.Golden) user.items.hatchingPotions.Golden = 0; - user.items.hatchingPotions.Golden += 1; + user.items.hatchingPotions = { + ...user.items.hatchingPotions, + Golden: user.items.hatchingPotions.Golden + 1, + }; if (!user.items.hatchingPotions.Red) user.items.hatchingPotions.Red = 0; - user.items.hatchingPotions.Red += 1; + user.items.hatchingPotions = { + ...user.items.hatchingPotions, + Red: user.items.hatchingPotions.Red + 1, + }; if (!user.items.hatchingPotions.Shade) user.items.hatchingPotions.Shade = 0; - user.items.hatchingPotions.Shade += 1; + user.items.hatchingPotions = { + ...user.items.hatchingPotions, + Shade: user.items.hatchingPotions.Shade + 1, + }; if (!user.items.hatchingPotions.Skeleton) user.items.hatchingPotions.Skeleton = 0; - user.items.hatchingPotions.Skeleton += 1; + user.items.hatchingPotions = { + ...user.items.hatchingPotions, + Skeleton: user.items.hatchingPotions.Skeleton + 1, + }; if (!user.items.hatchingPotions.White) user.items.hatchingPotions.White = 0; - user.items.hatchingPotions.White += 1; + user.items.hatchingPotions = { + ...user.items.hatchingPotions, + White: user.items.hatchingPotions.White + 1, + }; if (!user.items.hatchingPotions.Zombie) user.items.hatchingPotions.Zombie = 0; - user.items.hatchingPotions.Zombie += 1; + user.items.hatchingPotions = { + ...user.items.hatchingPotions, + Zombie: user.items.hatchingPotions.Zombie + 1, + }; if (user.markModified) user.markModified('items.hatchingPotions'); }, }, @@ -340,7 +499,10 @@ export default function getLoginIncentives (api) { reward: [api.hatchingPotions.RoyalPurple], assignReward: function assignReward (user) { if (!user.items.hatchingPotions.RoyalPurple) user.items.hatchingPotions.RoyalPurple = 0; - user.items.hatchingPotions.RoyalPurple += 1; + user.items.hatchingPotions = { + ...user.items.hatchingPotions, + RoyalPurple: user.items.hatchingPotions.RoyalPurple + 1, + }; if (user.markModified) user.markModified('items.hatchingPotions'); }, }, @@ -354,25 +516,55 @@ export default function getLoginIncentives (api) { rewardName: 'threeOfEachFood', assignReward: function assignReward (user) { if (!user.items.food.Meat) user.items.food.Meat = 0; - user.items.food.Meat += 3; + user.items.food = { + ...user.items.food, + Meat: user.items.food.Meat + 3, + }; if (!user.items.food.CottonCandyBlue) user.items.food.CottonCandyBlue = 0; - user.items.food.CottonCandyBlue += 3; + user.items.food = { + ...user.items.food, + CottonCandyBlue: user.items.food.CottonCandyBlue + 3, + }; if (!user.items.food.CottonCandyPink) user.items.food.CottonCandyPink = 0; - user.items.food.CottonCandyPink += 3; + user.items.food = { + ...user.items.food, + CottonCandyPink: user.items.food.CottonCandyPink + 3, + }; if (!user.items.food.Potatoe) user.items.food.Potatoe = 0; - user.items.food.Potatoe += 3; + user.items.food = { + ...user.items.food, + Potatoe: user.items.food.Potatoe + 3, + }; if (!user.items.food.Honey) user.items.food.Honey = 0; - user.items.food.Honey += 3; + user.items.food = { + ...user.items.food, + Honey: user.items.food.Honey + 3, + }; if (!user.items.food.Strawberry) user.items.food.Strawberry = 0; - user.items.food.Strawberry += 3; + user.items.food = { + ...user.items.food, + Strawberry: user.items.food.Strawberry + 3, + }; if (!user.items.food.Chocolate) user.items.food.Chocolate = 0; - user.items.food.Chocolate += 3; + user.items.food = { + ...user.items.food, + Chocolate: user.items.food.Chocolate + 3, + }; if (!user.items.food.Fish) user.items.food.Fish = 0; - user.items.food.Fish += 3; + user.items.food = { + ...user.items.food, + Fish: user.items.food.Fish + 3, + }; if (!user.items.food.Milk) user.items.food.Milk = 0; - user.items.food.Milk += 3; + user.items.food = { + ...user.items.food, + Milk: user.items.food.Milk + 3, + }; if (!user.items.food.RottenMeat) user.items.food.RottenMeat = 0; - user.items.food.RottenMeat += 3; + user.items.food = { + ...user.items.food, + RottenMeat: user.items.food.RottenMeat + 3, + }; if (user.markModified) user.markModified('items.food'); }, }, @@ -381,7 +573,10 @@ export default function getLoginIncentives (api) { reward: [api.hatchingPotions.RoyalPurple], assignReward: function assignReward (user) { if (!user.items.hatchingPotions.RoyalPurple) user.items.hatchingPotions.RoyalPurple = 0; - user.items.hatchingPotions.RoyalPurple += 1; + user.items.hatchingPotions = { + ...user.items.hatchingPotions, + RoyalPurple: user.items.hatchingPotions.RoyalPurple + 1, + }; if (user.markModified) user.markModified('items.hatchingPotions'); }, }, @@ -389,8 +584,14 @@ export default function getLoginIncentives (api) { rewardKey: ['shop_weapon_special_skeletonKey', 'shop_shield_special_lootBag'], reward: [api.gear.flat.weapon_special_skeletonKey, api.gear.flat.shield_special_lootBag], assignReward: function assignReward (user) { - user.items.gear.owned.weapon_special_skeletonKey = true; // eslint-disable-line camelcase - user.items.gear.owned.shield_special_lootBag = true; // eslint-disable-line camelcase + user.items.gear.owned = { + ...user.items.gear.owned, + weapon_special_skeletonKey: true, + }; // eslint-disable-line camelcase + user.items.gear.owned = { + ...user.items.gear.owned, + shield_special_lootBag: true, + }; // eslint-disable-line camelcase if (user.markModified) user.markModified('items.gear.owned'); }, }, @@ -399,7 +600,10 @@ export default function getLoginIncentives (api) { reward: [api.hatchingPotions.RoyalPurple], assignReward: function assignReward (user) { if (!user.items.hatchingPotions.RoyalPurple) user.items.hatchingPotions.RoyalPurple = 0; - user.items.hatchingPotions.RoyalPurple += 1; + user.items.hatchingPotions = { + ...user.items.hatchingPotions, + RoyalPurple: user.items.hatchingPotions.RoyalPurple + 1, + }; if (user.markModified) user.markModified('items.hatchingPotions'); }, }, @@ -410,8 +614,14 @@ export default function getLoginIncentives (api) { api.gear.flat.armor_special_sneakthiefRobes, ], assignReward: function assignReward (user) { - user.items.gear.owned.head_special_clandestineCowl = true; // eslint-disable-line camelcase - user.items.gear.owned.armor_special_sneakthiefRobes = true; // eslint-disable-line camelcase + user.items.gear.owned = { + ...user.items.gear.owned, + head_special_clandestineCowl: true, + }; // eslint-disable-line camelcase + user.items.gear.owned = { + ...user.items.gear.owned, + armor_special_sneakthiefRobes: true, + }; // eslint-disable-line camelcase if (user.markModified) user.markModified('items.gear.owned'); }, }, @@ -420,7 +630,10 @@ export default function getLoginIncentives (api) { reward: [api.hatchingPotions.RoyalPurple], assignReward: function assignReward (user) { if (!user.items.hatchingPotions.RoyalPurple) user.items.hatchingPotions.RoyalPurple = 0; - user.items.hatchingPotions.RoyalPurple += 1; + user.items.hatchingPotions = { + ...user.items.hatchingPotions, + RoyalPurple: user.items.hatchingPotions.RoyalPurple + 1, + }; if (user.markModified) user.markModified('items.hatchingPotions'); }, }, @@ -431,8 +644,14 @@ export default function getLoginIncentives (api) { api.gear.flat.armor_special_snowSovereignRobes, ], assignReward: function assignReward (user) { - user.items.gear.owned.head_special_snowSovereignCrown = true; // eslint-disable-line camelcase, max-len - user.items.gear.owned.armor_special_snowSovereignRobes = true; // eslint-disable-line camelcase, max-len + user.items.gear.owned = { + ...user.items.gear.owned, + head_special_snowSovereignCrown: true, + }; // eslint-disable-line camelcase, max-len + user.items.gear.owned = { + ...user.items.gear.owned, + armor_special_snowSovereignRobes: true, + }; // eslint-disable-line camelcase, max-len if (user.markModified) user.markModified('items.gear.owned'); }, }, @@ -441,7 +660,10 @@ export default function getLoginIncentives (api) { reward: [api.hatchingPotions.RoyalPurple], assignReward: function assignReward (user) { if (!user.items.hatchingPotions.RoyalPurple) user.items.hatchingPotions.RoyalPurple = 0; - user.items.hatchingPotions.RoyalPurple += 1; + user.items.hatchingPotions = { + ...user.items.hatchingPotions, + RoyalPurple: user.items.hatchingPotions.RoyalPurple + 1, + }; if (user.markModified) user.markModified('items.hatchingPotions'); }, }, @@ -449,8 +671,14 @@ export default function getLoginIncentives (api) { rewardKey: ['shop_shield_special_wintryMirror', 'shop_back_special_snowdriftVeil'], reward: [api.gear.flat.shield_special_wintryMirror, api.gear.flat.back_special_snowdriftVeil], assignReward: function assignReward (user) { - user.items.gear.owned.shield_special_wintryMirror = true; // eslint-disable-line camelcase - user.items.gear.owned.back_special_snowdriftVeil = true; // eslint-disable-line camelcase + user.items.gear.owned = { + ...user.items.gear.owned, + shield_special_wintryMirror: true, + }; // eslint-disable-line camelcase + user.items.gear.owned = { + ...user.items.gear.owned, + back_special_snowdriftVeil: true, + }; // eslint-disable-line camelcase if (user.markModified) user.markModified('items.gear.owned'); }, }, @@ -459,7 +687,10 @@ export default function getLoginIncentives (api) { reward: [api.hatchingPotions.RoyalPurple], assignReward: function assignReward (user) { if (!user.items.hatchingPotions.RoyalPurple) user.items.hatchingPotions.RoyalPurple = 0; - user.items.hatchingPotions.RoyalPurple += 1; + user.items.hatchingPotions = { + ...user.items.hatchingPotions, + RoyalPurple: user.items.hatchingPotions.RoyalPurple + 1, + }; if (user.markModified) user.markModified('items.hatchingPotions'); }, }, @@ -468,7 +699,10 @@ export default function getLoginIncentives (api) { reward: [api.food.Saddle], assignReward: function assignReward (user) { if (!user.items.food.Saddle) user.items.food.Saddle = 0; - user.items.food.Saddle += 1; + user.items.food = { + ...user.items.food, + Saddle: user.items.food.Saddle + 1, + }; if (user.markModified) user.markModified('items.food'); }, }, @@ -479,8 +713,14 @@ export default function getLoginIncentives (api) { api.gear.flat.armor_special_nomadsCuirass, ], assignReward: function assignReward (user) { - user.items.gear.owned.weapon_special_nomadsScimitar = true; // eslint-disable-line camelcase - user.items.gear.owned.armor_special_nomadsCuirass = true; // eslint-disable-line camelcase + user.items.gear.owned = { + ...user.items.gear.owned, + weapon_special_nomadsScimitar: true, + }; // eslint-disable-line camelcase + user.items.gear.owned = { + ...user.items.gear.owned, + armor_special_nomadsCuirass: true, + }; // eslint-disable-line camelcase if (user.markModified) user.markModified('items.gear.owned'); }, }, @@ -488,7 +728,10 @@ export default function getLoginIncentives (api) { rewardKey: ['shop_head_special_spikedHelm'], reward: [api.gear.flat.head_special_spikedHelm], assignReward: function assignReward (user) { - user.items.gear.owned.head_special_spikedHelm = true; // eslint-disable-line camelcase + user.items.gear.owned = { + ...user.items.gear.owned, + head_special_spikedHelm: true, + }; // eslint-disable-line camelcase if (user.markModified) user.markModified('items.gear.owned'); }, }, @@ -502,25 +745,55 @@ export default function getLoginIncentives (api) { rewardName: 'threeOfEachFood', assignReward: function assignReward (user) { if (!user.items.food.Meat) user.items.food.Meat = 0; - user.items.food.Meat += 3; + user.items.food = { + ...user.items.food, + Meat: user.items.food.Meat + 3, + }; if (!user.items.food.CottonCandyBlue) user.items.food.CottonCandyBlue = 0; - user.items.food.CottonCandyBlue += 3; + user.items.food = { + ...user.items.food, + CottonCandyBlue: user.items.food.CottonCandyBlue + 3, + }; if (!user.items.food.CottonCandyPink) user.items.food.CottonCandyPink = 0; - user.items.food.CottonCandyPink += 3; + user.items.food = { + ...user.items.food, + CottonCandyPink: user.items.food.CottonCandyPink + 3, + }; if (!user.items.food.Potatoe) user.items.food.Potatoe = 0; - user.items.food.Potatoe += 3; + user.items.food = { + ...user.items.food, + Potatoe: user.items.food.Potatoe + 3, + }; if (!user.items.food.Honey) user.items.food.Honey = 0; - user.items.food.Honey += 3; + user.items.food = { + ...user.items.food, + Honey: user.items.food.Honey + 3, + }; if (!user.items.food.Strawberry) user.items.food.Strawberry = 0; - user.items.food.Strawberry += 3; + user.items.food = { + ...user.items.food, + Strawberry: user.items.food.Strawberry + 3, + }; if (!user.items.food.Chocolate) user.items.food.Chocolate = 0; - user.items.food.Chocolate += 3; + user.items.food = { + ...user.items.food, + Chocolate: user.items.food.Chocolate + 3, + }; if (!user.items.food.Fish) user.items.food.Fish = 0; - user.items.food.Fish += 3; + user.items.food = { + ...user.items.food, + Fish: user.items.food.Fish + 3, + }; if (!user.items.food.Milk) user.items.food.Milk = 0; - user.items.food.Milk += 3; + user.items.food = { + ...user.items.food, + Milk: user.items.food.Milk + 3, + }; if (!user.items.food.RottenMeat) user.items.food.RottenMeat = 0; - user.items.food.RottenMeat += 3; + user.items.food = { + ...user.items.food, + RottenMeat: user.items.food.RottenMeat + 3, + }; if (user.markModified) user.markModified('items.food'); }, }, @@ -533,23 +806,50 @@ export default function getLoginIncentives (api) { rewardName: 'twoOfAllPetEggs', assignReward: function assignReward (user) { if (!user.items.eggs.BearCub) user.items.eggs.BearCub = 0; - user.items.eggs.BearCub += 2; + user.items.eggs = { + ...user.items.eggs, + BearCub: user.items.eggs.BearCub + 2, + }; if (!user.items.eggs.Cactus) user.items.eggs.Cactus = 0; - user.items.eggs.Cactus += 2; + user.items.eggs = { + ...user.items.eggs, + Cactus: user.items.eggs.Cactus + 2, + }; if (!user.items.eggs.Dragon) user.items.eggs.Dragon = 0; - user.items.eggs.Dragon += 2; + user.items.eggs = { + ...user.items.eggs, + Dragon: user.items.eggs.Dragon + 2, + }; if (!user.items.eggs.FlyingPig) user.items.eggs.FlyingPig = 0; - user.items.eggs.FlyingPig += 2; + user.items.eggs = { + ...user.items.eggs, + FlyingPig: user.items.eggs.FlyingPig + 2, + }; if (!user.items.eggs.Fox) user.items.eggs.Fox = 0; - user.items.eggs.Fox += 2; + user.items.eggs = { + ...user.items.eggs, + Fox: user.items.eggs.Fox + 2, + }; if (!user.items.eggs.LionCub) user.items.eggs.LionCub = 0; - user.items.eggs.LionCub += 2; + user.items.eggs = { + ...user.items.eggs, + LionCub: user.items.eggs.LionCub + 2, + }; if (!user.items.eggs.PandaCub) user.items.eggs.PandaCub = 0; - user.items.eggs.PandaCub += 2; + user.items.eggs = { + ...user.items.eggs, + PandaCub: user.items.eggs.PandaCub + 2, + }; if (!user.items.eggs.TigerCub) user.items.eggs.TigerCub = 0; - user.items.eggs.TigerCub += 2; + user.items.eggs = { + ...user.items.eggs, + TigerCub: user.items.eggs.TigerCub + 2, + }; if (!user.items.eggs.Wolf) user.items.eggs.Wolf = 0; - user.items.eggs.Wolf += 2; + user.items.eggs = { + ...user.items.eggs, + Wolf: user.items.eggs.Wolf + 2, + }; if (user.markModified) user.markModified('items.eggs'); }, }, @@ -557,7 +857,10 @@ export default function getLoginIncentives (api) { rewardKey: ['shop_head_special_dandyHat'], reward: [api.gear.flat.head_special_dandyHat], assignReward: function assignReward (user) { - user.items.gear.owned.head_special_dandyHat = true; // eslint-disable-line camelcase + user.items.gear.owned = { + ...user.items.gear.owned, + head_special_dandyHat: true, + }; // eslint-disable-line camelcase if (user.markModified) user.markModified('items.gear.owned'); }, }, @@ -565,8 +868,14 @@ export default function getLoginIncentives (api) { rewardKey: ['shop_weapon_special_fencingFoil', 'shop_armor_special_dandySuit'], reward: [api.gear.flat.weapon_special_fencingFoil, api.gear.flat.armor_special_dandySuit], assignReward: function assignReward (user) { - user.items.gear.owned.weapon_special_fencingFoil = true; // eslint-disable-line camelcase - user.items.gear.owned.armor_special_dandySuit = true; // eslint-disable-line camelcase + user.items.gear.owned = { + ...user.items.gear.owned, + weapon_special_fencingFoil: true, + }; // eslint-disable-line camelcase + user.items.gear.owned = { + ...user.items.gear.owned, + armor_special_dandySuit: true, + }; // eslint-disable-line camelcase if (user.markModified) user.markModified('items.gear.owned'); }, }, @@ -576,7 +885,10 @@ export default function getLoginIncentives (api) { rewardName: 'twoSaddles', assignReward: function assignReward (user) { if (!user.items.food.Saddle) user.items.food.Saddle = 0; - user.items.food.Saddle += 2; + user.items.food = { + ...user.items.food, + Saddle: user.items.food.Saddle + 2, + }; if (user.markModified) user.markModified('items.food'); }, }, @@ -589,23 +901,50 @@ export default function getLoginIncentives (api) { rewardName: 'threeOfAllPetEggs', assignReward: function assignReward (user) { if (!user.items.eggs.BearCub) user.items.eggs.BearCub = 0; - user.items.eggs.BearCub += 3; + user.items.eggs = { + ...user.items.eggs, + BearCub: user.items.eggs.BearCub + 3, + }; if (!user.items.eggs.Cactus) user.items.eggs.Cactus = 0; - user.items.eggs.Cactus += 3; + user.items.eggs = { + ...user.items.eggs, + Cactus: user.items.eggs.Cactus + 3, + }; if (!user.items.eggs.Dragon) user.items.eggs.Dragon = 0; - user.items.eggs.Dragon += 3; + user.items.eggs = { + ...user.items.eggs, + Dragon: user.items.eggs.Dragon + 3, + }; if (!user.items.eggs.FlyingPig) user.items.eggs.FlyingPig = 0; - user.items.eggs.FlyingPig += 3; + user.items.eggs = { + ...user.items.eggs, + FlyingPig: user.items.eggs.FlyingPig + 3, + }; if (!user.items.eggs.Fox) user.items.eggs.Fox = 0; - user.items.eggs.Fox += 3; + user.items.eggs = { + ...user.items.eggs, + Fox: user.items.eggs.Fox + 3, + }; if (!user.items.eggs.LionCub) user.items.eggs.LionCub = 0; - user.items.eggs.LionCub += 3; + user.items.eggs = { + ...user.items.eggs, + LionCub: user.items.eggs.LionCub + 3, + }; if (!user.items.eggs.PandaCub) user.items.eggs.PandaCub = 0; - user.items.eggs.PandaCub += 3; + user.items.eggs = { + ...user.items.eggs, + PandaCub: user.items.eggs.PandaCub + 3, + }; if (!user.items.eggs.TigerCub) user.items.eggs.TigerCub = 0; - user.items.eggs.TigerCub += 3; + user.items.eggs = { + ...user.items.eggs, + TigerCub: user.items.eggs.TigerCub + 3, + }; if (!user.items.eggs.Wolf) user.items.eggs.Wolf = 0; - user.items.eggs.Wolf += 3; + user.items.eggs = { + ...user.items.eggs, + Wolf: user.items.eggs.Wolf + 3, + }; if (user.markModified) user.markModified('items.eggs'); }, }, @@ -619,25 +958,55 @@ export default function getLoginIncentives (api) { rewardName: 'fourOfEachFood', assignReward: function assignReward (user) { if (!user.items.food.Meat) user.items.food.Meat = 0; - user.items.food.Meat += 4; + user.items.food = { + ...user.items.food, + Meat: user.items.food.Meat + 4, + }; if (!user.items.food.CottonCandyBlue) user.items.food.CottonCandyBlue = 0; - user.items.food.CottonCandyBlue += 4; + user.items.food = { + ...user.items.food, + CottonCandyBlue: user.items.food.CottonCandyBlue + 4, + }; if (!user.items.food.CottonCandyPink) user.items.food.CottonCandyPink = 0; - user.items.food.CottonCandyPink += 4; + user.items.food = { + ...user.items.food, + CottonCandyPink: user.items.food.CottonCandyPink + 4, + }; if (!user.items.food.Potatoe) user.items.food.Potatoe = 0; - user.items.food.Potatoe += 4; + user.items.food = { + ...user.items.food, + Potatoe: user.items.food.Potatoe + 4, + }; if (!user.items.food.Honey) user.items.food.Honey = 0; - user.items.food.Honey += 4; + user.items.food = { + ...user.items.food, + Honey: user.items.food.Honey + 4, + }; if (!user.items.food.Strawberry) user.items.food.Strawberry = 0; - user.items.food.Strawberry += 4; + user.items.food = { + ...user.items.food, + Strawberry: user.items.food.Strawberry + 4, + }; if (!user.items.food.Chocolate) user.items.food.Chocolate = 0; - user.items.food.Chocolate += 4; + user.items.food = { + ...user.items.food, + Chocolate: user.items.food.Chocolate + 4, + }; if (!user.items.food.Fish) user.items.food.Fish = 0; - user.items.food.Fish += 4; + user.items.food = { + ...user.items.food, + Fish: user.items.food.Fish + 4, + }; if (!user.items.food.Milk) user.items.food.Milk = 0; - user.items.food.Milk += 4; + user.items.food = { + ...user.items.food, + Milk: user.items.food.Milk + 4, + }; if (!user.items.food.RottenMeat) user.items.food.RottenMeat = 0; - user.items.food.RottenMeat += 4; + user.items.food = { + ...user.items.food, + RottenMeat: user.items.food.RottenMeat + 4, + }; if (user.markModified) user.markModified('items.food'); }, }, @@ -647,7 +1016,10 @@ export default function getLoginIncentives (api) { rewardName: 'threeSaddles', assignReward: function assignReward (user) { if (!user.items.food.Saddle) user.items.food.Saddle = 0; - user.items.food.Saddle += 3; + user.items.food = { + ...user.items.food, + Saddle: user.items.food.Saddle + 3, + }; if (user.markModified) user.markModified('items.food'); }, }, @@ -655,8 +1027,14 @@ export default function getLoginIncentives (api) { rewardKey: ['shop_weapon_special_tachi', 'shop_armor_special_samuraiArmor'], reward: [api.gear.flat.weapon_special_tachi, api.gear.flat.armor_special_samuraiArmor], assignReward: function assignReward (user) { - user.items.gear.owned.weapon_special_tachi = true; // eslint-disable-line camelcase - user.items.gear.owned.armor_special_samuraiArmor = true; // eslint-disable-line camelcase + user.items.gear.owned = { + ...user.items.gear.owned, + weapon_special_tachi: true, + }; // eslint-disable-line camelcase + user.items.gear.owned = { + ...user.items.gear.owned, + armor_special_samuraiArmor: true, + }; // eslint-disable-line camelcase if (user.markModified) user.markModified('items.gear.owned'); }, }, @@ -664,8 +1042,14 @@ export default function getLoginIncentives (api) { rewardKey: ['shop_head_special_kabuto', 'shop_shield_special_wakizashi'], reward: [api.gear.flat.head_special_kabuto, api.gear.flat.shield_special_wakizashi], assignReward: function assignReward (user) { - user.items.gear.owned.head_special_kabuto = true; // eslint-disable-line camelcase - user.items.gear.owned.shield_special_wakizashi = true; // eslint-disable-line camelcase + user.items.gear.owned = { + ...user.items.gear.owned, + head_special_kabuto: true, + }; // eslint-disable-line camelcase + user.items.gear.owned = { + ...user.items.gear.owned, + shield_special_wakizashi: true, + }; // eslint-disable-line camelcase if (user.markModified) user.markModified('items.gear.owned'); }, }, diff --git a/website/common/script/fns/randomDrop.js b/website/common/script/fns/randomDrop.js index a3f8101424..beec977469 100644 --- a/website/common/script/fns/randomDrop.js +++ b/website/common/script/fns/randomDrop.js @@ -79,7 +79,10 @@ export default function randomDrop (user, options, req = {}, analytics) { canDrop: true, }))); - user.items.food[drop.key] = user.items.food[drop.key] || 0; + user.items.food = { + ...user.items.food, + [drop.key]: user.items.food[drop.key] || 0, + }; user.items.food[drop.key] += 1; if (user.markModified) user.markModified('items.food'); @@ -91,7 +94,10 @@ export default function randomDrop (user, options, req = {}, analytics) { } else if (rarity > 0.3) { // eggs 30% chance drop = cloneDropItem(randomVal(content.dropEggs)); - user.items.eggs[drop.key] = user.items.eggs[drop.key] || 0; + user.items.eggs = { + ...user.items.eggs, + [drop.key]: user.items.eggs[drop.key] || 0, + }; user.items.eggs[drop.key] += 1; if (user.markModified) user.markModified('items.eggs'); @@ -114,8 +120,12 @@ export default function randomDrop (user, options, req = {}, analytics) { randomVal(pickBy(content.hatchingPotions, (v, k) => acceptableDrops.indexOf(k) >= 0)), ); - user.items.hatchingPotions[drop.key] = user.items.hatchingPotions[drop.key] || 0; + user.items.hatchingPotions = { + ...user.items.hatchingPotions, + [drop.key]: user.items.hatchingPotions[drop.key] || 0, + }; user.items.hatchingPotions[drop.key] += 1; + if (user.markModified) user.markModified('items.hatchingPotions'); drop.type = 'HatchingPotion'; diff --git a/website/common/script/fns/updateStats.js b/website/common/script/fns/updateStats.js index 49ca605959..79b4f660c7 100644 --- a/website/common/script/fns/updateStats.js +++ b/website/common/script/fns/updateStats.js @@ -71,9 +71,15 @@ export default function updateStats (user, stats, req = {}, analytics) { if (user.addNotification) user.addNotification('DROPS_ENABLED'); if (user.items.eggs.Wolf > 0) { - user.items.eggs.Wolf += 1; + user.items.eggs = { + ...user.items.eggs, + Wolf: user.items.eggs.Wolf + 1, + }; } else { - user.items.eggs.Wolf = 1; + user.items.eggs = { + ...user.items.eggs, + Wolf: 1, + }; } if (user.markModified) user.markModified('items.eggs'); @@ -89,7 +95,10 @@ export default function updateStats (user, stats, req = {}, analytics) { if (user.markModified) user.markModified('flags.levelDrops'); if (!user.items.quests[k]) user.items.quests[k] = 0; - user.items.quests[k] += 1; + user.items.quests = { + ...user.items.quests, + [k]: user.items.quests[k] + 1, + }; if (user.markModified) user.markModified('items.quests'); if (analytics) { diff --git a/website/common/script/ops/buy/buyArmoire.js b/website/common/script/ops/buy/buyArmoire.js index 97d5213aca..fab02460d7 100644 --- a/website/common/script/ops/buy/buyArmoire.js +++ b/website/common/script/ops/buy/buyArmoire.js @@ -90,7 +90,10 @@ export class BuyArmoireOperation extends AbstractGoldItemOperation { // eslint-d throw new NotAuthorized(this.i18n('equipmentAlreadyOwned')); } - user.items.gear.owned[drop.key] = true; + user.items.gear.owned = { + ...user.items.gear.owned, + [drop.key]: true, + }; if (user.markModified) user.markModified('items.gear.owned'); user.flags.armoireOpened = true; @@ -126,7 +129,10 @@ export class BuyArmoireOperation extends AbstractGoldItemOperation { // eslint-d canDrop: true, })); - user.items.food[drop.key] = user.items.food[drop.key] || 0; + user.items.food = { + ...user.items.food, + [drop.key]: user.items.food[drop.key] || 0, + }; user.items.food[drop.key] += 1; if (user.markModified) user.markModified('items.food'); diff --git a/website/common/script/ops/buy/buyMount.js b/website/common/script/ops/buy/buyMount.js index 660b78b1dd..dbc4517938 100644 --- a/website/common/script/ops/buy/buyMount.js +++ b/website/common/script/ops/buy/buyMount.js @@ -34,7 +34,10 @@ export class BuyHourglassMountOperation extends AbstractHourglassItemOperation { } executeChanges (user) { - user.items.mounts[this.key] = true; + user.items.mounts = { + ...user.items.mounts, + [this.key]: true, + }; if (user.markModified) user.markModified('items.mounts'); diff --git a/website/common/script/ops/buy/buyMysterySet.js b/website/common/script/ops/buy/buyMysterySet.js index 018322cba8..06ef1f9275 100644 --- a/website/common/script/ops/buy/buyMysterySet.js +++ b/website/common/script/ops/buy/buyMysterySet.js @@ -38,6 +38,11 @@ export default function buyMysterySet (user, req = {}, analytics) { } }); + // Here we need to trigger vue reactivity through reassign object + user.items.gear.owned = { + ...user.items.gear.owned, + }; + if (user.markModified) user.markModified('items.gear.owned'); user.purchased.plan.consecutive.trinkets -= 1; diff --git a/website/common/script/ops/buy/buyQuestGem.js b/website/common/script/ops/buy/buyQuestGem.js index 3f099d2a3a..91f60ad6df 100644 --- a/website/common/script/ops/buy/buyQuestGem.js +++ b/website/common/script/ops/buy/buyQuestGem.js @@ -47,7 +47,10 @@ export class BuyQuestWithGemOperation extends AbstractGemItemOperation { // esli !user.items.quests[item.key] || user.items.quests[item.key] < 0 ) user.items.quests[item.key] = 0; - user.items.quests[item.key] += this.quantity; + user.items.quests = { + ...user.items.quests, + [item.key]: user.items.quests[item.key] + this.quantity, + }; if (user.markModified) user.markModified('items.quests'); this.subtractCurrency(user, item, this.quantity); diff --git a/website/common/script/ops/buy/buyQuestGold.js b/website/common/script/ops/buy/buyQuestGold.js index ead059829c..a4f16d4bfd 100644 --- a/website/common/script/ops/buy/buyQuestGold.js +++ b/website/common/script/ops/buy/buyQuestGold.js @@ -67,7 +67,10 @@ export class BuyQuestWithGoldOperation extends AbstractGoldItemOperation { // es !user.items.quests[item.key] || user.items.quests[item.key] < 0 ) user.items.quests[item.key] = 0; - user.items.quests[item.key] += this.quantity; + user.items.quests = { + ...user.items.quests, + [item.key]: user.items.quests[item.key] + this.quantity, + }; if (user.markModified) user.markModified('items.quests'); this.subtractCurrency(user, item, this.quantity); diff --git a/website/common/script/ops/buy/hourglassPurchase.js b/website/common/script/ops/buy/hourglassPurchase.js index f721acbc43..3181bc49b4 100644 --- a/website/common/script/ops/buy/hourglassPurchase.js +++ b/website/common/script/ops/buy/hourglassPurchase.js @@ -47,12 +47,18 @@ export default function purchaseHourglass (user, req = {}, analytics, quantity = user.purchased.plan.consecutive.trinkets -= 1; if (type === 'pets') { - user.items.pets[key] = 5; + user.items.pets = { + ...user.items.pets, + [key]: 5, + }; if (user.markModified) user.markModified('items.pets'); } if (type === 'mounts') { - user.items.mounts[key] = true; + user.items.mounts = { + ...user.items.mounts, + [key]: true, + }; if (user.markModified) user.markModified('items.mounts'); } } diff --git a/website/common/script/ops/buy/purchase.js b/website/common/script/ops/buy/purchase.js index f4156f7683..67b65224eb 100644 --- a/website/common/script/ops/buy/purchase.js +++ b/website/common/script/ops/buy/purchase.js @@ -46,7 +46,10 @@ function purchaseItem (user, item, price, type, key) { user.balance -= price; if (type === 'gear') { - user.items.gear.owned[key] = true; + user.items.gear.owned = { + ...user.items.gear.owned, + [key]: true, + }; if (user.markModified) user.markModified('items.gear.owned'); } else if (type === 'bundles') { const subType = item.type; diff --git a/website/common/script/ops/changeClass.js b/website/common/script/ops/changeClass.js index 460786c6bd..a9d7104fa3 100644 --- a/website/common/script/ops/changeClass.js +++ b/website/common/script/ops/changeClass.js @@ -53,8 +53,16 @@ export default function changeClass (user, req = {}, analytics) { addPinnedGearByClass(user); - user.items.gear.owned[`weapon_${klass}_0`] = true; - if (klass === 'rogue') user.items.gear.owned[`shield_${klass}_0`] = true; + user.items.gear.owned = { + ...user.items.gear.owned, + [`weapon_${klass}_0`]: true, + }; + if (klass === 'rogue') { + user.items.gear.owned = { + ...user.items.gear.owned, + [`shield_${klass}_0`]: true, + }; + } if (user.markModified) user.markModified('items.gear.owned'); removePinnedItemsByOwnedGear(user); diff --git a/website/common/script/ops/feed.js b/website/common/script/ops/feed.js index b1031975db..36b99d2368 100644 --- a/website/common/script/ops/feed.js +++ b/website/common/script/ops/feed.js @@ -15,8 +15,11 @@ import { checkOnboardingStatus } from '../libs/onboarding'; function evolve (user, pet, req) { user.items.pets[pet.key] = -1; - user.items.mounts[pet.key] = true; + user.items.mounts = { + ...user.items.mounts, + [pet.key]: true, + }; if (user.markModified) { user.markModified('items.pets'); user.markModified('items.mounts'); @@ -48,9 +51,8 @@ export default function feed (user, req = {}) { throw new NotFound(errorMessage('invalidFoodName', req.language)); } - const userPets = user.items.pets; - if (!userPets[pet.key]) { + if (!user.items.pets[pet.key]) { throw new NotFound(i18n.t('messagePetNotFound', req.language)); } @@ -77,16 +79,16 @@ export default function feed (user, req = {}) { }; if (food.target === pet.potion || pet.type === 'premium') { - userPets[pet.key] += 5; + user.items.pets[pet.key] += 5; message = i18n.t('messageLikesFood', messageParams, req.language); } else { - userPets[pet.key] += 2; + user.items.pets[pet.key] += 2; message = i18n.t('messageDontEnjoyFood', messageParams, req.language); } if (user.markModified) user.markModified('items.pets'); - if (userPets[pet.key] >= 50 && !user.items.mounts[pet.key]) { + if (user.items.pets[pet.key] >= 50 && !user.items.mounts[pet.key]) { message = evolve(user, pet, req); } @@ -117,7 +119,7 @@ export default function feed (user, req = {}) { }); return [ - userPets[pet.key], + user.items.pets[pet.key], message, ]; } diff --git a/website/common/script/ops/hatch.js b/website/common/script/ops/hatch.js index 1965cd6496..c21f76d1d9 100644 --- a/website/common/script/ops/hatch.js +++ b/website/common/script/ops/hatch.js @@ -41,7 +41,10 @@ export default function hatch (user, req = {}) { throw new NotAuthorized(i18n.t('messageAlreadyPet', req.language)); } - user.items.pets[pet] = 5; + user.items.pets = { + ...user.items.pets, + [pet]: 5, + }; user.items.eggs[egg] -= 1; user.items.hatchingPotions[hatchingPotion] -= 1; if (user.markModified) { diff --git a/website/common/script/ops/openMysteryItem.js b/website/common/script/ops/openMysteryItem.js index 0ab7926c40..7df705aeb3 100644 --- a/website/common/script/ops/openMysteryItem.js +++ b/website/common/script/ops/openMysteryItem.js @@ -23,7 +23,10 @@ export default function openMysteryItem (user, req = {}, analytics) { item = cloneDeep(content.gear.flat[item]); item.text = content.gear.flat[item.key].text(user.preferences.language); - user.items.gear.owned[item.key] = true; + user.items.gear.owned = { + ...user.items.gear.owned, + [item.key]: true, + }; if (user.markModified) { user.markModified('purchased.plan.mysteryItems'); diff --git a/website/common/script/ops/pinnedGearUtils.js b/website/common/script/ops/pinnedGearUtils.js index e7a0f98bd1..53b8c119d0 100644 --- a/website/common/script/ops/pinnedGearUtils.js +++ b/website/common/script/ops/pinnedGearUtils.js @@ -95,7 +95,10 @@ export function removePinnedGearAddPossibleNewOnes (user, itemPath, newItemKey) // remove the old pinned gear items and add the new gear back removePinnedGearByClass(user); - user.items.gear.owned[newItemKey] = true; + user.items.gear.owned = { + ...user.items.gear.owned, + [newItemKey]: true, + }; if (user.markModified) user.markModified('items.gear.owned'); addPinnedGearByClass(user); diff --git a/website/common/script/ops/revive.js b/website/common/script/ops/revive.js index e8ce46010b..8718030005 100644 --- a/website/common/script/ops/revive.js +++ b/website/common/script/ops/revive.js @@ -90,6 +90,7 @@ export default function revive (user, req = {}, analytics) { removePinnedGearByClass(user); user.items.gear.owned[lostItem] = false; + if (user.markModified) user.markModified('items.gear.owned'); addPinnedGearByClass(user);