Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add life lost event and batch event to implement Ob Nixilis, Captive Kingpin #11974

Merged
merged 12 commits into from
Mar 21, 2024

Conversation

jimga150
Copy link
Contributor

#10020

In order to get this card to work properly, i implemented a LifeLostEvent that gets batched into LifeLostBatchEvent, similar to DamagedBatchEvent and DamagedEvent. It looks like batching the LOST_LIFE event is the only thing necessary to ensure this card sees all the triggers it should, since any form of damage, life paying costs, as well as "lose life" effects all fire the LOST_LIFE event.

So far i have playtested all of these with one and two opponents losing 1 and 2 or more life due to

  • combat damage
  • pay life effects
  • lose life effects

The card seems to work as intended.

Copy link
Contributor

@xenohedron xenohedron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable enough, definitely should have some unit tests to confirm functionality though

Mage.Sets/src/mage/cards/o/ObNixilisCaptiveKingpin.java Outdated Show resolved Hide resolved
Mage.Sets/src/mage/cards/o/ObNixilisCaptiveKingpin.java Outdated Show resolved Hide resolved
Mage.Sets/src/mage/cards/o/ObNixilisCaptiveKingpin.java Outdated Show resolved Hide resolved
@jimga150 jimga150 marked this pull request as draft March 21, 2024 03:57
@jimga150
Copy link
Contributor Author

jimga150 commented Mar 21, 2024

Writing the tests. Intended tests i plan to hit (Let me know if there should be more):

  • 1 opponent dealt 1 damage -> Ob Nixilis triggers
  • 1 opponent dealt 2 damage -> No trigger
  • 2 opponents dealt 1 damage each -> Ob Nixilis triggers
  • 2 opponents dealt 2 damage each -> No trigger
  • opponent pays 1 life-> Ob Nixilis triggers
  • opponent pays 2 life -> No trigger
  • 1 opponent loses 1 life -> Ob Nixilis triggers
  • 1 opponent loses 2 life -> No trigger
  • 2 opponents lose 1 life each -> Ob Nixilis triggers
  • 2 opponents lose 2 life each -> No trigger
  • controller loses 1 life -> No trigger

.sum();
}

public int getAmount(UUID targetID) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Raname to getLifeLoseByPlayer

@@ -808,6 +808,25 @@ public boolean hasSimultaneousEvents() {
return !simultaneousEvents.isEmpty();
}

public void addSimultaneousLifeLoss(LifeLostEvent lifeLossEvent, Game game) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current naming logic of all batch methods is wrong - it does not add real events to sim queue, only batches. So it must be renamed to addSimultaneousXxxEventToBatches - damaged, loseLife, tapped, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going to rename just this function in this PR for now, unless youre good with renaming the rest in here.

}

public boolean isCombatDamage() {
return events.stream().anyMatch(LifeLostEvent::isCombatDamage);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be wrong usage. Related card must use events list or use method like getLifeLoseByCombatDamage(isCombatDamage::Boolaean) > 0, not isCombatDamage.

@jimga150 jimga150 marked this pull request as ready for review March 21, 2024 13:56
@github-actions github-actions bot added the tests label Mar 21, 2024

attack(2, playerD, "Memnite", playerA);

setStopAt(2, PhaseStep.END_TURN);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Miss setStrictChooseMode before setstop/execute. It allows to check commands order and missing commands. Must be used all the time.


public class ObNixilisCaptiveKingpinTest extends CardTestCommander4Players {

@Test
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a details list from your comment about possible use cases can be useful here (just copy as comment).

IMG_0022

@xenohedron xenohedron self-requested a review March 21, 2024 14:44
@JayDi85 JayDi85 merged commit 50c75f0 into magefree:master Mar 21, 2024
3 checks passed
// - 1 opponent loses 2 life -> No trigger
// - 2 opponents lose 1 life each -> Ob Nixilis triggers
// - 2 opponents lose 2 life each -> No trigger
// - controller loses 1 life -> No trigger
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are a good starting point. I'd like to see a couple more tests:

  • opponent loses 1 life and another opponent simultaneously loses 2 life
  • opponent loses 1 life and controller simultaneously loses 2 life

playerId, source, playerId, amount, atCombat);
}

public boolean isCombatDamage() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be renamed same as the batch event for clarity

(also... is there existing card that cares about it? if not, maybe better to just remove entirely.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, currently no card uses this, but its a short road to walk.

@xenohedron
Copy link
Contributor

nice work though, this is great functionality to have in the engine, hopefully we can use it to fix some other longstanding bugs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants