Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
Add luck boost
Browse files Browse the repository at this point in the history
  • Loading branch information
Pluviolithic committed Nov 27, 2023
1 parent d4f3955 commit dddd2b4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/client/UI/BillboardShops/EggShop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
4 changes: 4 additions & 0 deletions src/server/Random/EggHatcher/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit dddd2b4

Please sign in to comment.