From c4ef0a2ad0f68c47be1fe7eea8d406744c1a2029 Mon Sep 17 00:00:00 2001 From: Nizar Beriane Date: Sat, 8 Nov 2025 19:13:21 +0100 Subject: [PATCH] Fix crash: check ret type before accessing table fields --- .gitignore | 1 + localization/en-us.lua | 2 +- src/bplus/override.lua | 93 +++++++++++++++++------------------------- 3 files changed, 39 insertions(+), 57 deletions(-) diff --git a/.gitignore b/.gitignore index c5f0577..05d706c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ release/ mktest +.idea \ No newline at end of file diff --git a/localization/en-us.lua b/localization/en-us.lua index 564a1b6..6f6d307 100644 --- a/localization/en-us.lua +++ b/localization/en-us.lua @@ -791,7 +791,7 @@ return { c_bplus_sigil_dupe = { name = "Dupe", text = { - "Covert all {C:attention}unselected", + "Convert all {C:attention}unselected", "cards to {C:attention}selected{} card", "{C:blue}-#1#{} Hand", }, diff --git a/src/bplus/override.lua b/src/bplus/override.lua index f589c8f..2f0f20c 100644 --- a/src/bplus/override.lua +++ b/src/bplus/override.lua @@ -53,24 +53,24 @@ end function Blind:hand_played() if self.config.blind.hand_played then if self.config.blind.hand_played(self) then - G.E_MANAGER:add_event(Event { - trigger = "immediate", - func = function() + G.E_MANAGER:add_event(Event({ + trigger = 'immediate', + func = (function() SMODS.juice_up_blind() G.E_MANAGER:add_event(Event { - trigger = "after", + trigger = 'after', delay = 0.06 * G.SETTINGS.GAMESPEED, blockable = false, blocking = false, func = function() - play_sound("tarot2", 0.76, 0.4) + play_sound('tarot2', 0.76, 0.4) return true end, }) - play_sound("tarot2", 1, 0.4) + play_sound('tarot2', 1, 0.4) return true - end, - }) + end) + })) delay(0.4) end end @@ -78,46 +78,34 @@ end local card_is_suit = Card.is_suit function Card:is_suit(suit, bypass_debuff, flush_calc) - local opt - local first_pass - local res - local orig_suit = self.base.suit - if not G.bplus_card_is_suit_opt then - G.bplus_card_is_suit_opt = {} - first_pass = true - end - opt = G.bplus_card_is_suit_opt - - if self.debuff and not bypass_debuff then - return - end + if flush_calc then + if SMODS.has_enhancement(self, "m_stone") and not self.debuff and next(find_joker("j_bplus_stone_carving")) then + return G.GAME.current_round.bplus_stone_carving_card.suit == suit + end - if not res and not opt.stone_carving and SMODS.has_enhancement(self, "m_stone") and next(find_joker("j_bplus_stone_carving")) then - opt.stone_carving = true - local orig_center = self.config.center - self.config.center = G.P_CENTERS.c_base - self.base.suit = G.GAME.current_round.bplus_stone_carving_card.suit - res = self:is_suit(suit, bypass_debuff, flush_calc) - self.config.center = orig_center - self.base.suit = orig_suit - end + if not self.debuff and next(find_joker("j_bplus_blured")) then + local blured_suit + local transform = G.GAME.current_round.bplus_blured_suit + if self.base.suit == transform.from then + blured_suit = transform.to + end + return self.base.suit == suit or blured_suit == suit + end + else + if self.debuff and not bypass_debuff then return end - if not res and not opt.blured and next(find_joker("j_bplus_blured")) then - opt.blured = true - local transform = G.GAME.current_round.bplus_blured_suit - if self:is_suit(transform.from, bypass_debuff, flush_calc) then - self.base.suit = transform.to + if self.ability.name == G.P_CENTERS.m_stone.name and next(find_joker("j_bplus_stone_carving")) then + return G.GAME.current_round.bplus_stone_carving_card.suit == suit end - res = self:is_suit(suit, bypass_debuff, flush_calc) - self.base.suit = orig_suit - res = res or self:is_suit(suit, bypass_debuff, flush_calc) - end - if first_pass then - G.bplus_card_is_suit_opt = nil - end - if res ~= nil then - return res + if next(find_joker("j_bplus_blured")) then + local blured_suit + local transform = G.GAME.current_round.bplus_blured_suit + if self.base.suit == transform.from then + blured_suit = transform.to + end + return self.base.suit == suit or blured_suit == suit + end end return card_is_suit(self, suit, bypass_debuff, flush_calc) end @@ -133,14 +121,9 @@ end local card_calculate_joker = Card.calculate_joker function Card:calculate_joker(ctx) local ret = card_calculate_joker(self, ctx) - if not ret then - return - end - if ret == true then - return ret - end + if not ret then return end - if ret.repetitions and not G.GAME.blind.disabled and G.GAME.blind.name == "bl_bplus_lazy" then + if type(ret) == "table" and ret.repetitions and not G.GAME.blind.disabled and G.GAME.blind.name == "bl_bplus_lazy" then BPlus.bl_lazy_trigger(ret.card or self) ret = nil end @@ -151,11 +134,9 @@ end local card_calculate_seal = Card.calculate_seal function Card:calculate_seal(ctx) local ret = card_calculate_seal(self, ctx) - if not ret then - return - end + if not ret then return end - if ret.repetitions and not G.GAME.blind.disabled and G.GAME.blind.name == "bl_bplus_lazy" then + if type(ret) == "table" and ret.repetitions and not G.GAME.blind.disabled and G.GAME.blind.name == "bl_bplus_lazy" then BPlus.bl_lazy_trigger(ret.card or self) ret = nil end @@ -195,4 +176,4 @@ for key, override in pairs(center_overrides) do for field, value in pairs(override) do G.P_CENTERS[key][field] = value end -end +end \ No newline at end of file