* Reworked TAPPED_FOR_MANA event handling to include the produced mana in the event.

This commit is contained in:
LevelX2 2014-12-05 20:16:42 +01:00
parent d26c1000f2
commit fd6e51b4f9
67 changed files with 490 additions and 1562 deletions

View file

@ -31,6 +31,7 @@ import java.util.UUID;
import mage.Mana; import mage.Mana;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.AddManaAnyColorAttachedControllerEffect;
import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.ManaEffect; import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.common.continious.GainAbilityAttachedEffect; import mage.abilities.effects.common.continious.GainAbilityAttachedEffect;
@ -96,7 +97,7 @@ public class TraceOfAbundance extends CardImpl {
class TraceOfAbundanceTriggeredAbility extends TriggeredManaAbility { class TraceOfAbundanceTriggeredAbility extends TriggeredManaAbility {
public TraceOfAbundanceTriggeredAbility() { public TraceOfAbundanceTriggeredAbility() {
super(Zone.BATTLEFIELD, new TraceOfAbundanceEffect()); super(Zone.BATTLEFIELD, new AddManaAnyColorAttachedControllerEffect());
} }
public TraceOfAbundanceTriggeredAbility(final TraceOfAbundanceTriggeredAbility ability) { public TraceOfAbundanceTriggeredAbility(final TraceOfAbundanceTriggeredAbility ability) {
@ -124,57 +125,3 @@ class TraceOfAbundanceTriggeredAbility extends TriggeredManaAbility {
return "Whenever enchanted land is tapped for mana, its controller adds one mana of any color to his or her mana pool."; return "Whenever enchanted land is tapped for mana, its controller adds one mana of any color to his or her mana pool.";
} }
} }
class TraceOfAbundanceEffect extends ManaEffect {
public TraceOfAbundanceEffect() {
super();
staticText = "its controller adds one mana of any color to his or her mana pool";
}
public TraceOfAbundanceEffect(final TraceOfAbundanceEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent enchantment = game.getPermanent(source.getSourceId());
if (enchantment != null) {
Permanent land = game.getPermanent(enchantment.getAttachedTo());
if (land != null) {
Player player = game.getPlayer(land.getControllerId());
if (player != null) {
ChoiceColor choice = new ChoiceColor();
while (!player.choose(outcome, choice, game)) {
if (!player.isInGame()) {
return false;
}
}
int amount = 1;
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);
}
if (player != null && mana != null) {
player.getManaPool().addMana(mana, game, source);
return true;
}
}
}
}
return false;
}
@Override
public TraceOfAbundanceEffect copy() {
return new TraceOfAbundanceEffect(this);
}
}

View file

@ -33,7 +33,7 @@ import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl; import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.common.AddManaToManaPoolEffect; import mage.abilities.effects.common.AddManaToManaPoolTargetControllerEffect;
import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.continious.GainAbilityAttachedEffect; import mage.abilities.effects.common.continious.GainAbilityAttachedEffect;
import mage.abilities.keyword.EnchantAbility; import mage.abilities.keyword.EnchantAbility;
@ -108,7 +108,7 @@ class MarkOfSakikoTriggeredAbility extends TriggeredAbilityImpl {
if (((DamagedPlayerEvent) event).isCombatDamage()) { if (((DamagedPlayerEvent) event).isCombatDamage()) {
if (event.getSourceId().equals(getSourceId())) { if (event.getSourceId().equals(getSourceId())) {
this.getEffects().clear(); this.getEffects().clear();
Effect effect = new AddManaToManaPoolEffect(new Mana(0,event.getAmount(),0,0,0,0,0), "that player", true); Effect effect = new AddManaToManaPoolTargetControllerEffect(new Mana(0,event.getAmount(),0,0,0,0,0), "that player", true);
effect.setTargetPointer(new FixedTarget(getControllerId())); effect.setTargetPointer(new FixedTarget(getControllerId()));
effect.setText("add that much {G} to your mana pool. Until end of turn, this mana doesn't empty from your mana pool as steps and phases end"); effect.setText("add that much {G} to your mana pool. Until end of turn, this mana doesn't empty from your mana pool as steps and phases end");
this.addEffect(effect); this.addEffect(effect);

View file

@ -141,9 +141,16 @@ public class PetalmaneBaku extends CardImpl {
return false; return false;
} }
@Override
public Mana getMana(Game game, Ability source) {
return null;
}
@Override @Override
public PetalmaneBakuManaEffect copy() { public PetalmaneBakuManaEffect copy() {
return new PetalmaneBakuManaEffect(this); return new PetalmaneBakuManaEffect(this);
} }
} }
} }

View file

@ -32,7 +32,7 @@ import mage.MageInt;
import mage.Mana; import mage.Mana;
import mage.abilities.TriggeredAbilityImpl; import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.common.AddManaToManaPoolEffect; import mage.abilities.effects.common.AddManaToManaPoolTargetControllerEffect;
import mage.abilities.effects.common.counter.AddCountersTargetEffect; import mage.abilities.effects.common.counter.AddCountersTargetEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
@ -99,7 +99,7 @@ class SakikoMotherOfSummerTriggeredAbility extends TriggeredAbilityImpl {
Permanent creature = game.getPermanent(event.getSourceId()); Permanent creature = game.getPermanent(event.getSourceId());
if (creature != null && creature.getControllerId().equals(controllerId)) { if (creature != null && creature.getControllerId().equals(controllerId)) {
this.getEffects().clear(); this.getEffects().clear();
Effect effect = new AddManaToManaPoolEffect(new Mana(0,event.getAmount(),0,0,0,0,0), "that player", true); Effect effect = new AddManaToManaPoolTargetControllerEffect(new Mana(0,event.getAmount(),0,0,0,0,0), "that player", true);
effect.setTargetPointer(new FixedTarget(creature.getControllerId())); effect.setTargetPointer(new FixedTarget(creature.getControllerId()));
effect.setText("add that much {G} to your mana pool. Until end of turn, this mana doesn't empty from your mana pool as steps and phases end"); effect.setText("add that much {G} to your mana pool. Until end of turn, this mana doesn't empty from your mana pool as steps and phases end");
this.addEffect(effect); this.addEffect(effect);

View file

@ -32,7 +32,7 @@ import mage.MageInt;
import mage.Mana; import mage.Mana;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.common.AddManaToManaPoolEffect; import mage.abilities.effects.common.AddManaToManaPoolTargetControllerEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Rarity; import mage.constants.Rarity;
@ -56,7 +56,7 @@ public class SakuraTribeSpringcaller extends CardImpl {
this.toughness = new MageInt(4); this.toughness = new MageInt(4);
// At the beginning of your upkeep, add {G} to your mana pool. Until end of turn, this mana doesn't empty from your mana pool as steps and phases end. // At the beginning of your upkeep, add {G} to your mana pool. Until end of turn, this mana doesn't empty from your mana pool as steps and phases end.
Effect effect = new AddManaToManaPoolEffect(new Mana(Mana.GreenMana), "your", true); Effect effect = new AddManaToManaPoolTargetControllerEffect(new Mana(Mana.GreenMana), "your", true);
effect.setText("add {G} to your mana pool. Until end of turn, this mana doesn't empty from your mana pool as steps and phases end"); effect.setText("add {G} to your mana pool. Until end of turn, this mana doesn't empty from your mana pool as steps and phases end");
this.addAbility(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, effect, TargetController.YOU, false)); this.addAbility(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, effect, TargetController.YOU, false));
} }

View file

@ -32,7 +32,7 @@ import mage.MageInt;
import mage.Mana; import mage.Mana;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.common.AddManaToManaPoolEffect; import mage.abilities.effects.common.AddManaToManaPoolTargetControllerEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Rarity; import mage.constants.Rarity;
@ -57,7 +57,7 @@ public class ShizukoCallerOfAutumn extends CardImpl {
this.toughness = new MageInt(3); this.toughness = new MageInt(3);
// At the beginning of each player's upkeep, that player adds {G}{G}{G} to his or her mana pool. Until end of turn, this mana doesn't empty from that player's mana pool as steps and phases end. // At the beginning of each player's upkeep, that player adds {G}{G}{G} to his or her mana pool. Until end of turn, this mana doesn't empty from that player's mana pool as steps and phases end.
Effect effect = new AddManaToManaPoolEffect(new Mana(0,3,0,0,0,0,0), "that player", true); Effect effect = new AddManaToManaPoolTargetControllerEffect(new Mana(0,3,0,0,0,0,0), "that player", true);
effect.setText("that player adds {G}{G}{G} to his or her mana pool. Until end of turn, this mana doesn't empty from that player's mana pool as steps and phases end"); effect.setText("that player adds {G}{G}{G} to his or her mana pool. Until end of turn, this mana doesn't empty from that player's mana pool as steps and phases end");
this.addAbility(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, effect, TargetController.ANY, false)); this.addAbility(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, effect, TargetController.ANY, false));

View file

@ -186,10 +186,17 @@ class AstralCornucopiaManaEffect extends ManaEffect {
break; break;
} }
} }
game.getPlayer(source.getControllerId()).getManaPool().addMana(computedMana, game, source); checkToFirePossibleEvents(computedMana, game, source);
controller.getManaPool().addMana(computedMana, game, source);
return true; return true;
} }
} }
return false; return false;
} }
@Override
public Mana getMana(Game game, Ability source) {
return null;
}
} }

View file

