* Vengeful Pharaoh - Fixed that it triggered for every creature doing simultaneously combat damage. Fixed that it wrongly also worked, if Vengeful Pharaoh already left the graveyard.

This commit is contained in:
LevelX2 2015-02-27 01:06:11 +01:00
parent 86393db911
commit 7a0e16fb33

View file

@ -28,22 +28,24 @@
package mage.sets.magic2012;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.MageInt;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.DeathtouchAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.DamagedEvent;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.game.turn.Step;
import mage.players.Player;
import mage.target.common.TargetAttackingCreature;
@ -58,11 +60,13 @@ public class VengefulPharaoh extends CardImpl {
this.expansionSetCode = "M12";
this.subtype.add("Zombie");
this.color.setBlack(true);
this.power = new MageInt(5);
this.toughness = new MageInt(4);
// Deathtouch (Any amount of damage this deals to a creature is enough to destroy it.)
this.addAbility(DeathtouchAbility.getInstance());
// Whenever combat damage is dealt to you or a planeswalker you control, if Vengeful Pharaoh is in your graveyard, destroy target attacking creature, then put Vengeful Pharaoh on top of your library.
this.addAbility(new VengefulPharaohTriggeredAbility());
}
@ -78,6 +82,12 @@ public class VengefulPharaoh extends CardImpl {
class VengefulPharaohTriggeredAbility extends TriggeredAbilityImpl {
Step stepTriggeredPlayer;
int turnTriggeredPlayer;
Step stepTriggeredPlansewalker;
int turnTriggeredPlaneswalker;
public VengefulPharaohTriggeredAbility() {
super(Zone.GRAVEYARD, new VengefulPharaohEffect(), false);
this.addTarget(new TargetAttackingCreature());
@ -85,6 +95,10 @@ class VengefulPharaohTriggeredAbility extends TriggeredAbilityImpl {
public VengefulPharaohTriggeredAbility(final VengefulPharaohTriggeredAbility ability) {
super(ability);
this.stepTriggeredPlansewalker = ability.stepTriggeredPlansewalker;
this.turnTriggeredPlaneswalker = ability.turnTriggeredPlaneswalker;
this.stepTriggeredPlayer = ability.stepTriggeredPlayer;
this.turnTriggeredPlayer = ability.turnTriggeredPlayer;
}
@Override
@ -92,18 +106,43 @@ class VengefulPharaohTriggeredAbility extends TriggeredAbilityImpl {
return new VengefulPharaohTriggeredAbility(this);
}
@Override
public boolean checkInterveningIfClause(Game game) {
// 9/22/2011 - If multiple creatures deal combat damage to you and to a planeswalker you control
// simultaneously, Vengeful Pharaoh will trigger twice. The first trigger will cause Vengeful Pharaoh
// to be put on top of your library. The second trigger will then do nothing, as Vengeful Pharaoh is
// no longer in your graveyard when it tries to resolve. Note that the second trigger will do nothing
// even if Vengeful Pharaoh is put back into your graveyard before it tries to resolve, as it's a
// different Vengeful Pharaoh than the one that was there before.
MageObjectReference mor = new MageObjectReference(getSourceId(), game);
return mor.refersTo(this.getSourceObject(game));
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == EventType.DAMAGED_PLAYER || event.getType() == EventType.DAMAGED_PLANESWALKER;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if ((event.getType() == EventType.DAMAGED_PLAYER && event.getTargetId().equals(this.getControllerId()))
&& ((DamagedEvent) event).isCombatDamage()) {
if (!game.getPhase().getStep().equals(stepTriggeredPlayer) || game.getTurnNum() != turnTriggeredPlayer) {
stepTriggeredPlayer = game.getPhase().getStep();
turnTriggeredPlayer = game.getTurnNum();
return true;
}
}
if (event.getType() == EventType.DAMAGED_PLANESWALKER && ((DamagedEvent) event).isCombatDamage()) {
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent != null && permanent.getControllerId().equals(this.getControllerId())) {
if (!game.getPhase().getStep().equals(stepTriggeredPlansewalker) || game.getTurnNum() != turnTriggeredPlaneswalker) {
stepTriggeredPlansewalker = game.getPhase().getStep();
turnTriggeredPlaneswalker = game.getTurnNum();
return true;
}
}
}
return false;
}
@ -131,19 +170,16 @@ class VengefulPharaohEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
boolean applied = false;
Player controller = game.getPlayer(source.getControllerId());
Card card = game.getCard(source.getSourceId());
if (card != null && controller != null) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null) {
permanent.destroy(source.getSourceId(), game, false);
applied = true;
}
Player player = game.getPlayer(source.getControllerId());
Card card = game.getCard(source.getSourceId());
if (card != null && player != null) {
player.getGraveyard().remove(card);
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
applied = true;
controller.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.GRAVEYARD, true, true);
return true;
}
return applied;
return false;
}
}