* Scythe of the Wretched - some minor updates.

This commit is contained in:
LevelX2 2015-03-25 22:48:00 +01:00
parent d876d6d183
commit 3d3e51a822

View file

@ -27,27 +27,24 @@
*/ */
package mage.sets.mirrodin; package mage.sets.mirrodin;
import java.util.HashSet;
import java.util.UUID; import java.util.UUID;
import mage.MageObjectReference; import mage.MageObjectReference;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.TriggeredAbility;
import mage.abilities.TriggeredAbilityImpl; import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.DiesAndDealtDamageThisTurnTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.common.SpellCastAllTriggeredAbility;
import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.ReturnToBattlefieldUnderYourControlAttachedEffect;
import mage.abilities.effects.common.ReturnToBattlefieldUnderYourControlSourceEffect;
import mage.abilities.effects.common.continuous.BoostEquippedEffect; import mage.abilities.effects.common.continuous.BoostEquippedEffect;
import mage.abilities.keyword.EquipAbility; import mage.abilities.keyword.EquipAbility;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.*; import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent; import mage.game.events.ZoneChangeEvent;
@ -55,12 +52,11 @@ import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTarget;
import mage.target.targetpointer.TargetPointer; import mage.target.targetpointer.TargetPointer;
import mage.watchers.common.CreaturesDiedWatcher;
/** /**
* *
* @author Jason E. Wall * @author Jason E. Wall
*
*/ */
public class ScytheOfTheWretched extends CardImpl { public class ScytheOfTheWretched extends CardImpl {
@ -71,8 +67,10 @@ public class ScytheOfTheWretched extends CardImpl {
// Equipped creature gets +2/+2. // Equipped creature gets +2/+2.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEquippedEffect(2, 2, Duration.WhileOnBattlefield))); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEquippedEffect(2, 2, Duration.WhileOnBattlefield)));
// Whenever a creature dealt damage by equipped creature this turn dies, return that card to the battlefield under your control. Attach Scythe of the Wretched to that creature. // Whenever a creature dealt damage by equipped creature this turn dies, return that card to the battlefield under your control. Attach Scythe of the Wretched to that creature.
this.addAbility(new ScytheOfTheWretchedAbility()); this.addAbility(new ScytheOfTheWretchedTriggeredAbility());
// Equip {4} // Equip {4}
this.addAbility(new EquipAbility(Outcome.AddAbility, new GenericManaCost(4))); this.addAbility(new EquipAbility(Outcome.AddAbility, new GenericManaCost(4)));
} }
@ -87,22 +85,22 @@ public class ScytheOfTheWretched extends CardImpl {
} }
} }
class ScytheOfTheWretchedAbility extends TriggeredAbilityImpl { class ScytheOfTheWretchedTriggeredAbility extends TriggeredAbilityImpl {
public ScytheOfTheWretchedAbility() { public ScytheOfTheWretchedTriggeredAbility() {
super(Zone.ALL, new ScytheOfTheWretchedReanimateEffect(), false); super(Zone.ALL, new ScytheOfTheWretchedReanimateEffect(), false);
Effect attachToThatCreature = new AttachEffect(Outcome.AddAbility); Effect effect = new AttachEffect(Outcome.AddAbility);
attachToThatCreature.setText("Attach {this} to that creature."); effect.setText("Attach {this} to that creature.");
addEffect(attachToThatCreature); addEffect(effect);
} }
public ScytheOfTheWretchedAbility(final ScytheOfTheWretchedAbility ability) { public ScytheOfTheWretchedTriggeredAbility(final ScytheOfTheWretchedTriggeredAbility ability) {
super(ability); super(ability);
} }
@Override @Override
public ScytheOfTheWretchedAbility copy() { public ScytheOfTheWretchedTriggeredAbility copy() {
return new ScytheOfTheWretchedAbility(this); return new ScytheOfTheWretchedTriggeredAbility(this);
} }
@Override @Override
@ -112,19 +110,19 @@ class ScytheOfTheWretchedAbility extends TriggeredAbilityImpl {
@Override @Override
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
Permanent equippedCreature = getEquippedCreature(game);
if(equippedCreature == null) { return false; }
ZoneChangeEvent zoneChange = (ZoneChangeEvent) event; ZoneChangeEvent zoneChange = (ZoneChangeEvent) event;
if(zoneChange.isDiesEvent() && zoneChange.getTarget().getCardType().contains(CardType.CREATURE)) { if (zoneChange.isDiesEvent() && zoneChange.getTarget().getCardType().contains(CardType.CREATURE)) {
for(MageObjectReference mor : zoneChange.getTarget().getDealtDamageByThisTurn()) { Permanent equippedCreature = getEquippedCreature(game);
if(mor.refersTo(equippedCreature)) { if (equippedCreature == null) {
return false;
}
for (MageObjectReference mor : zoneChange.getTarget().getDealtDamageByThisTurn()) {
if (mor.refersTo(equippedCreature)) {
setTarget(new FixedTarget(event.getTargetId())); setTarget(new FixedTarget(event.getTargetId()));
return true; return true;
} }
} }
} }
return false; return false;
} }
@ -134,14 +132,14 @@ class ScytheOfTheWretchedAbility extends TriggeredAbilityImpl {
} }
private void setTarget(TargetPointer target) { private void setTarget(TargetPointer target) {
for(Effect effect : getEffects()) { for (Effect effect : getEffects()) {
effect.setTargetPointer(target); effect.setTargetPointer(target);
} }
} }
private Permanent getEquippedCreature(Game game) { private Permanent getEquippedCreature(Game game) {
Permanent equipment = game.getPermanent(getSourceId()); Permanent equipment = game.getPermanent(getSourceId());
if(equipment != null && equipment.getAttachedTo() != null) { if (equipment != null && equipment.getAttachedTo() != null) {
return game.getPermanent(equipment.getAttachedTo()); return game.getPermanent(equipment.getAttachedTo());
} }
return null; return null;
@ -149,6 +147,7 @@ class ScytheOfTheWretchedAbility extends TriggeredAbilityImpl {
} }
class ScytheOfTheWretchedReanimateEffect extends OneShotEffect { class ScytheOfTheWretchedReanimateEffect extends OneShotEffect {
public ScytheOfTheWretchedReanimateEffect() { public ScytheOfTheWretchedReanimateEffect() {
super(Outcome.PutCreatureInPlay); super(Outcome.PutCreatureInPlay);
this.staticText = "return that card to the battlefield under your control"; this.staticText = "return that card to the battlefield under your control";
@ -161,12 +160,11 @@ class ScytheOfTheWretchedReanimateEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Card card = game.getCard(getTargetPointer().getFirst(game, source)); Card card = game.getCard(getTargetPointer().getFirst(game, source));
if(card != null) { Player controller = game.getPlayer(source.getControllerId());
if (card != null && controller != null) {
Zone currentZone = game.getState().getZone(card.getId()); Zone currentZone = game.getState().getZone(card.getId());
Player player = game.getPlayer(source.getControllerId()); controller.putOntoBattlefieldWithInfo(card, game, currentZone, source.getSourceId());
if(player != null && player.putOntoBattlefieldWithInfo(card, game, currentZone, source.getSourceId())) { return true;
return true;
}
} }
return false; return false;