Fixed Burnt Joker retriggers when upgrading None hand#874
Open
paulkent-coder wants to merge 1 commit into
Open
Fixed Burnt Joker retriggers when upgrading None hand#874paulkent-coder wants to merge 1 commit into
paulkent-coder wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
G.FUNCS.discard_cards_from_highlighted is the function Balatro uses to resolve discards. This includes manual discards as well as forcible discards from The Hook. It is this function's responsibility to trigger joker effects relating to discarding cards, such as Burnt Joker's ability to upgrade the first discarded hand each round.
G.FUNCS.discard_cards_from_highlighted has a failsafe by which joker on-discard effects do not activate if no cards are highlighted, perhaps because the player played all the cards in their hand against The Hook, leaving no cards in hand for The Hook to forcibly discard. This makes sense in a context where the None hand does not exist, since trying to upgrade an indeterminate poker hand would presumably not end well for the game.
However, in the context where None exists (and is unlocked for the profile), it is possible for the player to voluntarily discard a None by clicking the Discard button with no cards selected. In this case, it's important to trigger joker on-discard effects, so that it's possible to use Burnt Joker to upgrade None. This is handled by giving the Discard button a special case for the situation where no cards are highlighted, and manually triggering joker on-discard effects in that case. Trouble is, this manual triggering was implemented in an incomplete fashion – the jokers get triggered, but not in the holistic sense that would allow retriggers to be applied. Therefore, Burnt Joker could not be retriggered by Chad et al when upgrading a None hand, even though Burnt Joker's effect is otherwise eligible to be retriggered.
This PR corrects this mistake by replacing the for loop that sends joker triggers with an SMODS.calculate_context call, since calculate_context serves the same purpose while also resolving retriggers.
(I am left wondering whether it would be smarter to modify G.FUNCS.discard_cards_from_highlighted directly rather than go through this whole workaround, both to avoid inconsistencies like this and to allow Burnt Joker to upgrade None off of The Hook discarding nothing. But that's a question for another time.)