Some more changes to net mana handling.

This commit is contained in:
LevelX2 2014-11-17 23:44:40 +01:00
parent 1c2233b1f8
commit 036095f6ec
13 changed files with 352 additions and 391 deletions

View file

@ -27,7 +27,6 @@
*/ */
package mage.sets.bornofthegods; package mage.sets.bornofthegods;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import mage.Mana; import mage.Mana;
@ -40,7 +39,6 @@ import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ManaEffect; import mage.abilities.effects.common.ManaEffect;
import mage.abilities.mana.ManaAbility; import mage.abilities.mana.ManaAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.choices.Choice;
import mage.choices.ChoiceColor; import mage.choices.ChoiceColor;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
@ -49,6 +47,7 @@ import mage.constants.Zone;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player;
/** /**
* *
@ -64,11 +63,7 @@ public class AstralCornucopia extends CardImpl {
this.addAbility(new EntersBattlefieldAbility(new AstralCornucopiaEffect(), "with X charge counters on it")); this.addAbility(new EntersBattlefieldAbility(new AstralCornucopiaEffect(), "with X charge counters on it"));
// {T}: Choose a color. Add one mana of that color to your mana pool for each charge counter on Astral Cornucopia. // {T}: Choose a color. Add one mana of that color to your mana pool for each charge counter on Astral Cornucopia.
Ability ability = new AstralCornucopiaManaAbility(); this.addAbility(new AstralCornucopiaManaAbility());
Choice choice = new ChoiceColor();
choice.setMessage("Choose a color to add mana of that color");
ability.addChoice(choice);
this.addAbility(ability);
} }
public AstralCornucopia(final AstralCornucopia card) { public AstralCornucopia(final AstralCornucopia card) {
@ -130,15 +125,18 @@ class AstralCornucopiaManaAbility extends ManaAbility {
@Override @Override
public List<Mana> getNetMana(Game game) { public List<Mana> getNetMana(Game game) {
List<Mana> newNetMana = new ArrayList<>(); netMana.clear();
if (game != null) { Permanent sourcePermanent = game.getPermanent(getSourceId());
newNetMana.add(new Mana(((AstralCornucopiaManaEffect)this.getEffects().get(0)).computeMana(game, this))); if (sourcePermanent != null) {
int counters = sourcePermanent.getCounters().getCount(CounterType.CHARGE.getName());
if (counters > 0) {
netMana.add(new Mana(0,0,0,0,0,0,counters));
}
} }
return newNetMana; return netMana;
} }
} }
class AstralCornucopiaManaEffect extends ManaEffect { class AstralCornucopiaManaEffect extends ManaEffect {
private final Mana computedMana; private final Mana computedMana;
@ -161,32 +159,36 @@ class AstralCornucopiaManaEffect extends ManaEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
computeMana(game, source); Player controller = game.getPlayer(source.getControllerId());
game.getPlayer(source.getControllerId()).getManaPool().addMana(computedMana, game, source); if (controller != null) {
return true; ChoiceColor choice = new ChoiceColor();
} choice.setMessage("Choose a color to add mana of that color");
if (controller.choose(outcome, choice, game)) {
public Mana computeMana(Game game, Ability source){ Permanent sourcePermanent = game.getPermanent(source.getSourceId());
this.computedMana.clear(); if (choice.getChoice() != null) {
if (!source.getChoices().isEmpty()) { String color = choice.getChoice();
Permanent sourcePermanent = game.getPermanent(source.getSourceId()); int counters = sourcePermanent.getCounters().getCount(CounterType.CHARGE.getName());
ChoiceColor choice = (ChoiceColor) source.getChoices().get(0); switch (color) {
if (choice != null && choice instanceof ChoiceColor && choice.getChoice() != null) { case "Red":
String color = choice.getChoice(); computedMana.setRed(counters);
int counters = sourcePermanent.getCounters().getCount(CounterType.CHARGE.getName()); break;
if (color.equals("Red")) { case "Blue":
computedMana.setRed(counters); computedMana.setBlue(counters);
} else if (color.equals("Blue")) { break;
computedMana.setBlue(counters); case "White":
} else if (color.equals("White")) { computedMana.setWhite(counters);
computedMana.setWhite(counters); break;
} else if (color.equals("Black")) { case "Black":
computedMana.setBlack(counters); computedMana.setBlack(counters);
} else if (color.equals("Green")) { break;
computedMana.setGreen(counters); case "Green":
computedMana.setGreen(counters);
break;
}
} }
return true;
} }
} }
return computedMana; return false;
} }
} }

View file

@ -28,10 +28,6 @@
package mage.sets.championsofkamigawa; package mage.sets.championsofkamigawa;
import java.util.UUID; import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.Mana; import mage.Mana;
import mage.abilities.Abilities; import mage.abilities.Abilities;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -41,6 +37,9 @@ import mage.abilities.mana.TriggeredManaAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.choices.Choice; import mage.choices.Choice;
import mage.choices.ChoiceImpl; import mage.choices.ChoiceImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;

View file

@ -27,28 +27,11 @@
*/ */
package mage.sets.conflux; package mage.sets.conflux;
import java.util.List;
import java.util.UUID; import java.util.UUID;
import mage.abilities.mana.AnyColorOpponentLandsProduceManaAbility;
import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.Mana;
import mage.abilities.Abilities;
import mage.abilities.Ability;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.mana.ManaAbility;
import mage.abilities.mana.SimpleManaAbility;
import mage.cards.CardImpl;
import mage.choices.Choice;
import mage.choices.ChoiceImpl;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterLandPermanent;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
/** /**
* *
@ -61,7 +44,7 @@ public class ExoticOrchard extends CardImpl {
this.expansionSetCode = "CON"; this.expansionSetCode = "CON";
// {T}: Add to your mana pool one mana of any color that a land an opponent controls could produce. // {T}: Add to your mana pool one mana of any color that a land an opponent controls could produce.
this.addAbility(new SimpleManaAbility(Zone.BATTLEFIELD, new ExoticOrchardEffect(), new TapSourceCost())); this.addAbility(new AnyColorOpponentLandsProduceManaAbility());
} }
public ExoticOrchard(final ExoticOrchard card) { public ExoticOrchard(final ExoticOrchard card) {
@ -73,89 +56,3 @@ public class ExoticOrchard extends CardImpl {
return new ExoticOrchard(this); return new ExoticOrchard(this);
} }
} }
class ExoticOrchardEffect extends ManaEffect {
private static final FilterPermanent filter = new FilterLandPermanent();
static {
filter.add(new ControllerPredicate(TargetController.OPPONENT));
}
public ExoticOrchardEffect() {
super();
staticText = "Add to your mana pool one mana of any color that a land an opponent controls could produce";
}
public ExoticOrchardEffect(final ExoticOrchardEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
List<Permanent> lands = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game);
Mana types = new Mana();
for (Permanent land : lands) {
Abilities<ManaAbility> mana = land.getAbilities().getManaAbilities(Zone.BATTLEFIELD);
for (ManaAbility ability : mana) {
for (Mana netMana: ability.getNetMana(game)) {
types.add(netMana);
}
}
}
Choice choice = new ChoiceImpl(true);
choice.setMessage("Pick a mana color");
if (types.getBlack() > 0) {
choice.getChoices().add("Black");
}
if (types.getRed() > 0) {
choice.getChoices().add("Red");
}
if (types.getBlue() > 0) {
choice.getChoices().add("Blue");
}
if (types.getGreen() > 0) {
choice.getChoices().add("Green");
}
if (types.getWhite() > 0) {
choice.getChoices().add("White");
}
if (types.getAny() > 0) {
choice.getChoices().add("Black");
choice.getChoices().add("Red");
choice.getChoices().add("Blue");
choice.getChoices().add("Green");
choice.getChoices().add("White");
}
if (choice.getChoices().size() > 0) {
Player player = game.getPlayer(source.getControllerId());
if (choice.getChoices().size() == 1) {
choice.setChoice(choice.getChoices().iterator().next());
} else {
player.choose(outcome, choice, game);
}
switch (choice.getChoice()) {
case "Black":
player.getManaPool().addMana(Mana.BlackMana, game, source);
break;
case "Blue":
player.getManaPool().addMana(Mana.BlueMana, game, source);
break;
case "Red":
player.getManaPool().addMana(Mana.RedMana, game, source);
break;
case "Green":
player.getManaPool().addMana(Mana.GreenMana, game, source);
break;
case "White":
player.getManaPool().addMana(Mana.WhiteMana, game, source);
break;
}
}
return true;
}
@Override
public ExoticOrchardEffect copy() {
return new ExoticOrchardEffect(this);
}
}

View file

@ -164,24 +164,25 @@ class ZhurTaaAncientEffect extends ManaEffect {
} else { } else {
player.choose(outcome, choice, game); player.choose(outcome, choice, game);
} }
if (choice.getChoice().equals("Black")) { switch (choice.getChoice()) {
player.getManaPool().addMana(Mana.BlackMana, game, source); case "Black":
return true; player.getManaPool().addMana(Mana.BlackMana, game, source);
} else if (choice.getChoice().equals("Blue")) { return true;
player.getManaPool().addMana(Mana.BlueMana, game, source); case "Blue":
return true; player.getManaPool().addMana(Mana.BlueMana, game, source);
} else if (choice.getChoice().equals("Red")) { return true;
player.getManaPool().addMana(Mana.RedMana, game, source); case "Red":
return true; player.getManaPool().addMana(Mana.RedMana, game, source);
} else if (choice.getChoice().equals("Green")) { return true;
player.getManaPool().addMana(Mana.GreenMana, game, source); case "Green":
return true; player.getManaPool().addMana(Mana.GreenMana, game, source);
} else if (choice.getChoice().equals("White")) { return true;
player.getManaPool().addMana(Mana.WhiteMana, game, source); case "White":
return true; player.getManaPool().addMana(Mana.WhiteMana, game, source);
} else if (choice.getChoice().equals("Colorless")) { return true;
player.getManaPool().addMana(Mana.ColorlessMana, game, source); case "Colorless":
return true; player.getManaPool().addMana(Mana.ColorlessMana, game, source);
return true;
} }
} }
return true; return true;

View file

@ -27,29 +27,12 @@
*/ */
package mage.sets.fifthdawn; package mage.sets.fifthdawn;
import java.util.List;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.Mana; import mage.abilities.mana.AnyColorOpponentLandsProduceManaAbility;
import mage.abilities.Abilities;
import mage.abilities.Ability;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.mana.ManaAbility;
import mage.abilities.mana.SimpleManaAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.choices.Choice;
import mage.choices.ChoiceImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterLandPermanent;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
/** /**
* *
@ -67,8 +50,8 @@ public class SylvokExplorer extends CardImpl {
this.power = new MageInt(1); this.power = new MageInt(1);
this.toughness = new MageInt(1); this.toughness = new MageInt(1);
// {tap}: Add to your mana pool one mana of any color that a land an opponent controls could produce. // {T}: Add to your mana pool one mana of any color that a land an opponent controls could produce.
this.addAbility(new SimpleManaAbility(Zone.BATTLEFIELD, new SylvokExplorerEffect(), new TapSourceCost())); this.addAbility(new AnyColorOpponentLandsProduceManaAbility());
} }
public SylvokExplorer(final SylvokExplorer card) { public SylvokExplorer(final SylvokExplorer card) {
@ -80,83 +63,3 @@ public class SylvokExplorer extends CardImpl {
return new SylvokExplorer(this); return new SylvokExplorer(this);
} }
} }
class SylvokExplorerEffect extends ManaEffect {
private static final FilterPermanent filter = new FilterLandPermanent();
static {
filter.add(new ControllerPredicate(TargetController.OPPONENT));
}
public SylvokExplorerEffect() {
super();
staticText = "Add to your mana pool one mana of any color that a land an opponent controls could produce";
}
public SylvokExplorerEffect(final SylvokExplorerEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
List<Permanent> lands = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game);
Mana types = new Mana();
for (Permanent land : lands) {
Abilities<ManaAbility> mana = land.getAbilities().getManaAbilities(Zone.BATTLEFIELD);
for (ManaAbility ability : mana) {
for (Mana netMana: ability.getNetMana(game)) {
types.add(netMana);
}
}
}
Choice choice = new ChoiceImpl(true);
choice.setMessage("Pick a mana color");
if (types.getBlack() > 0) {
choice.getChoices().add("Black");
}
if (types.getRed() > 0) {
choice.getChoices().add("Red");
}
if (types.getBlue() > 0) {
choice.getChoices().add("Blue");
}
if (types.getGreen() > 0) {
choice.getChoices().add("Green");
}
if (types.getWhite() > 0) {
choice.getChoices().add("White");
}
if (types.getAny() > 0) {
choice.getChoices().add("Black");
choice.getChoices().add("Red");
choice.getChoices().add("Blue");
choice.getChoices().add("Green");
choice.getChoices().add("White");
}
if (choice.getChoices().size() > 0) {
Player player = game.getPlayer(source.getControllerId());
if (choice.getChoices().size() == 1) {
choice.setChoice(choice.getChoices().iterator().next());
} else {
player.choose(outcome, choice, game);
}
if (choice.getChoice().equals("Black")) {
player.getManaPool().addMana(Mana.BlackMana, game, source);
} else if (choice.getChoice().equals("Blue")) {
player.getManaPool().addMana(Mana.BlueMana, game, source);
} else if (choice.getChoice().equals("Red")) {
player.getManaPool().addMana(Mana.RedMana, game, source);
} else if (choice.getChoice().equals("Green")) {
player.getManaPool().addMana(Mana.GreenMana, game, source);
} else if (choice.getChoice().equals("White")) {
player.getManaPool().addMana(Mana.WhiteMana, game, source);
}
}
return true;
}
@Override
public SylvokExplorerEffect copy() {
return new SylvokExplorerEffect(this);
}
}

View file

@ -28,10 +28,6 @@
package mage.sets.mirage; package mage.sets.mirage;
import java.util.UUID; import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.constants.TimingRule;
import mage.constants.Zone;
import mage.Mana; import mage.Mana;
import mage.abilities.costs.Cost; import mage.abilities.costs.Cost;
import mage.abilities.costs.common.DiscardHandCost; import mage.abilities.costs.common.DiscardHandCost;
@ -40,7 +36,9 @@ import mage.abilities.effects.common.AddManaOfAnyColorEffect;
import mage.abilities.effects.common.BasicManaEffect; import mage.abilities.effects.common.BasicManaEffect;
import mage.abilities.mana.ManaAbility; import mage.abilities.mana.ManaAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.choices.ChoiceColor; import mage.constants.CardType;
import mage.constants.Rarity;
import mage.constants.Zone;
/** /**
* *
@ -72,11 +70,12 @@ 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.netMana.add(new Mana(0,0,0,0,0,0,3));
} }
public LionsEyeDiamondAbility(Zone zone, Mana mana, Cost cost) { public LionsEyeDiamondAbility(Zone zone, Mana mana, Cost cost) {
super(zone, new BasicManaEffect(mana), cost); super(zone, new BasicManaEffect(mana), cost);
this.netMana.add(mana.copy());
} }
public LionsEyeDiamondAbility(final LionsEyeDiamondAbility ability) { public LionsEyeDiamondAbility(final LionsEyeDiamondAbility ability) {

View file

@ -27,28 +27,11 @@
*/ */
package mage.sets.ninthedition; package mage.sets.ninthedition;
import java.util.List;
import java.util.UUID; import java.util.UUID;
import mage.Mana; import mage.abilities.mana.AnyColorOpponentLandsProduceManaAbility;
import mage.abilities.Abilities;
import mage.abilities.Ability;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.mana.ManaAbility;
import mage.abilities.mana.SimpleManaAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.choices.Choice;
import mage.choices.ChoiceImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterLandPermanent;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
/** /**
* *
@ -60,8 +43,8 @@ public class FellwarStone extends CardImpl {
super(ownerId, 297, "Fellwar Stone", Rarity.UNCOMMON, new CardType[]{CardType.ARTIFACT}, "{2}"); super(ownerId, 297, "Fellwar Stone", Rarity.UNCOMMON, new CardType[]{CardType.ARTIFACT}, "{2}");
this.expansionSetCode = "9ED"; this.expansionSetCode = "9ED";
// {tap}: Add to your mana pool one mana of any color that a land an opponent controls could produce. // {T}: Add to your mana pool one mana of any color that a land an opponent controls could produce.
this.addAbility(new SimpleManaAbility(Zone.BATTLEFIELD, new FellwarStoneEffect(), new TapSourceCost())); this.addAbility(new AnyColorOpponentLandsProduceManaAbility());
} }
public FellwarStone(final FellwarStone card) { public FellwarStone(final FellwarStone card) {
@ -73,83 +56,3 @@ public class FellwarStone extends CardImpl {
return new FellwarStone(this); return new FellwarStone(this);
} }
} }
class FellwarStoneEffect extends ManaEffect {
private static final FilterPermanent filter = new FilterLandPermanent();
static {
filter.add(new ControllerPredicate(TargetController.OPPONENT));
}
public FellwarStoneEffect() {
super();
staticText = "Add to your mana pool one mana of any color that a land an opponent controls could produce";
}
public FellwarStoneEffect(final FellwarStoneEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
List<Permanent> lands = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game);
Mana types = new Mana();
for (Permanent land : lands) {
Abilities<ManaAbility> mana = land.getAbilities().getManaAbilities(Zone.BATTLEFIELD);
for (ManaAbility ability : mana) {
for (Mana netMana: ability.getNetMana(game)) {
types.add(netMana);
}
}
}
Choice choice = new ChoiceImpl(true);
choice.setMessage("Pick a mana color");
if (types.getBlack() > 0) {
choice.getChoices().add("Black");
}
if (types.getRed() > 0) {
choice.getChoices().add("Red");
}
if (types.getBlue() > 0) {
choice.getChoices().add("Blue");
}
if (types.getGreen() > 0) {
choice.getChoices().add("Green");
}
if (types.getWhite() > 0) {
choice.getChoices().add("White");
}
if (types.getAny() > 0) {
choice.getChoices().add("Black");
choice.getChoices().add("Red");
choice.getChoices().add("Blue");
choice.getChoices().add("Green");
choice.getChoices().add("White");
}
if (choice.getChoices().size() > 0) {
Player player = game.getPlayer(source.getControllerId());
if (choice.getChoices().size() == 1) {
choice.setChoice(choice.getChoices().iterator().next());
} else {
player.choose(outcome, choice, game);
}
if (choice.getChoice().equals("Black")) {
player.getManaPool().addMana(Mana.BlackMana, game, source);
} else if (choice.getChoice().equals("Blue")) {
player.getManaPool().addMana(Mana.BlueMana, game, source);
} else if (choice.getChoice().equals("Red")) {
player.getManaPool().addMana(Mana.RedMana, game, source);
} else if (choice.getChoice().equals("Green")) {
player.getManaPool().addMana(Mana.GreenMana, game, source);
} else if (choice.getChoice().equals("White")) {
player.getManaPool().addMana(Mana.WhiteMana, game, source);
}
}
return true;
}
@Override
public FellwarStoneEffect copy() {
return new FellwarStoneEffect(this);
}
}

View file

@ -27,21 +27,21 @@
*/ */
package mage.sets.tempest; package mage.sets.tempest;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.Mana; import mage.Mana;
import mage.abilities.Abilities; import mage.abilities.Abilities;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.common.ManaEffect; import mage.abilities.effects.common.ManaEffect;
import mage.abilities.mana.ManaAbility; import mage.abilities.mana.ManaAbility;
import mage.abilities.mana.SimpleManaAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.choices.Choice; import mage.choices.Choice;
import mage.choices.ChoiceImpl; import mage.choices.ChoiceImpl;
import mage.constants.CardType;
import mage.constants.ColoredManaSymbol;
import mage.constants.Rarity;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.common.FilterControlledLandPermanent; import mage.filter.common.FilterControlledLandPermanent;
import mage.filter.common.FilterControlledPermanent; import mage.filter.common.FilterControlledPermanent;
@ -60,7 +60,7 @@ public class ReflectingPool extends CardImpl {
this.expansionSetCode = "TMP"; this.expansionSetCode = "TMP";
// {T}: Add to your mana pool one mana of any type that a land you control could produce. // {T}: Add to your mana pool one mana of any type that a land you control could produce.
this.addAbility(new SimpleManaAbility(Zone.BATTLEFIELD, new ReflectingPoolEffect(), new TapSourceCost())); this.addAbility(new ReflectingPoolManaAbility());
} }
public ReflectingPool(final ReflectingPool card) { public ReflectingPool(final ReflectingPool card) {
@ -73,6 +73,27 @@ public class ReflectingPool extends CardImpl {
} }
} }
class ReflectingPoolManaAbility extends ManaAbility {
public ReflectingPoolManaAbility() {
super(Zone.BATTLEFIELD, new ReflectingPoolEffect(),new TapSourceCost());
}
public ReflectingPoolManaAbility(final ReflectingPoolManaAbility ability) {
super(ability);
}
@Override
public ReflectingPoolManaAbility copy() {
return new ReflectingPoolManaAbility(this);
}
@Override
public List<Mana> getNetMana(Game game) {
return ((ReflectingPoolEffect)getEffects().get(0)).getNetMana(game, this);
}
}
class ReflectingPoolEffect extends ManaEffect { class ReflectingPoolEffect extends ManaEffect {
private static final FilterControlledPermanent filter = new FilterControlledLandPermanent(); private static final FilterControlledPermanent filter = new FilterControlledLandPermanent();
@ -88,16 +109,7 @@ class ReflectingPoolEffect extends ManaEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
List<Permanent> lands = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game); Mana types = getManaTypes(game, source);
Mana types = new Mana();
for (Permanent land : lands) {
Abilities<ManaAbility> mana = land.getAbilities().getManaAbilities(Zone.BATTLEFIELD);
for (ManaAbility ability : mana) {
for (Mana netMana: ability.getNetMana(game)) {
types.add(netMana);
}
}
}
Choice choice = new ChoiceImpl(false); 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) {
@ -161,6 +173,46 @@ class ReflectingPoolEffect extends ManaEffect {
return true; return true;
} }
public List<Mana> getNetMana(Game game, Ability source) {
List<Mana> netManas = new ArrayList<>();
Mana types = getManaTypes(game, source);
if (types.getBlack() > 0) {
netManas.add(new Mana(ColoredManaSymbol.B));
}
if (types.getRed() > 0) {
netManas.add(new Mana(ColoredManaSymbol.R));
}
if (types.getBlue() > 0) {
netManas.add(new Mana(ColoredManaSymbol.U));
}
if (types.getGreen() > 0) {
netManas.add(new Mana(ColoredManaSymbol.G));
}
if (types.getWhite() > 0) {
netManas.add(new Mana(ColoredManaSymbol.W));
}
if (types.getColorless() > 0) {
netManas.add(new Mana(0,0,0,0,0,1,0));
}
return netManas;
}
private Mana getManaTypes(Game game, Ability source) {
List<Permanent> lands = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game);
Mana types = new Mana();
for (Permanent land : lands) {
Abilities<ManaAbility> manaAbilities = land.getAbilities().getManaAbilities(Zone.BATTLEFIELD);
for (ManaAbility ability : manaAbilities) {
if (!ability.equals(source) && ability.definesMana()) {
for (Mana netMana: ability.getNetMana(game)) {
types.add(netMana);
}
}
}
}
return types;
}
@Override @Override
public ReflectingPoolEffect copy() { public ReflectingPoolEffect copy() {
return new ReflectingPoolEffect(this); return new ReflectingPoolEffect(this);

View file

@ -83,6 +83,8 @@ public class PutIntoPlayEffectsTest extends CardTestPlayerBase {
// onto the battlefield under your control. // onto the battlefield under your control.
addCard(Zone.BATTLEFIELD, playerB, "Island", 4); addCard(Zone.BATTLEFIELD, playerB, "Island", 4);
addCard(Zone.BATTLEFIELD, playerB, "Lord of the Void"); addCard(Zone.BATTLEFIELD, playerB, "Lord of the Void");
// Put target creature on top of its owner's library.
addCard(Zone.HAND, playerB, "Griptide"); addCard(Zone.HAND, playerB, "Griptide");
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Griptide", "Oracle of Mul Daya"); castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Griptide", "Oracle of Mul Daya");
@ -96,8 +98,8 @@ public class PutIntoPlayEffectsTest extends CardTestPlayerBase {
assertLife(playerA, 13); assertLife(playerA, 13);
assertPermanentCount(playerB, "Oracle of Mul Daya", 1); assertPermanentCount(playerB, "Oracle of Mul Daya", 1);
Assert.assertTrue("Top card of the library of player B should be reveled.", playerB.isTopCardRevealed()); Assert.assertTrue("Top card of the library of player B should be revealed.", playerB.isTopCardRevealed());
Assert.assertFalse("Top card of the library of player A should not be reveled.", playerA.isTopCardRevealed()); Assert.assertFalse("Top card of the library of player A should not be revealed.", playerA.isTopCardRevealed());
} }
/** /**

View file

@ -0,0 +1,190 @@
/*
* 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 java.util.ArrayList;
import java.util.List;
import mage.Mana;
import mage.abilities.Abilities;
import mage.abilities.Ability;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.common.ManaEffect;
import mage.choices.Choice;
import mage.choices.ChoiceImpl;
import mage.constants.ColoredManaSymbol;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterLandPermanent;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
/**
*
* @author LevelX2
*/
public class AnyColorOpponentLandsProduceManaAbility extends ManaAbility {
public AnyColorOpponentLandsProduceManaAbility() {
super(Zone.BATTLEFIELD, new AnyColorOpponentLandsProduceManaEffect(),new TapSourceCost());
}
public AnyColorOpponentLandsProduceManaAbility(final AnyColorOpponentLandsProduceManaAbility ability) {
super(ability);
}
@Override
public AnyColorOpponentLandsProduceManaAbility copy() {
return new AnyColorOpponentLandsProduceManaAbility(this);
}
@Override
public List<Mana> getNetMana(Game game) {
return ((AnyColorOpponentLandsProduceManaEffect)getEffects().get(0)).getNetMana(game, this);
}
}
class AnyColorOpponentLandsProduceManaEffect extends ManaEffect {
private static final FilterPermanent filter = new FilterLandPermanent();
static {
filter.add(new ControllerPredicate(TargetController.OPPONENT));
}
public AnyColorOpponentLandsProduceManaEffect() {
super();
staticText = "Add to your mana pool one mana of any color that a land an opponent controls could produce";
}
public AnyColorOpponentLandsProduceManaEffect(final AnyColorOpponentLandsProduceManaEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Mana types = getManaTypes(game, source);
Choice choice = new ChoiceImpl(true);
choice.setMessage("Pick a mana color");
if (types.getBlack() > 0) {
choice.getChoices().add("Black");
}
if (types.getRed() > 0) {
choice.getChoices().add("Red");
}
if (types.getBlue() > 0) {
choice.getChoices().add("Blue");
}
if (types.getGreen() > 0) {
choice.getChoices().add("Green");
}
if (types.getWhite() > 0) {
choice.getChoices().add("White");
}
if (types.getAny() > 0) {
choice.getChoices().add("Black");
choice.getChoices().add("Red");
choice.getChoices().add("Blue");
choice.getChoices().add("Green");
choice.getChoices().add("White");
}
if (choice.getChoices().size() > 0) {
Player player = game.getPlayer(source.getControllerId());
if (choice.getChoices().size() == 1) {
choice.setChoice(choice.getChoices().iterator().next());
} else {
player.choose(outcome, choice, game);
}
switch (choice.getChoice()) {
case "Black":
player.getManaPool().addMana(Mana.BlackMana, game, source);
break;
case "Blue":
player.getManaPool().addMana(Mana.BlueMana, game, source);
break;
case "Red":
player.getManaPool().addMana(Mana.RedMana, game, source);
break;
case "Green":
player.getManaPool().addMana(Mana.GreenMana, game, source);
break;
case "White":
player.getManaPool().addMana(Mana.WhiteMana, game, source);
break;
}
}
return true;
}
private Mana getManaTypes(Game game, Ability source) {
List<Permanent> lands = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game);
Mana types = new Mana();
for (Permanent land : lands) {
Abilities<ManaAbility> mana = land.getAbilities().getManaAbilities(Zone.BATTLEFIELD);
for (ManaAbility ability : mana) {
if (!ability.equals(source) && ability.definesMana()) {
for (Mana netMana: ability.getNetMana(game)) {
types.add(netMana);
}
}
}
}
return types;
}
public List<Mana> getNetMana(Game game, Ability source) {
List<Mana> netManas = new ArrayList<>();
Mana types = getManaTypes(game, source);
if (types.getBlack() > 0) {
netManas.add(new Mana(ColoredManaSymbol.B));
}
if (types.getRed() > 0) {
netManas.add(new Mana(ColoredManaSymbol.R));
}
if (types.getBlue() > 0) {
netManas.add(new Mana(ColoredManaSymbol.U));
}
if (types.getGreen() > 0) {
netManas.add(new Mana(ColoredManaSymbol.G));
}
if (types.getWhite() > 0) {
netManas.add(new Mana(ColoredManaSymbol.W));
}
if (types.getColorless() > 0) {
netManas.add(new Mana(0,0,0,0,0,1,0));
}
return netManas;
}
@Override
public AnyColorOpponentLandsProduceManaEffect copy() {
return new AnyColorOpponentLandsProduceManaEffect(this);
}
}

