* Mana Effects - Started to move choices to resolving. Allowed to cancel choices of some mana effects to cancel the mana ability activation.

This commit is contained in:
LevelX2 2014-09-06 16:22:45 +02:00
parent 1db5df220c
commit 5b34b46eac
18 changed files with 23 additions and 37 deletions

View file

@ -59,7 +59,6 @@ public class DruidsRepository extends CardImpl {
// Remove a charge counter from Druids' Repository: Add one mana of any color to your mana pool. // Remove a charge counter from Druids' Repository: Add one mana of any color to your mana pool.
Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD, new AddManaOfAnyColorEffect(), new RemoveCountersSourceCost(CounterType.CHARGE.createInstance())); Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD, new AddManaOfAnyColorEffect(), new RemoveCountersSourceCost(CounterType.CHARGE.createInstance()));
ability.addChoice(new ChoiceColor());
this.addAbility(ability); this.addAbility(ability);
} }

View file

@ -48,8 +48,6 @@ public class GoldToken extends Token {
this.setOriginalExpansionSetCode("BNG"); this.setOriginalExpansionSetCode("BNG");
cardType.add(CardType.ARTIFACT); cardType.add(CardType.ARTIFACT);
Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD, new AddManaOfAnyColorEffect(), new SacrificeSourceCost()); this.addAbility(new SimpleManaAbility(Zone.BATTLEFIELD, new AddManaOfAnyColorEffect(), new SacrificeSourceCost()));
ability.addChoice(new ChoiceColor());
this.addAbility(ability);
} }
} }

View file

@ -55,9 +55,7 @@ public class QuirionSentinel extends CardImpl {
this.toughness = new MageInt(1); this.toughness = new MageInt(1);
// When Quirion Sentinel enters the battlefield, add one mana of any color to your mana pool. // When Quirion Sentinel enters the battlefield, add one mana of any color to your mana pool.
Ability ability = new EntersBattlefieldTriggeredAbility(new AddManaOfAnyColorEffect()); this.addAbility(new EntersBattlefieldTriggeredAbility(new AddManaOfAnyColorEffect()));
ability.addChoice(new ChoiceColor());
this.addAbility(ability);
} }
public QuirionSentinel(final QuirionSentinel card) { public QuirionSentinel(final QuirionSentinel card) {

View file

@ -52,7 +52,6 @@ public class BlackLotus extends CardImpl {
// {tap}, Sacrifice Black Lotus: Add three mana of any one color to your mana pool. // {tap}, Sacrifice Black Lotus: Add three mana of any one color to your mana pool.
Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD, new AddManaOfAnyColorEffect(3), new TapSourceCost()); Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD, new AddManaOfAnyColorEffect(3), new TapSourceCost());
ability.addCost(new SacrificeSourceCost()); ability.addCost(new SacrificeSourceCost());
ability.addChoice(new ChoiceColor());
this.addAbility(ability); this.addAbility(ability);
} }

View file

@ -51,7 +51,6 @@ public class GildedLotus extends CardImpl {
// {tap}: Add three mana of any one color to your mana pool. // {tap}: Add three mana of any one color to your mana pool.
Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD, new AddManaOfAnyColorEffect(3), new TapSourceCost()); Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD, new AddManaOfAnyColorEffect(3), new TapSourceCost());
ability.addChoice(new ChoiceColor());
this.addAbility(ability); this.addAbility(ability);
} }

View file