@ -28,23 +28,13 @@
package mage.sets.championsofkamigawa; package mage.sets.championsofkamigawa;
import java.util.UUID; import java.util.UUID;
import mage.Mana; import mage.abilities.common.TapForManaAllTriggeredManaAbility;
import mage.abilities.Abilities; import mage.abilities.effects.common.AddManaOfAnyColorTargetCanProduceEffect;
import mage.abilities.Ability;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.mana.ManaAbility;
import mage.abilities.mana.TriggeredManaAbility;
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.Zone; import mage.constants.SetTargetPointer;
import mage.game.Game; import mage.filter.common.FilterLandPermanent;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
/** /**
* *
@ -56,8 +46,12 @@ public class HeartbeatOfSpring extends CardImpl {
super(ownerId, 212, "Heartbeat of Spring", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{2}{G}"); super(ownerId, 212, "Heartbeat of Spring", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{2}{G}");
this.expansionSetCode = "CHK"; this.expansionSetCode = "CHK";
this.color.setGreen(true); this.color.setGreen(true);
// Whenever a player taps a land for mana, that player adds one mana to his or her mana pool of any type that land produced. // Whenever a player taps a land for mana, that player adds one mana to his or her mana pool of any type that land produced.
this.addAbility(new HeartbeatOfSpringAbility()); this.addAbility(new TapForManaAllTriggeredManaAbility(
new AddManaOfAnyColorTargetCanProduceEffect(),
new FilterLandPermanent("a player taps a land"),
SetTargetPointer.PERMANENT));
} }
public HeartbeatOfSpring(final HeartbeatOfSpring card) { public HeartbeatOfSpring(final HeartbeatOfSpring card) {
@ -69,122 +63,3 @@ public class HeartbeatOfSpring extends CardImpl {
return new HeartbeatOfSpring(this); return new HeartbeatOfSpring(this);
} }
} }
class HeartbeatOfSpringAbility extends TriggeredManaAbility {
private static final String staticText = "Whenever a player taps a land for mana, that player adds one mana to his or her mana pool of any type that land produced.";
public HeartbeatOfSpringAbility() {
super(Zone.BATTLEFIELD, new HeartbeatOfSpringEffect());
}
public HeartbeatOfSpringAbility(HeartbeatOfSpringAbility ability) {
super(ability);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.TAPPED_FOR_MANA) {
Permanent permanent = game.getPermanent(event.getSourceId());
if (permanent == null) {
permanent = (Permanent) game.getLastKnownInformation(event.getSourceId(), Zone.BATTLEFIELD);
}
if (permanent != null && permanent.getCardType().contains(CardType.LAND)) {
getEffects().get(0).setTargetPointer(new FixedTarget(permanent.getId()));
return true;
}
}
return false;
}
@Override
public HeartbeatOfSpringAbility copy() {
return new HeartbeatOfSpringAbility(this);
}
@Override
public String getRule() {
return staticText;
}
}
class HeartbeatOfSpringEffect extends ManaEffect {
public HeartbeatOfSpringEffect() {
super();
staticText = "that player adds one mana to his or her mana pool of any type that land produced";
}
public HeartbeatOfSpringEffect(final HeartbeatOfSpringEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent land = game.getPermanent(this.targetPointer.getFirst(game, source));
if (land != null) {
Abilities<ManaAbility> mana = land.getAbilities().getManaAbilities(Zone.BATTLEFIELD);
Mana types = new Mana();
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.getColorless() > 0) {
choice.getChoices().add("Colorless");
}
if (choice.getChoices().size() > 0) {
Player player = game.getPlayer(land.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);
return true;
case "Blue":
player.getManaPool().addMana(Mana.BlueMana, game, source);
return true;
case "Red":
player.getManaPool().addMana(Mana.RedMana, game, source);
return true;
case "Green":
player.getManaPool().addMana(Mana.GreenMana, game, source);
return true;
case "White":
player.getManaPool().addMana(Mana.WhiteMana, game, source);
return true;
case "Colorless":
player.getManaPool().addMana(Mana.ColorlessMana, game, source);
return true;
}
}
return true;
}
return false;
}
@Override
public HeartbeatOfSpringEffect copy() {
return new HeartbeatOfSpringEffect(this);
}
}

View file

@ -39,6 +39,7 @@ import mage.abilities.effects.common.ManaEffect;
import mage.abilities.mana.SimpleManaAbility; import mage.abilities.mana.SimpleManaAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.ColoredManaSymbol;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.Zone; import mage.constants.Zone;
@ -89,27 +90,19 @@ class ColdsteelHeartManaEffect extends ManaEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
if (player != null) { if (player != null) {
ObjectColor color = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color"); player.getManaPool().addMana(getMana(game, source), game, source);
switch(color.toString()) {
case "W":
player.getManaPool().addMana(Mana.WhiteMana, game, source);
break;
case "B":
player.getManaPool().addMana(Mana.BlackMana, game, source);
break;
case "U":
player.getManaPool().addMana(Mana.BlueMana, game, source);
break;
case "G":
player.getManaPool().addMana(Mana.GreenMana, game, source);
break;
case "R":
player.getManaPool().addMana(Mana.RedMana, game, source);
break;
} }
return true; return true;
} }
return false;
@Override
public Mana getMana(Game game, Ability source) {
ObjectColor color = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color");
if (color != null) {
return new Mana(ColoredManaSymbol.lookup(color.toString().charAt(0)));
} else {
return null;
}
} }
@Override @Override

View file

@ -100,4 +100,10 @@ class RiteOfFlameManaEffect extends ManaEffect {
public RiteOfFlameManaEffect copy() { public RiteOfFlameManaEffect copy() {
return new RiteOfFlameManaEffect(this); return new RiteOfFlameManaEffect(this);
} }
@Override
public Mana getMana(Game game, Ability source) {
return null;
}
} }

View file

@ -34,7 +34,7 @@ import mage.abilities.costs.common.RemoveVariableCountersSourceCost;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.dynamicvalue.common.RemovedCountersForCostValue; import mage.abilities.dynamicvalue.common.RemovedCountersForCostValue;
import mage.abilities.effects.common.ManaInAnyCombinationEffect; import mage.abilities.effects.common.AddManaInAnyCombinationEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.mana.ColorlessManaAbility; import mage.abilities.mana.ColorlessManaAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -62,7 +62,7 @@ public class DreadshipReef extends CardImpl {
this.addAbility(ability); this.addAbility(ability);
// {1}, Remove X storage counters from Dreadship Reef: Add X mana in any combination of {U} and/or {B} to your mana pool. // {1}, Remove X storage counters from Dreadship Reef: Add X mana in any combination of {U} and/or {B} to your mana pool.
ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, ability = new SimpleActivatedAbility(Zone.BATTLEFIELD,
new ManaInAnyCombinationEffect(new RemovedCountersForCostValue(), ColoredManaSymbol.U, ColoredManaSymbol.B), new AddManaInAnyCombinationEffect(new RemovedCountersForCostValue(), ColoredManaSymbol.U, ColoredManaSymbol.B),
new GenericManaCost(1)); new GenericManaCost(1));
ability.addCost(new RemoveVariableCountersSourceCost(CounterType.STORAGE.createInstance())); ability.addCost(new RemoveVariableCountersSourceCost(CounterType.STORAGE.createInstance()));
this.addAbility(ability); this.addAbility(ability);

View file

@ -34,7 +34,7 @@ import mage.abilities.costs.common.RemoveVariableCountersSourceCost;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.dynamicvalue.common.RemovedCountersForCostValue; import mage.abilities.dynamicvalue.common.RemovedCountersForCostValue;
import mage.abilities.effects.common.ManaInAnyCombinationEffect; import mage.abilities.effects.common.AddManaInAnyCombinationEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.mana.ColorlessManaAbility; import mage.abilities.mana.ColorlessManaAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -64,7 +64,7 @@ public class FungalReaches extends CardImpl {
// {1}, Remove X storage counters from Fungal Reaches: Add X mana in any combination of {R} and/or {G} to your mana pool. // {1}, Remove X storage counters from Fungal Reaches: Add X mana in any combination of {R} and/or {G} to your mana pool.
ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, ability = new SimpleActivatedAbility(Zone.BATTLEFIELD,
new ManaInAnyCombinationEffect(new RemovedCountersForCostValue(), ColoredManaSymbol.R, ColoredManaSymbol.G), new AddManaInAnyCombinationEffect(new RemovedCountersForCostValue(), ColoredManaSymbol.R, ColoredManaSymbol.G),
new GenericManaCost(1)); new GenericManaCost(1));
ability.addCost(new RemoveVariableCountersSourceCost(CounterType.STORAGE.createInstance())); ability.addCost(new RemoveVariableCountersSourceCost(CounterType.STORAGE.createInstance()));
this.addAbility(ability); this.addAbility(ability);

View file

@ -31,7 +31,7 @@ import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import static mage.Mana.GreenMana; import static mage.Mana.GreenMana;
import mage.abilities.common.BeginningOfPreCombatMainTriggeredAbility; import mage.abilities.common.BeginningOfPreCombatMainTriggeredAbility;
import mage.abilities.effects.common.AddManaToManaPoolEffect; import mage.abilities.effects.common.AddManaToManaPoolTargetControllerEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Rarity; import mage.constants.Rarity;
@ -56,7 +56,7 @@ public class MagusOfTheVineyard extends CardImpl {
// At the beginning of each player's precombat main phase, add {G}{G} to that player's mana pool. // At the beginning of each player's precombat main phase, add {G}{G} to that player's mana pool.
this.addAbility(new BeginningOfPreCombatMainTriggeredAbility( this.addAbility(new BeginningOfPreCombatMainTriggeredAbility(
Zone.BATTLEFIELD, new AddManaToManaPoolEffect(GreenMana(2), "that player's"), TargetController.ANY, false, true)); Zone.BATTLEFIELD, new AddManaToManaPoolTargetControllerEffect(GreenMana(2), "that player's"), TargetController.ANY, false, true));
} }
public MagusOfTheVineyard(final MagusOfTheVineyard card) { public MagusOfTheVineyard(final MagusOfTheVineyard card) {

View file

@ -33,7 +33,8 @@ import mage.abilities.Ability;
import mage.abilities.common.delayed.AtTheBeginOMainPhaseDelayedTriggeredAbility; import mage.abilities.common.delayed.AtTheBeginOMainPhaseDelayedTriggeredAbility;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.AddManaToManaPoolEffect; import mage.abilities.effects.common.AddManaToManaPoolSourceControllerEffect;
import mage.abilities.effects.common.AddManaToManaPoolTargetControllerEffect;
import mage.abilities.effects.common.ClashEffect; import mage.abilities.effects.common.ClashEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
@ -97,8 +98,7 @@ class ScatteringStrokeEffect extends OneShotEffect {
if (controller != null && spell != null) { if (controller != null && spell != null) {
game.getStack().counter(spell.getId(), source.getSourceId(), game); game.getStack().counter(spell.getId(), source.getSourceId(), game);
if (ClashEffect.getInstance().apply(game, source)) { if (ClashEffect.getInstance().apply(game, source)) {
Effect effect = new AddManaToManaPoolEffect(new Mana(0,0,0,0,0,spell.getConvertedManaCost(),0), "your"); Effect effect = new AddManaToManaPoolSourceControllerEffect(new Mana(0,0,0,0,0,spell.getConvertedManaCost(),0));
effect.setTargetPointer(new FixedTarget(source.getControllerId()));
AtTheBeginOMainPhaseDelayedTriggeredAbility delayedAbility = AtTheBeginOMainPhaseDelayedTriggeredAbility delayedAbility =
new AtTheBeginOMainPhaseDelayedTriggeredAbility(effect, true, TargetController.YOU, AtTheBeginOMainPhaseDelayedTriggeredAbility.PhaseSelection.NEXT_MAIN); new AtTheBeginOMainPhaseDelayedTriggeredAbility(effect, true, TargetController.YOU, AtTheBeginOMainPhaseDelayedTriggeredAbility.PhaseSelection.NEXT_MAIN);
delayedAbility.setSourceId(source.getSourceId()); delayedAbility.setSourceId(source.getSourceId());

View file

@ -34,7 +34,7 @@ import mage.abilities.costs.common.RemoveVariableCountersSourceCost;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.dynamicvalue.common.RemovedCountersForCostValue; import mage.abilities.dynamicvalue.common.RemovedCountersForCostValue;
import mage.abilities.effects.common.ManaInAnyCombinationEffect; import mage.abilities.effects.common.AddManaInAnyCombinationEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.mana.ColorlessManaAbility; import mage.abilities.mana.ColorlessManaAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -62,7 +62,7 @@ public class MoltenSlagheap extends CardImpl {
this.addAbility(ability); this.addAbility(ability);
// {1}, Remove X storage counters from Molten Slagheap: Add X mana in any combination of {B} and/or {R} to your mana pool. // {1}, Remove X storage counters from Molten Slagheap: Add X mana in any combination of {B} and/or {R} to your mana pool.
ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, ability = new SimpleActivatedAbility(Zone.BATTLEFIELD,
new ManaInAnyCombinationEffect(new RemovedCountersForCostValue(), ColoredManaSymbol.B, ColoredManaSymbol.R), new AddManaInAnyCombinationEffect(new RemovedCountersForCostValue(), ColoredManaSymbol.B, ColoredManaSymbol.R),
new GenericManaCost(1)); new GenericManaCost(1));
ability.addCost(new RemoveVariableCountersSourceCost(CounterType.STORAGE.createInstance())); ability.addCost(new RemoveVariableCountersSourceCost(CounterType.STORAGE.createInstance()));
this.addAbility(ability); this.addAbility(ability);

View file

@ -152,6 +152,7 @@ class OpalPalaceManaEffect extends ManaEffect {
} }
// set to indicate, that the mana can boost the commander // set to indicate, that the mana can boost the commander
mana.setFlag(true); mana.setFlag(true);
checkToFirePossibleEvents(mana, game, source);
controller.getManaPool().addMana(mana, game, source); controller.getManaPool().addMana(mana, game, source);
} }
@ -160,6 +161,13 @@ class OpalPalaceManaEffect extends ManaEffect {
} }
return false; return false;
} }
@Override
public Mana getMana(Game game, Ability source) {
return null;
}
} }
class OpalPalaceWatcher extends Watcher { class OpalPalaceWatcher extends Watcher {

View file

@ -34,7 +34,7 @@ import mage.abilities.costs.common.RemoveVariableCountersSourceCost;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.dynamicvalue.common.RemovedCountersForCostValue; import mage.abilities.dynamicvalue.common.RemovedCountersForCostValue;
import mage.abilities.effects.common.ManaInAnyCombinationEffect; import mage.abilities.effects.common.AddManaInAnyCombinationEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.mana.ColorlessManaAbility; import mage.abilities.mana.ColorlessManaAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -62,7 +62,7 @@ public class SaltcrustedSteppe extends CardImpl {
this.addAbility(ability); this.addAbility(ability);
// {1}, Remove X storage counters from Saltcrusted Steppe: Add X mana in any combination of {G} and/or {W} to your mana pool. // {1}, Remove X storage counters from Saltcrusted Steppe: Add X mana in any combination of {G} and/or {W} to your mana pool.
ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, ability = new SimpleActivatedAbility(Zone.BATTLEFIELD,
new ManaInAnyCombinationEffect(new RemovedCountersForCostValue(), ColoredManaSymbol.G, ColoredManaSymbol.W), new AddManaInAnyCombinationEffect(new RemovedCountersForCostValue(), ColoredManaSymbol.G, ColoredManaSymbol.W),
new GenericManaCost(1)); new GenericManaCost(1));
ability.addCost(new RemoveVariableCountersSourceCost(CounterType.STORAGE.createInstance())); ability.addCost(new RemoveVariableCountersSourceCost(CounterType.STORAGE.createInstance()));
this.addAbility(ability); this.addAbility(ability);

View file

@ -34,12 +34,10 @@ import mage.abilities.Ability;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount; import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
import mage.abilities.effects.common.DynamicManaEffect; import mage.abilities.mana.DynamicManaAbility;
import mage.abilities.mana.SimpleManaAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterControlledPermanent; import mage.filter.common.FilterControlledPermanent;
import mage.filter.predicate.mageobject.SubtypePredicate; import mage.filter.predicate.mageobject.SubtypePredicate;
@ -66,9 +64,7 @@ public class MagusOfTheCoffers extends CardImpl {
this.toughness = new MageInt(4); this.toughness = new MageInt(4);
// {2}, {T}: Add {B} to your mana pool for each Swamp you control. // {2}, {T}: Add {B} to your mana pool for each Swamp you control.
Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD, Ability ability = new DynamicManaAbility(Mana.BlackMana, new PermanentsOnBattlefieldCount(filter), new GenericManaCost(2));
new DynamicManaEffect(Mana.BlackMana, new PermanentsOnBattlefieldCount(filter)),
new GenericManaCost(2));
ability.addCost(new TapSourceCost()); ability.addCost(new TapSourceCost());
this.addAbility(ability); this.addAbility(ability);
} }

View file

@ -28,18 +28,21 @@
package mage.sets.darkascension; package mage.sets.darkascension;
import java.util.UUID; import java.util.UUID;
import mage.constants.*;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.AttachEffect;
import mage.abilities.keyword.EnchantAbility; import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
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 static mage.game.events.GameEvent.EventType.DAMAGE_PLAYER;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.game.stack.StackObject;
import mage.players.Player; import mage.players.Player;
import mage.target.TargetPlayer; import mage.target.TargetPlayer;
@ -98,11 +101,10 @@ class CurseOfBloodlettingEffect extends ReplacementEffectImpl {
switch (event.getType()) { switch (event.getType()) {
case DAMAGE_PLAYER: case DAMAGE_PLAYER:
Permanent enchantment = game.getPermanent(source.getSourceId()); Permanent enchantment = game.getPermanent(source.getSourceId());
if (enchantment != null && enchantment.getAttachedTo() != null) { if (enchantment != null &&
Player player = game.getPlayer(enchantment.getAttachedTo()); enchantment.getAttachedTo() != null &&
if (player != null && event.getTargetId().equals(player.getId())) { event.getTargetId().equals(enchantment.getAttachedTo())) {
event.setAmount(event.getAmount() * 2); return true;
}
} }
} }
return false; return false;
@ -115,7 +117,8 @@ class CurseOfBloodlettingEffect extends ReplacementEffectImpl {
@Override @Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) { public boolean replaceEvent(GameEvent event, Ability source, Game game) {
return apply(game, source); event.setAmount(event.getAmount() * 2);
return false;
} }
} }

View file

@ -43,6 +43,7 @@ import mage.abilities.keyword.EnchantAbility;
import mage.abilities.mana.TriggeredManaAbility; import mage.abilities.mana.TriggeredManaAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.choices.ChoiceColor; import mage.choices.ChoiceColor;
import mage.constants.ColoredManaSymbol;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.filter.common.FilterLandPermanent; import mage.filter.common.FilterLandPermanent;
import mage.filter.predicate.mageobject.SubtypePredicate; import mage.filter.predicate.mageobject.SubtypePredicate;
@ -180,24 +181,7 @@ class UtopiaSprawlEffect extends ManaEffect {
if(land != null){ if(land != null){
Player player = game.getPlayer(land.getControllerId()); Player player = game.getPlayer(land.getControllerId());
if (player != null) { if (player != null) {
ObjectColor color = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color"); player.getManaPool().addMana(getMana(game, source), game, source);
switch(color.toString()) {
case "W":
player.getManaPool().addMana(Mana.WhiteMana, game, source);
break;
case "B":
player.getManaPool().addMana(Mana.BlackMana, game, source);
break;
case "U":
player.getManaPool().addMana(Mana.BlueMana, game, source);
break;
case "G":
player.getManaPool().addMana(Mana.GreenMana, game, source);
break;
case "R":
player.getManaPool().addMana(Mana.RedMana, game, source);
break;
}
return true; return true;
} }
} }
@ -205,6 +189,16 @@ class UtopiaSprawlEffect extends ManaEffect {
return false; return false;
} }
@Override
public Mana getMana(Game game, Ability source) {
ObjectColor color = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color");
if (color != null) {
return new Mana(ColoredManaSymbol.lookup(color.toString().charAt(0)));
} else {
return null;
}
}
@Override @Override
public UtopiaSprawlEffect copy() { public UtopiaSprawlEffect copy() {
return new UtopiaSprawlEffect(this); return new UtopiaSprawlEffect(this);

View file

@ -160,4 +160,10 @@ class PlasmCaptureManaEffect extends ManaEffect {
} }
return false; return false;
} }
@Override
public Mana getMana(Game game, Ability source) {
return null;
}
} }

View file

@ -28,25 +28,14 @@
package mage.sets.dragonsmaze; package mage.sets.dragonsmaze;
import java.util.UUID; import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.TapForManaAllTriggeredManaAbility;
import mage.abilities.effects.common.AddManaOfAnyColorTargetCanProduceEffect;
import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.MageInt; import mage.constants.SetTargetPointer;
import mage.Mana; import mage.filter.common.FilterLandPermanent;
import mage.abilities.Abilities;
import mage.abilities.Ability;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.mana.ManaAbility;
import mage.abilities.mana.TriggeredManaAbility;
import mage.cards.CardImpl;
import mage.choices.Choice;
import mage.choices.ChoiceImpl;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
/** /**
* *
@ -65,7 +54,10 @@ public class ZhurTaaAncient extends CardImpl {
this.toughness = new MageInt(5); this.toughness = new MageInt(5);
// Whenever a player taps a land for mana, that player adds one mana to his or her mana pool of any type that land produced. // Whenever a player taps a land for mana, that player adds one mana to his or her mana pool of any type that land produced.
this.addAbility(new ZhurTaaAncientAbility()); this.addAbility(new TapForManaAllTriggeredManaAbility(
new AddManaOfAnyColorTargetCanProduceEffect(),
new FilterLandPermanent("a player taps a land"),
SetTargetPointer.PERMANENT));
} }
public ZhurTaaAncient(final ZhurTaaAncient card) { public ZhurTaaAncient(final ZhurTaaAncient card) {
@ -77,119 +69,3 @@ public class ZhurTaaAncient extends CardImpl {
return new ZhurTaaAncient(this); return new ZhurTaaAncient(this);
} }
} }
class ZhurTaaAncientAbility extends TriggeredManaAbility {
private static final String staticText = "Whenever a player taps a land for mana, that player adds one mana to his or her mana pool of any type that land produced.";
public ZhurTaaAncientAbility() {
super(Zone.BATTLEFIELD, new ZhurTaaAncientEffect());
}
public ZhurTaaAncientAbility(ZhurTaaAncientAbility ability) {
super(ability);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.TAPPED_FOR_MANA) {
Permanent permanent = game.getPermanent(event.getSourceId());
if (permanent == null) {
permanent = (Permanent) game.getLastKnownInformation(event.getSourceId(), Zone.BATTLEFIELD);
}
if (permanent != null && permanent.getCardType().contains(CardType.LAND)) {
getEffects().get(0).setTargetPointer(new FixedTarget(permanent.getId()));
return true;
}
}
return false;
}
@Override
public ZhurTaaAncientAbility copy() {
return new ZhurTaaAncientAbility(this);
}
@Override
public String getRule() {
return staticText;
}
}
class ZhurTaaAncientEffect extends ManaEffect {
public ZhurTaaAncientEffect() {
super();
staticText = "that player adds one mana to his or her mana pool of any type that land produced";
}
public ZhurTaaAncientEffect(final ZhurTaaAncientEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent land = game.getPermanent(this.targetPointer.getFirst(game, source));
Abilities<ManaAbility> mana = land.getAbilities().getManaAbilities(Zone.BATTLEFIELD);
Mana types = new Mana();
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.getColorless() > 0) {
choice.getChoices().add("Colorless");
}
if (choice.getChoices().size() > 0) {
Player player = game.getPlayer(land.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);
return true;
case "Blue":
player.getManaPool().addMana(Mana.BlueMana, game, source);
return true;
case "Red":
player.getManaPool().addMana(Mana.RedMana, game, source);
return true;
case "Green":
player.getManaPool().addMana(Mana.GreenMana, game, source);
return true;
case "White":
player.getManaPool().addMana(Mana.WhiteMana, game, source);
return true;
case "Colorless":
player.getManaPool().addMana(Mana.ColorlessMana, game, source);
return true;
}
}
return true;
}
@Override
public ZhurTaaAncientEffect copy() {
return new ZhurTaaAncientEffect(this);
}
}

View file

@ -58,7 +58,7 @@ public class BloomTender extends CardImpl {
this.power = new MageInt(1); this.power = new MageInt(1);
this.toughness = new MageInt(1); this.toughness = new MageInt(1);
// {tap}: For each color among permanents you control, add one mana of that color to your mana pool. // {T}: For each color among permanents you control, add one mana of that color to your mana pool.
this.addAbility(new SimpleManaAbility(Zone.BATTLEFIELD, new BloomTenderEffect(), new TapSourceCost())); this.addAbility(new SimpleManaAbility(Zone.BATTLEFIELD, new BloomTenderEffect(), new TapSourceCost()));
} }
@ -91,10 +91,22 @@ class BloomTenderEffect extends ManaEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player you = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (you != null) { if (controller != null) {
Mana mana = getMana(game, source);
checkToFirePossibleEvents(mana, game, source);
controller.getManaPool().addMana(mana, game, source);
return true;
}
return false;
}
@Override
public Mana getMana(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Mana mana = new Mana(); Mana mana = new Mana();
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(you.getId())) { for (Permanent permanent : game.getBattlefield().getAllActivePermanents(controller.getId())) {
if (mana.getBlack() == 0 && permanent.getColor().isBlack()) { if (mana.getBlack() == 0 && permanent.getColor().isBlack()) {
mana.addBlack(); mana.addBlack();
} }
@ -111,9 +123,10 @@ class BloomTenderEffect extends ManaEffect {
mana.addWhite(); mana.addWhite();
} }
} }
you.getManaPool().addMana(mana, game, source); return mana;
return true;
} }
return false; return null;
} }
} }

View file

@ -32,19 +32,18 @@ import java.util.UUID;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.Mana; import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.common.AddManaToManaPoolTargetControllerEffect;
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect; import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.mana.DelayedTriggeredManaAbility; import mage.abilities.mana.DelayedTriggeredManaAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.ColoredManaSymbol;
import mage.constants.Duration; import mage.constants.Duration;
import mage.filter.common.FilterLandPermanent; import mage.filter.common.FilterLandPermanent;
import mage.filter.predicate.mageobject.SubtypePredicate; import mage.filter.predicate.mageobject.SubtypePredicate;
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;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTarget;
/** /**
@ -77,12 +76,13 @@ public class HighTide extends CardImpl {
class HighTideTriggeredAbility extends DelayedTriggeredManaAbility { class HighTideTriggeredAbility extends DelayedTriggeredManaAbility {
private static final FilterLandPermanent filter = new FilterLandPermanent("Island"); private static final FilterLandPermanent filter = new FilterLandPermanent("Island");
static { static {
filter.add(new SubtypePredicate("Island")); filter.add(new SubtypePredicate("Island"));
} }
public HighTideTriggeredAbility() { public HighTideTriggeredAbility() {
super(new AddBlueToTargetEffect(), Duration.EndOfTurn, false); super(new AddManaToManaPoolTargetControllerEffect(new Mana(ColoredManaSymbol.U), "his or her"), Duration.EndOfTurn, false);
this.usesStack = false; this.usesStack = false;
} }
@ -112,34 +112,3 @@ class HighTideTriggeredAbility extends DelayedTriggeredManaAbility {
return "Until end of turn, whenever a player taps an Island for mana, that player adds {U} to his or her mana pool"; return "Until end of turn, whenever a player taps an Island for mana, that player adds {U} to his or her mana pool";
} }
} }
class AddBlueToTargetEffect extends ManaEffect {
public AddBlueToTargetEffect() {
super();
staticText = "that player adds {U} to his or her mana pool";
}
public AddBlueToTargetEffect(final AddBlueToTargetEffect effect) {
super(effect);
}
@Override
public AddBlueToTargetEffect copy() {
return new AddBlueToTargetEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(this.getTargetPointer().getFirst(game, source));
if(player != null)
{
player.getManaPool().addMana(Mana.BlueMana(1), game, source);
}
return true;
}
}

View file

@ -29,7 +29,7 @@ package mage.sets.fifthdawn;
import mage.Mana; import mage.Mana;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.common.AddManaToControllersManaPoolEffect; import mage.abilities.effects.common.AddManaToManaPoolSourceControllerEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Rarity; import mage.constants.Rarity;
@ -49,7 +49,7 @@ public class ChannelTheSuns extends CardImpl {
this.color.setGreen(true); this.color.setGreen(true);
// Add {W}{U}{B}{R}{G} to your mana pool. // Add {W}{U}{B}{R}{G} to your mana pool.
Effect effect = new AddManaToControllersManaPoolEffect(new Mana(1, 1, 1, 1, 1, 0, 0)); Effect effect = new AddManaToManaPoolSourceControllerEffect(new Mana(1, 1, 1, 1, 1, 0, 0));
this.getSpellAbility().addEffect(effect); this.getSpellAbility().addEffect(effect);
} }

View file

@ -160,4 +160,11 @@ class DawnsReflectionManaEffect extends ManaEffect {
} }
return false; return false;
} }
@Override
public Mana getMana(Game game, Ability source) {
return null;
}
} }

View file

@ -28,25 +28,21 @@
package mage.sets.gatecrash; package mage.sets.gatecrash;
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.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.common.AddManaAnyColorAttachedControllerEffect;
import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.GainLifeEffect; import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.keyword.EnchantAbility; import mage.abilities.keyword.EnchantAbility;
import mage.abilities.mana.TriggeredManaAbility; import mage.abilities.mana.TriggeredManaAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.choices.ChoiceColor; import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
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;
import mage.players.Player;
import mage.target.TargetPermanent; import mage.target.TargetPermanent;
import mage.target.common.TargetLandPermanent; import mage.target.common.TargetLandPermanent;
@ -90,7 +86,7 @@ public class VerdantHaven extends CardImpl {
class VerdantHavenTriggeredAbility extends TriggeredManaAbility { class VerdantHavenTriggeredAbility extends TriggeredManaAbility {
public VerdantHavenTriggeredAbility() { public VerdantHavenTriggeredAbility() {
super(Zone.BATTLEFIELD, new VerdantHavenManaEffect()); super(Zone.BATTLEFIELD, new AddManaAnyColorAttachedControllerEffect());
} }
public VerdantHavenTriggeredAbility(final VerdantHavenTriggeredAbility ability) { public VerdantHavenTriggeredAbility(final VerdantHavenTriggeredAbility ability) {
@ -119,57 +115,3 @@ class VerdantHavenTriggeredAbility extends TriggeredManaAbility {
return "Whenever enchanted land is tapped for mana, its controller adds one mana of any color to his or her mana pool."; return "Whenever enchanted land is tapped for mana, its controller adds one mana of any color to his or her mana pool.";
} }
} }
class VerdantHavenManaEffect extends ManaEffect {
public VerdantHavenManaEffect() {
super();
staticText = "its controller adds one mana of any color to his or her mana pool";
}
public VerdantHavenManaEffect(final VerdantHavenManaEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent enchantment = game.getPermanent(source.getSourceId());
if(enchantment != null){
Permanent land = game.getPermanent(enchantment.getAttachedTo());
if(land != null){
Player player = game.getPlayer(land.getControllerId());
if (player != null) {
ChoiceColor choice = new ChoiceColor();
while (!player.choose(outcome, choice, game)) {
if (!player.isInGame()) {
return false;
}
}
int amount = 1;
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);
}
if (player != null && mana != null) {
player.getManaPool().addMana(mana, game, source);
return true;
}
}
}
}
return false;
}
@Override
public VerdantHavenManaEffect copy() {
return new VerdantHavenManaEffect(this);
}
}

View file

@ -115,8 +115,8 @@ class OrcishLumberjackManaEffect extends ManaEffect {
manaChoice.setChoices(choices); manaChoice.setChoices(choices);
manaChoice.setMessage("Select color of mana to add"); manaChoice.setMessage("Select color of mana to add");
for(int i = 0; i < 3; i++){
Mana mana = new Mana(); Mana mana = new Mana();
for(int i = 0; i < 3; i++){
while (!player.choose(Outcome.Benefit, manaChoice, game)) { while (!player.choose(Outcome.Benefit, manaChoice, game)) {
if (!player.isInGame()) { if (!player.isInGame()) {
return false; return false;
@ -130,10 +130,19 @@ class OrcishLumberjackManaEffect extends ManaEffect {
mana.addRed(); mana.addRed();
break; break;
} }
player.getManaPool().addMana(mana, game, source);
} }
checkToFirePossibleEvents(mana, game, source);
player.getManaPool().addMana(mana, game, source);
return true; return true;
} }
return false; return false;
} }
@Override
public Mana getMana(Game game, Ability source) {
return null;
}
} }

View file

@ -33,11 +33,13 @@ import mage.constants.CardType;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.Mana; import mage.Mana;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.common.AddManaToManaPoolTargetControllerEffect;
import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.ManaEffect; import mage.abilities.effects.common.ManaEffect;
import mage.abilities.keyword.EnchantAbility; import mage.abilities.keyword.EnchantAbility;
import mage.abilities.mana.TriggeredManaAbility; import mage.abilities.mana.TriggeredManaAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.ColoredManaSymbol;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
@ -84,7 +86,7 @@ class WildGrowthTriggeredAbility extends TriggeredManaAbility {
public WildGrowthTriggeredAbility() { public WildGrowthTriggeredAbility() {
super(Zone.BATTLEFIELD, new WildGrowthEffect()); super(Zone.BATTLEFIELD, new AddManaToManaPoolTargetControllerEffect(new Mana(ColoredManaSymbol.G), "his or her"));
} }
public WildGrowthTriggeredAbility(final WildGrowthTriggeredAbility ability) { public WildGrowthTriggeredAbility(final WildGrowthTriggeredAbility ability) {
@ -113,36 +115,3 @@ class WildGrowthTriggeredAbility extends TriggeredManaAbility {
return "Whenever enchanted land is tapped for mana, its controller adds {G} to his or her mana pool"; return "Whenever enchanted land is tapped for mana, its controller adds {G} to his or her mana pool";
} }
} }
class WildGrowthEffect extends ManaEffect {
public WildGrowthEffect() {
super();
staticText = "its controller adds {G} to his or her mana pool";
}
public WildGrowthEffect(final WildGrowthEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent enchantment = game.getPermanent(source.getSourceId());
if(enchantment != null){
Permanent land = game.getPermanent(enchantment.getAttachedTo());
if(land != null){
Player player = game.getPlayer(land.getControllerId());
if (player != null) {
player.getManaPool().addMana(Mana.GreenMana, game, source);
return true;
}
}
}
return false;
}
@Override
public WildGrowthEffect copy() {
return new WildGrowthEffect(this);
}
}

View file

@ -28,12 +28,14 @@
package mage.sets.journeyintonyx; package mage.sets.journeyintonyx;
import java.util.UUID; import java.util.UUID;
import mage.abilities.common.TapLandForManaAllTriggeredManaAbility; import mage.abilities.common.TapForManaAllTriggeredManaAbility;
import mage.abilities.effects.common.AddManaOfAnyColorTargetCanProduceEffect; import mage.abilities.effects.common.AddManaOfAnyColorTargetCanProduceEffect;
import mage.abilities.keyword.FlashAbility; import mage.abilities.keyword.FlashAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.SetTargetPointer;
import mage.filter.common.FilterLandPermanent;
/** /**
* *
@ -50,7 +52,10 @@ public class DictateOfKarametra extends CardImpl {
// Flash // Flash
this.addAbility(FlashAbility.getInstance()); this.addAbility(FlashAbility.getInstance());
// Whenever a player taps a land for mana, that player adds one mana to his or her mana pool of any type that land produced. // Whenever a player taps a land for mana, that player adds one mana to his or her mana pool of any type that land produced.
this.addAbility(new TapLandForManaAllTriggeredManaAbility(new AddManaOfAnyColorTargetCanProduceEffect(), false, true)); this.addAbility(new TapForManaAllTriggeredManaAbility(
new AddManaOfAnyColorTargetCanProduceEffect(),
new FilterLandPermanent("a player taps a land"),
SetTargetPointer.PERMANENT));
} }

View file

@ -165,11 +165,17 @@ class MarketFestivalManaEffect extends ManaEffect {
mana.addWhite(); mana.addWhite();
} }
} }
checkToFirePossibleEvents(mana, game, source);
controller.getManaPool().addMana(mana, game, source); controller.getManaPool().addMana(mana, game, source);
return true; return true;
} }
return false; return false;
} }
@Override
public Mana getMana(Game game, Ability source) {
return null;
}
} }

View file

@ -69,7 +69,7 @@ class RevelOfTheFallenGodSatyrToken extends Token {
public RevelOfTheFallenGodSatyrToken() { public RevelOfTheFallenGodSatyrToken() {
super("Satyr", "2/2 red and green Satyr creature tokens with haste"); super("Satyr", "2/2 red and green Satyr creature tokens with haste");
this.setOriginalExpansionSetCode("JOU"); this.setOriginalExpansionSetCode("THS");
cardType.add(CardType.CREATURE); cardType.add(CardType.CREATURE);
color.setColor(ObjectColor.RED); color.setColor(ObjectColor.RED);
color.setColor(ObjectColor.GREEN); color.setColor(ObjectColor.GREEN);

View file

@ -28,26 +28,17 @@
package mage.sets.judgment; package mage.sets.judgment;
import java.util.UUID; import java.util.UUID;
import mage.Mana;
import mage.abilities.Abilities;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.ManaEffect; import mage.abilities.common.TapForManaAllTriggeredManaAbility;
import mage.abilities.effects.common.AddManaOfAnyColorTargetCanProduceEffect;
import mage.abilities.effects.common.continious.BoostControlledEffect; import mage.abilities.effects.common.continious.BoostControlledEffect;
import mage.abilities.mana.ManaAbility;
import mage.abilities.mana.TriggeredManaAbility;
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.Duration; import mage.constants.Duration;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.SetTargetPointer;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.filter.common.FilterControlledLandPermanent;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
/** /**
* *
@ -65,7 +56,10 @@ public class MirarisWake extends CardImpl {
// Creatures you control get +1/+1. // Creatures you control get +1/+1.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostControlledEffect(1,1,Duration.WhileOnBattlefield))); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostControlledEffect(1,1,Duration.WhileOnBattlefield)));
// Whenever you tap a land for mana, add one mana to your mana pool of any type that land produced. // Whenever you tap a land for mana, add one mana to your mana pool of any type that land produced.
this.addAbility(new MirarisWakeManaAbility()); this.addAbility(new TapForManaAllTriggeredManaAbility(
new AddManaOfAnyColorTargetCanProduceEffect(),
new FilterControlledLandPermanent("you tap a land"),
SetTargetPointer.PERMANENT));
} }
@ -78,117 +72,3 @@ public class MirarisWake extends CardImpl {
return new MirarisWake(this); return new MirarisWake(this);
} }
} }
class MirarisWakeManaAbility extends TriggeredManaAbility {
private static final String staticText = "Whenever you tap a land for mana, add one mana to your mana pool of any type that land produced.";
public MirarisWakeManaAbility() {
super(Zone.BATTLEFIELD, new MirarisWakeManaEffect());
}
public MirarisWakeManaAbility(MirarisWakeManaAbility ability) {
super(ability);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.TAPPED_FOR_MANA && event.getPlayerId().equals(controllerId)) {
Permanent permanent = game.getPermanentOrLKIBattlefield(event.getSourceId());
if (permanent != null && permanent.getCardType().contains(CardType.LAND)) {
getEffects().get(0).setTargetPointer(new FixedTarget(permanent.getId()));
return true;
}
}
return false;
}
@Override
public MirarisWakeManaAbility copy() {
return new MirarisWakeManaAbility(this);
}
@Override
public String getRule() {
return staticText;
}
}
class MirarisWakeManaEffect extends ManaEffect {
public MirarisWakeManaEffect() {
super();
staticText = "add one mana to your mana pool of any type that land produced";
}
public MirarisWakeManaEffect(final MirarisWakeManaEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent land = game.getPermanentOrLKIBattlefield(this.targetPointer.getFirst(game, source));
Abilities<ManaAbility> mana = land.getAbilities().getManaAbilities(Zone.BATTLEFIELD);
Mana types = new Mana();
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.getColorless() > 0) {
choice.getChoices().add("Colorless");
}
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);
return true;
case "Blue":
player.getManaPool().addMana(Mana.BlueMana, game, source);
return true;
case "Red":
player.getManaPool().addMana(Mana.RedMana, game, source);
return true;
case "Green":
player.getManaPool().addMana(Mana.GreenMana, game, source);
return true;
case "White":
player.getManaPool().addMana(Mana.WhiteMana, game, source);
return true;
case "Colorless":
player.getManaPool().addMana(Mana.ColorlessMana, game, source);
return true;
}
}
return true;
}
@Override
public MirarisWakeManaEffect copy() {
return new MirarisWakeManaEffect(this);
}
}

View file

@ -33,7 +33,7 @@ import mage.Mana;
import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.condition.common.RaidCondition; import mage.abilities.condition.common.RaidCondition;
import mage.abilities.decorator.ConditionalTriggeredAbility; import mage.abilities.decorator.ConditionalTriggeredAbility;
import mage.abilities.effects.common.AddManaToControllersManaPoolEffect; import mage.abilities.effects.common.AddManaToManaPoolSourceControllerEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Rarity; import mage.constants.Rarity;
@ -56,7 +56,7 @@ public class MarduWarshrieker extends CardImpl {
this.toughness = new MageInt(3); this.toughness = new MageInt(3);
// <em>Raid</em> - When Mardu Warshrieker enters the battlefield, if you attacked with a creature this turn, add {R}{W}{B} to your mana pool. // <em>Raid</em> - When Mardu Warshrieker enters the battlefield, if you attacked with a creature this turn, add {R}{W}{B} to your mana pool.
this.addAbility(new ConditionalTriggeredAbility(new EntersBattlefieldTriggeredAbility(new AddManaToControllersManaPoolEffect(new Mana(1,0,0,1,1,0,0))), RaidCondition.getInstance(), this.addAbility(new ConditionalTriggeredAbility(new EntersBattlefieldTriggeredAbility(new AddManaToManaPoolSourceControllerEffect(new Mana(1,0,0,1,1,0,0))), RaidCondition.getInstance(),
"<i>Raid</i> - When {this} enters the battlefield, if you attacked with a creature this turn, add {R}{W}{B} to your mana pool.", false)); "<i>Raid</i> - When {this} enters the battlefield, if you attacked with a creature this turn, add {R}{W}{B} to your mana pool.", false));
this.addWatcher(new PlayerAttackedWatcher()); this.addWatcher(new PlayerAttackedWatcher());
} }

View file

@ -32,7 +32,7 @@ import mage.MageInt;
import mage.Mana; import mage.Mana;
import mage.abilities.common.TurnedFaceUpSourceTriggeredAbility; import mage.abilities.common.TurnedFaceUpSourceTriggeredAbility;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.common.AddManaToControllersManaPoolEffect; import mage.abilities.effects.common.AddManaToManaPoolSourceControllerEffect;
import mage.abilities.keyword.MorphAbility; import mage.abilities.keyword.MorphAbility;
import mage.abilities.mana.BlueManaAbility; import mage.abilities.mana.BlueManaAbility;
import mage.abilities.mana.GreenManaAbility; import mage.abilities.mana.GreenManaAbility;
@ -66,7 +66,7 @@ public class RattleclawMystic extends CardImpl {
this.addAbility(new MorphAbility(this, new ManaCostsImpl("{2}"))); this.addAbility(new MorphAbility(this, new ManaCostsImpl("{2}")));
// When Rattleclaw Mystic is turned face up, add {G}{U}{R} to your mana pool. // When Rattleclaw Mystic is turned face up, add {G}{U}{R} to your mana pool.
this.addAbility(new TurnedFaceUpSourceTriggeredAbility(new AddManaToControllersManaPoolEffect(new Mana(1,1,1,0,0,0,0)))); this.addAbility(new TurnedFaceUpSourceTriggeredAbility(new AddManaToManaPoolSourceControllerEffect(new Mana(1,1,1,0,0,0,0))));
} }

View file

@ -30,20 +30,13 @@ package mage.sets.legions;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.Mana; import mage.Mana;
import mage.abilities.Ability; import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.mana.DynamicManaAbility;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.mana.SimpleManaAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.choices.ChoiceColor;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.FilterPermanent; import mage.filter.FilterPermanent;
import mage.filter.common.FilterControlledPermanent;
import mage.filter.predicate.mageobject.SubtypePredicate; import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game;
import mage.players.Player;
/** /**
* *
@ -51,6 +44,12 @@ import mage.players.Player;
*/ */
public class WirewoodChanneler extends CardImpl { public class WirewoodChanneler extends CardImpl {
private static final FilterPermanent filter = new FilterPermanent("Elves");
static {
filter.add(new SubtypePredicate(("Elf")));
}
public WirewoodChanneler(UUID ownerId) { public WirewoodChanneler(UUID ownerId) {
super(ownerId, 144, "Wirewood Channeler", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{3}{G}"); super(ownerId, 144, "Wirewood Channeler", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{3}{G}");
this.expansionSetCode = "LGN"; this.expansionSetCode = "LGN";
@ -61,9 +60,9 @@ public class WirewoodChanneler extends CardImpl {
this.power = new MageInt(2); this.power = new MageInt(2);
this.toughness = new MageInt(2); this.toughness = new MageInt(2);
// {tap}: Add X mana of any one color to your mana pool, where X is the number of Elves on the battlefield. // {T}: Add X mana of any one color to your mana pool, where X is the number of Elves on the battlefield.
Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD, new WirewoodChannelerManaEffect(), new TapSourceCost()); DynamicManaAbility ability = new DynamicManaAbility(new Mana(0,0,0,0,0,0,1), new PermanentsOnBattlefieldCount(filter),
ability.addChoice(new ChoiceColor()); "Add X mana of any one color to your mana pool, where X is the number of Elves on the battlefield");
this.addAbility(ability); this.addAbility(ability);
} }
@ -76,50 +75,3 @@ public class WirewoodChanneler extends CardImpl {
return new WirewoodChanneler(this); return new WirewoodChanneler(this);
} }
} }
class WirewoodChannelerManaEffect extends ManaEffect {
private static final FilterPermanent filter = new FilterPermanent();
static {
filter.add(new SubtypePredicate("Elf"));
}
WirewoodChannelerManaEffect() {
super();
staticText = "Add X mana of any one color to your mana pool, where X is the number of Elves on the battlefield";
}
WirewoodChannelerManaEffect(final WirewoodChannelerManaEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
ChoiceColor choice = (ChoiceColor) source.getChoices().get(0);
Player player = game.getPlayer(source.getControllerId());
int count = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game);
if (choice.getColor().isBlack()) {
player.getManaPool().addMana(new Mana(0, 0, 0, 0, count, 0, 0), game, source);
return true;
} else if (choice.getColor().isBlue()) {
player.getManaPool().addMana(new Mana(0, 0, count, 0, 0, 0, 0), game, source);
return true;
} else if (choice.getColor().isRed()) {
player.getManaPool().addMana(new Mana(count, 0, 0, 0, 0, 0, 0), game, source);
return true;
} else if (choice.getColor().isGreen()) {
player.getManaPool().addMana(new Mana(0, count, 0, 0, 0, 0, 0), game, source);
return true;
} else if (choice.getColor().isWhite()) {
player.getManaPool().addMana(new Mana(0, 0, 0, count, 0, 0, 0), game, source);
return true;
}
return false;
}
@Override
public WirewoodChannelerManaEffect copy() {
return new WirewoodChannelerManaEffect(this);
}
}

