diff --git a/Mage.Sets/src/mage/sets/alarareborn/FieldmistBorderpost.java b/Mage.Sets/src/mage/sets/alarareborn/FieldmistBorderpost.java index 2e73f87efc1..b6107868a95 100644 --- a/Mage.Sets/src/mage/sets/alarareborn/FieldmistBorderpost.java +++ b/Mage.Sets/src/mage/sets/alarareborn/FieldmistBorderpost.java @@ -29,10 +29,12 @@ package mage.sets.alarareborn; import java.util.UUID; +import mage.abilities.Ability; import mage.constants.CardType; import mage.constants.Rarity; import mage.abilities.common.EntersBattlefieldTappedAbility; import mage.abilities.costs.AlternativeCostImpl; +import mage.abilities.costs.AlternativeCostSourceAbility; import mage.abilities.costs.CompositeCost; import mage.abilities.costs.Cost; import mage.abilities.costs.common.ReturnToHandTargetCost; @@ -51,9 +53,7 @@ import mage.target.common.TargetControlledPermanent; */ public class FieldmistBorderpost extends CardImpl { - private static final FilterControlledPermanent filter = new FilterControlledLandPermanent("basic land"); - private static final String COST_DESCRIPTION = "pay {1} and return a basic land you control to its owner's hand"; - private static final String ALTERNATIVE_COST_DESCRIPTION = "You may pay {1} and return a basic land you control to its owner's hand rather than pay Fieldmist Borderpost's mana cost"; + private static final FilterControlledPermanent filter = new FilterControlledLandPermanent("a basic land"); static { filter.add(new SupertypePredicate("Basic")); @@ -66,8 +66,9 @@ public class FieldmistBorderpost extends CardImpl { this.color.setBlue(true); // You may pay {1} and return a basic land you control to its owner's hand rather than pay Fieldmist Borderpost's mana cost. - Cost cost = new CompositeCost(new GenericManaCost(1), new ReturnToHandTargetCost(new TargetControlledPermanent(filter)), COST_DESCRIPTION); - this.getSpellAbility().addAlternativeCost(new AlternativeCostImpl(ALTERNATIVE_COST_DESCRIPTION, cost)); + Ability ability = new AlternativeCostSourceAbility(new GenericManaCost(1)); + ability.addCost(new ReturnToHandTargetCost(new TargetControlledPermanent(filter))); + this.addAbility(ability); // Fieldmist Borderpost enters the battlefield tapped. this.addAbility(new EntersBattlefieldTappedAbility()); diff --git a/Mage.Sets/src/mage/sets/alarareborn/FirewildBorderpost.java b/Mage.Sets/src/mage/sets/alarareborn/FirewildBorderpost.java index 74972d7e635..a3d63b14bb6 100644 --- a/Mage.Sets/src/mage/sets/alarareborn/FirewildBorderpost.java +++ b/Mage.Sets/src/mage/sets/alarareborn/FirewildBorderpost.java @@ -29,10 +29,12 @@ package mage.sets.alarareborn; import java.util.UUID; +import mage.abilities.Ability; import mage.constants.CardType; import mage.constants.Rarity; import mage.abilities.common.EntersBattlefieldTappedAbility; import mage.abilities.costs.AlternativeCostImpl; +import mage.abilities.costs.AlternativeCostSourceAbility; import mage.abilities.costs.CompositeCost; import mage.abilities.costs.Cost; import mage.abilities.costs.common.ReturnToHandTargetCost; @@ -51,9 +53,7 @@ import mage.target.common.TargetControlledPermanent; */ public class FirewildBorderpost extends CardImpl { - private static final FilterControlledPermanent filter = new FilterControlledLandPermanent("basic land"); - private static final String COST_DESCRIPTION = "pay {1} and return a basic land you control to its owner's hand"; - private static final String ALTERNATIVE_COST_DESCRIPTION = "You may pay {1} and return a basic land you control to its owner's hand rather than pay Firewild Borderpost's mana cost"; + private static final FilterControlledPermanent filter = new FilterControlledLandPermanent("a basic land"); static { filter.add(new SupertypePredicate("Basic")); @@ -66,8 +66,9 @@ public class FirewildBorderpost extends CardImpl { this.color.setGreen(true); // You may pay {1} and return a basic land you control to its owner's hand rather than pay Firewild Borderpost's mana cost. - Cost cost = new CompositeCost(new GenericManaCost(1), new ReturnToHandTargetCost(new TargetControlledPermanent(filter)), COST_DESCRIPTION); - this.getSpellAbility().addAlternativeCost(new AlternativeCostImpl(ALTERNATIVE_COST_DESCRIPTION, cost)); + Ability ability = new AlternativeCostSourceAbility(new GenericManaCost(1)); + ability.addCost(new ReturnToHandTargetCost(new TargetControlledPermanent(filter))); + this.addAbility(ability); // Veinfire Firewild enters the battlefield tapped. this.addAbility(new EntersBattlefieldTappedAbility()); diff --git a/Mage.Sets/src/mage/sets/alarareborn/MistveinBorderpost.java b/Mage.Sets/src/mage/sets/alarareborn/MistveinBorderpost.java index 2514abe9aab..bd88fc8c964 100644 --- a/Mage.Sets/src/mage/sets/alarareborn/MistveinBorderpost.java +++ b/Mage.Sets/src/mage/sets/alarareborn/MistveinBorderpost.java @@ -29,10 +29,12 @@ package mage.sets.alarareborn; import java.util.UUID; +import mage.abilities.Ability; import mage.constants.CardType; import mage.constants.Rarity; import mage.abilities.common.EntersBattlefieldTappedAbility; import mage.abilities.costs.AlternativeCostImpl; +import mage.abilities.costs.AlternativeCostSourceAbility; import mage.abilities.costs.CompositeCost; import mage.abilities.costs.Cost; import mage.abilities.costs.common.ReturnToHandTargetCost; @@ -51,9 +53,7 @@ import mage.target.common.TargetControlledPermanent; */ public class MistveinBorderpost extends CardImpl { - private static final FilterControlledPermanent filter = new FilterControlledLandPermanent("basic land"); - private static final String COST_DESCRIPTION = "pay {1} and return a basic land you control to its owner's hand"; - private static final String ALTERNATIVE_COST_DESCRIPTION = "You may pay {1} and return a basic land you control to its owner's hand rather than pay Mistvein Borderpos's mana cost"; + private static final FilterControlledPermanent filter = new FilterControlledLandPermanent("a basic land"); static { filter.add(new SupertypePredicate("Basic")); @@ -66,8 +66,9 @@ public class MistveinBorderpost extends CardImpl { this.color.setBlack(true); // You may pay {1} and return a basic land you control to its owner's hand rather than pay Mistvein Borderpost's mana cost. - Cost cost = new CompositeCost(new GenericManaCost(1), new ReturnToHandTargetCost(new TargetControlledPermanent(filter)), COST_DESCRIPTION); - this.getSpellAbility().addAlternativeCost(new AlternativeCostImpl(ALTERNATIVE_COST_DESCRIPTION, cost)); + Ability ability = new AlternativeCostSourceAbility(new GenericManaCost(1)); + ability.addCost(new ReturnToHandTargetCost(new TargetControlledPermanent(filter))); + this.addAbility(ability); // Mistvein Borderpost enters the battlefield tapped. this.addAbility(new EntersBattlefieldTappedAbility()); diff --git a/Mage.Sets/src/mage/sets/alarareborn/VeinfireBorderpost.java b/Mage.Sets/src/mage/sets/alarareborn/VeinfireBorderpost.java index b16b21cb52c..96cd5df7fdb 100644 --- a/Mage.Sets/src/mage/sets/alarareborn/VeinfireBorderpost.java +++ b/Mage.Sets/src/mage/sets/alarareborn/VeinfireBorderpost.java @@ -29,10 +29,12 @@ package mage.sets.alarareborn; import java.util.UUID; +import mage.abilities.Ability; import mage.constants.CardType; import mage.constants.Rarity; import mage.abilities.common.EntersBattlefieldTappedAbility; import mage.abilities.costs.AlternativeCostImpl; +import mage.abilities.costs.AlternativeCostSourceAbility; import mage.abilities.costs.CompositeCost; import mage.abilities.costs.Cost; import mage.abilities.costs.common.ReturnToHandTargetCost; @@ -51,9 +53,7 @@ import mage.target.common.TargetControlledPermanent; */ public class VeinfireBorderpost extends CardImpl { - private static final FilterControlledPermanent filter = new FilterControlledLandPermanent("basic land"); - private static final String COST_DESCRIPTION = "pay {1} and return a basic land you control to its owner's hand"; - private static final String ALTERNATIVE_COST_DESCRIPTION = "You may pay {1} and return a basic land you control to its owner's hand rather than pay Veinfire Borderpost's mana cost"; + private static final FilterControlledPermanent filter = new FilterControlledLandPermanent("a basic land"); static { filter.add(new SupertypePredicate("Basic")); @@ -66,8 +66,9 @@ public class VeinfireBorderpost extends CardImpl { this.color.setRed(true); // You may pay {1} and return a basic land you control to its owner's hand rather than pay Veinfire Borderpost's mana cost. - Cost cost = new CompositeCost(new GenericManaCost(1), new ReturnToHandTargetCost(new TargetControlledPermanent(filter)), COST_DESCRIPTION); - this.getSpellAbility().addAlternativeCost(new AlternativeCostImpl(ALTERNATIVE_COST_DESCRIPTION, cost)); + Ability ability = new AlternativeCostSourceAbility(new GenericManaCost(1)); + ability.addCost(new ReturnToHandTargetCost(new TargetControlledPermanent(filter))); + this.addAbility(ability); // Veinfire Borderpost enters the battlefield tapped. this.addAbility(new EntersBattlefieldTappedAbility()); diff --git a/Mage.Sets/src/mage/sets/alarareborn/WildfieldBorderpost.java b/Mage.Sets/src/mage/sets/alarareborn/WildfieldBorderpost.java index 77b7aa44c9f..f618ff99ccd 100644 --- a/Mage.Sets/src/mage/sets/alarareborn/WildfieldBorderpost.java +++ b/Mage.Sets/src/mage/sets/alarareborn/WildfieldBorderpost.java @@ -29,10 +29,12 @@ package mage.sets.alarareborn; import java.util.UUID; +import mage.abilities.Ability; import mage.constants.CardType; import mage.constants.Rarity; import mage.abilities.common.EntersBattlefieldTappedAbility; import mage.abilities.costs.AlternativeCostImpl; +import mage.abilities.costs.AlternativeCostSourceAbility; import mage.abilities.costs.CompositeCost; import mage.abilities.costs.Cost; import mage.abilities.costs.common.ReturnToHandTargetCost; @@ -51,9 +53,7 @@ import mage.target.common.TargetControlledPermanent; */ public class WildfieldBorderpost extends CardImpl { - private static final FilterControlledPermanent filter = new FilterControlledLandPermanent("basic land"); - private static final String COST_DESCRIPTION = "pay {1} and return a basic land you control to its owner's hand"; - private static final String ALTERNATIVE_COST_DESCRIPTION = "You may pay {1} and return a basic land you control to its owner's hand rather than pay Wildfield Borderpost's mana cost"; + private static final FilterControlledPermanent filter = new FilterControlledLandPermanent("a basic land"); static { filter.add(new SupertypePredicate("Basic")); @@ -66,8 +66,9 @@ public class WildfieldBorderpost extends CardImpl { this.color.setWhite(true); // You may pay {1} and return a basic land you control to its owner's hand rather than pay Wildfield Borderpost's mana cost. - Cost cost = new CompositeCost(new GenericManaCost(1), new ReturnToHandTargetCost(new TargetControlledPermanent(filter)), COST_DESCRIPTION); - this.getSpellAbility().addAlternativeCost(new AlternativeCostImpl(ALTERNATIVE_COST_DESCRIPTION, cost)); + Ability ability = new AlternativeCostSourceAbility(new GenericManaCost(1)); + ability.addCost(new ReturnToHandTargetCost(new TargetControlledPermanent(filter))); + this.addAbility(ability); // Wildfield Borderpost enters the battlefield tapped. this.addAbility(new EntersBattlefieldTappedAbility()); diff --git a/Mage.Sets/src/mage/sets/alliances/Pyrokinesis.java b/Mage.Sets/src/mage/sets/alliances/Pyrokinesis.java index 90c54a2d2b2..bb07ae0738e 100644 --- a/Mage.Sets/src/mage/sets/alliances/Pyrokinesis.java +++ b/Mage.Sets/src/mage/sets/alliances/Pyrokinesis.java @@ -32,6 +32,7 @@ import mage.constants.CardType; import mage.constants.Rarity; import mage.ObjectColor; import mage.abilities.costs.AlternativeCostImpl; +import mage.abilities.costs.AlternativeCostSourceAbility; import mage.abilities.costs.Cost; import mage.abilities.costs.CostsImpl; import mage.abilities.costs.common.ExileFromHandCost; @@ -57,12 +58,10 @@ public class Pyrokinesis extends CardImpl { this.color.setRed(true); // You may exile a red card from your hand rather than pay Pyrokinesis's mana cost. - FilterOwnedCard filter = new FilterOwnedCard("red card from your hand"); + FilterOwnedCard filter = new FilterOwnedCard("a red card from your hand"); filter.add(new ColorPredicate(ObjectColor.RED)); filter.add(Predicates.not(new CardIdPredicate(this.getId()))); // the exile cost can never be paid with the card itself - CostsImpl costs = new CostsImpl(); - costs.add(new ExileFromHandCost(new TargetCardInHand(filter))); - this.getSpellAbility().addAlternativeCost(new AlternativeCostImpl("You may exile a red card from your hand rather than pay Pyrokinesis's mana cost", costs)); + this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(new TargetCardInHand(filter)))); // Pyrokinesis deals 4 damage divided as you choose among any number of target creatures. this.getSpellAbility().addEffect(new DamageMultiEffect(4)); diff --git a/Mage.Sets/src/mage/sets/mercadianmasques/LandGrant.java b/Mage.Sets/src/mage/sets/mercadianmasques/LandGrant.java index b467d2e65d8..36607337104 100644 --- a/Mage.Sets/src/mage/sets/mercadianmasques/LandGrant.java +++ b/Mage.Sets/src/mage/sets/mercadianmasques/LandGrant.java @@ -28,16 +28,14 @@ package mage.sets.mercadianmasques; import java.util.UUID; -import mage.constants.CardType; -import mage.constants.Rarity; import mage.abilities.Ability; -import mage.abilities.costs.AlternativeCostImpl; -import mage.abilities.costs.CompositeCost; -import mage.abilities.costs.Cost; +import mage.abilities.condition.common.CardsInHandCondition; +import mage.abilities.costs.AlternativeCostSourceAbility; import mage.abilities.costs.CostImpl; -import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.effects.common.search.SearchLibraryPutInHandEffect; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Rarity; import mage.filter.common.FilterLandCard; import mage.game.Game; import mage.players.Player; @@ -57,8 +55,9 @@ public class LandGrant extends CardImpl { this.color.setGreen(true); // If you have no land cards in hand, you may reveal your hand rather than pay Land Grant's mana cost. - Cost cost = new CompositeCost(new GenericManaCost(0), new LandGrantCost(), "If you have no land cards in hand, you may reveal your hand"); - this.getSpellAbility().addAlternativeCost(new AlternativeCostImpl("If you have no land cards in hand, you may reveal your hand rather than pay Land Grant's mana cost", cost)); + this.addAbility(new AlternativeCostSourceAbility(new LandGrantReavealCost(), new CardsInHandCondition(CardsInHandCondition.CountType.EQUAL_TO, 0), + "If you have no land cards in hand, you may reveal your hand rather than pay Land Grant's mana cost.")); + // Search your library for a Forest card, reveal that card, and put it into your hand. Then shuffle your library. this.getSpellAbility().addEffect(new SearchLibraryPutInHandEffect(new TargetCardInLibrary(filter), true, true)); } @@ -73,13 +72,13 @@ public class LandGrant extends CardImpl { } } -class LandGrantCost extends CostImpl { +class LandGrantReavealCost extends CostImpl { - public LandGrantCost() { - this.text = "If you have no land cards in hand, you may reveal your hand"; + public LandGrantReavealCost() { + this.text = "reveal your hand"; } - public LandGrantCost(LandGrantCost cost) { + public LandGrantReavealCost(LandGrantReavealCost cost) { super(cost); } @@ -95,16 +94,12 @@ class LandGrantCost extends CostImpl { @Override public boolean canPay(UUID sourceId, UUID controllerId, Game game) { - Player player = game.getPlayer(controllerId); - if (player != null && player.getHand().count(new FilterLandCard(), game) == 0) { - return true; - } - return false; + return true; } @Override - public LandGrantCost copy() { - return new LandGrantCost(this); + public LandGrantReavealCost copy() { + return new LandGrantReavealCost(this); } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/sets/mercadianmasques/Misdirection.java b/Mage.Sets/src/mage/sets/mercadianmasques/Misdirection.java index 7d75051409f..863b0fd181d 100644 --- a/Mage.Sets/src/mage/sets/mercadianmasques/Misdirection.java +++ b/Mage.Sets/src/mage/sets/mercadianmasques/Misdirection.java @@ -32,7 +32,9 @@ import java.util.UUID; import mage.constants.CardType; import mage.constants.Rarity; import mage.ObjectColor; +import mage.abilities.condition.common.CardsInHandCondition; import mage.abilities.costs.AlternativeCostImpl; +import mage.abilities.costs.AlternativeCostSourceAbility; import mage.abilities.costs.Cost; import mage.abilities.costs.CostsImpl; import mage.abilities.costs.common.ExileFromHandCost; @@ -65,13 +67,12 @@ public class Misdirection extends CardImpl { this.color.setBlue(true); // You may exile a blue card from your hand rather than pay Misdirection's mana cost. - FilterOwnedCard filterCardInHand = new FilterOwnedCard("blue card from your hand"); + FilterOwnedCard filterCardInHand = new FilterOwnedCard("a blue card from your hand"); filterCardInHand.add(new ColorPredicate(ObjectColor.BLUE)); // the exile cost can never be paid with the card itself - filterCardInHand.add(Predicates.not(new CardIdPredicate(this.getId()))); - CostsImpl costs = new CostsImpl(); - costs.add(new ExileFromHandCost(new TargetCardInHand(filterCardInHand))); - this.getSpellAbility().addAlternativeCost(new AlternativeCostImpl("You may exile a blue card from your hand rather than pay Misdirection's mana cost", costs)); + filterCardInHand.add(Predicates.not(new CardIdPredicate(this.getId()))); + this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(new TargetCardInHand(filterCardInHand)))); + // Change the target of target spell with a single target. this.getSpellAbility().addEffect(new ChooseNewTargetsTargetEffect(true, true)); this.getSpellAbility().addTarget(new TargetSpell(filter2)); diff --git a/Mage.Sets/src/mage/sets/nemesis/Daze.java b/Mage.Sets/src/mage/sets/nemesis/Daze.java index 86de9fd2fdf..5562c9a0f09 100644 --- a/Mage.Sets/src/mage/sets/nemesis/Daze.java +++ b/Mage.Sets/src/mage/sets/nemesis/Daze.java @@ -28,15 +28,13 @@ package mage.sets.nemesis; import java.util.UUID; -import mage.constants.CardType; -import mage.constants.Rarity; -import mage.abilities.costs.AlternativeCostImpl; -import mage.abilities.costs.CompositeCost; -import mage.abilities.costs.Cost; +import mage.abilities.costs.AlternativeCostSourceAbility; import mage.abilities.costs.common.ReturnToHandTargetCost; import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.effects.common.CounterUnlessPaysEffect; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Rarity; import mage.filter.common.FilterControlledPermanent; import mage.filter.predicate.mageobject.CardTypePredicate; import mage.filter.predicate.mageobject.SubtypePredicate; @@ -49,9 +47,7 @@ import mage.target.common.TargetControlledPermanent; */ public class Daze extends CardImpl { - private static final FilterControlledPermanent filter = new FilterControlledPermanent("Island"); - private static final String COST_DESCRIPTION = "Return an island you control to its owner's hand"; - private static final String ALTERNATIVE_COST_DESCRIPTION = "You may return an island you control to its owner's hand rather than pay {this}'s mana cost"; + private static final FilterControlledPermanent filter = new FilterControlledPermanent("an Island"); static { filter.add(new SubtypePredicate("Island")); @@ -65,8 +61,8 @@ public class Daze extends CardImpl { this.color.setBlue(true); // You may return an Island you control to its owner's hand rather than pay Daze's mana cost. - Cost cost = new CompositeCost(new GenericManaCost(0), new ReturnToHandTargetCost(new TargetControlledPermanent(filter)), COST_DESCRIPTION); - this.getSpellAbility().addAlternativeCost(new AlternativeCostImpl(ALTERNATIVE_COST_DESCRIPTION, cost)); + this.addAbility(new AlternativeCostSourceAbility(new ReturnToHandTargetCost(new TargetControlledPermanent(filter)))); + // Counter target spell unless its controller pays {1}. this.getSpellAbility().addTarget(new TargetSpell()); this.getSpellAbility().addEffect(new CounterUnlessPaysEffect(new GenericManaCost(1))); diff --git a/Mage.Sets/src/mage/sets/nemesis/Massacre.java b/Mage.Sets/src/mage/sets/nemesis/Massacre.java index 9302451fa0c..051d5527cbd 100644 --- a/Mage.Sets/src/mage/sets/nemesis/Massacre.java +++ b/Mage.Sets/src/mage/sets/nemesis/Massacre.java @@ -28,18 +28,18 @@ package mage.sets.nemesis; import java.util.UUID; - -import mage.constants.CardType; -import mage.constants.Rarity; -import mage.abilities.Ability; -import mage.abilities.costs.AlternativeCostImpl; -import mage.abilities.costs.CostImpl; +import mage.abilities.condition.CompoundCondition; +import mage.abilities.condition.Condition; +import mage.abilities.condition.common.ControlsPermanentCondition; +import mage.abilities.condition.common.OpponentControlsPermanentCondition; +import mage.abilities.costs.AlternativeCostSourceAbility; import mage.abilities.effects.common.continious.BoostAllEffect; import mage.cards.CardImpl; +import mage.constants.CardType; import mage.constants.Duration; -import mage.filter.common.FilterControlledLandPermanent; +import mage.constants.Rarity; +import mage.filter.FilterPermanent; import mage.filter.predicate.mageobject.SubtypePredicate; -import mage.game.Game; /** * @@ -47,6 +47,14 @@ import mage.game.Game; */ public class Massacre extends CardImpl { + private static final FilterPermanent filterPlains = new FilterPermanent(); + private static final FilterPermanent filterSwamp = new FilterPermanent(); + + static { + filterPlains.add(new SubtypePredicate(("Plains"))); + filterSwamp.add(new SubtypePredicate(("Swamp"))); + } + public Massacre(UUID ownerId) { super(ownerId, 58, "Massacre", Rarity.UNCOMMON, new CardType[]{CardType.SORCERY}, "{2}{B}{B}"); this.expansionSetCode = "NMS"; @@ -54,7 +62,10 @@ public class Massacre extends CardImpl { this.color.setBlack(true); // If an opponent controls a Plains and you control a Swamp, you may cast Massacre without paying its mana cost. - this.getSpellAbility().addAlternativeCost(new AlternativeCostImpl("If an opponent controls a Plains and you control a Swamp, you may cast Massacre without paying its mana cost", new MassacreCost())); + Condition condition = new CompoundCondition("If an opponent controls a Plains and you control a Swamp", + new OpponentControlsPermanentCondition(filterPlains), + new ControlsPermanentCondition(filterSwamp)); + this.addAbility(new AlternativeCostSourceAbility(null, condition)); // All creatures get -2/-2 until end of turn. this.getSpellAbility().addEffect(new BoostAllEffect(-2, -2, Duration.EndOfTurn)); } @@ -68,44 +79,3 @@ public class Massacre extends CardImpl { return new Massacre(this); } } - -class MassacreCost extends CostImpl { - - - - public MassacreCost() { - this.text = "If an opponent controls a Plains and you control a Swamp, you may cast Massacre without paying its mana cost."; - } - - public MassacreCost(MassacreCost cost) { - super(cost); - } - - @Override - public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) { - paid = canPay(sourceId, controllerId, game); - return paid; - } - - @Override - public boolean canPay(UUID sourceId, UUID controllerId, Game game) { - FilterControlledLandPermanent filterSwamp = new FilterControlledLandPermanent("Swamp"); - filterSwamp.add(new SubtypePredicate("Swamp")); - FilterControlledLandPermanent filterPlains = new FilterControlledLandPermanent("Plains"); - filterPlains.add(new SubtypePredicate("Plains")); - if (game.getBattlefield().contains(filterSwamp, controllerId, 1, game)) { - for(UUID uuid : game.getOpponents(controllerId)){ - if(game.getBattlefield().contains(filterPlains, uuid, 1, game)){ - return true; - } - } - } - return false; - } - - @Override - public MassacreCost copy() { - return new MassacreCost(this); - } - -} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/prophecy/Abolish.java b/Mage.Sets/src/mage/sets/prophecy/Abolish.java index cfd9ec8d6d5..709b245ba49 100644 --- a/Mage.Sets/src/mage/sets/prophecy/Abolish.java +++ b/Mage.Sets/src/mage/sets/prophecy/Abolish.java @@ -31,6 +31,7 @@ import java.util.UUID; import mage.constants.CardType; import mage.constants.Rarity; import mage.abilities.costs.AlternativeCostImpl; +import mage.abilities.costs.AlternativeCostSourceAbility; import mage.abilities.costs.common.DiscardTargetCost; import mage.abilities.effects.common.DestroyTargetEffect; import mage.cards.CardImpl; @@ -62,9 +63,7 @@ public class Abolish extends CardImpl { this.color.setWhite(true); // You may discard a Plains card rather than pay Abolish's mana cost. - this.getSpellAbility().addAlternativeCost( - new AlternativeCostImpl("You may discard a Plains card rather than pay Abolish's mana cost", - new DiscardTargetCost(new TargetCardInHand(filterCost)))); + this.addAbility(new AlternativeCostSourceAbility(new DiscardTargetCost(new TargetCardInHand(filterCost)))); // Destroy target artifact or enchantment. this.getSpellAbility().addEffect(new DestroyTargetEffect()); diff --git a/Mage.Sets/src/mage/sets/riseoftheeldrazi/HandOfEmrakul.java b/Mage.Sets/src/mage/sets/riseoftheeldrazi/HandOfEmrakul.java index f3400118fee..930294a97c8 100644 --- a/Mage.Sets/src/mage/sets/riseoftheeldrazi/HandOfEmrakul.java +++ b/Mage.Sets/src/mage/sets/riseoftheeldrazi/HandOfEmrakul.java @@ -28,13 +28,13 @@ package mage.sets.riseoftheeldrazi; import java.util.UUID; -import mage.constants.CardType; -import mage.constants.Rarity; import mage.MageInt; -import mage.abilities.costs.AlternativeCostImpl; +import mage.abilities.costs.AlternativeCostSourceAbility; import mage.abilities.costs.common.SacrificeTargetCost; import mage.abilities.keyword.AnnihilatorAbility; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Rarity; import mage.filter.common.FilterControlledPermanent; import mage.filter.predicate.mageobject.NamePredicate; import mage.target.common.TargetControlledPermanent; @@ -45,8 +45,7 @@ import mage.target.common.TargetControlledPermanent; */ public class HandOfEmrakul extends CardImpl { - private static final String ALTERNATIVE_COST_DESCRIPTION = "You may sacrifice four Eldrazi Spawn rather than pay Hand of Emrakul's mana cost"; - private static final FilterControlledPermanent filter = new FilterControlledPermanent("Eldrazi Spawn"); + private static final FilterControlledPermanent filter = new FilterControlledPermanent("four Eldrazi Spawn"); static { filter.add(new NamePredicate("Eldrazi Spawn")); @@ -61,8 +60,8 @@ public class HandOfEmrakul extends CardImpl { this.toughness = new MageInt(7); // You may sacrifice four Eldrazi Spawn rather than pay Hand of Emrakul's mana cost. - this.getSpellAbility().addAlternativeCost(new AlternativeCostImpl(ALTERNATIVE_COST_DESCRIPTION, - new SacrificeTargetCost(new TargetControlledPermanent(4, 4, filter, true)))); + this.addAbility(new AlternativeCostSourceAbility(new SacrificeTargetCost(new TargetControlledPermanent(4, 4, filter, true)))); + // Annihilator 1 this.addAbility(new AnnihilatorAbility(1)); } diff --git a/Mage.Sets/src/mage/sets/shardsofalara/SalvageTitan.java b/Mage.Sets/src/mage/sets/shardsofalara/SalvageTitan.java index e25889ac046..091b6ca6079 100644 --- a/Mage.Sets/src/mage/sets/shardsofalara/SalvageTitan.java +++ b/Mage.Sets/src/mage/sets/shardsofalara/SalvageTitan.java @@ -28,17 +28,15 @@ package mage.sets.shardsofalara; import java.util.UUID; - -import mage.constants.CardType; -import mage.constants.Rarity; import mage.MageInt; import mage.abilities.common.SimpleActivatedAbility; -import mage.abilities.costs.AlternativeCostImpl; -import mage.abilities.costs.Cost; +import mage.abilities.costs.AlternativeCostSourceAbility; import mage.abilities.costs.common.ExileFromGraveCost; import mage.abilities.costs.common.SacrificeTargetCost; import mage.abilities.effects.common.ReturnSourceFromGraveyardToHandEffect; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Rarity; import mage.constants.Zone; import mage.filter.common.FilterArtifactCard; import mage.filter.common.FilterControlledArtifactPermanent; @@ -53,7 +51,7 @@ import mage.target.common.TargetControlledPermanent; */ public class SalvageTitan extends CardImpl { - private static final FilterControlledPermanent filter = new FilterControlledPermanent("artifacts"); + private static final FilterControlledPermanent filter = new FilterControlledPermanent("three artifacts"); static{ filter.add(new CardTypePredicate(CardType.ARTIFACT)); } @@ -68,8 +66,8 @@ public class SalvageTitan extends CardImpl { this.toughness = new MageInt(4); // You may sacrifice three artifacts rather than pay Salvage Titan's mana cost. - Cost cost = new SacrificeTargetCost(new TargetControlledPermanent(3, 3, new FilterControlledArtifactPermanent(), true)); - this.getSpellAbility().addAlternativeCost(new AlternativeCostImpl("You may sacrifice three artifacts rather than pay {this}'s mana cost", cost)); + this.addAbility(new AlternativeCostSourceAbility(new SacrificeTargetCost(new TargetControlledPermanent(3, 3, new FilterControlledArtifactPermanent(), true)))); + // Exile three artifact cards from your graveyard: Return Salvage Titan from your graveyard to your hand. this.addAbility(new SimpleActivatedAbility(Zone.GRAVEYARD, new ReturnSourceFromGraveyardToHandEffect(), new ExileFromGraveCost(new TargetCardInYourGraveyard(3, new FilterArtifactCard())))); } diff --git a/Mage/src/mage/abilities/condition/common/ControlsPermanentCondition.java b/Mage/src/mage/abilities/condition/common/ControlsPermanentCondition.java index 993c4bc5ea9..7b0469b8cb1 100644 --- a/Mage/src/mage/abilities/condition/common/ControlsPermanentCondition.java +++ b/Mage/src/mage/abilities/condition/common/ControlsPermanentCondition.java @@ -93,9 +93,6 @@ public class ControlsPermanentCondition implements Condition { this.condition = conditionToDecorate; } - /* - * {@inheritDoc} - */ @Override public boolean apply(Game game, Ability source) { boolean conditionApplies = false; diff --git a/Mage/src/mage/abilities/condition/common/OpponentControlsPermanentCondition.java b/Mage/src/mage/abilities/condition/common/OpponentControlsPermanentCondition.java new file mode 100644 index 00000000000..dfb0f89be91 --- /dev/null +++ b/Mage/src/mage/abilities/condition/common/OpponentControlsPermanentCondition.java @@ -0,0 +1,124 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ + +package mage.abilities.condition.common; + +import mage.abilities.Ability; +import mage.abilities.condition.Condition; +import mage.constants.TargetController; +import mage.filter.FilterPermanent; +import mage.filter.predicate.permanent.ControllerPredicate; +import mage.game.Game; + +/** + * + * @author LevelX2 + */ + +public class OpponentControlsPermanentCondition implements Condition { + + public static enum CountType { MORE_THAN, FEWER_THAN, EQUAL_TO }; + private FilterPermanent filter; + private Condition condition; + private CountType type; + private int count; + + /** + * Applies a filter and delegates creation to + * {@link #ControlsPermanent(mage.filter.FilterPermanent, mage.abilities.condition.common.ControlsPermanent.CountType, int)} + * with {@link CountType#MORE_THAN}, and 0. + * + * @param filter + */ + public OpponentControlsPermanentCondition(FilterPermanent filter) { + this(filter, CountType.MORE_THAN, 0); + } + + /** + * Applies a filter, a {@link CountType}, and count to permanents on the + * battlefield when checking the condition during the + * {@link #apply(mage.game.Game, mage.abilities.Ability) apply} method invocation. + * + * @param filter + * @param type + * @param count + */ + public OpponentControlsPermanentCondition ( FilterPermanent filter, CountType type, int count ) { + this.filter = filter; + this.type = type; + this.count = count; + } + + /** + * Applies a filter, a {@link CountType}, and count to permanents on the + * battlefield and calls the decorated condition to see if it + * {@link #apply(mage.game.Game, mage.abilities.Ability) applies} + * as well. This will force both conditions to apply for this to be true. + * + * @param filter + * @param type + * @param count + * @param conditionToDecorate + */ + public OpponentControlsPermanentCondition ( FilterPermanent filter, CountType type, int count, Condition conditionToDecorate ) { + this(filter, type, count); + this.condition = conditionToDecorate; + } + + @Override + public boolean apply(Game game, Ability source) { + boolean conditionApplies = false; + + FilterPermanent localFilter = filter.copy(); + localFilter.add(new ControllerPredicate(TargetController.OPPONENT)); + + switch ( this.type ) { + case FEWER_THAN: + conditionApplies = game.getBattlefield().count(localFilter, source.getSourceId(), source.getControllerId(), game) < this.count; + break; + case MORE_THAN: + conditionApplies = game.getBattlefield().count(localFilter, source.getSourceId(), source.getControllerId(), game) > this.count; + break; + case EQUAL_TO: + conditionApplies = game.getBattlefield().count(localFilter, source.getSourceId(), source.getControllerId(), game) == this.count; + break; + } + + //If a decorated condition exists, check it as well and apply them together. + if ( this.condition != null ) { + conditionApplies = conditionApplies && this.condition.apply(game, source); + } + + return conditionApplies; + } + + @Override + public String toString() { + return filter.getMessage(); + } +} diff --git a/Mage/src/mage/abilities/costs/AlternativeCostSourceAbility.java b/Mage/src/mage/abilities/costs/AlternativeCostSourceAbility.java index fb8712fe30b..290b9e6d14b 100644 --- a/Mage/src/mage/abilities/costs/AlternativeCostSourceAbility.java +++ b/Mage/src/mage/abilities/costs/AlternativeCostSourceAbility.java @@ -72,8 +72,10 @@ public class AlternativeCostSourceAbility extends StaticAbility