Skip to content

Commit

Permalink
* fixed dies events support in single cards (use cases like sacrifice…
Browse files Browse the repository at this point in the history
… cost);
  • Loading branch information
JayDi85 committed Nov 30, 2024
1 parent 66b338c commit 0f8416c
Show file tree
Hide file tree
Showing 17 changed files with 84 additions and 32 deletions.
2 changes: 1 addition & 1 deletion Mage.Sets/src/mage/cards/c/Chronozoa.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public Chronozoa(UUID ownerId, CardSetInfo setInfo) {
// Vanishing 3 (This permanent enters the battlefield with three time counters on it. At the beginning of your upkeep, remove a time counter from it. When the last is removed, sacrifice it.)
this.addAbility(new VanishingAbility(3));

// When Chronozoa is put into a graveyard from play, if it had no time counters on it, create two tokens that are copies of it.
// When Chronozoa dies, if it had no time counters on it, create two tokens that are copies of it.
Effect effect = new CreateTokenCopySourceEffect(2);
effect.setText("create two tokens that are copies of it");
this.addAbility(new ConditionalInterveningIfTriggeredAbility(new DiesSourceTriggeredAbility(effect, false),
Expand Down
8 changes: 8 additions & 0 deletions Mage.Sets/src/mage/cards/f/FalkenrathNoble.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package mage.cards.f;

import mage.MageInt;
import mage.MageObject;
import mage.abilities.AbilityImpl;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.effects.common.LoseLifeTargetEffect;
Expand Down Expand Up @@ -51,6 +53,7 @@ public FalkenrathNobleTriggeredAbility() {
super(Zone.BATTLEFIELD, new LoseLifeTargetEffect(1), false);
this.addEffect(new GainLifeEffect(1));
this.addTarget(new TargetPlayer());
this.setLeavesTheBattlefieldTrigger(true);
}

private FalkenrathNobleTriggeredAbility(final FalkenrathNobleTriggeredAbility ability) {
Expand Down Expand Up @@ -87,4 +90,9 @@ public boolean checkTrigger(GameEvent event, Game game) {
public String getRule() {
return "Whenever {this} or another creature dies, target player loses 1 life and you gain 1 life.";
}

@Override
public boolean isInUseableZone(Game game, MageObject source, GameEvent event) {
return TriggeredAbilityImpl.isInUseableZoneDiesTrigger(this, event, game);
}
}
9 changes: 8 additions & 1 deletion Mage.Sets/src/mage/cards/g/GraveBetrayal.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
package mage.cards.g;

import java.util.UUID;

import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.TriggeredAbilityImpl;
Expand Down Expand Up @@ -53,6 +55,7 @@ class GraveBetrayalTriggeredAbility extends TriggeredAbilityImpl {

public GraveBetrayalTriggeredAbility() {
super(Zone.BATTLEFIELD, null);
this.setLeavesTheBattlefieldTrigger(true);
}

private GraveBetrayalTriggeredAbility(final GraveBetrayalTriggeredAbility ability) {
Expand Down Expand Up @@ -92,6 +95,11 @@ public boolean checkTrigger(GameEvent event, Game game) {
public String getRule() {
return "Whenever a creature you don't control dies, return it to the battlefield under your control with an additional +1/+1 counter on it at the beginning of the next end step. That creature is a black Zombie in addition to its other colors and types.";
}

@Override
public boolean isInUseableZone(Game game, MageObject source, GameEvent event) {
return TriggeredAbilityImpl.isInUseableZoneDiesTrigger(this, event, game);
}
}

class GraveBetrayalEffect extends OneShotEffect {
Expand Down Expand Up @@ -125,7 +133,6 @@ public boolean apply(Game game, Ability source) {
}
return false;
}

}

class GraveBetrayalReplacementEffect extends ReplacementEffectImpl {
Expand Down
8 changes: 7 additions & 1 deletion Mage.Sets/src/mage/cards/g/GravePact.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package mage.cards.g;

import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.OneShotEffect;
Expand Down Expand Up @@ -29,7 +30,6 @@ public final class GravePact extends CardImpl {
public GravePact(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{B}{B}{B}");


// Whenever a creature you control dies, each other player sacrifices a creature.
this.addAbility(new GravePactTriggeredAbility());
}
Expand All @@ -49,6 +49,7 @@ class GravePactTriggeredAbility extends TriggeredAbilityImpl {
public GravePactTriggeredAbility() {
super(Zone.BATTLEFIELD, new GravePactEffect());
setTriggerPhrase("Whenever a creature you control dies, ");
setLeavesTheBattlefieldTrigger(true);
}

private GravePactTriggeredAbility(final GravePactTriggeredAbility ability) {
Expand All @@ -74,6 +75,11 @@ public boolean checkTrigger(GameEvent event, Game game) {
}
return false;
}

@Override
public boolean isInUseableZone(Game game, MageObject source, GameEvent event) {
return TriggeredAbilityImpl.isInUseableZoneDiesTrigger(this, event, game);
}
}

class GravePactEffect extends OneShotEffect {
Expand Down
1 change: 1 addition & 0 deletions Mage.Sets/src/mage/cards/k/KarmicJustice.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class KarmicJusticeTriggeredAbility extends TriggeredAbilityImpl {

KarmicJusticeTriggeredAbility() {
super(Zone.BATTLEFIELD, new DestroyTargetEffect(), true);
setLeavesTheBattlefieldTrigger(true);
}

private KarmicJusticeTriggeredAbility(final KarmicJusticeTriggeredAbility ability) {
Expand Down
17 changes: 1 addition & 16 deletions Mage.Sets/src/mage/cards/k/KayaTheInexorable.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class KayaTheInexorableTriggeredAbility extends TriggeredAbilityImpl {

public KayaTheInexorableTriggeredAbility() {
super(Zone.ALL, null, false);
setLeavesTheBattlefieldTrigger(true);
}

private KayaTheInexorableTriggeredAbility(KayaTheInexorableTriggeredAbility ability) {
Expand Down Expand Up @@ -107,22 +108,6 @@ public boolean checkTrigger(GameEvent event, Game game) {
return false;
}

@Override
public boolean isInUseableZone(Game game, MageObject source, GameEvent event) {
Permanent sourcePermanent = null;
if (game.getState().getZone(getSourceId()) == Zone.BATTLEFIELD) {
sourcePermanent = game.getPermanent(getSourceId());
} else {
if (game.checkShortLivingLKI(getSourceId(), Zone.BATTLEFIELD)) {
sourcePermanent = (Permanent) game.getLastKnownInformation(getSourceId(), Zone.BATTLEFIELD);
}
}
if (sourcePermanent == null) {
return false;
}
return hasSourceObjectAbility(game, sourcePermanent, event);
}

@Override
public KayaTheInexorableTriggeredAbility copy() {
return new KayaTheInexorableTriggeredAbility(this);
Expand Down
7 changes: 7 additions & 0 deletions Mage.Sets/src/mage/cards/m/MarchesaTheBlackRose.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.TriggeredAbilityImpl;
Expand Down Expand Up @@ -67,6 +68,7 @@ class MarchesaTheBlackRoseTriggeredAbility extends TriggeredAbilityImpl {
public MarchesaTheBlackRoseTriggeredAbility() {
super(Zone.BATTLEFIELD, new MarchesaTheBlackRoseEffect());
setTriggerPhrase("Whenever a creature you control with a +1/+1 counter on it dies, ");
setLeavesTheBattlefieldTrigger(true);
}

private MarchesaTheBlackRoseTriggeredAbility(final MarchesaTheBlackRoseTriggeredAbility ability) {
Expand Down Expand Up @@ -100,6 +102,11 @@ public boolean checkTrigger(GameEvent event, Game game) {
}
return false;
}

@Override
public boolean isInUseableZone(Game game, MageObject source, GameEvent event) {
return TriggeredAbilityImpl.isInUseableZoneDiesTrigger(this, event, game);
}
}

class MarchesaTheBlackRoseEffect extends OneShotEffect {
Expand Down
7 changes: 7 additions & 0 deletions Mage.Sets/src/mage/cards/m/MassacreWurm.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.Effect;
Expand Down Expand Up @@ -52,6 +53,7 @@ class MassacreWurmTriggeredAbility extends TriggeredAbilityImpl {
MassacreWurmTriggeredAbility() {
super(Zone.BATTLEFIELD, new LoseLifeTargetEffect(2));
setTriggerPhrase("Whenever a creature an opponent controls dies, ");
setLeavesTheBattlefieldTrigger(true);
}

private MassacreWurmTriggeredAbility(final MassacreWurmTriggeredAbility ability) {
Expand Down Expand Up @@ -81,4 +83,9 @@ public boolean checkTrigger(GameEvent event, Game game) {
}
return false;
}

@Override
public boolean isInUseableZone(Game game, MageObject source, GameEvent event) {
return TriggeredAbilityImpl.isInUseableZoneDiesTrigger(this, event, game);
}
}
8 changes: 8 additions & 0 deletions Mage.Sets/src/mage/cards/m/MimicVat.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;

import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.TriggeredAbilityImpl;
Expand Down Expand Up @@ -60,6 +62,7 @@ class MimicVatTriggeredAbility extends TriggeredAbilityImpl {

MimicVatTriggeredAbility() {
super(Zone.BATTLEFIELD, new MimicVatEffect(), true);
setLeavesTheBattlefieldTrigger(true);
}

private MimicVatTriggeredAbility(final MimicVatTriggeredAbility ability) {
Expand Down Expand Up @@ -105,6 +108,11 @@ public boolean checkTrigger(GameEvent event, Game game) {
public String getRule() {
return AbilityWord.IMPRINT.formatWord() + "Whenever a nontoken creature dies, you may exile that card. If you do, return each other card exiled with {this} to its owner's graveyard.";
}

@Override
public boolean isInUseableZone(Game game, MageObject source, GameEvent event) {
return TriggeredAbilityImpl.isInUseableZoneDiesTrigger(this, event, game);
}
}

class MimicVatEffect extends OneShotEffect {
Expand Down
6 changes: 6 additions & 0 deletions Mage.Sets/src/mage/cards/m/MycoidShepherd.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class MycoidShepherdTriggeredAbility extends TriggeredAbilityImpl {

public MycoidShepherdTriggeredAbility() {
super(Zone.BATTLEFIELD, new GainLifeEffect(5), true);
setLeavesTheBattlefieldTrigger(true);
}

private MycoidShepherdTriggeredAbility(final MycoidShepherdTriggeredAbility ability) {
Expand Down Expand Up @@ -91,4 +92,9 @@ public String getRule() {
public MycoidShepherdTriggeredAbility copy() {
return new MycoidShepherdTriggeredAbility(this);
}

@Override
public boolean isInUseableZone(Game game, MageObject source, GameEvent event) {
return TriggeredAbilityImpl.isInUseableZoneDiesTrigger(this, event, game);
}
}
7 changes: 7 additions & 0 deletions Mage.Sets/src/mage/cards/n/Necroskitter.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.ReturnToBattlefieldUnderYourControlTargetEffect;
Expand Down Expand Up @@ -55,6 +56,7 @@ class NecroskitterTriggeredAbility extends TriggeredAbilityImpl {

public NecroskitterTriggeredAbility() {
super(Zone.BATTLEFIELD, new ReturnToBattlefieldUnderYourControlTargetEffect(), true);
setLeavesTheBattlefieldTrigger(true);
}

private NecroskitterTriggeredAbility(final NecroskitterTriggeredAbility ability) {
Expand Down Expand Up @@ -92,4 +94,9 @@ public boolean checkTrigger(GameEvent event, Game game) {
public String getRule() {
return "Whenever a creature an opponent controls with a -1/-1 counter on it dies, you may return that card to the battlefield under your control.";
}

@Override
public boolean isInUseableZone(Game game, MageObject source, GameEvent event) {
return TriggeredAbilityImpl.isInUseableZoneDiesTrigger(this, event, game);
}
}
7 changes: 7 additions & 0 deletions Mage.Sets/src/mage/cards/o/OrahSkyclaveHierophant.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package mage.cards.o;

import mage.MageInt;
import mage.MageObject;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect;
import mage.abilities.keyword.LifelinkAbility;
Expand Down Expand Up @@ -51,6 +52,7 @@ class OrahSkyclaveHierophantTriggeredAbility extends TriggeredAbilityImpl {

OrahSkyclaveHierophantTriggeredAbility() {
super(Zone.BATTLEFIELD, new ReturnFromGraveyardToBattlefieldTargetEffect());
setLeavesTheBattlefieldTrigger(true);
}

private OrahSkyclaveHierophantTriggeredAbility(final OrahSkyclaveHierophantTriggeredAbility ability) {
Expand Down Expand Up @@ -94,4 +96,9 @@ public String getRule() {
return "Whenever {this} or another Cleric you control dies, return target Cleric card " +
"with lesser mana value from your graveyard to the battlefield.";
}

@Override
public boolean isInUseableZone(Game game, MageObject source, GameEvent event) {
return TriggeredAbilityImpl.isInUseableZoneDiesTrigger(this, event, game);
}
}
6 changes: 6 additions & 0 deletions Mage.Sets/src/mage/cards/p/PatronOfTheVein.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class PatronOfTheVeinCreatureDiesTriggeredAbility extends TriggeredAbilityImpl {

public PatronOfTheVeinCreatureDiesTriggeredAbility() {
super(Zone.BATTLEFIELD, new PatronOfTheVeinExileCreatureEffect(), false);
setLeavesTheBattlefieldTrigger(true);
}

private PatronOfTheVeinCreatureDiesTriggeredAbility(final PatronOfTheVeinCreatureDiesTriggeredAbility ability) {
Expand Down Expand Up @@ -107,6 +108,11 @@ public boolean checkTrigger(GameEvent event, Game game) {
public String getRule() {
return "Whenever a creature an opponent controls dies, exile it and put a +1/+1 counter on each Vampire you control.";
}

@Override
public boolean isInUseableZone(Game game, MageObject source, GameEvent event) {
return TriggeredAbilityImpl.isInUseableZoneDiesTrigger(this, event, game);
}
}

class PatronOfTheVeinExileCreatureEffect extends OneShotEffect {
Expand Down
4 changes: 1 addition & 3 deletions Mage.Sets/src/mage/cards/p/PhantasmalImage.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ public PhantasmalImage(UUID ownerId, CardSetInfo setInfo) {
this.power = new MageInt(0);
this.toughness = new MageInt(0);

// You may have Phantasmal Image enter the battlefield as a copy of any creature
// on the battlefield, except it's an Illusion in addition to its other types and
// it has "When this creature becomes the target of a spell or ability, sacrifice it."
// You may have Phantasmal Image enter the battlefield as a copy of any creature on the battlefield, except it's an Illusion in addition to its other types and it has "When this creature becomes the target of a spell or ability, sacrifice it."
Effect effect = new CopyPermanentEffect(StaticFilters.FILTER_PERMANENT_CREATURE, phantasmalImageApplier);
effect.setText(effectText);
this.addAbility(new EntersBattlefieldAbility(effect, true));
Expand Down
1 change: 1 addition & 0 deletions Mage.Sets/src/mage/cards/r/ReyhanLastOfTheAbzan.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class ReyhanLastOfTheAbzanTriggeredAbility extends TriggeredAbilityImpl {

public ReyhanLastOfTheAbzanTriggeredAbility() {
super(Zone.BATTLEFIELD, null, true);
setLeavesTheBattlefieldTrigger(true);
}

private ReyhanLastOfTheAbzanTriggeredAbility(final ReyhanLastOfTheAbzanTriggeredAbility ability) {
Expand Down
6 changes: 6 additions & 0 deletions Mage.Sets/src/mage/cards/s/ShelobChildOfUngoliant.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package mage.cards.s;

import mage.MageInt;
import mage.MageObject;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
Expand Down Expand Up @@ -185,6 +186,11 @@ public boolean checkTrigger(GameEvent event, Game game) {
}
return false;
}

@Override
public boolean isInUseableZone(Game game, MageObject source, GameEvent event) {
return TriggeredAbilityImpl.isInUseableZoneDiesTrigger(this, event, game);
}
}

class ShelobChildOfUngoliantEffect extends OneShotEffect {
Expand Down
12 changes: 2 additions & 10 deletions Mage.Sets/src/mage/cards/v/VindictiveVampire.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class VindictiveVampireTriggeredAbility extends TriggeredAbilityImpl {
public VindictiveVampireTriggeredAbility(Zone zone, Effect effect) {
super(zone, effect, false);
setTriggerPhrase("Whenever another creature you control dies, ");
setLeavesTheBattlefieldTrigger(true);
}

private VindictiveVampireTriggeredAbility(final VindictiveVampireTriggeredAbility ability) {
Expand All @@ -70,16 +71,7 @@ public VindictiveVampireTriggeredAbility copy() {

@Override
public boolean isInUseableZone(Game game, MageObject source, GameEvent event) {
Permanent sourcePermanent;
if (game.getState().getZone(getSourceId()) == Zone.BATTLEFIELD) {
sourcePermanent = game.getPermanent(getSourceId());
} else {
sourcePermanent = (Permanent) game.getPermanentOrLKIBattlefield(getSourceId());
}
if (sourcePermanent == null) {
return false;
}
return hasSourceObjectAbility(game, sourcePermanent, event);
return TriggeredAbilityImpl.isInUseableZoneDiesTrigger(this, event, game);
}

@Override
Expand Down

0 comments on commit 0f8416c

Please sign in to comment.