Skip to content

Commit

Permalink
fix retriggers again
Browse files Browse the repository at this point in the history
  • Loading branch information
Eremel committed Dec 31, 2024
1 parent 2d9883f commit 8c8d6c5
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 28 deletions.
56 changes: 32 additions & 24 deletions lovely/better_calc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,37 +33,41 @@ end
position = 'at'
match_indent = true
payload = '''
local reps = SMODS.calculate_repetitions(scoring_hand[i], {cardarea = G.play, full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, other_card = scoring_hand[i], repetition = true, card_effects = effects})
local reps = SMODS.calculate_repetitions(scoring_hand[i], {cardarea = G.play, full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, other_card = scoring_hand[i], repetition = true, card_effects = effects}, {1})
'''
[[patches]]
[patches.pattern]
target = 'functions/state_events.lua'
pattern = '''
--Check for hand doubling
if reps[j] == 1 then
--Check for hand doubling
--From Red seal
local eval = eval_card(G.hand.cards[i], {repetition_only = true,cardarea = G.hand, full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, repetition = true, card_effects = effects})
if next(eval) and (next(effects[1]) or #effects > 1) then
for h = 1, eval.seals.repetitions do
reps[#reps+1] = eval
--From Red seal
local eval = eval_card(G.hand.cards[i], {repetition_only = true,cardarea = G.hand, full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, repetition = true, card_effects = effects})
if next(eval) and (next(effects[1]) or #effects > 1) then
for h = 1, eval.seals.repetitions do
reps[#reps+1] = eval
end
end
end
--From Joker
for j=1, #G.jokers.cards do
--calculate the joker effects
local eval = eval_card(G.jokers.cards[j], {cardarea = G.hand, full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, other_card = G.hand.cards[i], repetition = true, card_effects = effects})
if next(eval) then
for h = 1, eval.jokers.repetitions do
reps[#reps+1] = eval
--From Joker
for j=1, #G.jokers.cards do
--calculate the joker effects
local eval = eval_card(G.jokers.cards[j], {cardarea = G.hand, full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, other_card = G.hand.cards[i], repetition = true, card_effects = effects})
if next(eval) then
for h = 1, eval.jokers.repetitions do
reps[#reps+1] = eval
end
end
end
end
'''
position = 'at'
match_indent = true
payload = '''
reps = SMODS.calculate_repetitions(G.hand.cards[i], {cardarea = G.hand, full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, other_card = G.hand.cards[i], repetition = true, card_effects = effects})
if reps[j] == 1 and next(effects) then
reps = SMODS.calculate_repetitions(G.hand.cards[i], {cardarea = G.hand, full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, other_card = G.hand.cards[i], repetition = true, card_effects = effects}, {})
end
'''

# Handle retrigger messages
Expand Down Expand Up @@ -111,18 +115,22 @@ for k=1, #G.jokers.cards do
mod_percent = true
table.insert(effects, eval)
end
end
'''
position = 'at'
match_indent = true
payload = '''
for k=1, #G.jokers.cards + #G.consumeables.cards do
local _card = G.jokers.cards[k] or G.consumeables.cards[k - #G.jokers.cards]
--calculate the joker individual card effects
local eval = eval_card(_card, {cardarea = G.hand, full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, other_card = G.hand.cards[i], individual = true})
if next(eval) then
mod_percent = true
table.insert(effects, eval)
if next(effects) then
for k=1, #G.jokers.cards + #G.consumeables.cards do
local _card = G.jokers.cards[k] or G.consumeables.cards[k - #G.jokers.cards]
--calculate the joker individual card effects
local eval = eval_card(_card, {cardarea = G.hand, full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, other_card = G.hand.cards[i], individual = true})
if next(eval) then
mod_percent = true
table.insert(effects, eval)
end
end
end
'''
## eval_card()
# handle debuffed playing cards
Expand Down Expand Up @@ -965,7 +973,7 @@ for k=1, #G.jokers.cards + #G.consumeables.cards do
end
if reps[j] == 1 then
reps = SMODS.calculate_repetitions(G.hand.cards[i], {cardarea = G.hand, other_card = G.hand.cards[i], repetition = true, end_of_round = true, card_effects = effects})
reps = SMODS.calculate_repetitions(G.hand.cards[i], {cardarea = G.hand, other_card = G.hand.cards[i], repetition = true, end_of_round = true, card_effects = effects}, {})
end
SMODS.trigger_effects(effects, G.hand.cards[i], percent)
Expand Down
14 changes: 10 additions & 4 deletions src/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,7 @@ SMODS.calculate_individual_effect = function(effect, scored_card, percent, key,
if key ~= 'Xmult_mod' then card_eval_status_text(scored_card, 'x_mult', amount, percent) end
end
end
xmult_triggers = xmult_triggers + 1
return true
end

Expand Down Expand Up @@ -1078,16 +1079,18 @@ SMODS.calculate_effect = function(effect, scored_card, percent, from_edition, no
return calculated
end

SMODS.calculate_repetitions = function(card, context)
local reps = {1}
SMODS.calculate_repetitions = function(card, context, reps)
--From Red seal
context.repetition_only = true
local eval = eval_card(card, context)
local retriggers = eval and eval.retriggers and #eval.retriggers or 1
for key, value in pairs(eval) do
if value.repetitions then
for h=1, value.repetitions do
value.card = value.card or card
reps[#reps+1] = {key = value}
for i=1, retriggers do
reps[#reps+1] = {key = value}
end
end
end
end
Expand All @@ -1097,11 +1100,14 @@ SMODS.calculate_repetitions = function(card, context)
local _card = G.jokers.cards[k] or G.consumeables.cards[k - #G.jokers.cards]
--calculate the joker effects
local eval = eval_card(_card, context)
local retriggers = eval and eval.retriggers and #eval.retriggers or 1
for key, value in pairs(eval) do
if value.repetitions then
for h=1, value.repetitions do
value.card = value.card or _card
reps[#reps+1] = {key = value}
for i=1, retriggers do
reps[#reps+1] = {key = value}
end
end
end
end
Expand Down

0 comments on commit 8c8d6c5

Please sign in to comment.