View file

@ -82,4 +82,14 @@ public abstract class ManaAbility extends ActivatedAbilityImpl {
public List<Mana> getNetMana(Game game) { public List<Mana> getNetMana(Game game) {
return netMana; return netMana;
} }
/**
* Used to check if the ability itself defines mana types
* it can produce.
*
* @return
*/
public boolean definesMana() {
return netMana.size() > 0;
}
} }

View file

@ -28,11 +28,13 @@
package mage.abilities.mana; package mage.abilities.mana;
import java.util.List;
import mage.constants.Zone; import mage.constants.Zone;
import mage.Mana; import mage.Mana;
import mage.abilities.costs.Cost; import mage.abilities.costs.Cost;
import mage.abilities.effects.common.BasicManaEffect; import mage.abilities.effects.common.BasicManaEffect;
import mage.abilities.effects.common.ManaEffect; import mage.abilities.effects.common.ManaEffect;
import mage.game.Game;
/** /**
* *

View file

@ -27,9 +27,9 @@
*/ */
package mage.abilities.mana; package mage.abilities.mana;
import mage.constants.Zone;
import mage.abilities.TriggeredAbilityImpl; import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.common.ManaEffect; import mage.abilities.effects.common.ManaEffect;
import mage.constants.Zone;
/** /**
* see 20110715 - 605.1b * see 20110715 - 605.1b
@ -43,6 +43,7 @@ public abstract class TriggeredManaAbility extends TriggeredAbilityImpl {
public TriggeredManaAbility(Zone zone, ManaEffect effect, boolean optional) { public TriggeredManaAbility(Zone zone, ManaEffect effect, boolean optional) {
super(zone, effect, optional); super(zone, effect, optional);
this.usesStack = false;
} }
public TriggeredManaAbility(final TriggeredManaAbility ability) { public TriggeredManaAbility(final TriggeredManaAbility ability) {