@ -72,8 +72,6 @@ class LionsEyeDiamondAbility extends ManaAbility {
public LionsEyeDiamondAbility() { public LionsEyeDiamondAbility() {
super(Zone.BATTLEFIELD, new AddManaOfAnyColorEffect(3), new SacrificeSourceCost()); super(Zone.BATTLEFIELD, new AddManaOfAnyColorEffect(3), new SacrificeSourceCost());
this.addCost(new DiscardHandCost()); this.addCost(new DiscardHandCost());
this.addChoice(new ChoiceColor());
this.timing = TimingRule.INSTANT;
} }
public LionsEyeDiamondAbility(Zone zone, Mana mana, Cost cost) { public LionsEyeDiamondAbility(Zone zone, Mana mana, Cost cost) {

View file

@ -77,7 +77,6 @@ public class DeathriteShaman extends CardImpl {
// {T}: Exile target land card from a graveyard. Add one mana of any color to your mana pool. // {T}: Exile target land card from a graveyard. Add one mana of any color to your mana pool.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ExileTargetEffect(), new TapSourceCost()); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ExileTargetEffect(), new TapSourceCost());
ability.addEffect(new AddManaOfAnyColorEffect()); ability.addEffect(new AddManaOfAnyColorEffect());
ability.addChoice(new ChoiceColor());
ability.addTarget(new TargetCardInGraveyard(new FilterLandCard("land card from a graveyard"))); ability.addTarget(new TargetCardInGraveyard(new FilterLandCard("land card from a graveyard")));
this.addAbility(ability); this.addAbility(ability);

View file

@ -73,7 +73,6 @@ public class ManaBloom extends CardImpl {
// Remove a charge counter from Mana Bloom: Add one mana of any color to your mana pool. Activate this ability only once each turn. // Remove a charge counter from Mana Bloom: Add one mana of any color to your mana pool. Activate this ability only once each turn.
Ability ability = new ActivateOncePerTurnManaAbility(Zone.BATTLEFIELD, new AddManaOfAnyColorEffect(), new RemoveCountersSourceCost(CounterType.CHARGE.createInstance())); Ability ability = new ActivateOncePerTurnManaAbility(Zone.BATTLEFIELD, new AddManaOfAnyColorEffect(), new RemoveCountersSourceCost(CounterType.CHARGE.createInstance()));
ability.addChoice(new ChoiceColor());
this.addAbility(ability); this.addAbility(ability);
// At the beginning of your upkeep, if Mana Bloom has no charge counters on it, return it to its owner's hand. // At the beginning of your upkeep, if Mana Bloom has no charge counters on it, return it to its owner's hand.

View file

@ -79,7 +79,6 @@ public class MulDayaChannelers extends CardImpl {
// As long as the top card of your library is a land card, Mul Daya Channelers has "T: Add two mana of any one color to your mana pool." // As long as the top card of your library is a land card, Mul Daya Channelers has "T: Add two mana of any one color to your mana pool."
SimpleManaAbility manaAbility = new SimpleManaAbility(Zone.BATTLEFIELD, new AddManaOfAnyColorEffect(2), new TapSourceCost()); SimpleManaAbility manaAbility = new SimpleManaAbility(Zone.BATTLEFIELD, new AddManaOfAnyColorEffect(2), new TapSourceCost());
manaAbility.addChoice(new ChoiceColor());
effect = new ConditionalContinousEffect(new GainAbilitySourceEffect(manaAbility, Duration.WhileOnBattlefield), effect = new ConditionalContinousEffect(new GainAbilitySourceEffect(manaAbility, Duration.WhileOnBattlefield),
new TopLibraryCardTypeCondition(TopLibraryCardTypeCondition.CheckType.LAND), new TopLibraryCardTypeCondition(TopLibraryCardTypeCondition.CheckType.LAND),
"As long as the top card of your library is a land card, Mul Daya Channelers has \"{T}: Add two mana of any one color to your mana pool.\""); "As long as the top card of your library is a land card, Mul Daya Channelers has \"{T}: Add two mana of any one color to your mana pool.\"");

View file

@ -96,7 +96,7 @@ class ReflectingPoolEffect extends ManaEffect {
types.add(ability.getNetMana(game)); types.add(ability.getNetMana(game));
} }
} }
Choice choice = new ChoiceImpl(true); Choice choice = new ChoiceImpl(false);
choice.setMessage("Pick a mana color"); choice.setMessage("Pick a mana color");
if (types.getBlack() > 0) { if (types.getBlack() > 0) {
choice.getChoices().add("Black"); choice.getChoices().add("Black");

View file

@ -58,7 +58,6 @@ public class LotusBloom extends CardImpl {
// {tap}, Sacrifice Lotus Bloom: Add three mana of any one color to your mana pool. // {tap}, Sacrifice Lotus Bloom: Add three mana of any one color to your mana pool.
Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD, new AddManaOfAnyColorEffect(3), new TapSourceCost()); Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD, new AddManaOfAnyColorEffect(3), new TapSourceCost());
ability.addCost(new SacrificeSourceCost()); ability.addCost(new SacrificeSourceCost());
ability.addChoice(new ChoiceColor());
this.addAbility(ability); this.addAbility(ability);
} }

View file

@ -83,7 +83,6 @@ class FertileGroundTriggeredAbility extends TriggeredManaAbility {
public FertileGroundTriggeredAbility() { public FertileGroundTriggeredAbility() {
super(Zone.BATTLEFIELD, new AddManaOfAnyColorEffect()); super(Zone.BATTLEFIELD, new AddManaOfAnyColorEffect());
this.addChoice(new ChoiceColor());
} }
public FertileGroundTriggeredAbility(FertileGroundTriggeredAbility ability) { public FertileGroundTriggeredAbility(FertileGroundTriggeredAbility ability) {

View file

@ -67,7 +67,6 @@ public class KhalniGem extends CardImpl {
this.addAbility(etbAbility); this.addAbility(etbAbility);
// {tap}: Add two mana of any one color to your mana pool. // {tap}: Add two mana of any one color to your mana pool.
SimpleManaAbility ability = new SimpleManaAbility(Zone.BATTLEFIELD, new AddManaOfAnyColorEffect(2), new TapSourceCost()); SimpleManaAbility ability = new SimpleManaAbility(Zone.BATTLEFIELD, new AddManaOfAnyColorEffect(2), new TapSourceCost());
ability.addChoice(new ChoiceColor());
this.addAbility(ability); this.addAbility(ability);
} }

View file

@ -52,9 +52,7 @@ public class LotusCobra extends CardImpl {
this.power = new MageInt(2); this.power = new MageInt(2);
this.toughness = new MageInt(1); this.toughness = new MageInt(1);
LandfallAbility ability = new LandfallAbility(new AddManaOfAnyColorEffect(), false); this.addAbility(new LandfallAbility(new AddManaOfAnyColorEffect(), false));
ability.addChoice(new ChoiceColor());
this.addAbility(ability);
} }
public LotusCobra(final LotusCobra card) { public LotusCobra(final LotusCobra card) {

View file

@ -155,14 +155,16 @@ public abstract class AbilityImpl implements Ability {
boolean effectResult = effect.apply(game, this); boolean effectResult = effect.apply(game, this);
result &= effectResult; result &= effectResult;
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
if (!effectResult) { if (!this.getAbilityType().equals(AbilityType.MANA)) {
if (this.getSourceId() != null) { if (!effectResult) {
MageObject mageObject = game.getObject(this.getSourceId()); if (this.getSourceId() != null) {
if (mageObject != null) { MageObject mageObject = game.getObject(this.getSourceId());
logger.debug("AbilityImpl.resolve: object: " + mageObject.getName()); if (mageObject != null) {
logger.debug("AbilityImpl.resolve: object: " + mageObject.getName());
}
} }
logger.debug("AbilityImpl.resolve: effect returned false -" + effect.getText(this.getModes().getMode()));
} }
logger.debug("AbilityImpl.resolve: effect returned false -" + effect.getText(this.getModes().getMode()));
} }
} }
} }

View file

@ -30,7 +30,6 @@ package mage.abilities.mana;
import mage.abilities.costs.Cost; import mage.abilities.costs.Cost;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.common.AddManaOfAnyColorEffect; import mage.abilities.effects.common.AddManaOfAnyColorEffect;
import mage.choices.ChoiceColor;
import mage.constants.Zone; import mage.constants.Zone;
public class AnyColorManaAbility extends ManaAbility { public class AnyColorManaAbility extends ManaAbility {
@ -40,7 +39,6 @@ public class AnyColorManaAbility extends ManaAbility {
public AnyColorManaAbility(Cost cost) { public AnyColorManaAbility(Cost cost) {
super(Zone.BATTLEFIELD, new AddManaOfAnyColorEffect(), cost); super(Zone.BATTLEFIELD, new AddManaOfAnyColorEffect(), cost);
this.addChoice(new ChoiceColor());
this.netMana.setAny(1); this.netMana.setAny(1);
} }

View file

@ -37,7 +37,11 @@ import mage.ObjectColor;
public class ChoiceColor extends ChoiceImpl { public class ChoiceColor extends ChoiceImpl {
public ChoiceColor() { public ChoiceColor() {
super(true); this(true);
}
public ChoiceColor(boolean required) {
super(required);
this.choices.add("Black"); this.choices.add("Black");
this.choices.add("Blue"); this.choices.add("Blue");
this.choices.add("Green"); this.choices.add("Green");

View file

@ -853,13 +853,12 @@ public abstract class PlayerImpl implements Player, Serializable {
if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.ACTIVATE_ABILITY, ability.getId(), ability.getSourceId(), playerId))) { if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.ACTIVATE_ABILITY, ability.getId(), ability.getSourceId(), playerId))) {
int bookmark = game.bookmarkState(); int bookmark = game.bookmarkState();
if (ability.activate(game, false)) { if (ability.activate(game, false)) {
ability.resolve(game); if (ability.resolve(game)) {
// #169 if (storedBookmark == -1 || storedBookmark > bookmark) { // e.g. usefull for undo Nykthos, Shrine to Nyx
if (storedBookmark == -1 || storedBookmark > bookmark) { // e.g. userfull for undo Nykthos, Shrine to Nyx setStoredBookmark(bookmark);
setStoredBookmark(bookmark); }
return true;
} }
//game.removeBookmark(bookmark);
return true;
} }
game.restoreState(bookmark); game.restoreState(bookmark);
} }