Store LKI about what a permanent was attacking/blocking; fix Gomazoa#14899
Open
xenohedron wants to merge 2 commits into
Open
Store LKI about what a permanent was attacking/blocking; fix Gomazoa#14899xenohedron wants to merge 2 commits into
xenohedron wants to merge 2 commits into
Conversation
Member
|
[[Gomazoa]] |
|
Gomazoa - (Gatherer) (Scryfall) (EDHREC)
|
JayDi85
reviewed
May 17, 2026
| creature.setAttacking(false); | ||
| creature.setBlocking(0); | ||
| creature.setAttacking(null); | ||
| creature.clearBlocking(); |
Member
There was a problem hiding this comment.
it's better to use same naming for attack-block like:
- setAttacking
- setBlocking
- clearAttacking
- clearBlocking
- and other
| creature.setBlocking(0); | ||
| creature.setAttacking(null); | ||
| creature.clearBlocking(); | ||
| creature.clearBandedCards(); |
Member
There was a problem hiding this comment.
|
|
||
| @Override | ||
| public void removeBlocking(UUID attackerId, Game game) { | ||
| this.blockingSet.remove(new MageObjectReference(attackerId, game)); |
Member
There was a problem hiding this comment.
See above comments about clear code -- make sure it's called for existing attacker. Maybe some runtime check can help like:
if (this.blockingSet.stream().anyMatch(ref -> Objects.equals(ref.getSourceId(), attackerId))) {
throw new IllegalArgumentException("Wrong code usage: trying to clear non existing blocking object");
}
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.


Was investigating one of the items in #13774 and turns out [[Gomazoa]] has a unique sort of effect. I added tests for a variety of edge cases. Although I tried various approaches with new/existing watchers, no easy combination of watched events was going to work in all my test cases. My conclusion is that the info needed to be stored in the LKI of the permanent, and after implementing that functionality it works nicely.
Previously, a permanent only stored a boolean for whether it was attacking. Now, it stores a MageObjectReference referring to what it's attacking (not just UUID, because e.g. planeswalker could be blinked). Null for not attacking, so testing for null reproduces existing behavior. Added a line to update the reference in the edge case of reselecting defender. This reference isn't actually used yet by any card I know of but since I was adding the functionality for blockers I thought it was good to make it consistent.
A permanent also stores an integer for the number of creatures it's blocking, with 0 for not blocking. This is used in some weird ways to check if further blocks are possible and didn't seem to be updated on every usage I would need, and I didn't want to change existing behavior. So I added a separate set of MageObjectReference to refer to the things it's blocking. This needed a special check for when creatures are explicitly removed from combat. It still holds references to permanents that have left the battlefield, which is what we need for LKI usage. It's not for the purpose of counting, that's handled by existing watchers.
The existing combat code is pretty messy and could likely be cleaned up with some investigation, but I kept these adjustments minimal here. All tests pass.