Skip to content

Retrigger Cerber on rank changes without startup crashes#19

Merged
Adesii merged 7 commits into
mainfrom
copilot/fix-cerber-joker-triggering
Apr 24, 2026
Merged

Retrigger Cerber on rank changes without startup crashes#19
Adesii merged 7 commits into
mainfrom
copilot/fix-cerber-joker-triggering

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 24, 2026

Cerber only applied to cards when the joker was obtained or when cards were added, so cards that became 2s mid-run were skipped. The first pass at fixing that also hooked Card:set_base too early in card initialization, causing startup crashes when base was still nil.

  • Behavior

    • Retrigger Cerber when a playing card's rank changes into a 2 during gameplay.
    • Keep the existing one-time full-deck application when Cerber itself is obtained.
    • Restore the original joker text: All 2s become Negative.
  • Implementation

    • Centralized Cerber application logic in shared helpers for single-card and multi-card paths.
    • Hooked Card:set_base and SMODS.change_base so transform effects and debug rank changes can reapply Cerber immediately.
    • Limited the hook to transitions from a non-2 rank into 2, avoiding unnecessary work on unrelated base changes.
  • Crash fix

    • Replaced get_id() reads in the transform hooks with safe rank checks against card.base.id.
    • Hardened Cerber’s helper path to no-op cleanly while a card is still being initialized.
local function cerber_card_id(card)
	return card and card.base and card.base.id or nil
end

function Card:set_base(...)
	local previous_id = cerber_card_id(self)
	local x = { card_set_base(self, ...) }
	if previous_id ~= 2 and cerber_card_id(self) == 2 then
		Neuratro.trigger_cerber_on_card(self)
	end
	return unpack(x)
end

@Adesii Adesii marked this pull request as ready for review April 24, 2026 09:34
@Adesii Adesii merged commit a5ff895 into main Apr 24, 2026
1 check passed
@Adesii Adesii deleted the copilot/fix-cerber-joker-triggering branch April 24, 2026 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants