mirror of
https://github.com/correl/mage.git
synced 2025-03-07 20:53:18 -10:00
* Some Aftermath fixes.
This commit is contained in:
parent
0ef94a588c
commit
6530b404c8
2 changed files with 81 additions and 3 deletions
|
@ -46,6 +46,10 @@ public class DuskDawnTest extends CardTestPlayerBase {
|
|||
|
||||
@Test
|
||||
public void testCastDawnFromGraveyard() {
|
||||
// Dusk
|
||||
// Destroy all creatures with power 3 or greater.
|
||||
// Dawn
|
||||
// Return all creature cards with power less than or equal to 2 from your graveyard to your hand.
|
||||
addCard(Zone.GRAVEYARD, playerA, "Dusk // Dawn");
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Plains", 5);
|
||||
addCard(Zone.GRAVEYARD, playerA, "Devoted Hero");
|
||||
|
@ -85,5 +89,4 @@ public class DuskDawnTest extends CardTestPlayerBase {
|
|||
assertGraveyardCount(playerA, "Devoted Hero", 1);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -31,11 +31,14 @@ import java.util.UUID;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.*;
|
||||
import mage.abilities.effects.common.ExileSpellEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.SplitCardHalf;
|
||||
import mage.constants.*;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
* Aftermath
|
||||
|
@ -52,7 +55,7 @@ public class AftermathAbility extends SimpleStaticAbility {
|
|||
public AftermathAbility() {
|
||||
super(Zone.ALL, new AftermathCastFromGraveyard());
|
||||
addEffect(new AftermathCantCastFromHand());
|
||||
addEffect(ExileSpellEffect.getInstance());
|
||||
addEffect(new AftermathExileAsResolvesFromGraveyard());
|
||||
}
|
||||
|
||||
public AftermathAbility(final AftermathAbility ability) {
|
||||
|
@ -141,3 +144,75 @@ class AftermathCantCastFromHand extends ContinuousRuleModifyingEffectImpl {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class AftermathExileAsResolvesFromGraveyard extends ReplacementEffectImpl {
|
||||
|
||||
AftermathExileAsResolvesFromGraveyard() {
|
||||
super(Duration.WhileOnStack, Outcome.Detriment);
|
||||
this.staticText = "Exile it afterwards.";
|
||||
}
|
||||
|
||||
AftermathExileAsResolvesFromGraveyard(AftermathExileAsResolvesFromGraveyard effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.ZONE_CHANGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent evt, Ability source, Game game) {
|
||||
ZoneChangeEvent event = (ZoneChangeEvent) evt;
|
||||
if (event.getFromZone() == Zone.STACK && event.getToZone() != Zone.EXILED) {
|
||||
// Moving something from stack to somewhere else
|
||||
|
||||
// Get the source id, getting the whole split card's ID, because
|
||||
// that's the card that is changing zones in the event, but
|
||||
// source.getSourceId is only the split card half.
|
||||
// If branch so that we also support putting Aftermath on
|
||||
// non-split cards for... whatever reason, in case somebody
|
||||
// wants to do that in the future.
|
||||
UUID sourceId = source.getSourceId();
|
||||
Card sourceCard = game.getCard(source.getSourceId());
|
||||
if (sourceCard != null && sourceCard instanceof SplitCardHalf) {
|
||||
sourceCard = ((SplitCardHalf) sourceCard).getParentCard();
|
||||
sourceId = sourceCard.getId();
|
||||
}
|
||||
|
||||
if (event.getTargetId() == sourceId) {
|
||||
// Moving this spell from stack to yard
|
||||
Spell spell = game.getStack().getSpell(source.getSourceId());
|
||||
if (spell != null && spell.getFromZone() == Zone.GRAVEYARD) {
|
||||
// And this spell was cast from the graveyard, so we need to exile it
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
UUID sourceId = source.getSourceId();
|
||||
Card sourceCard = game.getCard(source.getSourceId());
|
||||
if (sourceCard != null && sourceCard instanceof SplitCardHalf) {
|
||||
sourceCard = ((SplitCardHalf) sourceCard).getParentCard();
|
||||
sourceId = sourceCard.getId();
|
||||
}
|
||||
|
||||
if (sourceCard != null) {
|
||||
Player player = game.getPlayer(sourceCard.getOwnerId());
|
||||
if (player != null) {
|
||||
return player.moveCardToExileWithInfo(sourceCard, null, "", sourceId, game, ((ZoneChangeEvent) event).getFromZone(), true);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AftermathExileAsResolvesFromGraveyard copy() {
|
||||
return new AftermathExileAsResolvesFromGraveyard(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue