From 175dd21f92a5cbec8636ed35c199fbbbf3741762 Mon Sep 17 00:00:00 2001 From: North Date: Wed, 8 Jun 2011 23:06:40 +0300 Subject: [PATCH] Added 3 cards Added CardsInControllerGraveyardCount Refactoring --- .../sets/conflux/KnightOfTheReliquary.java | 112 +++++--------- .../src/mage/sets/conflux/SalvageSlasher.java | 72 +++++++++ .../mage/sets/newphyrexia/ScrapyardSalvo.java | 65 +++++++++ .../sets/newphyrexia/SwordofWarandPeace.java | 4 +- .../mage/sets/zendikar/CryptOfAgadeem.java | 138 ++++++++++++++++++ .../CardsInControllerGraveyardCount.java | 59 ++++++++ ...t.java => CardsInControllerHandCount.java} | 4 +- .../common/PermanentsOnBattlefieldCount.java | 2 +- 8 files changed, 375 insertions(+), 81 deletions(-) create mode 100644 Mage.Sets/src/mage/sets/conflux/SalvageSlasher.java create mode 100644 Mage.Sets/src/mage/sets/newphyrexia/ScrapyardSalvo.java create mode 100644 Mage.Sets/src/mage/sets/zendikar/CryptOfAgadeem.java create mode 100644 Mage/src/mage/abilities/dynamicvalue/common/CardsInControllerGraveyardCount.java rename Mage/src/mage/abilities/dynamicvalue/common/{CardsInControlledPlayerHandCount.java => CardsInControllerHandCount.java} (78%) diff --git a/Mage.Sets/src/mage/sets/conflux/KnightOfTheReliquary.java b/Mage.Sets/src/mage/sets/conflux/KnightOfTheReliquary.java index 9bc9b82192..5f04d220b0 100644 --- a/Mage.Sets/src/mage/sets/conflux/KnightOfTheReliquary.java +++ b/Mage.Sets/src/mage/sets/conflux/KnightOfTheReliquary.java @@ -25,33 +25,28 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. */ - package mage.sets.conflux; import java.util.UUID; import mage.Constants.CardType; import mage.Constants.Duration; -import mage.Constants.Layer; import mage.Constants.Outcome; import mage.Constants.Rarity; -import mage.Constants.SubLayer; import mage.Constants.Zone; import mage.MageInt; -import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.costs.Costs; import mage.abilities.costs.CostsImpl; import mage.abilities.costs.common.SacrificeTargetCost; import mage.abilities.costs.common.TapSourceCost; -import mage.abilities.effects.ContinuousEffectImpl; +import mage.abilities.dynamicvalue.common.CardsInControllerGraveyardCount; +import mage.abilities.effects.common.continious.BoostSourceEffect; import mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect; import mage.cards.CardImpl; import mage.filter.Filter.ComparisonScope; import mage.filter.common.FilterControlledPermanent; import mage.filter.common.FilterLandCard; -import mage.game.Game; -import mage.game.permanent.Permanent; import mage.target.common.TargetCardInLibrary; import mage.target.common.TargetControlledPermanent; @@ -62,78 +57,43 @@ import mage.target.common.TargetControlledPermanent; */ public class KnightOfTheReliquary extends CardImpl { - private static final FilterControlledPermanent filter = new FilterControlledPermanent("Forest or Plains"); + private static final FilterControlledPermanent filter = new FilterControlledPermanent("Forest or Plains"); - static { - filter.getCardType().add(CardType.LAND); - filter.setScopeCardType(ComparisonScope.Any); - filter.getSubtype().add("Forest"); - filter.getSubtype().add("Plains"); - filter.setScopeSubtype(ComparisonScope.Any); - } + static { + filter.getCardType().add(CardType.LAND); + filter.setScopeCardType(ComparisonScope.Any); + filter.getSubtype().add("Forest"); + filter.getSubtype().add("Plains"); + filter.setScopeSubtype(ComparisonScope.Any); + } - public KnightOfTheReliquary(UUID ownerId) { - super(ownerId, 113, "Knight of the Reliquary", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{1}{G}{W}"); - this.expansionSetCode = "CON"; - this.color.setWhite(true); - this.color.setGreen(true); - this.subtype.add("Human"); - this.subtype.add("Knight"); - this.power = new MageInt(2); - this.toughness = new MageInt(2); - TargetCardInLibrary target = new TargetCardInLibrary(new FilterLandCard()); - Costs costs = new CostsImpl(); - costs.add(new TapSourceCost()); - costs.add(new SacrificeTargetCost(new TargetControlledPermanent(1, 1, filter, false))); - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new KnightOfTheReliquaryEffect())); - this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new SearchLibraryPutInPlayEffect(target, false, Outcome.PutLandInPlay), costs)); - } + public KnightOfTheReliquary(UUID ownerId) { + super(ownerId, 113, "Knight of the Reliquary", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{1}{G}{W}"); + this.expansionSetCode = "CON"; + this.subtype.add("Human"); + this.subtype.add("Knight"); - public KnightOfTheReliquary(final KnightOfTheReliquary card) { - super(card); - } + this.color.setWhite(true); + this.color.setGreen(true); + this.power = new MageInt(2); + this.toughness = new MageInt(2); - @Override - public KnightOfTheReliquary copy() { - return new KnightOfTheReliquary(this); - } + CardsInControllerGraveyardCount value = new CardsInControllerGraveyardCount(new FilterLandCard()); + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostSourceEffect(value, value, Duration.WhileOnBattlefield))); + TargetCardInLibrary target = new TargetCardInLibrary(new FilterLandCard()); + Costs costs = new CostsImpl(); + costs.add(new TapSourceCost()); + costs.add(new SacrificeTargetCost(new TargetControlledPermanent(1, 1, filter, false))); + this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new SearchLibraryPutInPlayEffect(target, false, Outcome.PutLandInPlay), costs)); + } + + public KnightOfTheReliquary(final KnightOfTheReliquary card) { + super(card); + } + + @Override + public KnightOfTheReliquary copy() { + return new KnightOfTheReliquary(this); + } } - -class KnightOfTheReliquaryEffect extends ContinuousEffectImpl { - - private static FilterLandCard filter = new FilterLandCard(); - - public KnightOfTheReliquaryEffect() { - super(Duration.WhileOnBattlefield, Layer.PTChangingEffects_7, SubLayer.ModifyPT_7c, Outcome.BoostCreature); - } - - public KnightOfTheReliquaryEffect(final KnightOfTheReliquaryEffect effect) { - super(effect); - } - - @Override - public KnightOfTheReliquaryEffect copy() { - return new KnightOfTheReliquaryEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - int count = game.getPlayer(source.getControllerId()).getGraveyard().count(filter, game); - if (count > 0) { - Permanent target = (Permanent) game.getPermanent(source.getSourceId()); - if (target != null) { - target.addPower(count); - target.addToughness(count); - return true; - } - } - return false; - } - - @Override - public String getText(Ability source) { - return "{this} gets +1/+1 for each land card in your graveyard"; - } - -} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/conflux/SalvageSlasher.java b/Mage.Sets/src/mage/sets/conflux/SalvageSlasher.java new file mode 100644 index 0000000000..f00134e5f9 --- /dev/null +++ b/Mage.Sets/src/mage/sets/conflux/SalvageSlasher.java @@ -0,0 +1,72 @@ +/* + * 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.sets.conflux; + +import java.util.UUID; +import mage.Constants.CardType; +import mage.Constants.Duration; +import mage.Constants.Rarity; +import mage.Constants.Zone; +import mage.MageInt; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.dynamicvalue.common.CardsInControllerGraveyardCount; +import mage.abilities.dynamicvalue.common.StaticValue; +import mage.abilities.effects.common.continious.BoostSourceEffect; +import mage.cards.CardImpl; +import mage.filter.common.FilterArtifactCard; + +/** + * + * @author North + */ +public class SalvageSlasher extends CardImpl { + + public SalvageSlasher(UUID ownerId) { + super(ownerId, 52, "Salvage Slasher", Rarity.COMMON, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{1}{B}"); + this.expansionSetCode = "CON"; + this.subtype.add("Human"); + this.subtype.add("Rogue"); + + this.color.setBlack(true); + this.power = new MageInt(1); + this.toughness = new MageInt(1); + BoostSourceEffect effect = new BoostSourceEffect(new CardsInControllerGraveyardCount(new FilterArtifactCard()), + new StaticValue(0), + Duration.WhileOnBattlefield); + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect)); + } + + public SalvageSlasher(final SalvageSlasher card) { + super(card); + } + + @Override + public SalvageSlasher copy() { + return new SalvageSlasher(this); + } +} diff --git a/Mage.Sets/src/mage/sets/newphyrexia/ScrapyardSalvo.java b/Mage.Sets/src/mage/sets/newphyrexia/ScrapyardSalvo.java new file mode 100644 index 0000000000..472a71dce5 --- /dev/null +++ b/Mage.Sets/src/mage/sets/newphyrexia/ScrapyardSalvo.java @@ -0,0 +1,65 @@ +/* + * 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.sets.newphyrexia; + +import java.util.UUID; +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.abilities.dynamicvalue.common.CardsInControllerGraveyardCount; +import mage.abilities.effects.common.DamageTargetEffect; +import mage.cards.CardImpl; +import mage.filter.common.FilterArtifactCard; +import mage.target.TargetPlayer; + +/** + * + * @author North + */ +public class ScrapyardSalvo extends CardImpl { + + private static final FilterArtifactCard filter = new FilterArtifactCard(); + + public ScrapyardSalvo(UUID ownerId) { + super(ownerId, 94, "Scrapyard Salvo", Rarity.COMMON, new CardType[]{CardType.SORCERY}, "{1}{R}{R}"); + this.expansionSetCode = "NPH"; + + this.color.setRed(true); + + this.getSpellAbility().addTarget(new TargetPlayer()); + this.getSpellAbility().addEffect(new DamageTargetEffect(new CardsInControllerGraveyardCount(filter))); + } + + public ScrapyardSalvo(final ScrapyardSalvo card) { + super(card); + } + + @Override + public ScrapyardSalvo copy() { + return new ScrapyardSalvo(this); + } +} diff --git a/Mage.Sets/src/mage/sets/newphyrexia/SwordofWarandPeace.java b/Mage.Sets/src/mage/sets/newphyrexia/SwordofWarandPeace.java index 9f12256add..fd81134e3a 100644 --- a/Mage.Sets/src/mage/sets/newphyrexia/SwordofWarandPeace.java +++ b/Mage.Sets/src/mage/sets/newphyrexia/SwordofWarandPeace.java @@ -37,7 +37,7 @@ import mage.abilities.Ability; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.costs.mana.GenericManaCost; -import mage.abilities.dynamicvalue.common.CardsInControlledPlayerHandCount; +import mage.abilities.dynamicvalue.common.CardsInControllerHandCount; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.DiscardTargetEffect; import mage.abilities.effects.common.GainLifeEffect; @@ -95,7 +95,7 @@ class SwordofWarandPeaceAbility extends TriggeredAbilityImpl { + + public CryptOfAgadeem(UUID ownerId) { + super(ownerId, 212, "Crypt of Agadeem", Rarity.RARE, new CardType[]{CardType.LAND}, ""); + this.expansionSetCode = "ZEN"; + + this.addAbility(new EntersBattlefieldTappedAbility()); + this.addAbility(new BlackManaAbility()); + this.addAbility(new CryptOfAgadeemAbility()); + } + + public CryptOfAgadeem(final CryptOfAgadeem card) { + super(card); + } + + @Override + public CryptOfAgadeem copy() { + return new CryptOfAgadeem(this); + } +} + +class CryptOfAgadeemAbility extends ManaAbility { + + private static final DynamicValue amount; + + static { + FilterCreatureCard filter = new FilterCreatureCard(); + filter.setColor(ObjectColor.BLACK); + filter.setUseColor(true); + amount = new CardsInControllerGraveyardCount(filter); + } + + public CryptOfAgadeemAbility() { + super(Zone.BATTLEFIELD, new CryptOfAgadeemAbilityEffect(amount), new TapSourceCost()); + addCost(new GenericManaCost(2)); + } + + public CryptOfAgadeemAbility(final CryptOfAgadeemAbility ability) { + super(ability); + } + + @Override + public CryptOfAgadeemAbility copy() { + return new CryptOfAgadeemAbility(this); + } + + @Override + public Mana getNetMana(Game game) { + if (game == null) { + return new Mana(); + } + return Mana.BlackMana(amount.calculate(game, this)); + } +} + +class CryptOfAgadeemAbilityEffect extends ManaEffect { + + private DynamicValue amount; + + public CryptOfAgadeemAbilityEffect(DynamicValue amount) { + super(new Mana()); + this.amount = amount; + } + + public CryptOfAgadeemAbilityEffect(final CryptOfAgadeemAbilityEffect effect) { + super(effect); + this.amount = effect.amount.clone(); + } + + @Override + public CryptOfAgadeemAbilityEffect copy() { + return new CryptOfAgadeemAbilityEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + this.mana.clear(); + this.mana.setBlack(amount.calculate(game, source)); + return super.apply(game, source); + } + + @Override + public String getText(Ability source) { + return "Add {B} to your mana pool for each black creature card in your graveyard"; + } +} \ No newline at end of file diff --git a/Mage/src/mage/abilities/dynamicvalue/common/CardsInControllerGraveyardCount.java b/Mage/src/mage/abilities/dynamicvalue/common/CardsInControllerGraveyardCount.java new file mode 100644 index 0000000000..b99a14e3fc --- /dev/null +++ b/Mage/src/mage/abilities/dynamicvalue/common/CardsInControllerGraveyardCount.java @@ -0,0 +1,59 @@ +package mage.abilities.dynamicvalue.common; + +import mage.abilities.Ability; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.filter.FilterCard; +import mage.game.Game; +import mage.players.Player; + +/** + * + * @author North + */ +public class CardsInControllerGraveyardCount implements DynamicValue { + + private FilterCard filter; + private Integer amount; + + public CardsInControllerGraveyardCount() { + this(new FilterCard(), 1); + } + + public CardsInControllerGraveyardCount(FilterCard filter) { + this(filter, 1); + } + + public CardsInControllerGraveyardCount(FilterCard filter, Integer amount) { + this.filter = filter; + this.amount = amount; + } + + public CardsInControllerGraveyardCount(final CardsInControllerGraveyardCount dynamicValue) { + this.filter = dynamicValue.filter; + this.amount = dynamicValue.amount; + } + + @Override + public int calculate(Game game, Ability sourceAbility) { + Player player = game.getPlayer(sourceAbility.getControllerId()); + if (player != null) { + return amount * player.getGraveyard().count(filter, game); + } + return 0; + } + + @Override + public DynamicValue clone() { + return new CardsInControllerGraveyardCount(this); + } + + @Override + public String toString() { + return amount.toString(); + } + + @Override + public String getMessage() { + return " for each " + filter.getMessage() + " in your graveyard"; + } +} diff --git a/Mage/src/mage/abilities/dynamicvalue/common/CardsInControlledPlayerHandCount.java b/Mage/src/mage/abilities/dynamicvalue/common/CardsInControllerHandCount.java similarity index 78% rename from Mage/src/mage/abilities/dynamicvalue/common/CardsInControlledPlayerHandCount.java rename to Mage/src/mage/abilities/dynamicvalue/common/CardsInControllerHandCount.java index e7b6383856..83d015ae72 100644 --- a/Mage/src/mage/abilities/dynamicvalue/common/CardsInControlledPlayerHandCount.java +++ b/Mage/src/mage/abilities/dynamicvalue/common/CardsInControllerHandCount.java @@ -5,7 +5,7 @@ import mage.abilities.dynamicvalue.DynamicValue; import mage.game.Game; import mage.players.Player; -public class CardsInControlledPlayerHandCount implements DynamicValue { +public class CardsInControllerHandCount implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility) { Player controller = game.getPlayer(sourceAbility.getControllerId()); @@ -17,7 +17,7 @@ public class CardsInControlledPlayerHandCount implements DynamicValue { @Override public DynamicValue clone() { - return new CardsInControlledPlayerHandCount(); + return new CardsInControllerHandCount(); } @Override diff --git a/Mage/src/mage/abilities/dynamicvalue/common/PermanentsOnBattlefieldCount.java b/Mage/src/mage/abilities/dynamicvalue/common/PermanentsOnBattlefieldCount.java index 69e210adb1..68fbf2559e 100644 --- a/Mage/src/mage/abilities/dynamicvalue/common/PermanentsOnBattlefieldCount.java +++ b/Mage/src/mage/abilities/dynamicvalue/common/PermanentsOnBattlefieldCount.java @@ -34,7 +34,7 @@ public class PermanentsOnBattlefieldCount implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility) { - return game.getBattlefield().countAll(filter); + return amount * game.getBattlefield().countAll(filter); } @Override