mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
Merge pull request #2200 from Styxo/master
Refactored cards that use similar abilities
This commit is contained in:
commit
42669b9c01
15 changed files with 305 additions and 373 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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() ;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package mage.abilities.common;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Styxo
|
||||
*/
|
||||
public class AttacksWithCreaturesTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
private FilterCreaturePermanent filter;
|
||||
private int minAttackers;
|
||||
|
||||
public AttacksWithCreaturesTriggeredAbility(Effect effect, int minAttackers) {
|
||||
this(effect, minAttackers, new FilterCreaturePermanent("creatures"));
|
||||
}
|
||||
|
||||
public AttacksWithCreaturesTriggeredAbility(Effect effect, int minAttackers, FilterCreaturePermanent filter) {
|
||||
super(Zone.BATTLEFIELD, effect);
|
||||
this.filter = filter;
|
||||
this.minAttackers = minAttackers;
|
||||
}
|
||||
|
||||
public AttacksWithCreaturesTriggeredAbility(final AttacksWithCreaturesTriggeredAbility ability) {
|
||||
super(ability);
|
||||
this.filter = ability.filter;
|
||||
this.minAttackers = ability.minAttackers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttacksWithCreaturesTriggeredAbility copy() {
|
||||
return new AttacksWithCreaturesTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.DECLARED_ATTACKERS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
int attackerCount = 0;
|
||||
for (UUID attacker : game.getCombat().getAttackers()) {
|
||||
if (filter.match(game.getPermanent(attacker), game)) {
|
||||
attackerCount++;
|
||||
}
|
||||
}
|
||||
return attackerCount >= minAttackers && game.getCombat().getAttackerId().equals(getControllerId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
StringBuilder sb = new StringBuilder("Whenever you attack with " + minAttackers + " or more ");
|
||||
sb.append(filter.getMessage());
|
||||
sb.append(", ");
|
||||
sb.append(super.getRule());
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -30,9 +30,11 @@ package mage.abilities.effects.common;
|
|||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
|
@ -44,10 +46,19 @@ import mage.util.CardUtil;
|
|||
public class LookLibraryTopCardTargetPlayerEffect extends OneShotEffect {
|
||||
|
||||
protected int amount;
|
||||
|
||||
protected boolean putToGraveyard;
|
||||
|
||||
public LookLibraryTopCardTargetPlayerEffect(int amount) {
|
||||
super(Outcome.Benefit);
|
||||
this.amount = amount;
|
||||
this.putToGraveyard = false;
|
||||
setText();
|
||||
}
|
||||
|
||||
public LookLibraryTopCardTargetPlayerEffect(int amount, boolean putToGraveyard) {
|
||||
super(Outcome.Benefit);
|
||||
this.amount = amount;
|
||||
this.putToGraveyard = putToGraveyard;
|
||||
setText();
|
||||
}
|
||||
|
||||
|
@ -58,6 +69,7 @@ public class LookLibraryTopCardTargetPlayerEffect extends OneShotEffect {
|
|||
public LookLibraryTopCardTargetPlayerEffect(final LookLibraryTopCardTargetPlayerEffect effect) {
|
||||
super(effect);
|
||||
amount = effect.amount;
|
||||
putToGraveyard = effect.putToGraveyard;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -74,21 +86,38 @@ public class LookLibraryTopCardTargetPlayerEffect extends OneShotEffect {
|
|||
Cards cards = new CardsImpl();
|
||||
cards.addAll(targetPlayer.getLibrary().getTopCards(game, amount));
|
||||
player.lookAtCards(sourceObject.getName(), cards, game);
|
||||
if (putToGraveyard) {
|
||||
for (Card card : cards.getCards(game)) {
|
||||
if (player.chooseUse(outcome, "Do you wish to put card into the player's graveyard?", source, game)) {
|
||||
player.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
} else {
|
||||
game.informPlayers(player.getLogName() + " puts the card back on top of the library.");
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private void setText() {
|
||||
StringBuilder sb = new StringBuilder("look at the top ");
|
||||
StringBuilder sb = new StringBuilder("look at the top ");
|
||||
if (amount > 1) {
|
||||
sb.append(CardUtil.numberToText(amount));
|
||||
sb.append(" cards ");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sb.append(" card ");
|
||||
}
|
||||
sb.append("of target player's library");
|
||||
if (putToGraveyard) {
|
||||
sb.append(". You may put ");
|
||||
if (amount > 1) {
|
||||
sb.append("those cards");
|
||||
} else {
|
||||
sb.append("that card");
|
||||
}
|
||||
sb.append(" into that player's graveyard");
|
||||
}
|
||||
this.staticText = sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Styxo
|
||||
*/
|
||||
public class ShuffleIntoLibraryTargetEffect extends OneShotEffect {
|
||||
|
||||
public ShuffleIntoLibraryTargetEffect() {
|
||||
super(Outcome.Detriment);
|
||||
}
|
||||
|
||||
public ShuffleIntoLibraryTargetEffect(String effectText) {
|
||||
super(Outcome.Detriment);
|
||||
this.staticText = effectText;
|
||||
}
|
||||
|
||||
public ShuffleIntoLibraryTargetEffect(final ShuffleIntoLibraryTargetEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ShuffleIntoLibraryTargetEffect copy() {
|
||||
return new ShuffleIntoLibraryTargetEffect(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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
} else {
|
||||
return "choose target " + mode.getTargets().get(0).getTargetName() + ". Its owner shuffles it into his or her library";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package mage.abilities.effects.common.continuous;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.AsThoughEffectImpl;
|
||||
import mage.constants.AsThoughEffectType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Styxo
|
||||
*/
|
||||
public class ActivateAbilitiesAnyTimeYouCouldCastInstantEffect extends AsThoughEffectImpl {
|
||||
|
||||
private Class activatedAbility;
|
||||
|
||||
public ActivateAbilitiesAnyTimeYouCouldCastInstantEffect(Class activatedAbility, String activatedAbilityName) {
|
||||
super(AsThoughEffectType.ACTIVATE_AS_INSTANT, Duration.EndOfGame, Outcome.Benefit);
|
||||
this.activatedAbility = activatedAbility;
|
||||
staticText = "You may activate " + activatedAbilityName + " any time you could cast an instant";
|
||||
}
|
||||
|
||||
public ActivateAbilitiesAnyTimeYouCouldCastInstantEffect(final ActivateAbilitiesAnyTimeYouCouldCastInstantEffect effect) {
|
||||
super(effect);
|
||||
this.activatedAbility = effect.activatedAbility;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActivateAbilitiesAnyTimeYouCouldCastInstantEffect copy() {
|
||||
return new ActivateAbilitiesAnyTimeYouCouldCastInstantEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID objectId, Ability affectedAbility, Ability source, Game game) {
|
||||
if (affectedAbility.getControllerId().equals(source.getControllerId())
|
||||
&& activatedAbility.isInstance(affectedAbility)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
|
||||
return false; // Not used
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package mage.abilities.effects.common.cost;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.constants.CostModificationType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Styxo
|
||||
*/
|
||||
public class AbilitiesCostReductionControllerEffect extends CostModificationEffectImpl {
|
||||
|
||||
private Class activatedAbility;
|
||||
|
||||
public AbilitiesCostReductionControllerEffect(Class activatedAbility, String activatedAbilityName) {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Benefit, CostModificationType.REDUCE_COST);
|
||||
this.activatedAbility = activatedAbility;
|
||||
staticText = activatedAbilityName + " costs you pay cost {1} less";
|
||||
}
|
||||
|
||||
public AbilitiesCostReductionControllerEffect(AbilitiesCostReductionControllerEffect effect) {
|
||||
super(effect);
|
||||
this.activatedAbility = effect.activatedAbility;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public AbilitiesCostReductionControllerEffect copy() {
|
||||
return new AbilitiesCostReductionControllerEffect(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())
|
||||
&& activatedAbility.isInstance(abilityToModify);
|
||||
}
|
||||
}
|
|
@ -25,7 +25,6 @@
|
|||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.target.common;
|
||||
|
||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||
|
@ -44,6 +43,10 @@ public class TargetControlledCreaturePermanent extends TargetControlledPermanent
|
|||
this(numTargets, numTargets, new FilterControlledCreaturePermanent(), false);
|
||||
}
|
||||
|
||||
public TargetControlledCreaturePermanent(int minNumTargets, int maxNumTargets) {
|
||||
this(minNumTargets, maxNumTargets, new FilterControlledCreaturePermanent(), false);
|
||||
}
|
||||
|
||||
public TargetControlledCreaturePermanent(FilterControlledCreaturePermanent filter) {
|
||||
super(1, 1, filter, false);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue