* Nemesis of Mortals - Fixed wrong cost calculation of monstrosity ability.

This commit is contained in:
LevelX2 2013-09-28 01:17:18 +02:00
parent fcb50dd475
commit 608f7bd3e3
3 changed files with 39 additions and 20 deletions

View file

@ -30,7 +30,9 @@ package mage.sets.theros;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.MonstrosityAbility;
import mage.cards.CardImpl;
@ -61,20 +63,32 @@ public class NemesisOfMortals extends CardImpl<NemesisOfMortals> {
this.addAbility(new SimpleStaticAbility(Zone.ALL, new NemesisOfMortalsEffect()));
// {7}{G}{G}: Monstrosity 5. This ability costs {1} less to activate for each creature card in your graveyard.
this.addAbility(new MonstrosityAbility("{7}{G}{G}", 5));
Ability 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) {
Player player = game.getPlayer(this.getOwnerId());
int creatureCount = player.getGraveyard().count(new FilterCreatureCard(), game);
int cost = 4 - creatureCount;
String adjustedCost = "{G}{G}";
if (cost > 0) {
adjustedCost = "{" + String.valueOf(cost) + "}" + adjustedCost;
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());
}
ability.getManaCostsToPay().clear();
ability.getManaCostsToPay().load(adjustedCost);
}
public NemesisOfMortals(final NemesisOfMortals card) {

View file

@ -30,7 +30,6 @@ package mage.sets.theros;
import java.util.UUID;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DrawCardControllerEffect;
import mage.abilities.effects.common.LoseLifeControllerEffect;
import mage.abilities.effects.common.LoseLifeSourceEffect;
import mage.abilities.effects.common.ScryEffect;
import mage.cards.CardImpl;

View file

@ -78,7 +78,7 @@ public class MonstrosityAbility extends ActivatedAbilityImpl<MonstrosityAbility>
* @param monstrosityValue use Integer.MAX_VALUE for monstrosity X.
*/
public MonstrosityAbility(String manaString, int monstrosityValue) {
super(Zone.BATTLEFIELD, new BecomeMonstrousSourceEffect(),new ManaCostsImpl(manaString));
super(Zone.BATTLEFIELD, new BecomeMonstrousSourceEffect(monstrosityValue),new ManaCostsImpl(manaString));
this.monstrosityValue = monstrosityValue;
}
@ -94,25 +94,21 @@ public class MonstrosityAbility extends ActivatedAbilityImpl<MonstrosityAbility>
@Override
public String getRule() {
return new StringBuilder(manaCosts.getText()).append(": Monstrosity ")
.append(monstrosityValue == Integer.MAX_VALUE ? "X":monstrosityValue)
.append(". <i>(If this creature isn't monstrous, put ")
.append(monstrosityValue == Integer.MAX_VALUE ? "X":CardUtil.numberToText(monstrosityValue))
.append(" +1/+1 counters on it and it becomes monstrous.)</i>").toString();
return new StringBuilder(manaCosts.getText()).append(": ").append(super.getRule()).toString();
}
public int getMonstrosityValue() {
return monstrosityValue;
}
}
class BecomeMonstrousSourceEffect extends OneShotEffect<BecomeMonstrousSourceEffect> {
public BecomeMonstrousSourceEffect() {
public BecomeMonstrousSourceEffect(int monstrosityValue) {
super(Outcome.BoostCreature);
this.staticText = "";
this.staticText = setText(monstrosityValue);
}
public BecomeMonstrousSourceEffect(final BecomeMonstrousSourceEffect effect) {
@ -140,4 +136,14 @@ class BecomeMonstrousSourceEffect extends OneShotEffect<BecomeMonstrousSourceEff
}
return false;
}
private String setText(int monstrosityValue) {
StringBuilder sb = new StringBuilder("Monstrosity ");
sb.append(monstrosityValue == Integer.MAX_VALUE ? "X":monstrosityValue)
.append(". <i>(If this creature isn't monstrous, put ")
.append(monstrosityValue == Integer.MAX_VALUE ? "X":CardUtil.numberToText(monstrosityValue))
.append(" +1/+1 counters on it and it becomes monstrous.)</i>").toString();
return sb.toString();
}
}