* Reworked some cost reduction effects.

This commit is contained in:
LevelX2 2015-02-23 23:21:55 +01:00
parent 14eca696ce
commit 471bd835ad
5 changed files with 108 additions and 98 deletions

View file

@ -120,8 +120,7 @@ class KaradorGhostChieftainCostReductionEffect extends CostModificationEffectImp
@Override
public boolean applies(Ability abilityToModify, Ability source, Game game) {
if ((abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility || abilityToModify instanceof RetraceAbility)
&& abilityToModify.getSourceId().equals(source.getSourceId())) {
if ((abilityToModify instanceof SpellAbility) && abilityToModify.getSourceId().equals(source.getSourceId())) {
return game.getCard(abilityToModify.getSourceId()) != null;
}
return false;

View file

@ -34,12 +34,16 @@ import mage.constants.Rarity;
import mage.constants.Zone;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
import mage.cards.CardImpl;
import mage.constants.CostModificationType;
import mage.constants.Duration;
import mage.filter.common.FilterCreatureCard;
import mage.game.Game;
import mage.players.Player;
import mage.util.CardUtil;
/**
*
@ -53,25 +57,13 @@ public class Ghoultree extends CardImpl {
this.subtype.add("Zombie");
this.subtype.add("Treefolk");
this.color.setGreen(true);
this.power = new MageInt(10);
this.toughness = new MageInt(10);
// Ghoultree costs {1} less to cast for each creature card in your graveyard.
this.addAbility(new SimpleStaticAbility(Zone.ALL, new GhoultreeEffect()));
}
@Override
public void adjustCosts(Ability ability, Game game) {
Player player = game.getPlayer(this.getOwnerId());
int creatureCount = player.getGraveyard().count(new FilterCreatureCard(), game);
int cost = 7 - creatureCount;
String adjustedCost = "{G}";
if (cost > 0) {
adjustedCost = "{" + String.valueOf(cost) + "}" + adjustedCost;
}
ability.getManaCostsToPay().clear();
ability.getManaCostsToPay().load(adjustedCost);
Ability ability = new SimpleStaticAbility(Zone.ALL, new GhoultreeCostReductionEffect());
ability.setRuleAtTheTop(true);
this.addAbility(ability);
}
public Ghoultree(final Ghoultree card) {
@ -84,24 +76,39 @@ public class Ghoultree extends CardImpl {
}
}
class GhoultreeEffect extends OneShotEffect {
class GhoultreeCostReductionEffect extends CostModificationEffectImpl {
public GhoultreeEffect() {
super(Outcome.Neutral);
this.staticText = "{this} costs {1} less to cast for each creature card in your graveyard";
GhoultreeCostReductionEffect() {
super(Duration.WhileOnStack, Outcome.Benefit, CostModificationType.REDUCE_COST);
staticText = "{this} costs {1} less to cast for each creature card in your graveyard";
}
public GhoultreeEffect(final GhoultreeEffect effect) {
GhoultreeCostReductionEffect(GhoultreeCostReductionEffect effect) {
super(effect);
}
@Override
public GhoultreeEffect copy() {
return new GhoultreeEffect(this);
public boolean apply(Game game, Ability source, Ability abilityToModify) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
int reductionAmount = player.getGraveyard().count(new FilterCreatureCard(), game);
CardUtil.reduceCost(abilityToModify, reductionAmount);
return true;
}
return false;
}
@Override
public boolean apply(Game game, Ability source) {
return true;
public boolean applies(Ability abilityToModify, Ability source, Game game) {
if ((abilityToModify instanceof SpellAbility) && abilityToModify.getSourceId().equals(source.getSourceId())) {
return game.getCard(abilityToModify.getSourceId()) != null;
}
return false;
}
@Override
public GhoultreeCostReductionEffect copy() {
return new GhoultreeCostReductionEffect(this);
}
}

View file

@ -27,18 +27,26 @@
*/
package mage.sets.innistrad;
import java.util.List;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.SpellAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.DamageAllEffect;
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
import mage.abilities.keyword.FlashbackAbility;
import mage.abilities.keyword.RetraceAbility;
import mage.cards.CardImpl;
import mage.constants.CostModificationType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.util.CardUtil;
/**
@ -49,25 +57,14 @@ public class BlasphemousAct extends CardImpl {
public BlasphemousAct(UUID ownerId) {
super(ownerId, 130, "Blasphemous Act", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{8}{R}");
this.expansionSetCode = "ISD";
this.color.setRed(true);
// Blasphemous Act costs {1} less to cast for each creature on the battlefield.
Ability ability = new SimpleStaticAbility(Zone.ALL, new BlasphemousCostReductionEffect());
ability.setRuleAtTheTop(true);
this.addAbility(ability);
// Blasphemous Act deals 13 damage to each creature.
// need to override DamageAllEffect because of rules string
this.getSpellAbility().addEffect(new BlasphemousActEffect());
}
@Override
public void adjustCosts(Ability ability, Game game) {
int creatureCount = game.getState().getBattlefield().count(new FilterCreaturePermanent(), ability.getSourceId(), ability.getControllerId(), game);
int cost = 8 - creatureCount;
String adjustedCost = "{R}";
if (cost > 0) {
adjustedCost = "{" + String.valueOf(cost) + "}" + adjustedCost;
}
ability.getManaCostsToPay().clear();
ability.getManaCostsToPay().load(adjustedCost);
this.getSpellAbility().addEffect(new DamageAllEffect(13, new FilterCreaturePermanent()));
}
public BlasphemousAct(final BlasphemousAct card) {
@ -80,29 +77,39 @@ public class BlasphemousAct extends CardImpl {
}
}
class BlasphemousActEffect extends OneShotEffect {
class BlasphemousCostReductionEffect extends CostModificationEffectImpl {
public BlasphemousActEffect() {
super(Outcome.Damage);
staticText = "{this} costs {1} less to cast for each creature on the battlefield.\n {this} deals 13 damage to each creature";
BlasphemousCostReductionEffect() {
super(Duration.WhileOnStack, Outcome.Benefit, CostModificationType.REDUCE_COST);
staticText = "{this} costs {1} less to cast for each creature on the battlefield";
}
public BlasphemousActEffect(final BlasphemousActEffect effect) {
BlasphemousCostReductionEffect(BlasphemousCostReductionEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
List<Permanent> permanents = game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(), source.getControllerId(), game);
for (Permanent permanent : permanents) {
permanent.damage(13, source.getSourceId(), game, false, true);
public boolean apply(Game game, Ability source, Ability abilityToModify) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
int reductionAmount = game.getBattlefield().count(new FilterCreaturePermanent(), source.getSourceId(), source.getControllerId(), game);
CardUtil.reduceCost(abilityToModify, reductionAmount);
return true;
}
return true;
return false;
}
@Override
public BlasphemousActEffect copy() {
return new BlasphemousActEffect(this);
public boolean applies(Ability abilityToModify, Ability source, Game game) {
if ((abilityToModify instanceof SpellAbility) && abilityToModify.getSourceId().equals(source.getSourceId())) {
return game.getCard(abilityToModify.getSourceId()) != null;
}
return false;
}
@Override
public BlasphemousCostReductionEffect copy() {
return new BlasphemousCostReductionEffect(this);
}
}

View file

@ -34,15 +34,19 @@ import mage.abilities.SpellAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
import mage.abilities.keyword.MonstrosityAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.CostModificationType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterCreatureCard;
import mage.game.Game;
import mage.players.Player;
import mage.util.CardUtil;
/**
*
@ -60,37 +64,18 @@ public class NemesisOfMortals extends CardImpl {
this.toughness = new MageInt(5);
// Nemesis of Mortals costs {1} less to cast for each creature card in your graveyard.
this.addAbility(new SimpleStaticAbility(Zone.ALL, new NemesisOfMortalsEffect()));
Ability ability = new SimpleStaticAbility(Zone.ALL, new NemesisOfMortalsCostReductionEffect());
ability.setRuleAtTheTop(true);
this.addAbility(ability);
// {7}{G}{G}: Monstrosity 5. This ability costs {1} less to activate for each creature card in your graveyard.
Ability ability = new MonstrosityAbility("{7}{G}{G}", 5);
ability = new MonstrosityAbility("{7}{G}{G}", 5);
for (Effect effect : ability.getEffects()) {
effect.setText("Monstrosity 5. This ability costs {1} less to activate for each creature card in your graveyard");
}
this.addAbility(ability);
}
@Override
public void adjustCosts(Ability ability, Game game) {
if (ability instanceof SpellAbility || ability instanceof MonstrosityAbility) {
Player player = game.getPlayer(this.getOwnerId());
int creatureCount = player.getGraveyard().count(new FilterCreatureCard(), game);
int genericMana;
if (ability instanceof MonstrosityAbility) {
genericMana = 7 - creatureCount;
} else {
genericMana = 4 - creatureCount;
}
StringBuilder adjustedCost = new StringBuilder();
if (genericMana > 0) {
adjustedCost.append("{").append(genericMana).append("}");
}
adjustedCost.insert(0,"{G}{G}");
ability.getManaCostsToPay().clear();
ability.getManaCostsToPay().load(adjustedCost.toString());
}
}
public NemesisOfMortals(final NemesisOfMortals card) {
super(card);
}
@ -101,24 +86,39 @@ public class NemesisOfMortals extends CardImpl {
}
}
class NemesisOfMortalsEffect extends OneShotEffect {
class NemesisOfMortalsCostReductionEffect extends CostModificationEffectImpl {
public NemesisOfMortalsEffect() {
super(Outcome.Neutral);
this.staticText = "{this} costs {1} less to cast for each creature card in your graveyard";
NemesisOfMortalsCostReductionEffect() {
super(Duration.WhileOnStack, Outcome.Benefit, CostModificationType.REDUCE_COST);
staticText = "{this} costs {1} less to cast for each creature card in your graveyard";
}
public NemesisOfMortalsEffect(final NemesisOfMortalsEffect effect) {
NemesisOfMortalsCostReductionEffect(NemesisOfMortalsCostReductionEffect effect) {
super(effect);
}
@Override
public NemesisOfMortalsEffect copy() {
return new NemesisOfMortalsEffect(this);
public boolean apply(Game game, Ability source, Ability abilityToModify) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
int reductionAmount = player.getGraveyard().count(new FilterCreatureCard(), game);
CardUtil.reduceCost(abilityToModify, reductionAmount);
return true;
}
return false;
}
@Override
public boolean apply(Game game, Ability source) {
return true;
public boolean applies(Ability abilityToModify, Ability source, Game game) {
if ((abilityToModify instanceof SpellAbility) && abilityToModify.getSourceId().equals(source.getSourceId())) {
return game.getCard(abilityToModify.getSourceId()) != null;
}
return false;
}
@Override
public NemesisOfMortalsCostReductionEffect copy() {
return new NemesisOfMortalsCostReductionEffect(this);
}
}

View file

@ -62,10 +62,8 @@ public class StoneIdolTrap extends CardImpl {
this.expansionSetCode = "WWK";
this.subtype.add("Trap");
this.color.setRed(true);
// Stone Idol Trap costs {1} less to cast for each attacking creature.
Ability ability = new SimpleStaticAbility(Zone.STACK, new StoneIdolTrapCostReductionEffect());
Ability ability = new SimpleStaticAbility(Zone.ALL, new StoneIdolTrapCostReductionEffect());
ability.setRuleAtTheTop(true);
this.addAbility(ability);
@ -108,8 +106,7 @@ class StoneIdolTrapCostReductionEffect extends CostModificationEffectImpl {
@Override
public boolean applies(Ability abilityToModify, Ability source, Game game) {
if ((abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility || abilityToModify instanceof RetraceAbility)
&& abilityToModify.getSourceId().equals(source.getSourceId())) {
if ((abilityToModify instanceof SpellAbility) && abilityToModify.getSourceId().equals(source.getSourceId())) {
return game.getCard(abilityToModify.getSourceId()) != null;
}
return false;
@ -156,7 +153,7 @@ class StoneIdolTrapEffect extends OneShotEffect {
class StoneTrapIdolToken extends Token {
public StoneTrapIdolToken() {
super("Construct", "6/12 construct artifact creature token with trample");
super("Construct", "6/12 colorless Construct artifact creature token with trample");
cardType.add(CardType.CREATURE);
cardType.add(CardType.ARTIFACT);
subtype.add("Construct");