View file

@ -56,7 +56,7 @@ import mage.players.Player;
*/ */
public class DjinnOfWishes extends CardImpl { public class DjinnOfWishes extends CardImpl {
private static final String ruleText = "Djinn of Wishes enters the battlefield with three wish counters on it"; private static final String ruleText = "{this} enters the battlefield with three wish counters on it";
public DjinnOfWishes(UUID ownerId) { public DjinnOfWishes(UUID ownerId) {
super(ownerId, 50, "Djinn of Wishes", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{3}{U}{U}"); super(ownerId, 50, "Djinn of Wishes", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{3}{U}{U}");

View file

@ -28,16 +28,13 @@
package mage.sets.magic2014; package mage.sets.magic2014;
import java.util.UUID; import java.util.UUID;
import mage.abilities.TriggeredAbilityImpl; import mage.abilities.common.TapForManaAllTriggeredAbility;
import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.effects.common.DamageTargetEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.Zone; import mage.constants.SetTargetPointer;
import mage.game.Game; import mage.filter.common.FilterNonlandPermanent;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget;
/** /**
* *
@ -52,7 +49,10 @@ public class BurningEarth extends CardImpl {
this.color.setRed(true); this.color.setRed(true);
// Whenever a player taps a nonbasic land for mana, Burning Earth deals 1 damage to that player. // Whenever a player taps a nonbasic land for mana, Burning Earth deals 1 damage to that player.
this.addAbility(new BurningEarthTriggeredAbility()); this.addAbility(new TapForManaAllTriggeredAbility(
new DamageTargetEffect(1, true, "that player"),
new FilterNonlandPermanent("a player taps a nonbasic land"),
SetTargetPointer.PLAYER));
} }
public BurningEarth(final BurningEarth card) { public BurningEarth(final BurningEarth card) {
@ -64,41 +64,3 @@ public class BurningEarth extends CardImpl {
return new BurningEarth(this); return new BurningEarth(this);
} }
} }
class BurningEarthTriggeredAbility extends TriggeredAbilityImpl {
public BurningEarthTriggeredAbility() {
super(Zone.BATTLEFIELD, new DamageTargetEffect(1));
}
public BurningEarthTriggeredAbility(BurningEarthTriggeredAbility ability) {
super(ability);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.TAPPED_FOR_MANA) {
Permanent permanent = game.getPermanent(event.getSourceId());
if (permanent == null) {
permanent = (Permanent) game.getLastKnownInformation(event.getSourceId(), Zone.BATTLEFIELD);
}
if (permanent != null
&& permanent.getCardType().contains(CardType.LAND)
&& !permanent.getSupertype().contains("Basic")) {
getEffects().get(0).setTargetPointer(new FixedTarget(permanent.getControllerId()));
return true;
}
}
return false;
}
@Override
public BurningEarthTriggeredAbility copy() {
return new BurningEarthTriggeredAbility(this);
}
@Override
public String getRule() {
return "Whenever a player taps a nonbasic land for mana, {this} deals 1 damage to that player.";
}
}

View file

@ -134,9 +134,17 @@ class FoodChainManaEffect extends ManaEffect {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
if (player != null && mana != null) { if (player != null && mana != null) {
checkToFirePossibleEvents(mana, game, source);
player.getManaPool().addMana(mana, game, source); player.getManaPool().addMana(mana, game, source);
return true; return true;
} }
return false; return false;
} }
@Override
public Mana getMana(Game game, Ability source) {
return null;
}
} }

View file

@ -114,12 +114,19 @@ public class KyrenToy extends CardImpl {
numberOfMana = ((RemoveVariableCountersSourceCost)cost).getAmount(); numberOfMana = ((RemoveVariableCountersSourceCost)cost).getAmount();
} }
} }
player.getManaPool().addMana(new Mana(0, 0, 0, 0, 0, numberOfMana + 1, 0), game, source); Mana mana = new Mana(0, 0, 0, 0, 0, numberOfMana + 1, 0);
checkToFirePossibleEvents(mana, game, source);
player.getManaPool().addMana(mana, game, source);
return true; return true;
} }
return false; return false;
} }
@Override
public Mana getMana(Game game, Ability source) {
return null;
}
@Override @Override
public KyrenToyManaEffect copy() { public KyrenToyManaEffect copy() {
return new KyrenToyManaEffect(this); return new KyrenToyManaEffect(this);

View file

@ -29,9 +29,6 @@ package mage.sets.mirrodin;
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.ObjectColor; import mage.ObjectColor;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -44,7 +41,9 @@ import mage.cards.Card;
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.Outcome; import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.FilterCard; import mage.filter.FilterCard;
import mage.filter.predicate.Predicates; import mage.filter.predicate.Predicates;
@ -170,6 +169,7 @@ class ChromeMoxManaEffect extends ManaEffect {
} }
if (choice.getChoices().size() > 0) { if (choice.getChoices().size() > 0) {
Mana mana = new Mana();
if (choice.getChoices().size() == 1) { if (choice.getChoices().size() == 1) {
choice.setChoice(choice.getChoices().iterator().next()); choice.setChoice(choice.getChoices().iterator().next());
} else { } else {
@ -188,12 +188,18 @@ class ChromeMoxManaEffect extends ManaEffect {
} else if (choice.getChoice().equals("Colorless")) { } else if (choice.getChoice().equals("Colorless")) {
player.getManaPool().addMana(Mana.ColorlessMana, game, source); player.getManaPool().addMana(Mana.ColorlessMana, game, source);
} }
checkToFirePossibleEvents(mana, game, source);
player.getManaPool().addMana(mana, game, source);
} }
} }
} }
} }
return true; return true;
} }
@Override
public Mana getMana(Game game, Ability source) {
return null;
}
} }

View file

@ -28,14 +28,14 @@
package mage.sets.mirrodinbesieged; package mage.sets.mirrodinbesieged;
import mage.constants.CardType; import java.util.UUID;
import mage.constants.Rarity;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.DiesTriggeredAbility; import mage.abilities.common.DiesTriggeredAbility;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.PutIntoGraveFromBattlefieldTriggeredAbility;
import mage.abilities.effects.common.DrawCardSourceControllerEffect; import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType;
import java.util.UUID; import mage.constants.Rarity;
/** /**
* @author ayratn * @author ayratn
@ -45,8 +45,10 @@ public class IchorWellspring extends CardImpl {
public IchorWellspring(UUID ownerId) { public IchorWellspring(UUID ownerId) {
super(ownerId, 110, "Ichor Wellspring", Rarity.COMMON, new CardType[]{CardType.ARTIFACT}, "{2}"); super(ownerId, 110, "Ichor Wellspring", Rarity.COMMON, new CardType[]{CardType.ARTIFACT}, "{2}");
this.expansionSetCode = "MBS"; this.expansionSetCode = "MBS";
// When Ichor Wellspring enters the battlefield or is put into a graveyard from the battlefield, draw a card.
this.addAbility(new EntersBattlefieldTriggeredAbility(new DrawCardSourceControllerEffect(1))); this.addAbility(new EntersBattlefieldTriggeredAbility(new DrawCardSourceControllerEffect(1)));
this.addAbility(new DiesTriggeredAbility(new DrawCardSourceControllerEffect(1))); this.addAbility(new PutIntoGraveFromBattlefieldTriggeredAbility(new DrawCardSourceControllerEffect(1)));
} }
public IchorWellspring(final IchorWellspring card) { public IchorWellspring(final IchorWellspring card) {

View file

@ -108,7 +108,7 @@ class JhoiraOfTheGhituSuspendEffect extends OneShotEffect {
if (controller == null) { if (controller == null) {
return false; return false;
} }
List<Card> cards = new ArrayList<Card>(); List<Card> cards = new ArrayList<>();
for (Cost cost: source.getCosts()) { for (Cost cost: source.getCosts()) {
if (cost instanceof ExileFromHandCost) { if (cost instanceof ExileFromHandCost) {
cards = ((ExileFromHandCost) cost).getCards(); cards = ((ExileFromHandCost) cost).getCards();

View file

@ -40,10 +40,12 @@ import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ChooseColorEffect;
import mage.abilities.effects.common.ManaEffect; import mage.abilities.effects.common.ManaEffect;
import mage.abilities.mana.TriggeredManaAbility; import mage.abilities.mana.TriggeredManaAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.choices.ChoiceColor; import mage.choices.ChoiceColor;
import mage.constants.ColoredManaSymbol;
import mage.constants.Layer; import mage.constants.Layer;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubLayer; import mage.constants.SubLayer;
@ -65,7 +67,7 @@ public class CagedSun extends CardImpl {
this.expansionSetCode = "NPH"; this.expansionSetCode = "NPH";
// As Caged Sun enters the battlefield, choose a color. // As Caged Sun enters the battlefield, choose a color.
this.addAbility(new AsEntersBattlefieldAbility(new CagedSunEffect1())); this.addAbility(new AsEntersBattlefieldAbility(new ChooseColorEffect(Outcome.Benefit)));
// Creatures you control of the chosen color get +1/+1. // Creatures you control of the chosen color get +1/+1.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CagedSunEffect2())); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CagedSunEffect2()));
@ -84,39 +86,6 @@ public class CagedSun extends CardImpl {
} }
} }
class CagedSunEffect1 extends OneShotEffect {
public CagedSunEffect1() {
super(Outcome.BoostCreature);
staticText = "choose a color";
}
public CagedSunEffect1(final CagedSunEffect1 effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (player != null && permanent != null) {
ChoiceColor colorChoice = new ChoiceColor();
if (player.choose(Outcome.BoostCreature, colorChoice, game)) {
game.informPlayers(permanent.getName() + ": " + player.getName() + " has chosen " + colorChoice.getChoice());
game.getState().setValue(permanent.getId() + "_color", colorChoice.getColor());
permanent.addInfo("chosen color", CardUtil.addToolTipMarkTags("Chosen color: " + colorChoice.getColor().getDescription()));
}
}
return false;
}
@Override
public CagedSunEffect1 copy() {
return new CagedSunEffect1(this);
}
}
class CagedSunEffect2 extends ContinuousEffectImpl { class CagedSunEffect2 extends ContinuousEffectImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent(); private static final FilterCreaturePermanent filter = new FilterCreaturePermanent();
@ -207,22 +176,22 @@ class CagedSunEffect extends ManaEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
if (player != null) { if (player != null) {
ObjectColor color = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color"); player.getManaPool().addMana(getMana(game, source), game, source);
if (color.isBlack()) {
player.getManaPool().addMana(Mana.BlackMana, game, source);
} else if (color.isBlue()) {
player.getManaPool().addMana(Mana.BlueMana, game, source);
} else if (color.isRed()) {
player.getManaPool().addMana(Mana.RedMana, game, source);
} else if (color.isGreen()) {
player.getManaPool().addMana(Mana.GreenMana, game, source);
} else if (color.isWhite()) {
player.getManaPool().addMana(Mana.WhiteMana, game, source);
}
} }
return true; return true;
} }
@Override
public Mana getMana(Game game, Ability source) {
ObjectColor color = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color");
if (color != null) {
return new Mana(ColoredManaSymbol.lookup(color.toString().charAt(0)));
} else {
return null;
}
}
@Override @Override
public CagedSunEffect copy() { public CagedSunEffect copy() {
return new CagedSunEffect(this); return new CagedSunEffect(this);

View file

@ -32,18 +32,16 @@ import java.util.UUID;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.TargetController; import mage.constants.TargetController;
import mage.constants.Zone;
import mage.Mana; import mage.Mana;
import mage.ObjectColor; import mage.ObjectColor;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SpellCastControllerTriggeredAbility; import mage.abilities.common.SpellCastControllerTriggeredAbility;
import mage.abilities.costs.common.SacrificeSourceCost; import mage.abilities.costs.common.SacrificeSourceCost;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.dynamicvalue.common.CountersCount; import mage.abilities.dynamicvalue.common.CountersCount;
import mage.abilities.effects.common.DynamicManaEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.mana.DynamicManaAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.filter.FilterSpell; import mage.filter.FilterSpell;
@ -65,12 +63,15 @@ public class ShrineOfBoundlessGrowth extends CardImpl {
super(ownerId, 152, "Shrine of Boundless Growth", Rarity.UNCOMMON, new CardType[]{CardType.ARTIFACT}, "{3}"); super(ownerId, 152, "Shrine of Boundless Growth", Rarity.UNCOMMON, new CardType[]{CardType.ARTIFACT}, "{3}");
this.expansionSetCode = "NPH"; this.expansionSetCode = "NPH";
// At the beginning of your upkeep or whenever you cast a green spell, put a charge counter on Shrine of Boundless Growth.
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new AddCountersSourceEffect(CounterType.CHARGE.createInstance()), TargetController.YOU, false)); this.addAbility(new BeginningOfUpkeepTriggeredAbility(new AddCountersSourceEffect(CounterType.CHARGE.createInstance()), TargetController.YOU, false));
this.addAbility(new SpellCastControllerTriggeredAbility(new AddCountersSourceEffect(CounterType.CHARGE.createInstance()), filter, false)); this.addAbility(new SpellCastControllerTriggeredAbility(new AddCountersSourceEffect(CounterType.CHARGE.createInstance()), filter, false));
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DynamicManaEffect(Mana.ColorlessMana, new CountersCount(CounterType.CHARGE)), new TapSourceCost()); // {T}, Sacrifice Shrine of Boundless Growth: Add {1} to your mana pool for each charge counter on Shrine of Boundless Growth.
Ability ability = new DynamicManaAbility(Mana.BlackMana, new CountersCount(CounterType.CHARGE), new TapSourceCost());
ability.addCost(new SacrificeSourceCost()); ability.addCost(new SacrificeSourceCost());
this.addAbility(ability); this.addAbility(ability);
} }
public ShrineOfBoundlessGrowth (final ShrineOfBoundlessGrowth card) { public ShrineOfBoundlessGrowth (final ShrineOfBoundlessGrowth card) {

View file

@ -29,25 +29,20 @@ package mage.sets.newphyrexia;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.Mana;
import mage.abilities.Abilities;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl; import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.common.ManaEffect; import mage.abilities.common.TapForManaAllTriggeredManaAbility;
import mage.abilities.effects.common.AddManaOfAnyColorTargetCanProduceEffect;
import mage.abilities.effects.common.SkipNextUntapTargetEffect; import mage.abilities.effects.common.SkipNextUntapTargetEffect;
import mage.abilities.keyword.TrampleAbility; import mage.abilities.keyword.TrampleAbility;
import mage.abilities.mana.ManaAbility;
import mage.abilities.mana.TriggeredManaAbility;
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.SetTargetPointer;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.common.FilterControlledLandPermanent;
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;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTarget;
/** /**
@ -68,7 +63,10 @@ public class VorinclexVoiceOfHunger extends CardImpl {
this.addAbility(TrampleAbility.getInstance()); this.addAbility(TrampleAbility.getInstance());
// Whenever you tap a land for mana, add one mana to your mana pool of any type that land produced. // Whenever you tap a land for mana, add one mana to your mana pool of any type that land produced.
this.addAbility(new VorinclexTriggeredAbility1()); this.addAbility(new TapForManaAllTriggeredManaAbility(
new AddManaOfAnyColorTargetCanProduceEffect(),
new FilterControlledLandPermanent("you tap a land"),
SetTargetPointer.PERMANENT));
// Whenever an opponent taps a land for mana, that land doesn't untap during its controller's next untap step. // Whenever an opponent taps a land for mana, that land doesn't untap during its controller's next untap step.
this.addAbility(new VorinclexTriggeredAbility2()); this.addAbility(new VorinclexTriggeredAbility2());
@ -84,121 +82,6 @@ public class VorinclexVoiceOfHunger extends CardImpl {
} }
} }
class VorinclexTriggeredAbility1 extends TriggeredManaAbility {
private static final String staticText = "Whenever you tap a land for mana, add one mana to your mana pool of any type that land produced.";
public VorinclexTriggeredAbility1() {
super(Zone.BATTLEFIELD, new VorinclexEffect());
}
public VorinclexTriggeredAbility1(VorinclexTriggeredAbility1 ability) {
super(ability);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.TAPPED_FOR_MANA && event.getPlayerId().equals(controllerId)) {
Permanent permanent = game.getPermanentOrLKIBattlefield(event.getSourceId());
if (permanent != null && permanent.getCardType().contains(CardType.LAND)) {
getEffects().get(0).setTargetPointer(new FixedTarget(permanent.getId()));
return true;
}
}
return false;
}
@Override
public VorinclexTriggeredAbility1 copy() {
return new VorinclexTriggeredAbility1(this);
}
@Override
public String getRule() {
return staticText;
}
}
class VorinclexEffect extends ManaEffect {
public VorinclexEffect() {
super();
staticText = "add one mana to your mana pool of any type that land produced";
}
public VorinclexEffect(final VorinclexEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent land = game.getPermanentOrLKIBattlefield(this.targetPointer.getFirst(game, source));
Abilities<ManaAbility> mana = land.getAbilities().getManaAbilities(Zone.BATTLEFIELD);
Mana types = new Mana();
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.getColorless() > 0) {
choice.getChoices().add("Colorless");
}
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);
return true;
case "Blue":
player.getManaPool().addMana(Mana.BlueMana, game, source);
return true;
case "Red":
player.getManaPool().addMana(Mana.RedMana, game, source);
return true;
case "Green":
player.getManaPool().addMana(Mana.GreenMana, game, source);
return true;
case "White":
player.getManaPool().addMana(Mana.WhiteMana, game, source);
return true;
case "Colorless":
player.getManaPool().addMana(Mana.ColorlessMana, game, source);
return true;
}
}
return true;
}
@Override
public VorinclexEffect copy() {
return new VorinclexEffect(this);
}
}
class VorinclexTriggeredAbility2 extends TriggeredAbilityImpl { class VorinclexTriggeredAbility2 extends TriggeredAbilityImpl {
private static final String staticText = "Whenever an opponent taps a land for mana, that land doesn't untap during its controller's next untap step."; private static final String staticText = "Whenever an opponent taps a land for mana, that land doesn't untap during its controller's next untap step.";

View file

@ -33,12 +33,10 @@ import mage.abilities.Ability;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount; import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
import mage.abilities.effects.common.DynamicManaEffect; import mage.abilities.mana.DynamicManaAbility;
import mage.abilities.mana.SimpleManaAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterControlledPermanent; import mage.filter.common.FilterControlledPermanent;
import mage.filter.predicate.mageobject.SubtypePredicate; import mage.filter.predicate.mageobject.SubtypePredicate;
@ -59,9 +57,7 @@ public class CabalCoffers extends CardImpl {
this.expansionSetCode = "HOP"; this.expansionSetCode = "HOP";
// {2}, {tap}: Add {B} to your mana pool for each Swamp you control. // {2}, {tap}: Add {B} to your mana pool for each Swamp you control.
Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD, Ability ability = new DynamicManaAbility(Mana.BlackMana, new PermanentsOnBattlefieldCount(filter), new GenericManaCost(2));
new DynamicManaEffect(Mana.BlackMana, new PermanentsOnBattlefieldCount(filter)),
new GenericManaCost(2));
ability.addCost(new TapSourceCost()); ability.addCost(new TapSourceCost());
this.addAbility(ability); this.addAbility(ability);
} }

View file

@ -43,6 +43,7 @@ import mage.abilities.mana.ManaAbility;
import mage.abilities.mana.builder.ConditionalManaBuilder; import mage.abilities.mana.builder.ConditionalManaBuilder;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.choices.ChoiceColor; import mage.choices.ChoiceColor;
import mage.constants.Outcome;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
@ -114,7 +115,6 @@ class VedalkenEngineerAbility extends ManaAbility {
public VedalkenEngineerAbility(Cost cost, int amount, ConditionalManaBuilder manaBuilder) { public VedalkenEngineerAbility(Cost cost, int amount, ConditionalManaBuilder manaBuilder) {
super(Zone.BATTLEFIELD, new VedalkenEngineerEffect(amount, manaBuilder), cost); super(Zone.BATTLEFIELD, new VedalkenEngineerEffect(amount, manaBuilder), cost);
this.addChoice(new ChoiceColor());
this.netMana.add(new Mana(0,0,0,0,0,0, amount)); this.netMana.add(new Mana(0,0,0,0,0,0, amount));
} }
@ -153,31 +153,38 @@ class VedalkenEngineerEffect extends ManaEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (player == null) { if (controller == null) {
return false; return false;
} }
boolean result = false; Mana mana = new Mana();
for (int i = 0; i < amount; i++) { ChoiceColor choiceColor = (ChoiceColor) source.getChoices().get(0);
ChoiceColor choice = (ChoiceColor) source.getChoices().get(0); while (!controller.choose(Outcome.Benefit, choiceColor, game)) {
Mana mana = null; if (!controller.isInGame()) {
if (choice.getColor().isBlack()) { return false;
mana = manaBuilder.setMana(Mana.BlackMana(1), source, game).build();
} else if (choice.getColor().isBlue()) {
mana = manaBuilder.setMana(Mana.BlueMana(1), source, game).build();
} else if (choice.getColor().isRed()) {
mana = manaBuilder.setMana(Mana.RedMana(1), source, game).build();
} else if (choice.getColor().isGreen()) {
mana = manaBuilder.setMana(Mana.GreenMana(1), source, game).build();
} else if (choice.getColor().isWhite()) {
mana = manaBuilder.setMana(Mana.WhiteMana(1), source, game).build();
}
if (mana != null) {
player.getManaPool().addMana(mana, game, source);
result = true;
} }
} }
return result; if (choiceColor.getColor().isBlack()) {
mana.setBlack(amount);
} else if (choiceColor.getColor().isBlue()) {
mana.setBlue(amount);
} else if (choiceColor.getColor().isRed()) {
mana.setRed(amount);
} else if (choiceColor.getColor().isGreen()) {
mana.setGreen(amount);
} else if (choiceColor.getColor().isWhite()) {
mana.setWhite(amount);
} }
Mana condMana = manaBuilder.setMana(mana, source, game).build();
checkToFirePossibleEvents(condMana, game, source);
controller.getManaPool().addMana(condMana, game, source);
return true;
}
@Override
public Mana getMana(Game game, Ability source) {
return null;
}
} }

View file

@ -28,23 +28,19 @@
package mage.sets.ravnika; package mage.sets.ravnika;
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.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTappedAbility; import mage.abilities.common.EntersBattlefieldTappedAbility;
import mage.abilities.common.PutIntoGraveFromBattlefieldTriggeredAbility; import mage.abilities.common.PutIntoGraveFromBattlefieldTriggeredAbility;
import mage.abilities.costs.common.SacrificeSourceCost; import mage.abilities.costs.common.SacrificeSourceCost;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.common.AddManaInAnyCombinationEffect;
import mage.abilities.effects.common.DrawCardSourceControllerEffect; import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.mana.SimpleManaAbility; import mage.abilities.mana.SimpleManaAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.choices.ChoiceColor; import mage.constants.CardType;
import mage.game.Game; import mage.constants.Rarity;
import mage.players.Player; import mage.constants.Zone;
/** /**
* *
@ -58,12 +54,10 @@ public class Terrarion extends CardImpl {
// Terrarion enters the battlefield tapped. // Terrarion enters the battlefield tapped.
this.addAbility(new EntersBattlefieldTappedAbility()); this.addAbility(new EntersBattlefieldTappedAbility());
// {2}, {tap}, Sacrifice Terrarion: Add two mana in any combination of colors to your mana pool. // {2}, {T}, Sacrifice Terrarion: Add two mana in any combination of colors to your mana pool.
Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD, new TerrarionManaEffect(), new GenericManaCost(2)); Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD, new AddManaInAnyCombinationEffect(2), new GenericManaCost(2));
ability.addCost(new TapSourceCost()); ability.addCost(new TapSourceCost());
ability.addCost(new SacrificeSourceCost()); ability.addCost(new SacrificeSourceCost());
ability.addChoice(new ChoiceColor());
ability.addChoice(new ChoiceColor());
this.addAbility(ability); this.addAbility(ability);
// When Terrarion is put into a graveyard from the battlefield, draw a card. // When Terrarion is put into a graveyard from the battlefield, draw a card.
this.addAbility(new PutIntoGraveFromBattlefieldTriggeredAbility(new DrawCardSourceControllerEffect(1))); this.addAbility(new PutIntoGraveFromBattlefieldTriggeredAbility(new DrawCardSourceControllerEffect(1)));
@ -78,51 +72,3 @@ public class Terrarion extends CardImpl {
return new Terrarion(this); return new Terrarion(this);
} }
} }
class TerrarionManaEffect extends ManaEffect {
public TerrarionManaEffect() {
super();
this.staticText = "Add two mana in any combination of colors to your mana pool";
}
public TerrarionManaEffect(final TerrarionManaEffect effect) {
super(effect);
}
@Override
public TerrarionManaEffect copy() {
return new TerrarionManaEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
boolean result = false;
for (int i = 0; i < 2; i++) {
ChoiceColor choice = (ChoiceColor) source.getChoices().get(i);
Mana mana = null;
if (choice.getColor().isBlack()) {
mana = Mana.BlackMana(1);
} else if (choice.getColor().isBlue()) {
mana = Mana.BlueMana(1);
} else if (choice.getColor().isRed()) {
mana = Mana.RedMana(1);
} else if (choice.getColor().isGreen()) {
mana = Mana.GreenMana(1);
} else if (choice.getColor().isWhite()) {
mana = Mana.WhiteMana(1);
}
if (mana != null) {
player.getManaPool().addMana(mana, game, source);
result = true;
}
}
return result;
}
}

View file

@ -28,18 +28,11 @@
package mage.sets.shadowmoor; package mage.sets.shadowmoor;
import java.util.UUID; import java.util.UUID;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.AddManaInAnyCombinationEffect;
import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.Mana;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.ManaEffect;
import mage.cards.CardImpl;
import mage.choices.ChoiceColor;
import mage.constants.Outcome;
import mage.game.Game;
import mage.players.Player;
/** /**
* *
@ -55,7 +48,7 @@ public class Manamorphose extends CardImpl {
this.color.setGreen(true); this.color.setGreen(true);
// Add two mana in any combination of colors to your mana pool. // Add two mana in any combination of colors to your mana pool.
this.getSpellAbility().addEffect(new ManamorphoseEffect()); this.getSpellAbility().addEffect(new AddManaInAnyCombinationEffect(2));
// Draw a card. // Draw a card.
this.getSpellAbility().addEffect(new DrawCardSourceControllerEffect(1)); this.getSpellAbility().addEffect(new DrawCardSourceControllerEffect(1));
@ -70,68 +63,3 @@ public class Manamorphose extends CardImpl {
return new Manamorphose(this); return new Manamorphose(this);
} }
} }
class ManamorphoseEffect extends ManaEffect {
public ManamorphoseEffect() {
super();
this.staticText = "Add two mana in any combination of colors to your mana pool";
}
public ManamorphoseEffect(final ManamorphoseEffect effect) {
super(effect);
}
@Override
public ManamorphoseEffect copy() {
return new ManamorphoseEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
boolean result = false;
for (int i = 0; i < 2; i++) {
ChoiceColor choice = getManaChoice(player, game);
if (choice == null) {
return false;
}
Mana mana = null;
if (choice.getColor().isBlack()) {
mana = Mana.BlackMana(1);
} else if (choice.getColor().isBlue()) {
mana = Mana.BlueMana(1);
} else if (choice.getColor().isRed()) {
mana = Mana.RedMana(1);
} else if (choice.getColor().isGreen()) {
mana = Mana.GreenMana(1);
} else if (choice.getColor().isWhite()) {
mana = Mana.WhiteMana(1);
}
if (mana != null) {
player.getManaPool().addMana(mana, game, source);
result = true;
}
}
return result;
}
private ChoiceColor getManaChoice(Player controller, Game game) {
ChoiceColor choice = new ChoiceColor();
while (!choice.isChosen()) {
controller.choose(Outcome.PutManaInPool, choice, game);
if (!controller.isInGame()) {
return null;
}
}
return choice;
}
}

View file

@ -28,24 +28,16 @@
package mage.sets.shardsofalara; package mage.sets.shardsofalara;
import java.util.UUID; import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.TapForManaAllTriggeredManaAbility;
import mage.abilities.effects.common.AddManaOfAnyColorTargetCanProduceEffect;
import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.Zone; import mage.constants.SetTargetPointer;
import mage.MageInt; import mage.filter.common.FilterLandPermanent;
import mage.Mana; import mage.filter.predicate.Predicates;
import mage.abilities.Abilities; import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.abilities.Ability;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.mana.ManaAbility;
import mage.abilities.mana.TriggeredManaAbility;
import mage.cards.CardImpl;
import mage.choices.Choice;
import mage.choices.ChoiceImpl;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
/** /**
* *
@ -53,6 +45,16 @@ import mage.target.targetpointer.FixedTarget;
*/ */
public class KeeperOfProgenitus extends CardImpl { public class KeeperOfProgenitus extends CardImpl {
private static final FilterLandPermanent filter = new FilterLandPermanent("a player taps a Mountain, Forest, or Plains");
static {
filter.add(Predicates.or(
new SubtypePredicate("Mountain"),
new SubtypePredicate("Forest"),
new SubtypePredicate("Plains")
));
}
public KeeperOfProgenitus(UUID ownerId) { public KeeperOfProgenitus(UUID ownerId) {
super(ownerId, 135, "Keeper of Progenitus", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{3}{G}"); super(ownerId, 135, "Keeper of Progenitus", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{3}{G}");
this.expansionSetCode = "ALA"; this.expansionSetCode = "ALA";
@ -64,7 +66,9 @@ public class KeeperOfProgenitus extends CardImpl {
this.toughness = new MageInt(3); this.toughness = new MageInt(3);
// Whenever a player taps a Mountain, Forest, or Plains for mana, that player adds one mana to his or her mana pool of any type that land produced. // Whenever a player taps a Mountain, Forest, or Plains for mana, that player adds one mana to his or her mana pool of any type that land produced.
this.addAbility(new HeartbeatOfSpringAbility()); this.addAbility(new TapForManaAllTriggeredManaAbility(
new AddManaOfAnyColorTargetCanProduceEffect(),
filter, SetTargetPointer.PERMANENT));
} }
public KeeperOfProgenitus(final KeeperOfProgenitus card) { public KeeperOfProgenitus(final KeeperOfProgenitus card) {
@ -76,127 +80,3 @@ public class KeeperOfProgenitus extends CardImpl {
return new KeeperOfProgenitus(this); return new KeeperOfProgenitus(this);
} }
} }
class HeartbeatOfSpringAbility extends TriggeredManaAbility {
private static final String staticText = "Whenever a player taps a Mountain, Forest, or Plains for mana, that player adds one mana to his or her mana pool of any type that land produced.";
public HeartbeatOfSpringAbility() {
super(Zone.BATTLEFIELD, new HeartbeatOfSpringEffect());
}
public HeartbeatOfSpringAbility(HeartbeatOfSpringAbility ability) {
super(ability);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.TAPPED_FOR_MANA ) {
Permanent permanent = game.getPermanent(event.getSourceId());
if (permanent == null) {
permanent = (Permanent) game.getLastKnownInformation(event.getSourceId(), Zone.BATTLEFIELD);
}
if (permanent != null && permanent.getCardType().contains(CardType.LAND)){
if(permanent.getSubtype().contains("Mountain") || permanent.getSubtype().contains("Forest") || permanent.getSubtype().contains("Plains")){
getEffects().get(0).setTargetPointer(new FixedTarget(permanent.getId()));
return true;
}
}
}
return false;
}
@Override
public HeartbeatOfSpringAbility copy() {
return new HeartbeatOfSpringAbility(this);
}
@Override
public String getRule() {
return staticText;
}
}
class HeartbeatOfSpringEffect extends ManaEffect {
public HeartbeatOfSpringEffect() {
super();
staticText = "that player adds one mana to his or her mana pool of any type that land produced";
}
public HeartbeatOfSpringEffect(final HeartbeatOfSpringEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent land = game.getPermanent(this.targetPointer.getFirst(game, source));
Player player = game.getPlayer(land.getControllerId());
Abilities<ManaAbility> mana = land.getAbilities().getManaAbilities(Zone.BATTLEFIELD);
Mana types = new Mana();
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.getColorless() > 0) {
choice.getChoices().add("Colorless");
}
if (choice.getChoices().size() > 0) {
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);
return true;
}
else if (choice.getChoice().equals("Blue")) {
player.getManaPool().addMana(Mana.BlueMana, game, source);
return true;
}
else if (choice.getChoice().equals("Red")) {
player.getManaPool().addMana(Mana.RedMana, game, source);
return true;
}
else if (choice.getChoice().equals("Green")) {
player.getManaPool().addMana(Mana.GreenMana, game, source);
return true;
}
else if (choice.getChoice().equals("White")) {
player.getManaPool().addMana(Mana.WhiteMana, game, source);
return true;
}
else if (choice.getChoice().equals("Colorless")) {
player.getManaPool().addMana(Mana.ColorlessMana, game, source);
return true;
}
}
return true;
}
@Override
public HeartbeatOfSpringEffect copy() {
return new HeartbeatOfSpringEffect(this);
}
}

View file

@ -62,7 +62,7 @@ public class SacellumGodspeaker extends CardImpl {
this.power = new MageInt(2); this.power = new MageInt(2);
this.toughness = new MageInt(2); this.toughness = new MageInt(2);
// {tap}: Reveal any number of creature cards with power 5 or greater from your hand. Add {G} to your mana pool for each card revealed this way. // {T}: Reveal any number of creature cards with power 5 or greater from your hand. Add {G} to your mana pool for each card revealed this way.
this.addAbility(new SimpleManaAbility(Zone.BATTLEFIELD, new SacellumGodspeakerEffect(), new TapSourceCost())); this.addAbility(new SimpleManaAbility(Zone.BATTLEFIELD, new SacellumGodspeakerEffect(), new TapSourceCost()));
} }
@ -103,9 +103,18 @@ class SacellumGodspeakerEffect extends ManaEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
TargetCardInHand target = new TargetCardInHand(0,Integer.MAX_VALUE, filter); TargetCardInHand target = new TargetCardInHand(0,Integer.MAX_VALUE, filter);
if (target.choose(Outcome.Benefit, source.getControllerId(), source.getSourceId(), game)) { if (target.choose(Outcome.Benefit, source.getControllerId(), source.getSourceId(), game)) {
game.getPlayer(source.getControllerId()).getManaPool().addMana(Mana.GreenMana(target.getTargets().size()), game, source); Mana mana = Mana.GreenMana(target.getTargets().size());
checkToFirePossibleEvents(mana, game, source);
game.getPlayer(source.getControllerId()).getManaPool().addMana(mana, game, source);
return true; return true;
} }
return false; return false;
} }
@Override
public Mana getMana(Game game, Ability source) {
return null;
}
} }

