Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lsp_def/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@
---@field old? string Key of the old center after a card's ability is set.
---@field new? string Key of the new center after a card's ability is set.
---@field unchanged? boolean `true` if the key of the old center is the same as the new one after a card's ability is set.
---@field poker_hand_changed? boolean `true` if a poker hand's values are being altered.
---@field old_level? integer Level of the poker hand before the alteration, if it was changed.
---@field new_level? integer Level of the poker hand after the alteration, if it was changed.
---@field old_parameters? table<'chips'|'mult'|string, number> Altered scoring parameters of the poker hand before the alteration.
---@field new_parameters? table<'chips'|'mult'|string, number> Altered scoring parameters of the poker hand after the alteration.

--- Util Functions

Expand Down
10 changes: 10 additions & 0 deletions src/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3313,18 +3313,25 @@ function SMODS.upgrade_poker_hands(args)
end

local displayed = false
---@type CalcContext
local context = {card = args.from, poker_hand_changed = true}
for _, hand in ipairs(args.hands) do
displayed = hand == SMODS.displayed_hand
context.scoring_name = hand
if not instant then
update_hand_text({sound = 'button', volume = 0.7, pitch = 0.8, delay = 0.3}, {handname=localize(hand, 'poker_hands'), level=G.GAME.hands[hand].level})
for name, p in pairs(SMODS.Scoring_Parameters) do
p.current = G.GAME.hands[hand][name] or p.default_value
update_hand_text({nopulse = nil, delay = 0}, {[name] = p.current})
end
end
context.old_parameters = {}
context.new_parameters = {}
for i, parameter in ipairs(args.parameters) do
if G.GAME.hands[hand][parameter] then
context.old_parameters[parameter] = G.GAME.hands[hand][parameter]
G.GAME.hands[hand][parameter] = args.func(G.GAME.hands[hand][parameter], hand, parameter)
context.new_parameters[parameter] = G.GAME.hands[hand][parameter]
if not instant then
G.E_MANAGER:add_event(Event({trigger = 'after', delay = i == 1 and 0.2 or 0.9, func = function()
play_sound('tarot1')
Expand All @@ -3336,7 +3343,9 @@ function SMODS.upgrade_poker_hands(args)
end
end
if args.level_up then
context.old_level = G.GAME.hands[hand].level
G.GAME.hands[hand].level = G.GAME.hands[hand].level + (type(args.level_up) == 'number' and args.level_up or 1)
context.new_level = G.GAME.hands[hand].level
if not instant then
G.E_MANAGER:add_event(Event({trigger = 'after', delay = 0.9, func = function()
play_sound('tarot1')
Expand All @@ -3347,6 +3356,7 @@ function SMODS.upgrade_poker_hands(args)
end
end
if not instant then delay(1.3) end
SMODS.calculate_context(context)
end

if not instant and not displayed then
Expand Down