From dddd2b4b18eee69b04a841d461c9841514fdf789 Mon Sep 17 00:00:00 2001 From: pluviolithic Date: Mon, 27 Nov 2023 10:54:35 -0500 Subject: [PATCH] Add luck boost --- src/client/UI/BillboardShops/EggShop.lua | 9 ++++++++- src/server/Random/EggHatcher/init.lua | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/client/UI/BillboardShops/EggShop.lua b/src/client/UI/BillboardShops/EggShop.lua index ac09e80..81d3837 100644 --- a/src/client/UI/BillboardShops/EggShop.lua +++ b/src/client/UI/BillboardShops/EggShop.lua @@ -464,6 +464,9 @@ local function updateFoundsDisplay(foundPets): () end local function updateRarityListeners(luck: number): () + if selectors.getActiveBoosts(store:getState(), player.Name)["LuckBoost"] then + luck += 5 + end for _, listener in rarityListeners do listener(luck) end @@ -478,7 +481,11 @@ playerStatePromise:andThen(function() return end - if selectors.getStat(newState, player.Name, "Luck") ~= selectors.getStat(oldState, player.Name, "Luck") then + if + selectors.getStat(newState, player.Name, "Luck") ~= selectors.getStat(oldState, player.Name, "Luck") + or selectors.getActiveBoosts(newState, player.Name)["LuckBoost"] + and not selectors.getActiveBoosts(oldState, player.Name)["LuckBoost"] + then updateRarityListeners(selectors.getStat(newState, player.Name, "Luck")) end diff --git a/src/server/Random/EggHatcher/init.lua b/src/server/Random/EggHatcher/init.lua index 0dc2482..f3f143e 100644 --- a/src/server/Random/EggHatcher/init.lua +++ b/src/server/Random/EggHatcher/init.lua @@ -24,6 +24,10 @@ local function getWeightedRandom(player: Player, weights: { [string]: { [string] local luck = selectors.getStat(store:getState(), player.Name, "Luck") local newWeights = {} + if selectors.getActiveBoosts(store:getState(), player.Name)["LuckBoost"] then + luck += 5 + end + if luck ~= 0 then local normalRarity = 0 local boostedRarity = 0