Refactored cards that use similar abilities

This commit is contained in:
Styxo 2016-08-28 16:39:33 +02:00
parent 292105f60e
commit b29c70a3c7
15 changed files with 305 additions and 373 deletions

View file

@ -28,19 +28,13 @@
package mage.sets.bornofthegods;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ShuffleIntoLibraryTargetEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.FilterPermanent;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.Target;
import mage.target.TargetPermanent;
/**
@ -49,11 +43,10 @@ import mage.target.TargetPermanent;
*/
public class UnravelTheAEther extends CardImpl {
private static final FilterPermanent filter = new FilterPermanent();
private static final FilterPermanent filter = new FilterPermanent("artifact or enchantment");
static {
filter.add(Predicates.or(new CardTypePredicate(CardType.ARTIFACT),
new CardTypePredicate(CardType.ENCHANTMENT)));
filter.add(Predicates.or(new CardTypePredicate(CardType.ARTIFACT), new CardTypePredicate(CardType.ENCHANTMENT)));
}
public UnravelTheAEther(UUID ownerId) {
@ -61,9 +54,8 @@ public class UnravelTheAEther extends CardImpl {
this.expansionSetCode = "BNG";
// Choose target artifact or enchantment. Its owner shuffles it into his or her library.
this.getSpellAbility().addEffect(new UnravelTheAEtherShuffleIntoLibraryEffect());
Target target = new TargetPermanent(1, 1, filter, false);
this.getSpellAbility().addTarget(target);
this.getSpellAbility().addEffect(new ShuffleIntoLibraryTargetEffect());
this.getSpellAbility().addTarget(new TargetPermanent(1, 1, filter, true));
}
public UnravelTheAEther(final UnravelTheAEther card) {
@ -75,32 +67,3 @@ public class UnravelTheAEther extends CardImpl {
return new UnravelTheAEther(this);
}
}
class UnravelTheAEtherShuffleIntoLibraryEffect extends OneShotEffect {
public UnravelTheAEtherShuffleIntoLibraryEffect() {
super(Outcome.Detriment);
this.staticText = "Choose target artifact or enchantment. Its owner shuffles it into his or her library";
}
public UnravelTheAEtherShuffleIntoLibraryEffect(final UnravelTheAEtherShuffleIntoLibraryEffect effect) {
super(effect);
}
@Override
public UnravelTheAEtherShuffleIntoLibraryEffect copy() {
return new UnravelTheAEtherShuffleIntoLibraryEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source));
if (permanent != null) {
if (permanent.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true)) {
game.getPlayer(permanent.getOwnerId()).shuffleLibrary(source, game);
return true;
}
}
return false;
}
}

View file

@ -28,26 +28,21 @@
package mage.sets.commander2014;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.LoyaltyAbility;
import mage.abilities.common.CanBeYourCommanderAbility;
import mage.abilities.common.PlanswalkerEntersWithLoyalityCountersAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.AsThoughEffectImpl;
import mage.abilities.effects.common.GetEmblemEffect;
import mage.abilities.effects.common.LookLibraryAndPickControllerEffect;
import mage.abilities.effects.common.UntapTargetEffect;
import mage.abilities.effects.common.continuous.ActivateAbilitiesAnyTimeYouCouldCastInstantEffect;
import mage.cards.CardImpl;
import mage.constants.AsThoughEffectType;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.FilterPermanent;
import mage.game.Game;
import mage.game.command.Emblem;
import mage.target.TargetPermanent;
@ -96,42 +91,6 @@ class TeferiTemporalArchmageEmblem extends Emblem {
// "You may activate loyalty abilities of planeswalkers you control on any player's turn any time you could cast an instant."
public TeferiTemporalArchmageEmblem() {
this.setName("EMBLEM: Teferi, Temporal Archmage");
this.getAbilities().add(new SimpleStaticAbility(Zone.COMMAND, new TeferiTemporalArchmageAsThoughEffect()));
this.getAbilities().add(new SimpleStaticAbility(Zone.COMMAND, new ActivateAbilitiesAnyTimeYouCouldCastInstantEffect(LoyaltyAbility.class, "loyalty abilities of planeswalkers you control on any player's turn")));
}
}
class TeferiTemporalArchmageAsThoughEffect extends AsThoughEffectImpl {
public TeferiTemporalArchmageAsThoughEffect() {
super(AsThoughEffectType.ACTIVATE_AS_INSTANT, Duration.EndOfGame, Outcome.Benefit);
staticText = "You may activate loyalty abilities of planeswalkers you control on any player's turn any time you could cast an instant";
}
public TeferiTemporalArchmageAsThoughEffect(final TeferiTemporalArchmageAsThoughEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public TeferiTemporalArchmageAsThoughEffect copy() {
return new TeferiTemporalArchmageAsThoughEffect(this);
}
@Override
public boolean applies(UUID objectId, Ability affectedAbility, Ability source, Game game) {
if (affectedAbility.getControllerId().equals(source.getControllerId()) && affectedAbility instanceof LoyaltyAbility) {
return true;
}
return false;
}
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
return false; // Not used
}
}