View file

@ -30,8 +30,8 @@ package mage.sets.stronghold;
import java.util.UUID; import java.util.UUID;
import mage.Mana; import mage.Mana;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.common.AddManaToManaPoolTargetControllerEffect;
import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.keyword.EnchantAbility; import mage.abilities.keyword.EnchantAbility;
import mage.abilities.mana.TriggeredManaAbility; import mage.abilities.mana.TriggeredManaAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -42,9 +42,9 @@ 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;
import mage.players.Player;
import mage.target.TargetPermanent; import mage.target.TargetPermanent;
import mage.target.common.TargetLandPermanent; import mage.target.common.TargetLandPermanent;
import mage.target.targetpointer.FixedTarget;
/** /**
* *
@ -66,7 +66,6 @@ public class Overgrowth extends CardImpl {
Ability ability = new EnchantAbility(auraTarget.getTargetName()); Ability ability = new EnchantAbility(auraTarget.getTargetName());
this.addAbility(ability); this.addAbility(ability);
// Whenever enchanted land is tapped for mana, its controller adds {G}{G} to his or her mana pool. // Whenever enchanted land is tapped for mana, its controller adds {G}{G} to his or her mana pool.
this.addAbility(new OvergrowthTriggeredAbility()); this.addAbility(new OvergrowthTriggeredAbility());
} }
@ -84,7 +83,7 @@ class OvergrowthTriggeredAbility extends TriggeredManaAbility {
public OvergrowthTriggeredAbility() { public OvergrowthTriggeredAbility() {
super(Zone.BATTLEFIELD, new OvergrowthEffect()); super(Zone.BATTLEFIELD, new AddManaToManaPoolTargetControllerEffect(new Mana(0,2,0,0,0,0,0), "his or her"));
} }
public OvergrowthTriggeredAbility(final OvergrowthTriggeredAbility ability) { public OvergrowthTriggeredAbility(final OvergrowthTriggeredAbility ability) {
@ -101,9 +100,13 @@ class OvergrowthTriggeredAbility extends TriggeredManaAbility {
Permanent enchantment = game.getPermanent(this.getSourceId()); Permanent enchantment = game.getPermanent(this.getSourceId());
if(event.getType() == GameEvent.EventType.TAPPED_FOR_MANA){ if(event.getType() == GameEvent.EventType.TAPPED_FOR_MANA){
if (enchantment != null && event.getSourceId().equals(enchantment.getAttachedTo())) { if (enchantment != null && event.getSourceId().equals(enchantment.getAttachedTo())) {
Permanent enchanted = game.getPermanent(enchantment.getAttachedTo());
if (enchanted != null) {
getEffects().get(0).setTargetPointer(new FixedTarget(enchanted.getControllerId()));
return true; return true;
} }
} }
}
return false; return false;
} }
@ -113,36 +116,3 @@ class OvergrowthTriggeredAbility extends TriggeredManaAbility {
return "Whenever enchanted land is tapped for mana, its controller adds {G}{G} to his or her mana pool"; return "Whenever enchanted land is tapped for mana, its controller adds {G}{G} to his or her mana pool";
} }
} }
class OvergrowthEffect extends ManaEffect {
public OvergrowthEffect() {
super();
staticText = "its controller adds {G}{G} to his or her mana pool";
}
public OvergrowthEffect(final OvergrowthEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent enchantment = game.getPermanent(source.getSourceId());
if(enchantment != null){
Permanent land = game.getPermanent(enchantment.getAttachedTo());
if(land != null){
Player player = game.getPlayer(land.getControllerId());
if (player != null) {
player.getManaPool().addMana(Mana.GreenMana(2), game, source);
return true;
}
}
}
return false;
}
@Override
public OvergrowthEffect copy() {
return new OvergrowthEffect(this);
}
}

View file

@ -30,7 +30,7 @@ package mage.sets.tempest;
import java.util.UUID; import java.util.UUID;
import static mage.Mana.GreenMana; import static mage.Mana.GreenMana;
import mage.abilities.common.BeginningOfPreCombatMainTriggeredAbility; import mage.abilities.common.BeginningOfPreCombatMainTriggeredAbility;
import mage.abilities.effects.common.AddManaToManaPoolEffect; import mage.abilities.effects.common.AddManaToManaPoolTargetControllerEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Rarity; import mage.constants.Rarity;
@ -51,7 +51,7 @@ public class EladamrisVineyard extends CardImpl {
// At the beginning of each player's precombat main phase, add {G}{G} to that player's mana pool. // At the beginning of each player's precombat main phase, add {G}{G} to that player's mana pool.
this.addAbility(new BeginningOfPreCombatMainTriggeredAbility( this.addAbility(new BeginningOfPreCombatMainTriggeredAbility(
Zone.BATTLEFIELD, new AddManaToManaPoolEffect(GreenMana(2), "that player's"), TargetController.ANY, false, true)); Zone.BATTLEFIELD, new AddManaToManaPoolTargetControllerEffect(GreenMana(2), "that player's"), TargetController.ANY, false, true));
} }
public EladamrisVineyard(final EladamrisVineyard card) { public EladamrisVineyard(final EladamrisVineyard card) {

View file

@ -146,26 +146,29 @@ class ReflectingPoolEffect extends ManaEffect {
player.choose(outcome, choice, game); player.choose(outcome, choice, game);
} }
if (choice.getChoice() != null) { if (choice.getChoice() != null) {
Mana mana = new Mana();
switch (choice.getChoice()) { switch (choice.getChoice()) {
case "Black": case "Black":
player.getManaPool().addMana(Mana.BlackMana, game, source); mana.setBlack(1);
break; break;
case "Blue": case "Blue":
player.getManaPool().addMana(Mana.BlueMana, game, source); mana.setBlue(1);
break; break;
case "Red": case "Red":
player.getManaPool().addMana(Mana.RedMana, game, source); mana.setRed(1);
break; break;
case "Green": case "Green":
player.getManaPool().addMana(Mana.GreenMana, game, source); mana.setGreen(1);
break; break;
case "White": case "White":
player.getManaPool().addMana(Mana.WhiteMana, game, source); mana.setWhite(1);
break; break;
case "Colorless": case "Colorless":
player.getManaPool().addMana(Mana.ColorlessMana, game, source); mana.setColorless(1);
break; break;
} }
checkToFirePossibleEvents(mana, game, source);
player.getManaPool().addMana(mana, game, source);
return true; return true;
} }
return false; return false;
@ -213,6 +216,11 @@ class ReflectingPoolEffect extends ManaEffect {
return types; return types;
} }
@Override
public Mana getMana(Game game, Ability source) {
return null;
}
@Override @Override
public ReflectingPoolEffect copy() { public ReflectingPoolEffect copy() {
return new ReflectingPoolEffect(this); return new ReflectingPoolEffect(this);

View file

@ -53,7 +53,7 @@ public class DoublingCube extends CardImpl {
super(ownerId, 321, "Doubling Cube", Rarity.RARE, new CardType[]{CardType.ARTIFACT}, "{2}"); super(ownerId, 321, "Doubling Cube", Rarity.RARE, new CardType[]{CardType.ARTIFACT}, "{2}");
this.expansionSetCode = "10E"; this.expansionSetCode = "10E";
// {3}, {tap}: Double the amount of each type of mana in your mana pool. // {3}, {T}: Double the amount of each type of mana in your mana pool.
Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD, new DoublingCubeEffect(), new ManaCostsImpl("{3}")); Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD, new DoublingCubeEffect(), new ManaCostsImpl("{3}"));
ability.addCost(new TapSourceCost()); ability.addCost(new TapSourceCost());
this.addAbility(ability); this.addAbility(ability);
@ -94,10 +94,18 @@ class DoublingCubeEffect extends ManaEffect {
int greenMana = pool.getGreen(); int greenMana = pool.getGreen();
int redMana = pool.getRed(); int redMana = pool.getRed();
int colorlessMana = pool.getColorless(); int colorlessMana = pool.getColorless();
pool.addMana(new Mana(redMana, greenMana, blueMana, whiteMana, blackMana, colorlessMana, 0), game, source); Mana mana = new Mana(redMana, greenMana, blueMana, whiteMana, blackMana, colorlessMana, 0);
checkToFirePossibleEvents(mana, game, source);
pool.addMana(mana, game, source);
return true; return true;
} }
@Override
public Mana getMana(Game game, Ability source) {
return null;
}
@Override @Override
public DoublingCubeEffect copy() { public DoublingCubeEffect copy() {
return new DoublingCubeEffect(this); return new DoublingCubeEffect(this);

View file

@ -29,17 +29,14 @@ package mage.sets.tenth;
import java.util.UUID; import java.util.UUID;
import mage.constants.Zone;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.abilities.TriggeredAbilityImpl; import mage.abilities.common.TapForManaAllTriggeredAbility;
import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.effects.common.DamageTargetEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.game.Game; import mage.constants.SetTargetPointer;
import mage.game.events.GameEvent; import mage.filter.common.FilterLandPermanent;
import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget;
/** /**
* *
@ -54,7 +51,9 @@ public class Manabarbs extends CardImpl {
this.color.setRed(true); this.color.setRed(true);
// Whenever a player taps a land for mana, Manabarbs deals 1 damage to that player. // Whenever a player taps a land for mana, Manabarbs deals 1 damage to that player.
this.addAbility(new ManabarbsTriggeredAbility()); this.addAbility(new TapForManaAllTriggeredAbility(
new DamageTargetEffect(1, true, "that player"),
new FilterLandPermanent("a player taps a land"), SetTargetPointer.PLAYER));
} }
public Manabarbs(final Manabarbs card) { public Manabarbs(final Manabarbs card) {
@ -66,41 +65,3 @@ public class Manabarbs extends CardImpl {
return new Manabarbs(this); return new Manabarbs(this);
} }
} }
class ManabarbsTriggeredAbility extends TriggeredAbilityImpl {
private static final String staticText = "Whenever a player taps a land for mana, Manabarbs deals 1 damage to that player.";
public ManabarbsTriggeredAbility() {
super(Zone.BATTLEFIELD, new DamageTargetEffect(1));
}
public ManabarbsTriggeredAbility(ManabarbsTriggeredAbility ability) {
super(ability);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.TAPPED_FOR_MANA) {
Permanent permanent = game.getPermanent(event.getSourceId());
if (permanent == null) {
permanent = (Permanent) game.getLastKnownInformation(event.getSourceId(), Zone.BATTLEFIELD);
}
if (permanent != null && permanent.getCardType().contains(CardType.LAND)) {
getEffects().get(0).setTargetPointer(new FixedTarget(permanent.getControllerId()));
return true;
}
}
return false;
}
@Override
public ManabarbsTriggeredAbility copy() {
return new ManabarbsTriggeredAbility(this);
}
@Override
public String getRule() {
return staticText;
}
}

View file

@ -131,6 +131,7 @@ class NykthosDynamicManaEffect extends ManaEffect {
choice.setMessage("Choose a color for devotion of Nykthos"); choice.setMessage("Choose a color for devotion of Nykthos");
if (controller.choose(outcome, choice, game)) { if (controller.choose(outcome, choice, game)) {
computeMana(choice.getChoice(), game, source); computeMana(choice.getChoice(), game, source);
checkToFirePossibleEvents(computedMana, game, source);
game.getPlayer(source.getControllerId()).getManaPool().addMana(computedMana, game, source); game.getPlayer(source.getControllerId()).getManaPool().addMana(computedMana, game, source);
return true; return true;
} }
@ -139,6 +140,12 @@ class NykthosDynamicManaEffect extends ManaEffect {
} }
@Override
public Mana getMana(Game game, Ability source) {
return null;
}
public Mana computeMana(String color, Game game, Ability source){ public Mana computeMana(String color, Game game, Ability source){
this.computedMana.clear(); this.computedMana.clear();
if (color !=null && !color.isEmpty()) { if (color !=null && !color.isEmpty()) {

View file

@ -28,9 +28,6 @@
package mage.sets.timespiral; package mage.sets.timespiral;
import java.util.UUID; import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
@ -38,6 +35,8 @@ import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.common.PutOnLibraryTargetEffect; import mage.abilities.effects.common.PutOnLibraryTargetEffect;
import mage.abilities.mana.ColorlessManaAbility; import mage.abilities.mana.ColorlessManaAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.common.FilterArtifactCard; import mage.filter.common.FilterArtifactCard;
import mage.target.common.TargetCardInYourGraveyard; import mage.target.common.TargetCardInYourGraveyard;

View file

@ -34,7 +34,7 @@ import mage.abilities.costs.common.RemoveVariableCountersSourceCost;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.dynamicvalue.common.RemovedCountersForCostValue; import mage.abilities.dynamicvalue.common.RemovedCountersForCostValue;
import mage.abilities.effects.common.ManaInAnyCombinationEffect; import mage.abilities.effects.common.AddManaInAnyCombinationEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.mana.ColorlessManaAbility; import mage.abilities.mana.ColorlessManaAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -62,7 +62,7 @@ public class CalciformPools extends CardImpl {
this.addAbility(ability); this.addAbility(ability);
// {1}, Remove X storage counters from Calciform Pools: Add X mana in any combination of {W} and/or {U} to your mana pool. // {1}, Remove X storage counters from Calciform Pools: Add X mana in any combination of {W} and/or {U} to your mana pool.
ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, ability = new SimpleActivatedAbility(Zone.BATTLEFIELD,
new ManaInAnyCombinationEffect(new RemovedCountersForCostValue(), ColoredManaSymbol.W, ColoredManaSymbol.U), new AddManaInAnyCombinationEffect(new RemovedCountersForCostValue(), ColoredManaSymbol.W, ColoredManaSymbol.U),
new GenericManaCost(1)); new GenericManaCost(1));
ability.addCost(new RemoveVariableCountersSourceCost(CounterType.STORAGE.createInstance())); ability.addCost(new RemoveVariableCountersSourceCost(CounterType.STORAGE.createInstance()));
this.addAbility(ability); this.addAbility(ability);

View file

@ -114,7 +114,10 @@ class MetalworkerManaEffect extends ManaEffect {
cards.add(player.getHand().get(uuid, game)); cards.add(player.getHand().get(uuid, game));
} }
player.revealCards("Revealed card", cards, game); player.revealCards("Revealed card", cards, game);
player.getManaPool().addMana(Mana.ColorlessMana(target.getTargets().size()*2), game, source); Mana mana = Mana.ColorlessMana(target.getTargets().size()*2);
checkToFirePossibleEvents(mana, game, source);
player.getManaPool().addMana(mana, game, source);
} }
} }
@ -122,4 +125,10 @@ class MetalworkerManaEffect extends ManaEffect {
return true; return true;
} }
@Override
public Mana getMana(Game game, Ability source) {
return null;
}
} }

View file

@ -181,26 +181,41 @@ class CarpetOfFlowersEffect extends ManaEffect {
choiceCount.setMessage("Choose number of mana"); choiceCount.setMessage("Choose number of mana");
controller.choose(Outcome.PutManaInPool, choiceCount, game); controller.choose(Outcome.PutManaInPool, choiceCount, game);
int count = Integer.parseInt(choiceCount.getChoice()); int count = Integer.parseInt(choiceCount.getChoice());
if (choice.getColor().isBlack()) { if (count > 0) {
controller.getManaPool().addMana(new Mana(0, 0, 0, 0, count, 0, 0), game, source); Mana mana = new Mana();
return true; switch (choice.getChoice()) {
} else if (choice.getColor().isBlue()) { case "Black":
controller.getManaPool().addMana(new Mana(0, 0, count, 0, 0, 0, 0), game, source); mana.setBlack(count);
return true; break;
} else if (choice.getColor().isRed()) { case "Blue":
controller.getManaPool().addMana(new Mana(count, 0, 0, 0, 0, 0, 0), game, source); mana.setBlue(count);
return true; break;
} else if (choice.getColor().isGreen()) { case "Red":
controller.getManaPool().addMana(new Mana(0, count, 0, 0, 0, 0, 0), game, source); mana.setRed(count);
return true; break;
} else if (choice.getColor().isWhite()) { case "Green":
controller.getManaPool().addMana(new Mana(0, 0, 0, count, 0, 0, 0), game, source); mana.setGreen(count);
return true; break;
case "White":
mana.setWhite(count);
break;
case "Colorless":
mana.setColorless(count);
break;
} }
checkToFirePossibleEvents(mana, game, source);
controller.getManaPool().addMana(mana, game, source);
}
return true;
} }
return false; return false;
} }
@Override
public Mana getMana(Game game, Ability source) {
return null;
}
@Override @Override
public CarpetOfFlowersEffect copy() { public CarpetOfFlowersEffect copy() {
return new CarpetOfFlowersEffect(this); return new CarpetOfFlowersEffect(this);

View file

@ -28,8 +28,10 @@
package mage.sets.urzassaga; package mage.sets.urzassaga;
import java.util.UUID; import java.util.UUID;
import mage.Mana;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.common.AddManaOfAnyColorEffect; import mage.abilities.effects.common.AddManaAnyColorAttachedControllerEffect;
import mage.abilities.effects.common.AddManaToManaPoolTargetControllerEffect;
import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.AttachEffect;
import mage.abilities.keyword.EnchantAbility; import mage.abilities.keyword.EnchantAbility;
import mage.abilities.mana.TriggeredManaAbility; import mage.abilities.mana.TriggeredManaAbility;
@ -43,6 +45,7 @@ import mage.game.events.GameEvent;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.target.TargetPermanent; import mage.target.TargetPermanent;
import mage.target.common.TargetLandPermanent; import mage.target.common.TargetLandPermanent;
import mage.target.targetpointer.FixedTarget;
/** /**
* *
@ -81,7 +84,7 @@ class FertileGroundTriggeredAbility extends TriggeredManaAbility {
public FertileGroundTriggeredAbility() { public FertileGroundTriggeredAbility() {
super(Zone.BATTLEFIELD, new AddManaOfAnyColorEffect()); super(Zone.BATTLEFIELD, new AddManaAnyColorAttachedControllerEffect());
} }
public FertileGroundTriggeredAbility(FertileGroundTriggeredAbility ability) { public FertileGroundTriggeredAbility(FertileGroundTriggeredAbility ability) {
@ -90,12 +93,16 @@ class FertileGroundTriggeredAbility extends TriggeredManaAbility {
@Override @Override
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
Permanent enchantment = game.getPermanent(this.getSourceId());
if(event.getType() == GameEvent.EventType.TAPPED_FOR_MANA){ if(event.getType() == GameEvent.EventType.TAPPED_FOR_MANA){
Permanent enchantment = game.getPermanent(this.getSourceId());
if (enchantment != null && event.getSourceId().equals(enchantment.getAttachedTo())) { if (enchantment != null && event.getSourceId().equals(enchantment.getAttachedTo())) {
Permanent enchanted = game.getPermanent(enchantment.getAttachedTo());
if (enchanted != null) {
getEffects().get(0).setTargetPointer(new FixedTarget(enchanted.getControllerId()));
return true; return true;
} }
} }
}
return false; return false;
} }

View file

@ -28,23 +28,16 @@
package mage.sets.urzassaga; package mage.sets.urzassaga;
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.Ability; import mage.abilities.common.TapForManaAllTriggeredManaAbility;
import mage.abilities.effects.Effect; import mage.abilities.effects.common.AddManaToManaPoolTargetControllerEffect;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.mana.TriggeredManaAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.Zone; import mage.constants.CardType;
import mage.constants.ColoredManaSymbol;
import mage.constants.Rarity;
import mage.constants.SetTargetPointer;
import mage.filter.common.FilterLandPermanent; import mage.filter.common.FilterLandPermanent;
import mage.filter.predicate.mageobject.SubtypePredicate; import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
/** /**
* *
@ -52,6 +45,11 @@ import mage.target.targetpointer.FixedTarget;
*/ */
public class VernalBloom extends CardImpl { public class VernalBloom extends CardImpl {
private static final FilterLandPermanent filter = new FilterLandPermanent("a Forest");
static {
filter.add(new SubtypePredicate("Forest"));
}
public VernalBloom(UUID ownerId) { public VernalBloom(UUID ownerId) {
super(ownerId, 281, "Vernal Bloom", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{3}{G}"); super(ownerId, 281, "Vernal Bloom", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{3}{G}");
this.expansionSetCode = "USG"; this.expansionSetCode = "USG";
@ -59,7 +57,9 @@ public class VernalBloom extends CardImpl {
this.color.setGreen(true); this.color.setGreen(true);
// Whenever a Forest is tapped for mana, its controller adds {G} to his or her mana pool. // Whenever a Forest is tapped for mana, its controller adds {G} to his or her mana pool.
this.addAbility(new VernalBloomTriggeredAbility()); this.addAbility(new TapForManaAllTriggeredManaAbility(
new AddManaToManaPoolTargetControllerEffect(new Mana(ColoredManaSymbol.G), "his or her"),
filter, SetTargetPointer.PLAYER));
} }
public VernalBloom(final VernalBloom card) { public VernalBloom(final VernalBloom card) {
@ -71,73 +71,3 @@ public class VernalBloom extends CardImpl {
return new VernalBloom(this); return new VernalBloom(this);
} }
} }
class VernalBloomTriggeredAbility extends TriggeredManaAbility {
private static final FilterLandPermanent filter = new FilterLandPermanent("Forest");
static {
filter.add(new SubtypePredicate("Forest"));
}
public VernalBloomTriggeredAbility() {
super(Zone.BATTLEFIELD, new AddGreenToTargetEffect());
this.usesStack = false;
}
public VernalBloomTriggeredAbility(VernalBloomTriggeredAbility ability) {
super(ability);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent land = game.getPermanent(event.getTargetId());
if (event.getType() == GameEvent.EventType.TAPPED_FOR_MANA && land != null && filter.match(land, game)) {
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(land.getControllerId()));
}
return true;
}
return false;
}
@Override
public VernalBloomTriggeredAbility copy() {
return new VernalBloomTriggeredAbility(this);
}
@Override
public String getRule() {
return "Whenever a Forest is tapped for mana, its controller adds {G} to his or her mana pool";
}
}
class AddGreenToTargetEffect extends ManaEffect {
public AddGreenToTargetEffect() {
super();
staticText = "its controller adds {G} to his or her mana pool";
}
public AddGreenToTargetEffect(final AddGreenToTargetEffect effect) {
super(effect);
}
@Override
public AddGreenToTargetEffect copy() {
return new AddGreenToTargetEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(this.getTargetPointer().getFirst(game, source));
if(player != null)
{
player.getManaPool().addMana(Mana.GreenMana(1), game, source);
}
return true;
}
}

