-
Notifications
You must be signed in to change notification settings - Fork 751
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
JayDi85
merged 12 commits into
magefree:master
from
jimga150:add-lifelost-events-and-batch
Mar 21, 2024
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
cdcb797
Initial commit, need to add real effect to Ob Nixilis
jimga150 cea3eb7
Fix Ob Nixilis effect
jimga150 196d232
add author to LifeLostEvent
jimga150 dd1c90d
use equals function
jimga150 6777640
clean up card specific triggered ability
jimga150 5e29221
Add counter clause
jimga150 a31468f
Add tests
jimga150 90bc630
rename convenience function
jimga150 c2cfbc0
rename batch event combiner
jimga150 c7a11d0
rename combat damage checker
jimga150 778eca8
Add test list as comment
jimga150 0faa61d
set strict mode
jimga150 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
105 changes: 105 additions & 0 deletions
105
Mage.Sets/src/mage/cards/o/ObNixilisCaptiveKingpin.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
package mage.cards.o; | ||
|
||
import java.util.UUID; | ||
import mage.MageInt; | ||
import mage.abilities.Ability; | ||
import mage.abilities.TriggeredAbilityImpl; | ||
import mage.abilities.effects.Effect; | ||
import mage.abilities.effects.common.ExileTopXMayPlayUntilEffect; | ||
import mage.abilities.effects.common.counter.AddCountersSourceEffect; | ||
import mage.constants.*; | ||
import mage.abilities.keyword.FlyingAbility; | ||
import mage.abilities.keyword.TrampleAbility; | ||
import mage.cards.CardImpl; | ||
import mage.cards.CardSetInfo; | ||
import mage.counters.CounterType; | ||
import mage.game.Game; | ||
import mage.game.events.*; | ||
import mage.util.CardUtil; | ||
|
||
/** | ||
* | ||
* @author jimga150 | ||
*/ | ||
public final class ObNixilisCaptiveKingpin extends CardImpl { | ||
|
||
public ObNixilisCaptiveKingpin(UUID ownerId, CardSetInfo setInfo) { | ||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{B}{R}"); | ||
|
||
this.supertype.add(SuperType.LEGENDARY); | ||
this.subtype.add(SubType.DEMON); | ||
this.power = new MageInt(4); | ||
this.toughness = new MageInt(3); | ||
|
||
// Flying | ||
this.addAbility(FlyingAbility.getInstance()); | ||
|
||
// Trample | ||
this.addAbility(TrampleAbility.getInstance()); | ||
|
||
// Whenever one or more opponents each lose exactly 1 life, put a +1/+1 counter on Ob Nixilis, Captive Kingpin. Exile the top card of your library. Until your next end step, you may play that card. | ||
Ability ability = new ObNixilisCaptiveKingpinAbility( | ||
new AddCountersSourceEffect(CounterType.P1P1.createInstance()) | ||
); | ||
ability.addEffect(new ExileTopXMayPlayUntilEffect(1, Duration.UntilYourNextEndStep) | ||
.withTextOptions("that card", false)); | ||
|
||
this.addAbility(ability); | ||
|
||
} | ||
|
||
private ObNixilisCaptiveKingpin(final ObNixilisCaptiveKingpin card) { | ||
super(card); | ||
} | ||
|
||
@Override | ||
public ObNixilisCaptiveKingpin copy() { | ||
return new ObNixilisCaptiveKingpin(this); | ||
} | ||
} | ||
|
||
class ObNixilisCaptiveKingpinAbility extends TriggeredAbilityImpl { | ||
|
||
ObNixilisCaptiveKingpinAbility(Effect effect) { | ||
super(Zone.BATTLEFIELD, effect); | ||
setTriggerPhrase("Whenever one or more opponents each lose exactly 1 life, "); | ||
} | ||
|
||
private ObNixilisCaptiveKingpinAbility(final ObNixilisCaptiveKingpinAbility ability) { | ||
super(ability); | ||
} | ||
|
||
@Override | ||
public boolean checkEventType(GameEvent event, Game game) { | ||
return event.getType() == GameEvent.EventType.LOST_LIFE_BATCH; | ||
} | ||
|
||
@Override | ||
public boolean checkTrigger(GameEvent event, Game game) { | ||
|
||
LifeLostBatchEvent lifeLostBatchEvent = (LifeLostBatchEvent) event; | ||
|
||
boolean opponentLostLife = false; | ||
boolean allis1 = true; | ||
|
||
for (UUID targetPlayer : CardUtil.getEventTargets(lifeLostBatchEvent)){ | ||
// skip controller | ||
if (targetPlayer.equals(getControllerId())){ | ||
continue; | ||
} | ||
opponentLostLife = true; | ||
|
||
int lifelost = lifeLostBatchEvent.getLifeLostByPlayer(targetPlayer); | ||
if (lifelost != 1){ | ||
allis1 = false; | ||
break; | ||
} | ||
} | ||
return opponentLostLife && allis1; | ||
} | ||
|
||
@Override | ||
public ObNixilisCaptiveKingpinAbility copy() { | ||
return new ObNixilisCaptiveKingpinAbility(this); | ||
} | ||
} |
This file contains 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
204 changes: 204 additions & 0 deletions
204
....Tests/src/test/java/org/mage/test/cards/triggers/damage/ObNixilisCaptiveKingpinTest.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,204 @@ | ||
package org.mage.test.cards.triggers.damage; | ||
|
||
import mage.constants.PhaseStep; | ||
import mage.constants.Zone; | ||
import mage.counters.CounterType; | ||
import org.junit.Test; | ||
import org.mage.test.serverside.base.CardTestCommander4Players; | ||
|
||
public class ObNixilisCaptiveKingpinTest extends CardTestCommander4Players { | ||
|
||
// - 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 | ||
|
||
@Test | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
public void damageController1Point() { | ||
addCard(Zone.BATTLEFIELD, playerA, "Ob Nixilis, Captive Kingpin", 1); | ||
addCard(Zone.BATTLEFIELD, playerD, "Memnite"); | ||
|
||
attack(2, playerD, "Memnite", playerA); | ||
|
||
setStopAt(2, PhaseStep.END_TURN); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
setStrictChooseMode(true); | ||
execute(); | ||
|
||
assertCounterCount("Ob Nixilis, Captive Kingpin", CounterType.P1P1, 0); | ||
} | ||
|
||
@Test | ||
public void damage1Opp1Point() { | ||
addCard(Zone.BATTLEFIELD, playerA, "Ob Nixilis, Captive Kingpin", 1); | ||
addCard(Zone.BATTLEFIELD, playerA, "Memnite"); | ||
|
||
attack(1, playerA, "Memnite", playerB); | ||
|
||
setStopAt(1, PhaseStep.END_TURN); | ||
setStrictChooseMode(true); | ||
execute(); | ||
|
||
assertCounterCount("Ob Nixilis, Captive Kingpin", CounterType.P1P1, 1); | ||
} | ||
|
||
@Test | ||
public void damage1Opp2Points() { | ||
addCard(Zone.BATTLEFIELD, playerA, "Ob Nixilis, Captive Kingpin", 1); | ||
addCard(Zone.BATTLEFIELD, playerA, "Expedition Envoy"); | ||
|
||
attack(1, playerA, "Expedition Envoy", playerB); | ||
|
||
setStopAt(1, PhaseStep.END_TURN); | ||
setStrictChooseMode(true); | ||
execute(); | ||
|
||
assertCounterCount("Ob Nixilis, Captive Kingpin", CounterType.P1P1, 0); | ||
} | ||
|
||
@Test | ||
public void damage2Opp1Point() { | ||
addCard(Zone.BATTLEFIELD, playerA, "Ob Nixilis, Captive Kingpin", 1); | ||
addCard(Zone.BATTLEFIELD, playerA, "Memnite", 2); | ||
|
||
attack(1, playerA, "Memnite", playerB); | ||
attack(1, playerA, "Memnite", playerC); | ||
|
||
setStopAt(1, PhaseStep.END_TURN); | ||
setStrictChooseMode(true); | ||
execute(); | ||
|
||
assertCounterCount("Ob Nixilis, Captive Kingpin", CounterType.P1P1, 1); | ||
} | ||
|
||
@Test | ||
public void damage2Opp2Points() { | ||
addCard(Zone.BATTLEFIELD, playerA, "Ob Nixilis, Captive Kingpin", 1); | ||
addCard(Zone.BATTLEFIELD, playerA, "Expedition Envoy", 2); | ||
|
||
attack(1, playerA, "Expedition Envoy", playerB); | ||
attack(1, playerA, "Expedition Envoy", playerC); | ||
|
||
setStopAt(1, PhaseStep.END_TURN); | ||
setStrictChooseMode(true); | ||
execute(); | ||
|
||
assertCounterCount("Ob Nixilis, Captive Kingpin", CounterType.P1P1, 0); | ||
} | ||
|
||
@Test | ||
public void payLife1Opp1Point() { | ||
addCard(Zone.BATTLEFIELD, playerA, "Ob Nixilis, Captive Kingpin", 1); | ||
addCard(Zone.BATTLEFIELD, playerB, "Arid Mesa"); | ||
// addCard(Zone.LIBRARY, playerA, "Mountain"); | ||
|
||
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerB, "{T}, Pay 1 life"); | ||
|
||
addTarget(playerB, "Mountain"); | ||
|
||
setStopAt(1, PhaseStep.END_TURN); | ||
setStrictChooseMode(true); | ||
execute(); | ||
|
||
assertCounterCount("Ob Nixilis, Captive Kingpin", CounterType.P1P1, 1); | ||
} | ||
|
||
@Test | ||
public void payLife1Opp2Point() { | ||
addCard(Zone.BATTLEFIELD, playerA, "Ob Nixilis, Captive Kingpin", 1); | ||
|
||
addCard(Zone.BATTLEFIELD, playerB, "Forest", 2); | ||
|
||
// {2}, Pay 2 life: Draw a card. | ||
addCard(Zone.BATTLEFIELD, playerB, "Book of Rass"); | ||
|
||
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerB, "{2}, Pay 2 life"); | ||
|
||
setStopAt(1, PhaseStep.END_TURN); | ||
setStrictChooseMode(true); | ||
execute(); | ||
|
||
assertCounterCount("Ob Nixilis, Captive Kingpin", CounterType.P1P1, 0); | ||
} | ||
|
||
@Test | ||
public void loseLife1Opp1Point() { | ||
addCard(Zone.BATTLEFIELD, playerA, "Ob Nixilis, Captive Kingpin", 1); | ||
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2); | ||
|
||
// {1}{B}, {T}: Target player loses 1 life. | ||
addCard(Zone.BATTLEFIELD, playerA, "Acolyte of Xathrid"); | ||
|
||
addTarget(playerA, playerC); | ||
|
||
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{1}{B}, {T}"); | ||
|
||
setStopAt(1, PhaseStep.END_TURN); | ||
setStrictChooseMode(true); | ||
execute(); | ||
|
||
assertCounterCount("Ob Nixilis, Captive Kingpin", CounterType.P1P1, 1); | ||
} | ||
|
||
@Test | ||
public void loseLife1Opp2Point() { | ||
addCard(Zone.BATTLEFIELD, playerA, "Ob Nixilis, Captive Kingpin", 1); | ||
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 3); | ||
|
||
// Target player draws two cards and loses 2 life. | ||
addCard(Zone.HAND, playerA, "Blood Pact"); | ||
|
||
addTarget(playerA, playerD); | ||
|
||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Blood Pact"); | ||
|
||
setStopAt(1, PhaseStep.END_TURN); | ||
setStrictChooseMode(true); | ||
execute(); | ||
|
||
assertCounterCount("Ob Nixilis, Captive Kingpin", CounterType.P1P1, 0); | ||
} | ||
|
||
@Test | ||
public void loseLifeAll1Point() { | ||
addCard(Zone.BATTLEFIELD, playerA, "Ob Nixilis, Captive Kingpin", 1); | ||
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 3); | ||
|
||
// {2}{W}: Target player gains 1 life. | ||
// {2}{B}: Each player loses 1 life. | ||
addCard(Zone.BATTLEFIELD, playerA, "Orzhov Guildmage"); | ||
|
||
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{2}{B}"); | ||
|
||
setStopAt(1, PhaseStep.END_TURN); | ||
setStrictChooseMode(true); | ||
execute(); | ||
|
||
assertCounterCount("Ob Nixilis, Captive Kingpin", CounterType.P1P1, 1); | ||
} | ||
|
||
@Test | ||
public void loseLifeAll2Point() { | ||
addCard(Zone.BATTLEFIELD, playerA, "Ob Nixilis, Captive Kingpin", 1); | ||
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 4); | ||
|
||
// Each player loses 2 life. You draw two cards. | ||
addCard(Zone.HAND, playerA, "Crushing Disappointment"); | ||
|
||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Crushing Disappointment"); | ||
|
||
setStopAt(1, PhaseStep.END_TURN); | ||
setStrictChooseMode(true); | ||
execute(); | ||
|
||
assertCounterCount("Ob Nixilis, Captive Kingpin", CounterType.P1P1, 0); | ||
} | ||
|
||
} | ||
|
This file contains 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
This file contains 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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
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: