Added 3 cards

Added CardsInControllerGraveyardCount
Refactoring
This commit is contained in:
North 2011-06-08 23:06:40 +03:00
parent 0aae5d6559
commit 175dd21f92
8 changed files with 375 additions and 81 deletions

View file

@ -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;
@ -75,17 +70,21 @@ public class KnightOfTheReliquary extends CardImpl<KnightOfTheReliquary> {
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.color.setWhite(true);
this.color.setGreen(true);
this.power = new MageInt(2);
this.toughness = new MageInt(2);
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 SimpleStaticAbility(Zone.BATTLEFIELD, new KnightOfTheReliquaryEffect()));
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new SearchLibraryPutInPlayEffect(target, false, Outcome.PutLandInPlay), costs));
}
@ -97,43 +96,4 @@ public class KnightOfTheReliquary extends CardImpl<KnightOfTheReliquary> {
public KnightOfTheReliquary copy() {
return new KnightOfTheReliquary(this);
}
}
class KnightOfTheReliquaryEffect extends ContinuousEffectImpl<KnightOfTheReliquaryEffect> {
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";
}
}

View file

@ -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<SalvageSlasher> {
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);
}
}

View file

@ -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<ScrapyardSalvo> {
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);
}
}

View file

@ -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<SwordofWarandPeaceA
public SwordofWarandPeaceAbility() {
super(Constants.Zone.BATTLEFIELD, new SwordofWarandPeaceDamageEffect());
this.addEffect(new GainLifeEffect(new CardsInControlledPlayerHandCount()));
this.addEffect(new GainLifeEffect(new CardsInControllerHandCount()));
this.addTarget(new TargetPlayer());
}

View file

@ -0,0 +1,138 @@
/*
* 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.zendikar;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.Mana;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTappedAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.CardsInControllerGraveyardCount;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.mana.BlackManaAbility;
import mage.abilities.mana.ManaAbility;
import mage.cards.CardImpl;
import mage.filter.common.FilterCreatureCard;
import mage.game.Game;
/**
*
* @author North
*/
public class CryptOfAgadeem extends CardImpl<CryptOfAgadeem> {
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<CryptOfAgadeemAbility> {
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";
}
}

View file

@ -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";
}
}

View file

@ -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

View file

@ -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