View file

@ -34,7 +34,7 @@ import mage.abilities.common.delayed.AtTheBeginOMainPhaseDelayedTriggeredAbility
import mage.abilities.common.delayed.AtTheBeginOMainPhaseDelayedTriggeredAbility.PhaseSelection; import mage.abilities.common.delayed.AtTheBeginOMainPhaseDelayedTriggeredAbility.PhaseSelection;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.AddManaToManaPoolEffect; import mage.abilities.effects.common.AddManaToManaPoolTargetControllerEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
@ -95,7 +95,7 @@ class ManaDrainCounterEffect extends OneShotEffect {
game.getStack().counter(getTargetPointer().getFirst(game, source), source.getSourceId(), game); game.getStack().counter(getTargetPointer().getFirst(game, source), source.getSourceId(), game);
// mana gets added also if counter is not successful // mana gets added also if counter is not successful
int cmc = spell.getConvertedManaCost(); int cmc = spell.getConvertedManaCost();
Effect effect = new AddManaToManaPoolEffect(new Mana(0,0,0,0,0,cmc,0), "your"); Effect effect = new AddManaToManaPoolTargetControllerEffect(new Mana(0,0,0,0,0,cmc,0), "your");
effect.setTargetPointer(new FixedTarget(source.getControllerId())); effect.setTargetPointer(new FixedTarget(source.getControllerId()));
AtTheBeginOMainPhaseDelayedTriggeredAbility delayedAbility = AtTheBeginOMainPhaseDelayedTriggeredAbility delayedAbility =
new AtTheBeginOMainPhaseDelayedTriggeredAbility(effect, false, TargetController.YOU, PhaseSelection.NEXT_MAIN); new AtTheBeginOMainPhaseDelayedTriggeredAbility(effect, false, TargetController.YOU, PhaseSelection.NEXT_MAIN);

View file

@ -28,26 +28,27 @@
package mage.sets.worldwake; package mage.sets.worldwake;
import java.util.UUID; import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.MageInt; import mage.MageInt;
import mage.Mana; import mage.Mana;
import mage.abilities.Ability; import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
import mage.abilities.effects.common.ManaEffect; import mage.abilities.mana.DynamicManaAbility;
import mage.abilities.mana.BasicManaAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.choices.ChoiceColor; import mage.constants.CardType;
import mage.filter.common.FilterControlledPermanent; import mage.constants.Rarity;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.predicate.mageobject.SubtypePredicate; import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game;
import mage.players.Player;
/** /**
* @author Loki * @author Loki
*/ */
public class HarabazDruid extends CardImpl { public class HarabazDruid extends CardImpl {
private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("Allies you control");
static {
filter.add(new SubtypePredicate("Ally"));
}
public HarabazDruid(UUID ownerId) { public HarabazDruid(UUID ownerId) {
super(ownerId, 105, "Harabaz Druid", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{1}{G}"); super(ownerId, 105, "Harabaz Druid", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{1}{G}");
this.expansionSetCode = "WWK"; this.expansionSetCode = "WWK";
@ -59,8 +60,9 @@ public class HarabazDruid extends CardImpl {
this.power = new MageInt(0); this.power = new MageInt(0);
this.toughness = new MageInt(1); this.toughness = new MageInt(1);
// {tap}: Add X mana of any one color to your mana pool, where X is the number of Allies you control. // {T}: Add X mana of any one color to your mana pool, where X is the number of Allies you control.
this.addAbility(new HarabazDruidManaAbility()); this.addAbility(new DynamicManaAbility(new Mana(0,0,0,0,0,0,1), new PermanentsOnBattlefieldCount(filter),
"Add X mana of any one color to your mana pool, where X is the number of Allies you control"));
} }
public HarabazDruid(final HarabazDruid card) { public HarabazDruid(final HarabazDruid card) {
@ -72,65 +74,3 @@ public class HarabazDruid extends CardImpl {
return new HarabazDruid(this); return new HarabazDruid(this);
} }
} }
class HarabazDruidManaAbility extends BasicManaAbility {
HarabazDruidManaAbility() {
super(new HarabazDruidManaEffect());
this.addChoice(new ChoiceColor());
}
HarabazDruidManaAbility(final HarabazDruidManaAbility ability) {
super(ability);
}
@Override
public HarabazDruidManaAbility copy() {
return new HarabazDruidManaAbility(this);
}
}
class HarabazDruidManaEffect extends ManaEffect {
private static final FilterControlledPermanent filter = new FilterControlledPermanent();
static {
filter.add(new SubtypePredicate("Ally"));
}
HarabazDruidManaEffect() {
super();
staticText = "Add X mana of any one color to your mana pool, where X is the number of Allies you control";
}
HarabazDruidManaEffect(final HarabazDruidManaEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
ChoiceColor choice = (ChoiceColor) source.getChoices().get(0);
Player player = game.getPlayer(source.getControllerId());
int count = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game);
if (choice.getColor().isBlack()) {
player.getManaPool().addMana(new Mana(0, 0, 0, 0, count, 0, 0), game, source);
return true;
} else if (choice.getColor().isBlue()) {
player.getManaPool().addMana(new Mana(0, 0, count, 0, 0, 0, 0), game, source);
return true;
} else if (choice.getColor().isRed()) {
player.getManaPool().addMana(new Mana(count, 0, 0, 0, 0, 0, 0), game, source);
return true;
} else if (choice.getColor().isGreen()) {
player.getManaPool().addMana(new Mana(0, count, 0, 0, 0, 0, 0), game, source);
return true;
} else if (choice.getColor().isWhite()) {
player.getManaPool().addMana(new Mana(0, 0, 0, count, 0, 0, 0), game, source);
return true;
}
return false;
}
@Override
public HarabazDruidManaEffect copy() {
return new HarabazDruidManaEffect(this);
}
}