View file

@ -29,18 +29,13 @@ package mage.sets.darksteel;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.AsThoughEffectImpl;
import mage.abilities.effects.common.continuous.ActivateAbilitiesAnyTimeYouCouldCastInstantEffect;
import mage.abilities.keyword.EquipAbility;
import mage.cards.CardImpl;
import mage.constants.AsThoughEffectType;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.game.Game;
/**
*
@ -57,7 +52,7 @@ public class LeoninShikari extends CardImpl {
this.toughness = new MageInt(2);
// You may activate equip abilities any time you could cast an instant.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new LeoninShikariEffect()));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ActivateAbilitiesAnyTimeYouCouldCastInstantEffect(EquipAbility.class, "equip abilities")));
}
public LeoninShikari(final LeoninShikari card) {
@ -69,35 +64,3 @@ public class LeoninShikari extends CardImpl {
return new LeoninShikari(this);
}
}
class LeoninShikariEffect extends AsThoughEffectImpl {
LeoninShikariEffect() {
super(AsThoughEffectType.ACTIVATE_AS_INSTANT, Duration.EndOfGame, Outcome.Benefit);
staticText = "You may activate equip abilities any time you could cast an instant";
}
LeoninShikariEffect(final LeoninShikariEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public LeoninShikariEffect copy() {
return new LeoninShikariEffect(this);
}
@Override
public boolean applies(UUID objectId, Ability affectedAbility, Ability source, Game game) {
return affectedAbility.getControllerId().equals(source.getControllerId()) && affectedAbility instanceof EquipAbility;
}
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
return false; // Not used
}
}

View file

@ -29,7 +29,7 @@ package mage.sets.magic2014;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.AttacksWithCreaturesTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.Condition;
import mage.abilities.decorator.ConditionalContinuousEffect;
@ -45,8 +45,6 @@ import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.players.Player;
/**
@ -66,12 +64,11 @@ public class PathOfBravery extends CardImpl {
super(ownerId, 26, "Path of Bravery", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{2}{W}");
this.expansionSetCode = "M14";
// As long as your life total is greater than or equal to your starting life total, creatures you control get +1/+1.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ConditionalContinuousEffect(new BoostAllEffect(1, 1, Duration.WhileOnBattlefield, filter, true), new LifeCondition(), rule)));
// Whenever one or more creatures you control attack, you gain life equal to the number of attacking creatures.
this.addAbility(new PathOfBraveryTriggeredAbility());
this.addAbility(new AttacksWithCreaturesTriggeredAbility(new PathOfBraveryEffect(), 1));
}
@ -103,37 +100,6 @@ class LifeCondition implements Condition {
}
}
class PathOfBraveryTriggeredAbility extends TriggeredAbilityImpl {
public PathOfBraveryTriggeredAbility() {
super(Zone.BATTLEFIELD, new PathOfBraveryEffect(), false);
}
public PathOfBraveryTriggeredAbility(final PathOfBraveryTriggeredAbility ability) {
super(ability);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == EventType.DECLARED_ATTACKERS;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return !game.getCombat().noAttackers() && event.getPlayerId().equals(controllerId);
}
@Override
public PathOfBraveryTriggeredAbility copy() {
return new PathOfBraveryTriggeredAbility(this);
}
@Override
public String getRule() {
return "Whenever one or more creatures you control attack, " + super.getRule();
}
}
class PathOfBraveryEffect extends OneShotEffect {
private int attackers;

View file

@ -28,16 +28,11 @@
package mage.sets.magic2015;
import java.util.UUID;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.abilities.common.AttacksWithCreaturesTriggeredAbility;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
/**
*
@ -49,9 +44,8 @@ public class MilitaryIntelligence extends CardImpl {
super(ownerId, 69, "Military Intelligence", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{1}{U}");
this.expansionSetCode = "M15";
// Whenever you attack with two or more creatures, draw a card.
this.addAbility(new MilitaryIntelligenceTriggeredAbility(new DrawCardSourceControllerEffect(1)));
this.addAbility(new AttacksWithCreaturesTriggeredAbility(new DrawCardSourceControllerEffect(1), 2));
}
public MilitaryIntelligence(final MilitaryIntelligence card) {
@ -63,34 +57,3 @@ public class MilitaryIntelligence extends CardImpl {
return new MilitaryIntelligence(this);
}
}
class MilitaryIntelligenceTriggeredAbility extends TriggeredAbilityImpl {
public MilitaryIntelligenceTriggeredAbility(Effect effect) {
super(Zone.BATTLEFIELD, effect);
}
public MilitaryIntelligenceTriggeredAbility(final MilitaryIntelligenceTriggeredAbility ability) {
super(ability);
}
@Override
public MilitaryIntelligenceTriggeredAbility copy() {
return new MilitaryIntelligenceTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == EventType.DECLARED_ATTACKERS;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return game.getCombat().getAttackers().size() >= 2 && game.getCombat().getAttackerId().equals(getControllerId());
}
@Override
public String getRule() {
return new StringBuilder("Whenever you attack with two or more creatures, ").append(super.getRule()).toString() ;
}
}

View file

@ -29,27 +29,25 @@ package mage.sets.mirrodin;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.common.EquippedSourceCondition;
import mage.abilities.decorator.ConditionalContinuousEffect;
import mage.abilities.effects.common.continuous.BoostControlledEffect;
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
import mage.abilities.effects.common.cost.AbilitiesCostReductionControllerEffect;
import mage.abilities.keyword.EquipAbility;
import mage.cards.CardImpl;
import mage.constants.*;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game;
import mage.util.CardUtil;
/**
*
* @author Jason E. Wall
*
*/
public class AuriokSteelshaper extends CardImpl {
private static final FilterCreaturePermanent soldiersOrKnights = new FilterCreaturePermanent();
static {
@ -68,7 +66,7 @@ public class AuriokSteelshaper extends CardImpl {
this.toughness = new MageInt(1);
// Equip costs you pay cost {1} less.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new AuriokSteelshaperCostReductionEffect()));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new AbilitiesCostReductionControllerEffect(EquipAbility.class, "Equip")));
// As long as Auriok Steelshaper is equipped, each creature you control that's a Soldier or a Knight gets +1/+1.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ConditionalContinuousEffect(
@ -87,32 +85,3 @@ public class AuriokSteelshaper extends CardImpl {
return new AuriokSteelshaper(this);
}
}
class AuriokSteelshaperCostReductionEffect extends CostModificationEffectImpl {
public AuriokSteelshaperCostReductionEffect() {
super(Duration.WhileOnBattlefield, Outcome.Benefit, CostModificationType.REDUCE_COST);
staticText = "Equip costs you pay cost {1} less";
}
public AuriokSteelshaperCostReductionEffect(AuriokSteelshaperCostReductionEffect effect) {
super(effect);
}
@java.lang.Override
public AuriokSteelshaperCostReductionEffect copy() {
return new AuriokSteelshaperCostReductionEffect(this);
}
@java.lang.Override
public boolean apply(Game game, Ability source, Ability abilityToModify) {
CardUtil.reduceCost(abilityToModify, 1);
return true;
}
@java.lang.Override
public boolean applies(Ability abilityToModify, Ability source, Game game) {
return abilityToModify.getControllerId().equals(source.getControllerId()) &&
(abilityToModify instanceof EquipAbility);
}
}

View file

@ -29,18 +29,12 @@ package mage.sets.morningtide;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ShuffleIntoLibraryTargetEffect;
import mage.cards.CardImpl;
import mage.filter.FilterPermanent;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.Target;
import mage.target.TargetPermanent;
/**
@ -49,21 +43,18 @@ import mage.target.TargetPermanent;
*/
public class Deglamer extends CardImpl {
private static final FilterPermanent filter = new FilterPermanent();
private static final FilterPermanent filter = new FilterPermanent("artifact or enchantment");
static {
filter.add(Predicates.or(new CardTypePredicate(CardType.ARTIFACT),
new CardTypePredicate(CardType.ENCHANTMENT)));
filter.add(Predicates.or(new CardTypePredicate(CardType.ARTIFACT), new CardTypePredicate(CardType.ENCHANTMENT)));
}
public Deglamer(UUID ownerId) {
super(ownerId, 118, "Deglamer", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{1}{G}");
this.expansionSetCode = "MOR";
// Choose target artifact or enchantment. Its owner shuffles it into his or her library.
this.getSpellAbility().addEffect(new DeglamerShuffleIntoLibraryEffect());
Target target = new TargetPermanent(1,1,filter,true);
this.getSpellAbility().addTarget(target);
this.getSpellAbility().addEffect(new ShuffleIntoLibraryTargetEffect());
this.getSpellAbility().addTarget(new TargetPermanent(1, 1, filter, true));
}
public Deglamer(final Deglamer card) {
@ -74,33 +65,4 @@ public class Deglamer extends CardImpl {
public Deglamer copy() {
return new Deglamer(this);
}
}
class DeglamerShuffleIntoLibraryEffect extends OneShotEffect {
public DeglamerShuffleIntoLibraryEffect() {
super(Outcome.Detriment);
this.staticText = "Choose target artifact or enchantment. Its owner shuffles it into his or her library";
}
public DeglamerShuffleIntoLibraryEffect(final DeglamerShuffleIntoLibraryEffect effect) {
super(effect);
}
@Override
public DeglamerShuffleIntoLibraryEffect copy() {
return new DeglamerShuffleIntoLibraryEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source));
if (permanent != null) {
if (permanent.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true) ) {
game.getPlayer(permanent.getOwnerId()).shuffleLibrary(source, game);
return true;
}
}
return false;
}
}
}

View file

@ -34,6 +34,7 @@ import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.LookLibraryTopCardTargetPlayerEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.Cards;
@ -62,7 +63,7 @@ public class LurkingInformant extends CardImpl {
// <i>({UB} can be paid with either {U} or {B}.)</i>
// {2}, {tap}: Look at the top card of target player's library. You may put that card into that player's graveyard.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new LurkingInformantEffect(), new GenericManaCost(2));
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new LookLibraryTopCardTargetPlayerEffect(1, true), new GenericManaCost(2));
ability.addCost(new TapSourceCost());
ability.addTarget(new TargetPlayer());
this.addAbility(ability);
@ -77,42 +78,3 @@ public class LurkingInformant extends CardImpl {
return new LurkingInformant(this);
}
}
class LurkingInformantEffect extends OneShotEffect {
public LurkingInformantEffect() {
super(Outcome.Detriment);
staticText = "Look at the top card of target player's library. You may put that card into his or her graveyard";
}
public LurkingInformantEffect(final LurkingInformantEffect effect) {
super(effect);
}
@Override
public LurkingInformantEffect copy() {
return new LurkingInformantEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player player = game.getPlayer(source.getFirstTarget());
if (controller != null && player != null) {
Card card = player.getLibrary().getFromTop(game);
if (card != null) {
Cards cards = new CardsImpl();
cards.add(card);
controller.lookAtCards("Lurking Informant", cards, game);
if (controller.chooseUse(outcome, "Do you wish to put card into the player's graveyard?", source, game)) {
controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
} else {
game.informPlayers(controller.getLogName() + " puts the card back on top of the library.");
}
return true;
}
}
return false;
}
}

View file

@ -28,18 +28,10 @@
package mage.sets.starter1999;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.abilities.effects.common.LookLibraryTopCardTargetPlayerEffect;
import mage.cards.CardImpl;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetPlayer;
/**
@ -53,7 +45,7 @@ public class EyeSpy extends CardImpl {
this.expansionSetCode = "S99";
// Look at the top card of target player's library. You may put that card into his or her graveyard.
this.getSpellAbility().addEffect(new EyeSpyEffect());
this.getSpellAbility().addEffect(new LookLibraryTopCardTargetPlayerEffect(1, true));
this.getSpellAbility().addTarget(new TargetPlayer());
}
@ -66,42 +58,3 @@ public class EyeSpy extends CardImpl {
return new EyeSpy(this);
}
}
class EyeSpyEffect extends OneShotEffect {
public EyeSpyEffect() {
super(Outcome.Detriment);
staticText = "Look at the top card of target player's library. You may put that card into his or her graveyard";
}
public EyeSpyEffect(final EyeSpyEffect effect) {
super(effect);
}
@Override
public EyeSpyEffect copy() {
return new EyeSpyEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player player = game.getPlayer(source.getFirstTarget());
if (controller != null && player != null) {
Card card = player.getLibrary().getFromTop(game);
if (card != null) {
Cards cards = new CardsImpl();
cards.add(card);
controller.lookAtCards("Eye Spy", cards, game);
if (controller.chooseUse(outcome, "Do you wish to put card into the player's graveyard?", source, game)) {
controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
} else {
game.informPlayers(controller.getLogName() + " puts the card back on top of the library.");
}
return true;
}
}
return false;
}
}