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
4 changes: 2 additions & 2 deletions lovely/better_calc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -324,13 +324,13 @@ if card.area and area_set[card.area] then
if type(jokers) ~= 'table' then jokers = nil end
if jokers or triggered then
ret.jokers = jokers
if not (context.retrigger_joker_check or context.retrigger_joker) and not (jokers and jokers.no_retrigger) and not SMODS.is_getter_context(context) then
if not (jokers and jokers.no_retrigger) then
local retriggers = SMODS.calculate_retriggers(card, context, ret)
if next(retriggers) then
ret.retriggers = retriggers
end
end
if not context.post_trigger and not context.retrigger_joker_check and SMODS.optional_features.post_trigger then
if SMODS.optional_features.post_trigger and SMODS.can_context_post_trigger(context) then
SMODS.calculate_context({blueprint_card = context.blueprint_card, post_trigger = true, other_card = card, other_context = context, other_ret = ret}, post_trig)
end
end
Expand Down
10 changes: 10 additions & 0 deletions lsp_def/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,16 @@ function SMODS.update_context_flags(context, flags) end
--- or false if the [context] isn't a getter context.
function SMODS.is_getter_context(context) end

---@param context CalcContext|table The context checked
---@return boolean
-- Returns whether or not the given context can retrigger (by checking SMODS.CONTEXT_RETRIGGER_BLACKLIST)
function SMODS.can_context_retrigger(context) end

---@param context CalcContext|table The context checked
---@return boolean
--- Returns whether or not the given context can post_trigger (by checking SMODS.CONTEXT_POST_TRIGGER_BLACKLIST)
function SMODS.can_context_post_trigger(context) end

---@param eval_object SMODS.GameObject|table The object that will be evaluated next if this returns false
---@return boolean
--- This functions checks whether a previous getter context of the same type
Expand Down
53 changes: 45 additions & 8 deletions src/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1672,7 +1672,7 @@ SMODS.calculate_repetitions = function(card, context, reps)
for i = curr_size + 1, new_size do
if not first then
post = {}
if not context.post_trigger and SMODS.optional_features.post_trigger then
if SMODS.optional_features.post_trigger and SMODS.can_context_post_trigger(context) then
SMODS.calculate_context({blueprint_card = context.blueprint_card, post_trigger = true, other_card = _card, other_context = context, other_ret = eval}, post)
end
end
Expand Down Expand Up @@ -1740,7 +1740,7 @@ end

SMODS.calculate_retriggers = function(card, context, _ret)
local retriggers = {}
if not SMODS.optional_features.retrigger_joker then return retriggers end
if not SMODS.optional_features.retrigger_joker or not SMODS.can_context_retrigger(context) then return retriggers end
for _, area in ipairs(SMODS.get_card_areas('jokers')) do
for _, _card in ipairs(area.cards) do
local eval, post = eval_card(_card, {retrigger_joker_check = true, other_card = card, other_context = context, other_ret = _ret})
Expand Down Expand Up @@ -1990,6 +1990,45 @@ function SMODS.is_getter_context(context)
return false
end

SMODS.CONTEXT_RETRIGGER_BLACKLIST = {
mod_probability = true, fix_probability = true,
check_enhancement = true,
retrigger_joker_check = true, retrigger_joker = true,
modify_scoring_hand = true,
modify_weights = true,
evaluate_poker_hand = true,
debuff_hand = true,
}

function SMODS.can_context_retrigger(context)
for entry, _ in pairs(SMODS.CONTEXT_RETRIGGER_BLACKLIST) do
if context[entry] then
return false
end
end
return true
end

SMODS.CONTEXT_POST_TRIGGER_BLACKLIST = {
mod_probability = true, fix_probability = true,
check_enhancement = true,
retrigger_joker_check = true,
post_trigger = true,
modify_scoring_hand = true,
modify_weights = true,
evaluate_poker_hand = true,
debuff_hand = true,
}

function SMODS.can_context_post_trigger(context)
for entry, _ in pairs(SMODS.CONTEXT_POST_TRIGGER_BLACKLIST) do
if context[entry] then
return false
end
end
return true
end


function SMODS.check_looping_context(eval_object)
if #SMODS.context_stack < 2 then return false end
Expand Down Expand Up @@ -2371,13 +2410,11 @@ function SMODS.eval_individual(individual, context)
if (eff and not eff.no_retrigger) or triggered then
--if type(eff) == 'table' then eff.juice_card = eff.juice_card or individual.scored_card end
ret.individual = eff
if not (context.retrigger_joker_check or context.retrigger_joker) then
local retriggers = SMODS.calculate_retriggers(individual.object, context, ret)
if next(retriggers) then
ret.retriggers = retriggers
end
local retriggers = SMODS.calculate_retriggers(individual.object, context, ret)
if next(retriggers) then
ret.retriggers = retriggers
end
if not context.post_trigger and not context.retrigger_joker_check and SMODS.optional_features.post_trigger then
if SMODS.optional_features.post_trigger and SMODS.can_context_post_trigger(context) then
SMODS.calculate_context({blueprint_card = context.blueprint_card, post_trigger = true, other_card = individual.object, other_context = context, other_ret = ret}, post_trig)
end
end
Expand Down