* River of Tears, Gemstone Cavern - Fixed that this acrds did not work with Refelecting Pool.

This commit is contained in:
LevelX2 2014-09-06 16:18:07 +02:00
parent 8d7e9f6cb6
commit 1db5df220c
5 changed files with 116 additions and 36 deletions

View file

@ -36,7 +36,7 @@ import mage.abilities.condition.common.LandfallCondition;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.decorator.ConditionalManaEffect;
import mage.abilities.effects.common.BasicManaEffect;
import mage.abilities.mana.SimpleManaAbility;
import mage.abilities.mana.ConditionalManaAbility;
import mage.cards.CardImpl;
import mage.watchers.common.LandfallWatcher;
@ -51,7 +51,7 @@ public class RiverOfTears extends CardImpl {
this.expansionSetCode = "FUT";
// {tap}: Add {U} to your mana pool. If you played a land this turn, add {B} to your mana pool instead.
this.addAbility(new SimpleManaAbility(Zone.BATTLEFIELD, new ConditionalManaEffect(
this.addAbility(new ConditionalManaAbility(Zone.BATTLEFIELD, new ConditionalManaEffect(
new BasicManaEffect(Mana.BlackMana),
new BasicManaEffect(Mana.BlueMana),
LandfallCondition.getInstance(),

View file

@ -36,6 +36,7 @@ import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.decorator.ConditionalManaEffect;
import mage.abilities.effects.common.AddManaOfAnyColorEffect;
import mage.abilities.effects.common.BasicManaEffect;
import mage.abilities.mana.ConditionalManaAbility;
import mage.abilities.mana.SimpleManaAbility;
import mage.cards.CardImpl;
import mage.choices.ChoiceColor;
@ -59,14 +60,13 @@ public class GemstoneCaverns extends CardImpl {
this.addAbility(new GemstoneCavernsAbility());
// {tap}: Add {1} to your mana pool. If Gemstone Caverns has a luck counter on it, instead add one mana of any color to your mana pool.
Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD,
Ability ability = new ConditionalManaAbility(Zone.BATTLEFIELD,
new ConditionalManaEffect(
new AddManaOfAnyColorEffect(),
new BasicManaEffect(Mana.ColorlessMana),
new SourceHasCounterCondition(CounterType.LUCK),
"Add {1} to your mana pool. If Gemstone Caverns has a luck counter on it, instead add one mana of any color to your mana pool."),
new TapSourceCost());
ability.addChoice(new ChoiceColor());
"Add {1} to your mana pool. If {this} has a luck counter on it, instead add one mana of any color to your mana pool."),
new TapSourceCost());
this.addAbility(ability);
}

View file

@ -28,8 +28,10 @@
package mage.abilities.decorator;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.abilities.effects.common.BasicManaEffect;
import mage.abilities.effects.common.ManaEffect;
import mage.game.Game;
@ -41,15 +43,15 @@ import mage.game.Game;
public class ConditionalManaEffect extends ManaEffect {
private ManaEffect effect;
private ManaEffect otherwiseEffect;
private BasicManaEffect effect;
private BasicManaEffect otherwiseEffect;
private Condition condition;
public ConditionalManaEffect(ManaEffect effect, Condition condition, String text) {
public ConditionalManaEffect(BasicManaEffect effect, Condition condition, String text) {
this(effect, null, condition, text);
}
public ConditionalManaEffect(ManaEffect effect, ManaEffect otherwiseEffect, Condition condition, String text) {
public ConditionalManaEffect(BasicManaEffect effect, BasicManaEffect otherwiseEffect, Condition condition, String text) {
super();
this.effect = effect;
this.otherwiseEffect = otherwiseEffect;
@ -59,9 +61,9 @@ public class ConditionalManaEffect extends ManaEffect {
public ConditionalManaEffect(ConditionalManaEffect effect) {
super(effect);
this.effect = (ManaEffect) effect.effect.copy();
this.effect = (BasicManaEffect) effect.effect.copy();
if (effect.otherwiseEffect != null) {
this.otherwiseEffect = (ManaEffect) effect.otherwiseEffect.copy();
this.otherwiseEffect = (BasicManaEffect) effect.otherwiseEffect.copy();
}
this.condition = effect.condition;
}
@ -83,4 +85,12 @@ public class ConditionalManaEffect extends ManaEffect {
return new ConditionalManaEffect(this);
}
public Mana getMana(Game game, Ability source) {
if (condition.apply(game, source)) {
return effect.getMana();
} else if (otherwiseEffect != null) {
return otherwiseEffect.getMana();
}
return null;
}
}

View file

@ -37,7 +37,7 @@ import mage.util.CardUtil;
/**
* @author BetaSteward_at_googlemail.com
*/
public class AddManaOfAnyColorEffect extends ManaEffect {
public class AddManaOfAnyColorEffect extends BasicManaEffect {
protected int amount;
@ -46,7 +46,7 @@ public class AddManaOfAnyColorEffect extends ManaEffect {
}
public AddManaOfAnyColorEffect(final int amount) {
super();
super(new Mana(0,0,0,0,0,0,1));
this.amount = amount;
this.staticText = new StringBuilder("add ")
.append(CardUtil.numberToText(amount))
@ -67,34 +67,39 @@ public class AddManaOfAnyColorEffect extends ManaEffect {
@Override
public boolean apply(Game game, Ability source) {
ChoiceColor choice = (ChoiceColor) source.getChoices().get(0);
if (choice == null || choice.getColor() == null) {
return false;
}
Mana mana = null;
if (choice.getColor().isBlack()) {
mana = Mana.BlackMana(amount);
} else if (choice.getColor().isBlue()) {
mana = Mana.BlueMana(amount);
} else if (choice.getColor().isRed()) {
mana = Mana.RedMana(amount);
} else if (choice.getColor().isGreen()) {
mana = Mana.GreenMana(amount);
} else if (choice.getColor().isWhite()) {
mana = Mana.WhiteMana(amount);
}
Player player = game.getPlayer(source.getControllerId());
if (player != null && mana != null) {
player.getManaPool().addMana(mana, game, source);
return true;
}
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
ChoiceColor choice = new ChoiceColor(false);
if (controller.choose(outcome, choice, game)) {
Mana createdMana = null;
if (choice.getColor().isBlack()) {
createdMana = Mana.BlackMana(amount);
} else if (choice.getColor().isBlue()) {
createdMana = Mana.BlueMana(amount);
} else if (choice.getColor().isRed()) {
createdMana = Mana.RedMana(amount);
} else if (choice.getColor().isGreen()) {
createdMana = Mana.GreenMana(amount);
} else if (choice.getColor().isWhite()) {
createdMana = Mana.WhiteMana(amount);
}
if (createdMana != null) {
controller.getManaPool().addMana(createdMana, game, source);
}
return true;
}
}
return false;
}
public int getAmount() {
return amount;
}
@Override
public Mana getMana() {
return (new Mana(0,0,0,0,0,0,amount));
}
}

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.abilities.mana;
import mage.Mana;
import mage.abilities.costs.Cost;
import mage.abilities.decorator.ConditionalManaEffect;
import mage.constants.Zone;
import mage.game.Game;
/**
*
* @author LevelX2
*/
public class ConditionalManaAbility extends ManaAbility {
ConditionalManaEffect conditionalManaEffect;
public ConditionalManaAbility(Zone zone, ConditionalManaEffect effect, Cost cost) {
super(zone, effect, cost);
this.conditionalManaEffect = effect;
}
public ConditionalManaAbility(final ConditionalManaAbility ability) {
super(ability);
this.conditionalManaEffect = ability.conditionalManaEffect;
}
@Override
public ConditionalManaAbility copy() {
return new ConditionalManaAbility(this);
}
@Override
public Mana getNetMana(Game game) {
return conditionalManaEffect.getMana(game, this);
}
}