mirror of
https://github.com/correl/mage.git
synced 2025-01-11 19:13:02 +00:00
Removed choices that should not be made while casting of a spell.
For example: color choices for protection abilities.
This commit is contained in:
parent
4b4417d88d
commit
9d380331d7
35 changed files with 619 additions and 630 deletions
|
@ -45,7 +45,6 @@ import mage.abilities.costs.mana.ManaCostsImpl;
|
|||
import mage.abilities.costs.mana.VariableManaCost;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.cards.Card;
|
||||
import mage.choices.Choice;
|
||||
import mage.constants.AbilityType;
|
||||
import mage.game.Game;
|
||||
import mage.game.combat.Combat;
|
||||
|
@ -452,9 +451,6 @@ public class SimulatedPlayer2 extends ComputerPlayer {
|
|||
newNode.getTargets().add(targetId);
|
||||
}
|
||||
}
|
||||
for (Choice choice : ability.getChoices()) {
|
||||
newNode.getChoices().add(choice.getChoice());
|
||||
}
|
||||
parent.children.add(newNode);
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,6 @@ import mage.abilities.SpellAbility;
|
|||
import mage.abilities.TriggeredAbility;
|
||||
import mage.abilities.common.PassAbility;
|
||||
import mage.abilities.costs.mana.GenericManaCost;
|
||||
import mage.choices.Choice;
|
||||
import mage.game.Game;
|
||||
import mage.game.combat.Combat;
|
||||
import mage.game.events.GameEvent;
|
||||
|
@ -270,9 +269,6 @@ public class SimulatedPlayer extends ComputerPlayer {
|
|||
newNode.getTargets().add(targetId);
|
||||
}
|
||||
}
|
||||
for (Choice choice: ability.getChoices()) {
|
||||
newNode.getChoices().add(choice.getChoice());
|
||||
}
|
||||
parent.children.add(newNode);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,23 +32,17 @@ import mage.MageInt;
|
|||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SpellCastControllerTriggeredAbility;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.common.RemoveVariableCountersSourceCost;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.dynamicvalue.common.CountersCount;
|
||||
import mage.abilities.dynamicvalue.common.RemovedCountersForCostValue;
|
||||
import mage.abilities.effects.common.ManaEffect;
|
||||
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
||||
import mage.abilities.mana.BasicManaAbility;
|
||||
import mage.abilities.mana.DynamicManaAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.choices.ChoiceColor;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.counters.CounterType;
|
||||
import mage.filter.common.FilterSpiritOrArcaneCard;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
* @author LevelX2
|
||||
|
@ -88,76 +82,4 @@ public class PetalmaneBaku extends CardImpl {
|
|||
public PetalmaneBaku copy() {
|
||||
return new PetalmaneBaku(this);
|
||||
}
|
||||
|
||||
private class PetalmaneBakuManaAbility extends BasicManaAbility {
|
||||
|
||||
PetalmaneBakuManaAbility() {
|
||||
super(new PetalmaneBakuManaEffect());
|
||||
this.addChoice(new ChoiceColor());
|
||||
}
|
||||
|
||||
PetalmaneBakuManaAbility(final PetalmaneBakuManaAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PetalmaneBakuManaAbility copy() {
|
||||
return new PetalmaneBakuManaAbility(this);
|
||||
}
|
||||
}
|
||||
|
||||
private class PetalmaneBakuManaEffect extends ManaEffect {
|
||||
|
||||
PetalmaneBakuManaEffect() {
|
||||
super();
|
||||
staticText = "Add X mana of any one color to your mana pool";
|
||||
}
|
||||
|
||||
PetalmaneBakuManaEffect(final PetalmaneBakuManaEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
ChoiceColor choice = (ChoiceColor) source.getChoices().get(0);
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
|
||||
if (player != null && choice != null) {
|
||||
int numberOfMana = 0;
|
||||
for (Cost cost : source.getCosts()) {
|
||||
if (cost instanceof RemoveVariableCountersSourceCost) {
|
||||
numberOfMana = ((RemoveVariableCountersSourceCost) cost).getAmount();
|
||||
}
|
||||
}
|
||||
if (choice.getColor().isBlack()) {
|
||||
player.getManaPool().addMana(new Mana(0, 0, 0, 0, numberOfMana, 0, 0, 0), game, source);
|
||||
return true;
|
||||
} else if (choice.getColor().isBlue()) {
|
||||
player.getManaPool().addMana(new Mana(0, 0, numberOfMana, 0, 0, 0, 0, 0), game, source);
|
||||
return true;
|
||||
} else if (choice.getColor().isRed()) {
|
||||
player.getManaPool().addMana(new Mana(numberOfMana, 0, 0, 0, 0, 0, 0, 0), game, source);
|
||||
return true;
|
||||
} else if (choice.getColor().isGreen()) {
|
||||
player.getManaPool().addMana(new Mana(0, numberOfMana, 0, 0, 0, 0, 0, 0), game, source);
|
||||
return true;
|
||||
} else if (choice.getColor().isWhite()) {
|
||||
player.getManaPool().addMana(new Mana(0, 0, 0, numberOfMana, 0, 0, 0, 0), game, source);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mana getMana(Game game, Ability source) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PetalmaneBakuManaEffect copy() {
|
||||
return new PetalmaneBakuManaEffect(this);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,11 +27,13 @@
|
|||
*/
|
||||
package mage.sets.commander2013;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.common.EntersBattlefieldAbility;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.CostImpl;
|
||||
import mage.abilities.costs.VariableCost;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
|
@ -56,9 +58,6 @@ import mage.players.Player;
|
|||
import mage.target.common.TargetCreatureOrPlayer;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.costs.Cost;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
|
@ -109,7 +108,7 @@ public class MarathWillOfTheWild extends CardImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void adjustChoices(Ability ability, Game game) {
|
||||
public void adjustCosts(Ability ability, Game game) {
|
||||
if (ability instanceof SimpleActivatedAbility && ability.getModes().size() == 3) {
|
||||
Permanent sourcePermanent = game.getPermanent(ability.getSourceId());
|
||||
if (sourcePermanent != null) {
|
||||
|
@ -124,7 +123,6 @@ public class MarathWillOfTheWild extends CardImpl {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public MarathWillOfTheWild(final MarathWillOfTheWild card) {
|
||||
|
|
|
@ -35,6 +35,7 @@ import mage.abilities.effects.ContinuousEffect;
|
|||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.continuous.GainControlTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.choices.Choice;
|
||||
import mage.choices.ChoiceLeftOrRight;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
|
@ -62,7 +63,6 @@ public class OrderOfSuccession extends CardImpl {
|
|||
|
||||
|
||||
// Choose left or right. Starting with you and proceeding in the chosen direction, each player chooses a creature controlled by the next player in that direction. Each player gains control of the creature he or she chose.
|
||||
this.getSpellAbility().addChoice(new ChoiceLeftOrRight());
|
||||
this.getSpellAbility().addEffect(new OrderOfSuccessionEffect());
|
||||
}
|
||||
|
||||
|
@ -96,8 +96,10 @@ class OrderOfSuccessionEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
Map<UUID, UUID> playerCreature = new HashMap<>();
|
||||
boolean left = source.getChoices().get(0).getChoice().equals("Left");
|
||||
Map<UUID, UUID> playerCreature = new HashMap<>(2);
|
||||
Choice choice = new ChoiceLeftOrRight();
|
||||
controller.choose(Outcome.Neutral, choice, game);
|
||||
boolean left = choice.getChoice().equals("Left");
|
||||
PlayerList playerList = game.getState().getPlayerList().copy();
|
||||
// set playerlist to controller
|
||||
while (!playerList.get().equals(source.getControllerId()) && controller.canRespond()) {
|
||||
|
|
|
@ -35,21 +35,17 @@ import mage.abilities.costs.common.SacrificeXTargetCost;
|
|||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.dynamicvalue.common.GetXValue;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.CreateTokenEffect;
|
||||
import mage.abilities.effects.common.GainLifeEffect;
|
||||
import mage.abilities.mana.ColorlessManaAbility;
|
||||
import mage.abilities.mana.DynamicManaAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.choices.ChoiceColor;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||
import mage.filter.predicate.mageobject.SubtypePredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.token.GoatToken;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -77,8 +73,12 @@ public class SpringjackPasture extends CardImpl {
|
|||
this.addAbility(ability);
|
||||
|
||||
// {tap}, Sacrifice X Goats: Add X mana of any one color to your mana pool. You gain X life.
|
||||
ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new SpringjackPastureEffect(), new TapSourceCost());
|
||||
ability.addChoice(new ChoiceColor());
|
||||
ability = new DynamicManaAbility(
|
||||
new Mana(0,0,0,0,0,0,1,0),
|
||||
new GetXValue(),
|
||||
new TapSourceCost(),
|
||||
"Add X mana of any one color to your mana pool",
|
||||
true);
|
||||
ability.addCost(new SacrificeXTargetCost(filter));
|
||||
ability.addEffect(new GainLifeEffect(new GetXValue()));
|
||||
this.addAbility(ability);
|
||||
|
@ -94,43 +94,3 @@ public class SpringjackPasture extends CardImpl {
|
|||
return new SpringjackPasture(this);
|
||||
}
|
||||
}
|
||||
|
||||
class SpringjackPastureEffect extends OneShotEffect {
|
||||
|
||||
public SpringjackPastureEffect() {
|
||||
super(Outcome.Benefit);
|
||||
staticText = "Add X mana of any one color to your mana pool";
|
||||
}
|
||||
|
||||
public SpringjackPastureEffect(final SpringjackPastureEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player you = game.getPlayer(source.getControllerId());
|
||||
ChoiceColor choice = (ChoiceColor) source.getChoices().get(0);
|
||||
if (you != null && choice != null) {
|
||||
int count = new GetXValue().calculate(game, source, this);
|
||||
if (choice.getColor().isBlack()) {
|
||||
you.getManaPool().addMana(new Mana(0, 0, 0, 0, count, 0, 0, 0), game, source);
|
||||
} else if (choice.getColor().isBlue()) {
|
||||
you.getManaPool().addMana(new Mana(0, 0, count, 0, 0, 0, 0, 0), game, source);
|
||||
} else if (choice.getColor().isRed()) {
|
||||
you.getManaPool().addMana(new Mana(count, 0, 0, 0, 0, 0, 0, 0), game, source);
|
||||
} else if (choice.getColor().isGreen()) {
|
||||
you.getManaPool().addMana(new Mana(0, count, 0, 0, 0, 0, 0, 0), game, source);
|
||||
} else if (choice.getColor().isWhite()) {
|
||||
you.getManaPool().addMana(new Mana(0, 0, 0, count, 0, 0, 0, 0), game, source);
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpringjackPastureEffect copy() {
|
||||
return new SpringjackPastureEffect(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,12 +30,6 @@ package mage.sets.gatecrash;
|
|||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.TargetController;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.BeginningOfCombatTriggeredAbility;
|
||||
|
@ -48,6 +42,11 @@ import mage.abilities.keyword.VigilanceAbility;
|
|||
import mage.cards.CardImpl;
|
||||
import mage.choices.Choice;
|
||||
import mage.choices.ChoiceImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.TargetController;
|
||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
@ -59,16 +58,6 @@ import mage.players.Player;
|
|||
*/
|
||||
public class AngelicSkirmisher extends CardImpl {
|
||||
|
||||
private static final Choice abilityChoice = new ChoiceImpl(true);
|
||||
private static final Set<String> abilityChoices = new HashSet<String>();
|
||||
static {
|
||||
abilityChoice.setMessage("Choose ability for your creatures");
|
||||
abilityChoices.add("First strike");
|
||||
abilityChoices.add("Vigilance");
|
||||
abilityChoices.add("Lifelink");
|
||||
abilityChoice.setChoices(abilityChoices);
|
||||
}
|
||||
|
||||
public AngelicSkirmisher(UUID ownerId) {
|
||||
super(ownerId, 3, "Angelic Skirmisher", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{4}{W}{W}");
|
||||
this.expansionSetCode = "GTC";
|
||||
|
@ -82,7 +71,6 @@ public class AngelicSkirmisher extends CardImpl {
|
|||
|
||||
// At the beginning of each combat, choose first strike, vigilance or lifelink. Creatures you control gain that ability until end of turn.
|
||||
Ability ability = new BeginningOfCombatTriggeredAbility(new AngelicSkirmisherEffect(), TargetController.ANY, false);
|
||||
ability.addChoice(abilityChoice);
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
||||
|
@ -108,17 +96,30 @@ class AngelicSkirmisherEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Choice abilityChoice = source.getChoices().get(0);
|
||||
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
||||
if (controller != null && sourcePermanent != null && abilityChoice != null && abilityChoice.isChosen()) {
|
||||
if (controller != null && sourcePermanent != null) {
|
||||
Choice abilityChoice = new ChoiceImpl(true);
|
||||
Set<String> abilityChoices = new HashSet<>(3);
|
||||
abilityChoice.setMessage("Choose ability for your creatures");
|
||||
abilityChoices.add("First strike");
|
||||
abilityChoices.add("Vigilance");
|
||||
abilityChoices.add("Lifelink");
|
||||
abilityChoice.setChoices(abilityChoices);
|
||||
Ability ability = null;
|
||||
if (abilityChoice.getChoice().equals("First strike")) {
|
||||
ability = FirstStrikeAbility.getInstance();
|
||||
} else if (abilityChoice.getChoice().equals("Vigilance")) {
|
||||
ability = VigilanceAbility.getInstance();
|
||||
} else if (abilityChoice.getChoice().equals("Lifelink")) {
|
||||
ability = LifelinkAbility.getInstance();
|
||||
switch (abilityChoice.getChoice()) {
|
||||
case "First strike":
|
||||
ability = FirstStrikeAbility.getInstance();
|
||||
break;
|
||||
case "Vigilance":
|
||||
ability = VigilanceAbility.getInstance();
|
||||
break;
|
||||
case "Lifelink":
|
||||
ability = LifelinkAbility.getInstance();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (ability != null) {
|
||||
GainAbilityControlledEffect effect = new GainAbilityControlledEffect(ability, Duration.EndOfTurn, new FilterControlledCreaturePermanent());
|
||||
|
|
|
@ -28,17 +28,17 @@
|
|||
package mage.sets.invasion;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.choices.Choice;
|
||||
import mage.choices.ChoiceImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.filter.Filter;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.predicate.Predicates;
|
||||
|
@ -59,16 +59,7 @@ public class Void extends CardImpl {
|
|||
super(ownerId, 287, "Void", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{3}{B}{R}");
|
||||
this.expansionSetCode = "INV";
|
||||
|
||||
|
||||
// Choose a number. Destroy all artifacts and creatures with converted mana cost equal to that number. Then target player reveals his or her hand and discards all nonland cards with converted mana cost equal to the number.
|
||||
Choice numberChoice = new ChoiceImpl();
|
||||
HashSet<String> numbers = new HashSet<String>();
|
||||
for (int i = 0; i <= 30; i++) {
|
||||
numbers.add(Integer.toString(i));
|
||||
}
|
||||
numberChoice.setChoices(numbers);
|
||||
numberChoice.setMessage("Choose a number");
|
||||
this.getSpellAbility().addChoice(numberChoice);
|
||||
this.getSpellAbility().addTarget(new TargetPlayer());
|
||||
this.getSpellAbility().addEffect(new VoidEffect());
|
||||
|
||||
|
@ -102,28 +93,38 @@ class VoidEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
int number = Integer.parseInt(source.getChoices().get(0).getChoice());
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(source.getControllerId(), game)) {
|
||||
if ((permanent.getCardType().contains(CardType.ARTIFACT) || permanent.getCardType().contains(CardType.CREATURE))
|
||||
&& permanent.getConvertedManaCost() == number) {
|
||||
permanent.destroy(source.getSourceId(), game, false);
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
Choice numberChoice = new ChoiceImpl();
|
||||
Set<String> numbers = new HashSet<>(16);
|
||||
for (int i = 0; i <= 15; i++) {
|
||||
numbers.add(Integer.toString(i));
|
||||
}
|
||||
}
|
||||
FilterCard filterCard = new FilterCard();
|
||||
filterCard.add(new ConvertedManaCostPredicate(Filter.ComparisonType.Equal, number));
|
||||
filterCard.add(Predicates.not(new CardTypePredicate(CardType.LAND)));
|
||||
|
||||
Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source));
|
||||
if (targetPlayer != null) {
|
||||
targetPlayer.revealCards("Void", targetPlayer.getHand(), game);
|
||||
for (Card card : targetPlayer.getHand().getCards(game)) {
|
||||
if (filterCard.match(card, game)) {
|
||||
targetPlayer.discard(card, source, game);
|
||||
numberChoice.setChoices(numbers);
|
||||
numberChoice.setMessage("Choose a number");
|
||||
controller.choose(Outcome.DestroyPermanent, numberChoice, game);
|
||||
int number = Integer.parseInt(numberChoice.getChoice());
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(source.getControllerId(), game)) {
|
||||
if ((permanent.getCardType().contains(CardType.ARTIFACT) || permanent.getCardType().contains(CardType.CREATURE))
|
||||
&& permanent.getConvertedManaCost() == number) {
|
||||
permanent.destroy(source.getSourceId(), game, false);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
FilterCard filterCard = new FilterCard();
|
||||
filterCard.add(new ConvertedManaCostPredicate(Filter.ComparisonType.Equal, number));
|
||||
filterCard.add(Predicates.not(new CardTypePredicate(CardType.LAND)));
|
||||
|
||||
Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source));
|
||||
if (targetPlayer != null) {
|
||||
targetPlayer.revealCards("Void", targetPlayer.getHand(), game);
|
||||
for (Card card : targetPlayer.getHand().getCards(game)) {
|
||||
if (filterCard.match(card, game)) {
|
||||
targetPlayer.discard(card, source, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ import mage.filter.predicate.mageobject.ColorPredicate;
|
|||
import mage.filter.predicate.permanent.ControllerPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -52,6 +53,7 @@ import mage.game.permanent.Permanent;
|
|||
public class WashOut extends CardImpl {
|
||||
|
||||
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature an opponent controls");
|
||||
|
||||
static {
|
||||
filter.add(new ControllerPredicate(TargetController.OPPONENT));
|
||||
}
|
||||
|
@ -60,9 +62,7 @@ public class WashOut extends CardImpl {
|
|||
super(ownerId, 87, "Wash Out", Rarity.UNCOMMON, new CardType[]{CardType.SORCERY}, "{3}{U}");
|
||||
this.expansionSetCode = "INV";
|
||||
|
||||
|
||||
// Return all permanents of the color of your choice to their owners' hands.
|
||||
this.getSpellAbility().addChoice(new ChoiceColor());
|
||||
this.getSpellAbility().addEffect(new WashOutEffect());
|
||||
|
||||
}
|
||||
|
@ -90,15 +90,19 @@ class WashOutEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
FilterPermanent filter = new FilterPermanent();
|
||||
ObjectColor color = ((ChoiceColor) source.getChoices().get(0)).getColor();
|
||||
if (color != null) {
|
||||
filter.add(new ColorPredicate(color));
|
||||
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
|
||||
permanent.moveToZone(Zone.HAND, source.getSourceId(), game, true);
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
ChoiceColor choice = new ChoiceColor();
|
||||
controller.choose(Outcome.ReturnToHand, choice, game);
|
||||
ObjectColor color = choice.getColor();
|
||||
if (color != null) {
|
||||
FilterPermanent filter = new FilterPermanent();
|
||||
filter.add(new ColorPredicate(color));
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
|
||||
permanent.moveToZone(Zone.HAND, source.getSourceId(), game, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -32,12 +32,14 @@ import mage.MageObject;
|
|||
import mage.ObjectColor;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.costs.common.TapTargetCost;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.PreventionEffectImpl;
|
||||
import mage.abilities.keyword.FlashbackAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.choices.ChoiceColor;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.TimingRule;
|
||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||
|
@ -46,6 +48,7 @@ import mage.filter.predicate.mageobject.ColorPredicate;
|
|||
import mage.filter.predicate.permanent.TappedPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetControlledCreaturePermanent;
|
||||
|
||||
/**
|
||||
|
@ -65,8 +68,7 @@ public class PrismaticStrands extends CardImpl {
|
|||
this.expansionSetCode = "JUD";
|
||||
|
||||
// Prevent all damage that sources of the color of your choice would deal this turn.
|
||||
this.getSpellAbility().addEffect(new PrismaticStrandsEffect(Duration.EndOfTurn, Integer.MAX_VALUE, false));
|
||||
this.getSpellAbility().addChoice(new ChoiceColor());
|
||||
this.getSpellAbility().addEffect(new PrismaticStrandsEffect());
|
||||
|
||||
// Flashback-Tap an untapped white creature you control.
|
||||
this.addAbility(new FlashbackAbility(new TapTargetCost(new TargetControlledCreaturePermanent(1,1,filter,false)), TimingRule.INSTANT));
|
||||
|
@ -82,16 +84,48 @@ public class PrismaticStrands extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
class PrismaticStrandsEffect extends PreventionEffectImpl {
|
||||
|
||||
public PrismaticStrandsEffect(Duration duration, int amount, boolean onlyCombat) {
|
||||
super(duration, amount, onlyCombat, false);
|
||||
class PrismaticStrandsEffect extends OneShotEffect {
|
||||
|
||||
PrismaticStrandsEffect() {
|
||||
super(Outcome.PreventDamage);
|
||||
this.staticText = "Prevent all damage that sources of the color of your choice would deal this turn";
|
||||
}
|
||||
|
||||
public PrismaticStrandsEffect(PrismaticStrandsEffect effect) {
|
||||
|
||||
PrismaticStrandsEffect(final PrismaticStrandsEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrismaticStrandsEffect copy() {
|
||||
return new PrismaticStrandsEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
ChoiceColor choice = new ChoiceColor();
|
||||
controller.choose(Outcome.PreventDamage, choice, game);
|
||||
game.addEffect(new PrismaticStrandsPreventionEffect(choice.getColor()), source);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class PrismaticStrandsPreventionEffect extends PreventionEffectImpl {
|
||||
|
||||
private final ObjectColor color;
|
||||
|
||||
PrismaticStrandsPreventionEffect(ObjectColor color) {
|
||||
super(Duration.EndOfTurn, Integer.MAX_VALUE, false, false);
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
PrismaticStrandsPreventionEffect(PrismaticStrandsPreventionEffect effect) {
|
||||
super(effect);
|
||||
this.color = effect.color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
|
@ -104,9 +138,8 @@ class PrismaticStrandsEffect extends PreventionEffectImpl {
|
|||
if (event.getType().equals(GameEvent.EventType.DAMAGE_PLAYER)
|
||||
|| event.getType().equals(GameEvent.EventType.DAMAGE_CREATURE)
|
||||
|| event.getType().equals(GameEvent.EventType.DAMAGE_PLANESWALKER)) {
|
||||
ChoiceColor choice = (ChoiceColor) source.getChoices().get(0);
|
||||
MageObject sourceObject = game.getObject(event.getSourceId());
|
||||
if (sourceObject != null && choice != null && sourceObject.getColor(game).shares(choice.getColor())) {
|
||||
if (sourceObject != null && sourceObject.getColor(game).shares(this.color)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -115,7 +148,7 @@ class PrismaticStrandsEffect extends PreventionEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PrismaticStrandsEffect copy() {
|
||||
return new PrismaticStrandsEffect(this);
|
||||
public PrismaticStrandsPreventionEffect copy() {
|
||||
return new PrismaticStrandsPreventionEffect(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ public class NecropolisFiend extends CardImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void adjustChoices(Ability ability, Game game) {
|
||||
public void adjustCosts(Ability ability, Game game) {
|
||||
if (ability instanceof SimpleActivatedAbility) {
|
||||
Player controller = game.getPlayer(ability.getControllerId());
|
||||
if (controller != null) {
|
||||
|
@ -101,7 +101,7 @@ public class NecropolisFiend extends CardImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void adjustCosts(Ability ability, Game game) {
|
||||
public void adjustTargets(Ability ability, Game game) {
|
||||
if (ability instanceof SimpleActivatedAbility) {
|
||||
int xValue = ability.getManaCostsToPay().getX();
|
||||
for(Cost cost: ability.getCosts()) {
|
||||
|
|
|
@ -30,9 +30,11 @@ package mage.sets.magic2015;
|
|||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.MageObject;
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.PreventionEffectImpl;
|
||||
import mage.abilities.keyword.FlyingAbility;
|
||||
import mage.abilities.keyword.VigilanceAbility;
|
||||
|
@ -40,12 +42,14 @@ import mage.cards.CardImpl;
|
|||
import mage.choices.ChoiceColor;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.permanent.AnotherPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetPlayer;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
||||
|
@ -76,17 +80,15 @@ public class AvacynGuardianAngel extends CardImpl {
|
|||
this.addAbility(VigilanceAbility.getInstance());
|
||||
// {1}{W}: Prevent all damage that would be dealt to another target creature this turn by sources of the color of your choice.
|
||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD,
|
||||
new AvacynGuardianAngelPreventToCreatureEffect(Duration.EndOfTurn, Integer.MAX_VALUE, false),
|
||||
new ManaCostsImpl("{1}{W}"));
|
||||
ability.addChoice(new ChoiceColor());
|
||||
new AvacynGuardianAngelPreventToCreatureEffect(),
|
||||
new ManaCostsImpl<>("{1}{W}"));
|
||||
ability.addTarget(new TargetCreaturePermanent(filter));
|
||||
this.addAbility(ability);
|
||||
|
||||
// {5}{W}{W}: Prevent all damage that would be dealt to target player this turn by sources of the color of your choice.
|
||||
ability = new SimpleActivatedAbility(Zone.BATTLEFIELD,
|
||||
new AvacynGuardianAngelPreventToPlayerEffect(Duration.EndOfTurn, Integer.MAX_VALUE, false),
|
||||
new ManaCostsImpl("{5}{W}{W}"));
|
||||
ability.addChoice(new ChoiceColor());
|
||||
new AvacynGuardianAngelPreventToPlayerEffect(),
|
||||
new ManaCostsImpl<>("{5}{W}{W}"));
|
||||
ability.addTarget(new TargetPlayer());
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
@ -101,18 +103,49 @@ public class AvacynGuardianAngel extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
class AvacynGuardianAngelPreventToCreatureEffect extends PreventionEffectImpl {
|
||||
|
||||
public AvacynGuardianAngelPreventToCreatureEffect(Duration duration, int amount, boolean onlyCombat) {
|
||||
super(duration, amount, onlyCombat, false);
|
||||
class AvacynGuardianAngelPreventToCreatureEffect extends OneShotEffect {
|
||||
|
||||
AvacynGuardianAngelPreventToCreatureEffect() {
|
||||
super(Outcome.PreventDamage);
|
||||
this.staticText = "Prevent all damage that would be dealt to another target creature this turn by sources of the color of your choice";
|
||||
}
|
||||
|
||||
public AvacynGuardianAngelPreventToCreatureEffect(AvacynGuardianAngelPreventToCreatureEffect effect) {
|
||||
|
||||
AvacynGuardianAngelPreventToCreatureEffect(final AvacynGuardianAngelPreventToCreatureEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AvacynGuardianAngelPreventToCreatureEffect copy() {
|
||||
return new AvacynGuardianAngelPreventToCreatureEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
ChoiceColor choice = new ChoiceColor();
|
||||
if (controller.choose(Outcome.PreventDamage, choice, game)) {
|
||||
game.addEffect(new AvacynGuardianAngelPreventToCreaturePreventionEffect(choice.getColor()), source);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class AvacynGuardianAngelPreventToCreaturePreventionEffect extends PreventionEffectImpl {
|
||||
|
||||
private final ObjectColor color;
|
||||
|
||||
AvacynGuardianAngelPreventToCreaturePreventionEffect(ObjectColor color) {
|
||||
super(Duration.EndOfTurn, Integer.MAX_VALUE, false, false);
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
AvacynGuardianAngelPreventToCreaturePreventionEffect(AvacynGuardianAngelPreventToCreaturePreventionEffect effect) {
|
||||
super(effect);
|
||||
this.color = effect.color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
|
@ -124,9 +157,8 @@ class AvacynGuardianAngelPreventToCreatureEffect extends PreventionEffectImpl {
|
|||
if (super.applies(event, source, game)) {
|
||||
if (event.getType().equals(GameEvent.EventType.DAMAGE_CREATURE)
|
||||
&& event.getTargetId().equals(getTargetPointer().getFirst(game, source))) {
|
||||
ChoiceColor choice = (ChoiceColor) source.getChoices().get(0);
|
||||
MageObject sourceObject = game.getObject(event.getSourceId());
|
||||
if (sourceObject != null && choice != null && sourceObject.getColor(game).shares(choice.getColor())) {
|
||||
if (sourceObject != null && sourceObject.getColor(game).shares(this.color)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -135,21 +167,54 @@ class AvacynGuardianAngelPreventToCreatureEffect extends PreventionEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AvacynGuardianAngelPreventToCreatureEffect copy() {
|
||||
return new AvacynGuardianAngelPreventToCreatureEffect(this);
|
||||
public AvacynGuardianAngelPreventToCreaturePreventionEffect copy() {
|
||||
return new AvacynGuardianAngelPreventToCreaturePreventionEffect(this);
|
||||
}
|
||||
}
|
||||
|
||||
class AvacynGuardianAngelPreventToPlayerEffect extends PreventionEffectImpl {
|
||||
|
||||
public AvacynGuardianAngelPreventToPlayerEffect(Duration duration, int amount, boolean onlyCombat) {
|
||||
super(duration, amount, onlyCombat, false);
|
||||
class AvacynGuardianAngelPreventToPlayerEffect extends OneShotEffect {
|
||||
|
||||
AvacynGuardianAngelPreventToPlayerEffect() {
|
||||
super(Outcome.PreventDamage);
|
||||
this.staticText = "Prevent all damage that would be dealt to target player this turn by sources of the color of your choice";
|
||||
}
|
||||
|
||||
public AvacynGuardianAngelPreventToPlayerEffect(AvacynGuardianAngelPreventToPlayerEffect effect) {
|
||||
|
||||
AvacynGuardianAngelPreventToPlayerEffect(final AvacynGuardianAngelPreventToPlayerEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AvacynGuardianAngelPreventToPlayerEffect copy() {
|
||||
return new AvacynGuardianAngelPreventToPlayerEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
ChoiceColor choice = new ChoiceColor();
|
||||
if (controller.choose(Outcome.PreventDamage, choice, game)) {
|
||||
game.addEffect(new AvacynGuardianAngelPreventToPlayerPreventionEffect(choice.getColor()), source);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class AvacynGuardianAngelPreventToPlayerPreventionEffect extends PreventionEffectImpl {
|
||||
|
||||
private final ObjectColor color;
|
||||
|
||||
AvacynGuardianAngelPreventToPlayerPreventionEffect(ObjectColor color) {
|
||||
super(Duration.EndOfTurn, Integer.MAX_VALUE, false, false);
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
AvacynGuardianAngelPreventToPlayerPreventionEffect(AvacynGuardianAngelPreventToPlayerPreventionEffect effect) {
|
||||
super(effect);
|
||||
this.color = effect.color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
|
@ -161,9 +226,8 @@ class AvacynGuardianAngelPreventToPlayerEffect extends PreventionEffectImpl {
|
|||
if (super.applies(event, source, game)) {
|
||||
if (event.getType().equals(GameEvent.EventType.DAMAGE_PLAYER)
|
||||
&& event.getTargetId().equals(getTargetPointer().getFirst(game, source))) {
|
||||
ChoiceColor choice = (ChoiceColor) source.getChoices().get(0);
|
||||
MageObject sourceObject = game.getObject(event.getSourceId());
|
||||
if (sourceObject != null && choice != null && sourceObject.getColor(game).shares(choice.getColor())) {
|
||||
if (sourceObject != null && sourceObject.getColor(game).shares(this.color)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -172,7 +236,7 @@ class AvacynGuardianAngelPreventToPlayerEffect extends PreventionEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AvacynGuardianAngelPreventToPlayerEffect copy() {
|
||||
return new AvacynGuardianAngelPreventToPlayerEffect(this);
|
||||
public AvacynGuardianAngelPreventToPlayerPreventionEffect copy() {
|
||||
return new AvacynGuardianAngelPreventToPlayerPreventionEffect(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ package mage.sets.mercadianmasques;
|
|||
import java.util.UUID;
|
||||
import mage.ConditionalMana;
|
||||
import mage.Mana;
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.common.ExileTargetCost;
|
||||
|
@ -41,6 +42,7 @@ import mage.cards.Card;
|
|||
import mage.cards.CardImpl;
|
||||
import mage.choices.ChoiceColor;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||
|
@ -58,10 +60,8 @@ public class FoodChain extends CardImpl {
|
|||
super(ownerId, 246, "Food Chain", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{2}{G}");
|
||||
this.expansionSetCode = "MMQ";
|
||||
|
||||
|
||||
// Exile a creature you control: Add X mana of any one color to your mana pool, where X is the exiled creature's converted mana cost plus one. Spend this mana only to cast creature spells.
|
||||
Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD, new FoodChainManaEffect(), new ExileTargetCost(new TargetControlledCreaturePermanent(1, 1, new FilterControlledCreaturePermanent("a creature you control"), true)));
|
||||
ability.addChoice(new ChoiceColor());
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
||||
|
@ -76,6 +76,7 @@ public class FoodChain extends CardImpl {
|
|||
}
|
||||
|
||||
class FoodChainManaBuilder extends ConditionalManaBuilder {
|
||||
|
||||
@Override
|
||||
public ConditionalMana build(Object... options) {
|
||||
return new CreatureCastConditionalMana(this.mana);
|
||||
|
@ -88,55 +89,58 @@ class FoodChainManaBuilder extends ConditionalManaBuilder {
|
|||
}
|
||||
|
||||
class FoodChainManaEffect extends ManaEffect {
|
||||
|
||||
|
||||
FoodChainManaEffect() {
|
||||
this.staticText = "Add X mana of any one color to your mana pool, where X is the exiled creature's converted mana cost plus one. Spend this mana only to cast creature spells.";
|
||||
}
|
||||
|
||||
|
||||
FoodChainManaEffect(final FoodChainManaEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public FoodChainManaEffect copy() {
|
||||
return new FoodChainManaEffect(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
int manaCostExiled = 0;
|
||||
for (Cost cost: source.getCosts()) {
|
||||
if (cost.isPaid() && cost instanceof ExileTargetCost) {
|
||||
for (Card card : ((ExileTargetCost) cost).getPermanents()) {
|
||||
manaCostExiled += card.getConvertedManaCost();
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
int manaCostExiled = 0;
|
||||
for (Cost cost : source.getCosts()) {
|
||||
if (cost.isPaid() && cost instanceof ExileTargetCost) {
|
||||
for (Card card : ((ExileTargetCost) cost).getPermanents()) {
|
||||
manaCostExiled += card.getConvertedManaCost();
|
||||
}
|
||||
}
|
||||
}
|
||||
ChoiceColor choice = new ChoiceColor();
|
||||
controller.choose(Outcome.PutManaInPool, choice, game);
|
||||
ObjectColor chosenColor = choice.getColor();
|
||||
Mana mana = null;
|
||||
if (chosenColor.isBlack()) {
|
||||
mana = new FoodChainManaBuilder().setMana(Mana.BlackMana(manaCostExiled + 1), source, game).build();
|
||||
}
|
||||
else if (chosenColor.isBlue()) {
|
||||
mana = new FoodChainManaBuilder().setMana(Mana.BlueMana(manaCostExiled + 1), source, game).build();
|
||||
}
|
||||
else if (chosenColor.isRed()) {
|
||||
mana = new FoodChainManaBuilder().setMana(Mana.RedMana(manaCostExiled + 1), source, game).build();
|
||||
}
|
||||
else if (chosenColor.isGreen()) {
|
||||
mana = new FoodChainManaBuilder().setMana(Mana.GreenMana(manaCostExiled + 1), source, game).build();
|
||||
}
|
||||
else if (chosenColor.isWhite()) {
|
||||
mana = new FoodChainManaBuilder().setMana(Mana.WhiteMana(manaCostExiled + 1), source, game).build();
|
||||
}
|
||||
if (mana != null) {
|
||||
checkToFirePossibleEvents(mana, game, source);
|
||||
controller.getManaPool().addMana(mana, game, source);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
ChoiceColor choice = (ChoiceColor) source.getChoices().get(0);
|
||||
Mana mana = null;
|
||||
if (choice.getColor().isBlack()) {
|
||||
mana = new FoodChainManaBuilder().setMana(Mana.BlackMana(manaCostExiled + 1), source, game).build();
|
||||
}
|
||||
else if (choice.getColor().isBlue()) {
|
||||
mana = new FoodChainManaBuilder().setMana(Mana.BlueMana(manaCostExiled + 1), source, game).build();
|
||||
}
|
||||
else if (choice.getColor().isRed()) {
|
||||
mana = new FoodChainManaBuilder().setMana(Mana.RedMana(manaCostExiled + 1), source, game).build();
|
||||
}
|
||||
else if (choice.getColor().isGreen()) {
|
||||
mana = new FoodChainManaBuilder().setMana(Mana.GreenMana(manaCostExiled + 1), source, game).build();
|
||||
}
|
||||
else if (choice.getColor().isWhite()) {
|
||||
mana = new FoodChainManaBuilder().setMana(Mana.WhiteMana(manaCostExiled + 1), source, game).build();
|
||||
}
|
||||
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null && mana != null) {
|
||||
checkToFirePossibleEvents(mana, game, source);
|
||||
player.getManaPool().addMana(mana, game, source);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -145,5 +149,4 @@ class FoodChainManaEffect extends ManaEffect {
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -27,41 +27,32 @@
|
|||
*/
|
||||
package mage.sets.modernmasters;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.ActivatedAbility;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.CostImpl;
|
||||
import mage.abilities.costs.common.RemoveCounterCost;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.common.continuous.BoostSourceEffect;
|
||||
import mage.abilities.keyword.SuspendAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.choices.Choice;
|
||||
import mage.choices.ChoiceImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.TargetController;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.Counter;
|
||||
import mage.counters.CounterType;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.predicate.mageobject.AbilityPredicate;
|
||||
import mage.filter.predicate.other.CounterCardPredicate;
|
||||
import mage.filter.common.FilterPermanentOrSuspendedCard;
|
||||
import mage.filter.predicate.other.OwnerPredicate;
|
||||
import mage.filter.predicate.permanent.ControllerPredicate;
|
||||
import mage.filter.predicate.permanent.CounterPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetCard;
|
||||
import mage.target.common.TargetCardInExile;
|
||||
import mage.target.common.TargetControlledCreaturePermanent;
|
||||
import mage.target.Target;
|
||||
import mage.target.common.TargetPermanentOrSuspendedCard;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -69,13 +60,6 @@ import mage.target.common.TargetControlledCreaturePermanent;
|
|||
*/
|
||||
public class RiftElemental extends CardImpl {
|
||||
|
||||
private static final FilterCard filter = new FilterCard("suspended card you own");
|
||||
static {
|
||||
filter.add(new CounterCardPredicate(CounterType.TIME));
|
||||
filter.add(new AbilityPredicate(SuspendAbility.class));
|
||||
filter.add(new OwnerPredicate(TargetController.YOU));
|
||||
}
|
||||
|
||||
public RiftElemental(UUID ownerId) {
|
||||
super(ownerId, 127, "Rift Elemental", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{R}");
|
||||
this.expansionSetCode = "MMA";
|
||||
|
@ -85,30 +69,11 @@ public class RiftElemental extends CardImpl {
|
|||
this.toughness = new MageInt(1);
|
||||
|
||||
// {1}{R}, Remove a time counter from a permanent you control or suspended card you own: Rift Elemental gets +2/+0 until end of turn.
|
||||
Choice targetChoice = new ChoiceImpl();
|
||||
targetChoice.setMessage("Choose what to target");
|
||||
targetChoice.getChoices().add("Permanent");
|
||||
targetChoice.getChoices().add("Suspended Card");
|
||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BoostSourceEffect(2,0,Duration.EndOfTurn), new ManaCostsImpl("{1}{R}"));
|
||||
ability.addChoice(targetChoice);
|
||||
ability.addCost(new RemoveCounterFromCardCost(new TargetCardInExile(1,1,filter, null, true), CounterType.TIME));
|
||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BoostSourceEffect(2, 0, Duration.EndOfTurn), new ManaCostsImpl<>("{1}{R}"));
|
||||
ability.addCost(new RiftElementalCost());
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adjustCosts(Ability ability, Game game) {
|
||||
if (ability instanceof ActivatedAbility && !ability.getChoices().isEmpty()) {
|
||||
ability.getCosts().clear();
|
||||
Choice targetChoice = ability.getChoices().get(0);
|
||||
if (targetChoice.getChoice().equals("Permanent")) {
|
||||
ability.addCost(new RemoveCounterCost(new TargetControlledCreaturePermanent(), CounterType.TIME));
|
||||
}
|
||||
if (targetChoice.getChoice().equals("Suspended Card")) {
|
||||
ability.addCost(new RemoveCounterFromCardCost(new TargetCardInExile(1,1,filter, null, true), CounterType.TIME));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public RiftElemental(final RiftElemental card) {
|
||||
super(card);
|
||||
}
|
||||
|
@ -119,88 +84,55 @@ public class RiftElemental extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
class RemoveCounterFromCardCost extends CostImpl {
|
||||
class RiftElementalCost extends CostImpl {
|
||||
|
||||
private TargetCard target;
|
||||
private String name;
|
||||
private CounterType counterTypeToRemove;
|
||||
|
||||
public RemoveCounterFromCardCost(TargetCard target) {
|
||||
this(target, null);
|
||||
private static final FilterPermanentOrSuspendedCard filter = new FilterPermanentOrSuspendedCard("permanent you control with a time counter or suspended card you own");
|
||||
static {
|
||||
filter.getPermanentFilter().add(new ControllerPredicate(TargetController.YOU));
|
||||
filter.getPermanentFilter().add(new CounterPredicate(CounterType.TIME));
|
||||
filter.getCardFilter().add(new OwnerPredicate(TargetController.YOU));
|
||||
}
|
||||
|
||||
public RemoveCounterFromCardCost(TargetCard target, CounterType counterTypeToRemove) {
|
||||
this.target = target;
|
||||
this.counterTypeToRemove = counterTypeToRemove;
|
||||
text = setText();
|
||||
RiftElementalCost() {
|
||||
text = "Remove a time counter from a permanent you control or suspended card you own";
|
||||
}
|
||||
|
||||
public RemoveCounterFromCardCost(final RemoveCounterFromCardCost cost) {
|
||||
RiftElementalCost(final RiftElementalCost cost) {
|
||||
super(cost);
|
||||
this.target = cost.target.copy();
|
||||
this.name = cost.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
paid = false;
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
if (target.choose(Outcome.UnboostCreature, controllerId, sourceId, game)) {
|
||||
for (UUID targetId: (List<UUID>)target.getTargets()) {
|
||||
Card card = game.getCard(targetId);
|
||||
if (card != null) {
|
||||
if (card.getCounters(game).size() > 0 && (counterTypeToRemove == null || card.getCounters(game).containsKey(counterTypeToRemove))) {
|
||||
String counterName = null;
|
||||
if (counterTypeToRemove != null) {
|
||||
counterName = counterTypeToRemove.getName();
|
||||
} else {
|
||||
if (card.getCounters(game).size() > 1 && counterTypeToRemove == null) {
|
||||
Choice choice = new ChoiceImpl(true);
|
||||
Set<String> choices = new HashSet<String>();
|
||||
for (Counter counter : card.getCounters(game).values()) {
|
||||
if (card.getCounters(game).getCount(counter.getName()) > 0) {
|
||||
choices.add(counter.getName());
|
||||
}
|
||||
}
|
||||
choice.setChoices(choices);
|
||||
choice.setMessage("Choose a counter to remove from " + card.getName());
|
||||
controller.choose(Outcome.UnboostCreature, choice, game);
|
||||
counterName = choice.getChoice();
|
||||
} else {
|
||||
for (Counter counter : card.getCounters(game).values()) {
|
||||
if (counter.getCount() > 0) {
|
||||
counterName = counter.getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (counterName != null) {
|
||||
card.removeCounters(counterName, 1, game);
|
||||
if (card.getCounters(game).getCount(counterName) == 0 ){
|
||||
card.getCounters(game).removeCounter(counterName);
|
||||
}
|
||||
this.paid = true;
|
||||
game.informPlayers(new StringBuilder(controller.getLogName()).append(" removes a ").append(counterName).append(" counter from ").append(card.getName()).toString());
|
||||
}
|
||||
if (controller != null) {
|
||||
Target target = new TargetPermanentOrSuspendedCard(filter, true);
|
||||
if (target.choose(Outcome.Neutral, controllerId, sourceId, game)) {
|
||||
Permanent permanent = game.getPermanent(target.getFirstTarget());
|
||||
if (permanent != null) {
|
||||
permanent.removeCounters(CounterType.TIME.createInstance(), game);
|
||||
this.paid = true;
|
||||
}
|
||||
else {
|
||||
Card card = game.getCard(target.getFirstTarget());
|
||||
if (card != null) {
|
||||
card.removeCounters(CounterType.TIME.createInstance(), game);
|
||||
this.paid = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
target.clearChosen();
|
||||
return paid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
return target.canChoose(controllerId, game);
|
||||
}
|
||||
|
||||
private String setText() {
|
||||
return "Remove a time counter from a permanent you control or suspended card you own";
|
||||
Target target = new TargetPermanentOrSuspendedCard(filter, true);
|
||||
return target.canChoose(sourceId, controllerId, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RemoveCounterFromCardCost copy() {
|
||||
return new RemoveCounterFromCardCost(this);
|
||||
public RiftElementalCost copy() {
|
||||
return new RiftElementalCost(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@ package mage.sets.planarchaos;
|
|||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.DestroyTargetEffect;
|
||||
|
@ -40,8 +39,6 @@ import mage.abilities.keyword.SuspendAbility;
|
|||
import mage.abilities.keyword.TrampleAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.choices.Choice;
|
||||
import mage.choices.ChoiceImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
|
@ -52,10 +49,9 @@ import mage.filter.predicate.mageobject.AbilityPredicate;
|
|||
import mage.filter.predicate.other.CounterCardPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.Target;
|
||||
import mage.target.common.TargetArtifactPermanent;
|
||||
import mage.target.common.TargetCardInExile;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
import mage.target.common.TargetPermanentOrSuspendedCard;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -73,7 +69,6 @@ public class FuryCharm extends CardImpl {
|
|||
super(ownerId, 100, "Fury Charm", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{1}{R}");
|
||||
this.expansionSetCode = "PLC";
|
||||
|
||||
|
||||
// Choose one -
|
||||
this.getSpellAbility().getModes().setMinModes(1);
|
||||
this.getSpellAbility().getModes().setMaxModes(1);
|
||||
|
@ -92,34 +87,9 @@ public class FuryCharm extends CardImpl {
|
|||
this.getSpellAbility().getModes().addMode(mode);
|
||||
// or remove two time counters from target permanent or suspended card.
|
||||
mode = new Mode();
|
||||
Choice targetChoice = new ChoiceImpl();
|
||||
targetChoice.setMessage("Choose what to target");
|
||||
targetChoice.getChoices().add("Permanent");
|
||||
targetChoice.getChoices().add("Suspended Card");
|
||||
mode.getChoices().add(targetChoice);
|
||||
mode.getTargets().add(new TargetPermanentOrSuspendedCard());
|
||||
mode.getEffects().add(new FuryCharmRemoveCounterEffect());
|
||||
this.getSpellAbility().getModes().addMode(mode);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adjustTargets(Ability ability, Game game) {
|
||||
if (ability instanceof SpellAbility) {
|
||||
for(Effect effect :ability.getEffects()) {
|
||||
if (effect instanceof FuryCharmRemoveCounterEffect) {
|
||||
Choice targetChoice = ability.getChoices().get(0);
|
||||
if (targetChoice.getChoice().equals("Permanent")) {
|
||||
ability.addTarget(new TargetCreaturePermanent());
|
||||
}
|
||||
if (targetChoice.getChoice().equals("Suspended Card")) {
|
||||
Target target = new TargetCardInExile(1,1, filter, null, true);
|
||||
ability.addTarget(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public FuryCharm(final FuryCharm card) {
|
||||
|
@ -152,12 +122,12 @@ class FuryCharmRemoveCounterEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(this.getTargetPointer().getFirst(game, source));
|
||||
if (permanent != null) {
|
||||
permanent.removeCounters(CounterType.TIME.getName(), 2, game);
|
||||
permanent.removeCounters(CounterType.TIME.getName(), 2, game);
|
||||
return true;
|
||||
}
|
||||
Card card = game.getCard(this.getTargetPointer().getFirst(game, source));
|
||||
if (card != null) {
|
||||
card.removeCounters(CounterType.TIME.getName(), 2, game);
|
||||
card.removeCounters(CounterType.TIME.getName(), 2, game);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -31,13 +31,10 @@ import java.util.HashSet;
|
|||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.counter.AddCountersTargetEffect;
|
||||
import mage.abilities.effects.common.counter.RemoveCounterTargetEffect;
|
||||
import mage.abilities.keyword.BuybackAbility;
|
||||
import mage.abilities.keyword.SuspendAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.choices.Choice;
|
||||
|
@ -46,18 +43,10 @@ import mage.constants.CardType;
|
|||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.counters.Counter;
|
||||
import mage.counters.CounterType;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.predicate.mageobject.AbilityPredicate;
|
||||
import mage.filter.predicate.other.CounterCardPredicate;
|
||||
import mage.filter.predicate.permanent.CounterAnyPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.target.common.TargetCardInExile;
|
||||
import mage.target.common.TargetPermanentOrSuspendedCard;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
/**
|
||||
|
@ -74,39 +63,10 @@ public class Clockspinning extends CardImpl {
|
|||
this.addAbility(new BuybackAbility("{3}"));
|
||||
|
||||
// Choose a counter on target permanent or suspended card. Remove that counter from that permanent or card or put another of those counters on it.
|
||||
Choice targetChoice = new ChoiceImpl();
|
||||
targetChoice.setMessage("Choose what to target");
|
||||
targetChoice.getChoices().add("Permanent");
|
||||
targetChoice.getChoices().add("Suspended Card");
|
||||
|
||||
this.getSpellAbility().addChoice(targetChoice);
|
||||
this.getSpellAbility().addTarget(new TargetPermanentOrSuspendedCard());
|
||||
this.getSpellAbility().addEffect(new ClockspinningAddOrRemoveCounterEffect());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adjustTargets(Ability ability, Game game) {
|
||||
if (ability instanceof SpellAbility) {
|
||||
for (Effect effect : ability.getEffects()) {
|
||||
if (effect instanceof ClockspinningAddOrRemoveCounterEffect) {
|
||||
Choice targetChoice = ability.getChoices().get(0);
|
||||
if (targetChoice.getChoice().equals("Permanent")) {
|
||||
FilterPermanent filter = new FilterPermanent("target permanent with a counter");
|
||||
filter.add(new CounterAnyPredicate());
|
||||
ability.addTarget(new TargetPermanent(filter));
|
||||
}
|
||||
if (targetChoice.getChoice().equals("Suspended Card")) {
|
||||
FilterCard suspendFilter = new FilterCard("suspended card");
|
||||
suspendFilter.add(new AbilityPredicate(SuspendAbility.class));
|
||||
suspendFilter.add(new CounterCardPredicate(CounterType.TIME));
|
||||
|
||||
Target target = new TargetCardInExile(1, 1, suspendFilter, null, true);
|
||||
ability.addTarget(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Clockspinning(final Clockspinning card) {
|
||||
super(card);
|
||||
}
|
||||
|
@ -121,7 +81,7 @@ class ClockspinningAddOrRemoveCounterEffect extends OneShotEffect {
|
|||
|
||||
ClockspinningAddOrRemoveCounterEffect() {
|
||||
super(Outcome.Removal);
|
||||
this.staticText = "Remove or add a counter from a target suspended card or a target permanent";
|
||||
this.staticText = "Choose a counter on target permanent or suspended card. Remove that counter from that permanent or card or put another of those counters on it";
|
||||
}
|
||||
|
||||
ClockspinningAddOrRemoveCounterEffect(final ClockspinningAddOrRemoveCounterEffect effect) {
|
||||
|
@ -139,7 +99,7 @@ class ClockspinningAddOrRemoveCounterEffect extends OneShotEffect {
|
|||
String counterName = null;
|
||||
if (permanent.getCounters().size() > 1) {
|
||||
Choice choice = new ChoiceImpl(true);
|
||||
Set<String> choices = new HashSet<>();
|
||||
Set<String> choices = new HashSet<>(2);
|
||||
for (Counter counter : permanent.getCounters().values()) {
|
||||
if (permanent.getCounters().getCount(counter.getName()) > 0) {
|
||||
choices.add(counter.getName());
|
||||
|
|
|
@ -59,7 +59,6 @@ public class CarpetOfFlowers extends CardImpl {
|
|||
super(ownerId, 240, "Carpet of Flowers", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{G}");
|
||||
this.expansionSetCode = "USG";
|
||||
|
||||
|
||||
// At the beginning of each of your main phases, if you haven't added mana to your mana pool with this ability this turn, you may add up to X mana of any one color to your mana pool, where X is the number of Islands target opponent controls.
|
||||
this.addAbility(new CarpetOfFlowersTriggeredAbility());
|
||||
}
|
||||
|
@ -74,17 +73,14 @@ public class CarpetOfFlowers extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
class CarpetOfFlowersTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
public CarpetOfFlowersTriggeredAbility() {
|
||||
CarpetOfFlowersTriggeredAbility() {
|
||||
super(Zone.BATTLEFIELD, new CarpetOfFlowersEffect(), true);
|
||||
this.addChoice(new ChoiceColor());
|
||||
this.addTarget(new TargetOpponent());
|
||||
}
|
||||
|
||||
public CarpetOfFlowersTriggeredAbility(final CarpetOfFlowersTriggeredAbility ability) {
|
||||
CarpetOfFlowersTriggeredAbility(final CarpetOfFlowersTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
|
@ -106,34 +102,29 @@ class CarpetOfFlowersTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkInterveningIfClause(Game game) {
|
||||
Boolean activated = (Boolean)game.getState().getValue(this.originalId.toString() + "addMana");
|
||||
if (activated == null)
|
||||
{
|
||||
Boolean activatedThisTurn = (Boolean) game.getState().getValue(this.originalId.toString() + "addMana");
|
||||
if (activatedThisTurn == null) {
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return !activated;
|
||||
else {
|
||||
return !activatedThisTurn;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean resolve(Game game) {
|
||||
boolean value = super.resolve(game);
|
||||
if(value == true)
|
||||
{
|
||||
if (value == true) {
|
||||
game.getState().setValue(this.originalId.toString() + "addMana", Boolean.TRUE);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void reset(Game game) {
|
||||
game.getState().setValue(this.originalId.toString() + "addMana", Boolean.FALSE);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
StringBuilder sb = new StringBuilder("At the beginning of each of your main phases, if you haven't added mana to your mana pool with this ability this turn");
|
||||
|
@ -142,9 +133,8 @@ class CarpetOfFlowersTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
}
|
||||
|
||||
|
||||
class CarpetOfFlowersEffect extends ManaEffect {
|
||||
|
||||
|
||||
private static final FilterControlledPermanent filter = new FilterControlledPermanent("Island ");
|
||||
|
||||
static {
|
||||
|
@ -164,19 +154,18 @@ class CarpetOfFlowersEffect extends ManaEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null){
|
||||
if (controller != null) {
|
||||
ChoiceColor choice = new ChoiceColor();
|
||||
while (!choice.isChosen()) {
|
||||
controller.choose(Outcome.Protect, choice, game);
|
||||
controller.choose(Outcome.Benefit, choice, game);
|
||||
if (!controller.canRespond()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int countMax = game.getBattlefield().count(filter, source.getSourceId(), source.getTargets().getFirstTarget(), game);
|
||||
ChoiceImpl choiceCount = new ChoiceImpl(true);
|
||||
LinkedHashSet<String> set = new LinkedHashSet<>();
|
||||
for(int i = 0; i <= countMax; i++)
|
||||
{
|
||||
LinkedHashSet<String> set = new LinkedHashSet<>(countMax + 1);
|
||||
for (int i = 0; i <= countMax; i++) {
|
||||
set.add(Integer.toString(i));
|
||||
}
|
||||
choiceCount.setChoices(set);
|
||||
|
@ -201,8 +190,7 @@ class CarpetOfFlowersEffect extends ManaEffect {
|
|||
case "White":
|
||||
mana.setWhite(count);
|
||||
break;
|
||||
case "Colorless":
|
||||
mana.setGeneric(count);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
checkToFirePossibleEvents(mana, game, source);
|
||||
|
|
|
@ -44,8 +44,6 @@ public interface MageObject extends MageItem, Serializable {
|
|||
|
||||
MageInt getToughness();
|
||||
|
||||
void adjustChoices(Ability ability, Game game);
|
||||
|
||||
void adjustCosts(Ability ability, Game game);
|
||||
|
||||
void adjustTargets(Ability ability, Game game);
|
||||
|
|
|
@ -173,10 +173,6 @@ public abstract class MageObjectImpl implements MageObject {
|
|||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adjustChoices(Ability ability, Game game) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adjustCosts(Ability ability, Game game) {
|
||||
}
|
||||
|
|
|
@ -37,8 +37,6 @@ import mage.abilities.costs.mana.ManaCost;
|
|||
import mage.abilities.costs.mana.ManaCosts;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.Effects;
|
||||
import mage.choices.Choice;
|
||||
import mage.choices.Choices;
|
||||
import mage.constants.AbilityType;
|
||||
import mage.constants.AbilityWord;
|
||||
import mage.constants.EffectType;
|
||||
|
@ -248,20 +246,6 @@ public interface Ability extends Controllable, Serializable {
|
|||
*/
|
||||
void addTarget(Target target);
|
||||
|
||||
/**
|
||||
* Choices
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Choices getChoices();
|
||||
|
||||
/**
|
||||
* TODO: Javadoc me
|
||||
*
|
||||
* @param choice
|
||||
*/
|
||||
void addChoice(Choice choice);
|
||||
|
||||
/**
|
||||
* Retrieves the {@link Zone} that this ability is active within.
|
||||
*
|
||||
|
|
|
@ -54,8 +54,6 @@ import mage.abilities.effects.common.DynamicManaEffect;
|
|||
import mage.abilities.keyword.FlashbackAbility;
|
||||
import mage.abilities.mana.ManaAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.choices.Choice;
|
||||
import mage.choices.Choices;
|
||||
import mage.constants.AbilityType;
|
||||
import mage.constants.AbilityWord;
|
||||
import mage.constants.EffectType;
|
||||
|
@ -271,19 +269,7 @@ public abstract class AbilityImpl implements Ability {
|
|||
if (this.abilityType.equals(AbilityType.SPELL)) {
|
||||
game.getContinuousEffects().applySpliceEffects(this, game);
|
||||
}
|
||||
|
||||
if (sourceObject != null) {
|
||||
sourceObject.adjustChoices(this, game);
|
||||
}
|
||||
// TODO: Because all (non targeted) choices have to be done during resolution
|
||||
// this has to be removed, if all using effects are changed
|
||||
for (Mode mode : this.getModes().getSelectedModes()) {
|
||||
if (mode.getChoices().size() > 0 && mode.getChoices().choose(game, this) == false) {
|
||||
logger.debug("activate failed - choice");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// if ability can be cast for no mana, clear the mana costs now, because additional mana costs must be paid.
|
||||
// For Flashback ability can be set X before, so the X costs have to be restored for the flashbacked ability
|
||||
if (noMana) {
|
||||
|
@ -687,11 +673,6 @@ public abstract class AbilityImpl implements Ability {
|
|||
return typedEffects;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Choices getChoices() {
|
||||
return getModes().getMode().getChoices();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Zone getZone() {
|
||||
return zone;
|
||||
|
@ -840,13 +821,6 @@ public abstract class AbilityImpl implements Ability {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addChoice(Choice choice) {
|
||||
if (choice != null) {
|
||||
getChoices().add(choice);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Targets getTargets() {
|
||||
return getModes().getMode().getTargets();
|
||||
|
@ -1121,9 +1095,6 @@ public abstract class AbilityImpl implements Ability {
|
|||
}
|
||||
}
|
||||
}
|
||||
for (Choice choice : this.getChoices()) {
|
||||
sb.append(" - ").append(choice.getMessage()).append(": ").append(choice.getChoice());
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@ package mage.abilities;
|
|||
import java.io.Serializable;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.effects.Effects;
|
||||
import mage.choices.Choices;
|
||||
import mage.target.Targets;
|
||||
|
||||
/**
|
||||
|
@ -41,20 +40,17 @@ public class Mode implements Serializable {
|
|||
|
||||
protected UUID id;
|
||||
protected Targets targets;
|
||||
protected Choices choices;
|
||||
protected Effects effects;
|
||||
|
||||
public Mode() {
|
||||
this.id = UUID.randomUUID();
|
||||
this.targets = new Targets();
|
||||
this.choices = new Choices();
|
||||
this.effects = new Effects();
|
||||
}
|
||||
|
||||
public Mode(Mode mode) {
|
||||
this.id = mode.id;
|
||||
this.targets = mode.targets.copy();
|
||||
this.choices = mode.choices.copy();
|
||||
this.effects = mode.effects.copy();
|
||||
}
|
||||
|
||||
|
@ -70,10 +66,6 @@ public class Mode implements Serializable {
|
|||
return targets;
|
||||
}
|
||||
|
||||
public Choices getChoices() {
|
||||
return choices;
|
||||
}
|
||||
|
||||
public Effects getEffects() {
|
||||
return effects;
|
||||
}
|
||||
|
|
|
@ -143,7 +143,6 @@ public class SpellAbility extends ActivatedAbilityImpl {
|
|||
}
|
||||
|
||||
public void clear() {
|
||||
getChoices().clearChosen();
|
||||
getTargets().clearChosen();
|
||||
this.manaCosts.clearPaid();
|
||||
this.costs.clearPaid();
|
||||
|
|
|
@ -72,7 +72,6 @@ public class AwakenAbility extends SpellAbility {
|
|||
this.getCosts().addAll(card.getSpellAbility().getCosts().copy());
|
||||
this.getEffects().addAll(card.getSpellAbility().getEffects().copy());
|
||||
this.getTargets().addAll(card.getSpellAbility().getTargets().copy());
|
||||
this.getChoices().addAll(card.getSpellAbility().getChoices().copy());
|
||||
this.spellAbilityType = SpellAbilityType.BASE_ALTERNATE;
|
||||
this.timing = card.getSpellAbility().getTiming();
|
||||
this.addTarget(new TargetControlledPermanent(new FilterControlledLandPermanent(filterMessage)));
|
||||
|
|
|
@ -50,7 +50,6 @@ public class RetraceAbility extends SpellAbility {
|
|||
this.addCost(cost);
|
||||
this.getEffects().addAll(card.getSpellAbility().getEffects().copy());
|
||||
this.getTargets().addAll(card.getSpellAbility().getTargets().copy());
|
||||
this.getChoices().addAll(card.getSpellAbility().getChoices().copy());
|
||||
this.spellAbilityType = SpellAbilityType.BASE_ALTERNATE;
|
||||
this.timing = card.getSpellAbility().getTiming();
|
||||
|
||||
|
|
|
@ -53,7 +53,6 @@ public class SurgeAbility extends SpellAbility {
|
|||
this.getCosts().addAll(card.getSpellAbility().getCosts().copy());
|
||||
this.getEffects().addAll(card.getSpellAbility().getEffects().copy());
|
||||
this.getTargets().addAll(card.getSpellAbility().getTargets().copy());
|
||||
this.getChoices().addAll(card.getSpellAbility().getChoices().copy());
|
||||
this.spellAbilityType = SpellAbilityType.BASE_ALTERNATE;
|
||||
this.timing = card.getSpellAbility().getTiming();
|
||||
this.setRuleAtTheTop(true);
|
||||
|
|
|
@ -0,0 +1,117 @@
|
|||
/*
|
||||
*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*
|
||||
*/
|
||||
package mage.filter.common;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.keyword.SuspendAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.counters.CounterType;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.FilterImpl;
|
||||
import mage.filter.FilterInPlay;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.predicate.mageobject.AbilityPredicate;
|
||||
import mage.filter.predicate.other.CounterCardPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author emerald000
|
||||
*/
|
||||
public class FilterPermanentOrSuspendedCard extends FilterImpl<Object> implements FilterInPlay<Object> {
|
||||
|
||||
protected FilterCard cardFilter;
|
||||
protected FilterPermanent permanentFilter;
|
||||
|
||||
public FilterPermanentOrSuspendedCard() {
|
||||
this("permanent or suspended card");
|
||||
}
|
||||
|
||||
public FilterPermanentOrSuspendedCard(String name) {
|
||||
super(name);
|
||||
permanentFilter = new FilterPermanent();
|
||||
cardFilter = new FilterCard();
|
||||
cardFilter.add(new AbilityPredicate(SuspendAbility.class));
|
||||
cardFilter.add(new CounterCardPredicate(CounterType.TIME));
|
||||
}
|
||||
|
||||
public FilterPermanentOrSuspendedCard(final FilterPermanentOrSuspendedCard filter) {
|
||||
super(filter);
|
||||
this.permanentFilter = filter.permanentFilter.copy();
|
||||
this.cardFilter = filter.cardFilter.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkObjectClass(Object object) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean match(Object o, Game game) {
|
||||
if (o instanceof Permanent) {
|
||||
return permanentFilter.match((Permanent) o, game);
|
||||
} else if (o instanceof Card) {
|
||||
return cardFilter.match((Card) o, game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean match(Object o, UUID sourceId, UUID playerId, Game game) {
|
||||
if (o instanceof Permanent) {
|
||||
return permanentFilter.match((Permanent) o, sourceId, playerId, game);
|
||||
} else if (o instanceof Card) {
|
||||
return cardFilter.match((Card) o, sourceId, playerId, game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public FilterPermanent getPermanentFilter() {
|
||||
return this.permanentFilter;
|
||||
}
|
||||
|
||||
public FilterCard getCardFilter() {
|
||||
return this.cardFilter;
|
||||
}
|
||||
|
||||
public void setPermanentFilter(FilterPermanent permanentFilter) {
|
||||
this.permanentFilter = permanentFilter;
|
||||
}
|
||||
|
||||
public void setSpellFilter(FilterCard cardFilter) {
|
||||
this.cardFilter = cardFilter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FilterPermanentOrSuspendedCard copy() {
|
||||
return new FilterPermanentOrSuspendedCard(this);
|
||||
}
|
||||
}
|
|
@ -56,7 +56,6 @@ import mage.abilities.effects.ContinuousEffects;
|
|||
import mage.abilities.effects.Effect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.SplitCard;
|
||||
import mage.choices.Choice;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.combat.Combat;
|
||||
import mage.game.combat.CombatGroup;
|
||||
|
@ -322,12 +321,6 @@ public class GameState implements Serializable, Copyable<GameState> {
|
|||
sb.append(target.getTargets());
|
||||
}
|
||||
}
|
||||
if (!mode.getChoices().isEmpty()) {
|
||||
sb.append("choices");
|
||||
for (Choice choice : mode.getChoices()) {
|
||||
sb.append(choice.getChoice());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -380,12 +373,6 @@ public class GameState implements Serializable, Copyable<GameState> {
|
|||
sb.append(target.getTargets());
|
||||
}
|
||||
}
|
||||
if (!mode.getChoices().isEmpty()) {
|
||||
sb.append("choices");
|
||||
for (Choice choice : mode.getChoices()) {
|
||||
sb.append(choice.getChoice());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -165,10 +165,6 @@ public class Commander implements CommandObject {
|
|||
return card.getToughness();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adjustChoices(Ability ability, Game game) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adjustCosts(Ability ability, Game game) {
|
||||
}
|
||||
|
|
|
@ -174,10 +174,6 @@ public class Emblem implements CommandObject {
|
|||
return MageInt.EmptyMageInt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adjustChoices(Ability ability, Game game) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adjustCosts(Ability ability, Game game) {
|
||||
}
|
||||
|
|
|
@ -249,11 +249,6 @@ public class PermanentCard extends PermanentImpl {
|
|||
card.adjustCosts(ability, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adjustChoices(Ability ability, Game game) {
|
||||
card.adjustChoices(ability, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManaCosts<ManaCost> getManaCost() {
|
||||
if (faceDown) { // face down permanent has always {0} mana costs
|
||||
|
|
|
@ -647,13 +647,6 @@ public class Spell extends StackObjImpl implements Card {
|
|||
return copy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adjustChoices(Ability ability, Game game) {
|
||||
if (card != null) {
|
||||
card.adjustChoices(ability, game);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adjustCosts(Ability ability, Game game) {
|
||||
if (card != null) {
|
||||
|
|
|
@ -49,8 +49,6 @@ import mage.abilities.costs.mana.ManaCostsImpl;
|
|||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.Effects;
|
||||
import mage.cards.Card;
|
||||
import mage.choices.Choice;
|
||||
import mage.choices.Choices;
|
||||
import mage.constants.AbilityType;
|
||||
import mage.constants.AbilityWord;
|
||||
import mage.constants.CardType;
|
||||
|
@ -307,15 +305,6 @@ public class StackAbility extends StackObjImpl implements Ability {
|
|||
return ability.getFirstTarget();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Choices getChoices() {
|
||||
return ability.getChoices();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addChoice(Choice choice) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManaCosts<ManaCost> getManaCosts() {
|
||||
return ability.getManaCosts();
|
||||
|
@ -354,14 +343,6 @@ public class StackAbility extends StackObjImpl implements Ability {
|
|||
this.expansionSetCode = expansionSetCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adjustChoices(Ability ability, Game game) {
|
||||
Card card = game.getCard(ability.getSourceId());
|
||||
if (card != null) {
|
||||
card.adjustChoices(ability, game);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adjustCosts(Ability ability, Game game) {
|
||||
Card card = game.getCard(ability.getSourceId());
|
||||
|
|
|
@ -2812,8 +2812,6 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
} else {
|
||||
addTargetOptions(options, ability, 0, game);
|
||||
}
|
||||
} else if (ability.getChoices().getUnchosen().size() > 0) {
|
||||
addChoiceOptions(options, ability, 0, game);
|
||||
} else if (ability.getCosts().getTargets().getUnchosen().size() > 0) {
|
||||
addCostTargetOptions(options, ability, 0, game);
|
||||
}
|
||||
|
@ -2834,8 +2832,6 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
} else {
|
||||
addTargetOptions(options, newOption, 0, game);
|
||||
}
|
||||
} else if (newOption.getChoices().getUnchosen().size() > 0) {
|
||||
addChoiceOptions(options, newOption, 0, game);
|
||||
} else if (newOption.getCosts().getTargets().getUnchosen().size() > 0) {
|
||||
addCostTargetOptions(options, newOption, 0, game);
|
||||
} else {
|
||||
|
@ -2863,22 +2859,6 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
}
|
||||
if (targetNum < option.getTargets().size() - 2) {
|
||||
addTargetOptions(options, newOption, targetNum + 1, game);
|
||||
} else if (option.getChoices().size() > 0) {
|
||||
addChoiceOptions(options, newOption, 0, game);
|
||||
} else if (option.getCosts().getTargets().size() > 0) {
|
||||
addCostTargetOptions(options, newOption, 0, game);
|
||||
} else {
|
||||
options.add(newOption);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addChoiceOptions(List<Ability> options, Ability option, int choiceNum, Game game) {
|
||||
for (String choice : option.getChoices().get(choiceNum).getChoices()) {
|
||||
Ability newOption = option.copy();
|
||||
newOption.getChoices().get(choiceNum).setChoice(choice);
|
||||
if (choiceNum < option.getChoices().size() - 1) {
|
||||
addChoiceOptions(options, newOption, choiceNum + 1, game);
|
||||
} else if (option.getCosts().getTargets().size() > 0) {
|
||||
addCostTargetOptions(options, newOption, 0, game);
|
||||
} else {
|
||||
|
|
|
@ -0,0 +1,177 @@
|
|||
/*
|
||||
*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*
|
||||
*/
|
||||
package mage.target.common;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.Filter;
|
||||
import mage.filter.common.FilterPermanentOrSuspendedCard;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.TargetImpl;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author emerald000
|
||||
*/
|
||||
public class TargetPermanentOrSuspendedCard extends TargetImpl {
|
||||
|
||||
protected FilterPermanentOrSuspendedCard filter;
|
||||
|
||||
public TargetPermanentOrSuspendedCard() {
|
||||
this(new FilterPermanentOrSuspendedCard(), false);
|
||||
}
|
||||
|
||||
public TargetPermanentOrSuspendedCard(FilterPermanentOrSuspendedCard filter, boolean notTarget) {
|
||||
super(notTarget);
|
||||
this.filter = filter;
|
||||
this.zone = Zone.ALL;
|
||||
this.targetName = filter.getMessage();
|
||||
this.minNumberOfTargets = 1;
|
||||
this.maxNumberOfTargets = 1;
|
||||
}
|
||||
|
||||
public TargetPermanentOrSuspendedCard(final TargetPermanentOrSuspendedCard target) {
|
||||
super(target);
|
||||
this.filter = target.filter.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Filter<Object> getFilter() {
|
||||
return this.filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetPermanentOrSuspendedCard copy() {
|
||||
return new TargetPermanentOrSuspendedCard(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
MageObject sourceObject = game.getObject(sourceId);
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter.getPermanentFilter(), sourceControllerId, game)) {
|
||||
if (permanent.canBeTargetedBy(sourceObject, sourceControllerId, game) && filter.match(permanent, sourceId, sourceControllerId, game)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
for (Card card : game.getExile().getAllCards(game)) {
|
||||
if (filter.match(card, sourceId, sourceControllerId, game)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
Set<UUID> possibleTargets = new HashSet<>(20);
|
||||
MageObject sourceObject = game.getObject(sourceId);
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter.getPermanentFilter(), sourceControllerId, game)) {
|
||||
if (permanent.canBeTargetedBy(sourceObject, sourceControllerId, game) && filter.match(permanent, sourceId, sourceControllerId, game)) {
|
||||
possibleTargets.add(permanent.getId());
|
||||
}
|
||||
}
|
||||
for (Card card : game.getExile().getAllCards(game)) {
|
||||
if (filter.match(card, sourceId, sourceControllerId, game)) {
|
||||
possibleTargets.add(card.getId());
|
||||
}
|
||||
}
|
||||
return possibleTargets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID id, Game game) {
|
||||
Permanent permanent = game.getPermanent(id);
|
||||
if (permanent != null) {
|
||||
return filter.match(permanent, game);
|
||||
}
|
||||
Card card = game.getExile().getCard(id, game);
|
||||
if (card != null) {
|
||||
return filter.match(card, game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID id, Ability source, Game game) {
|
||||
Permanent permanent = game.getPermanent(id);
|
||||
if (permanent != null) {
|
||||
if (source != null) {
|
||||
MageObject targetSource = game.getObject(source.getSourceId());
|
||||
return permanent.canBeTargetedBy(targetSource, source.getControllerId(), game)
|
||||
&& filter.match(permanent, source.getSourceId(), source.getControllerId(), game);
|
||||
} else {
|
||||
return filter.match(permanent, game);
|
||||
}
|
||||
}
|
||||
Card card = game.getExile().getCard(id, game);
|
||||
if (card != null) {
|
||||
return filter.match(card, game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID playerId, UUID id, Ability source, Game game) {
|
||||
return this.canTarget(id, source, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canChoose(UUID sourceControllerId, Game game) {
|
||||
return this.canChoose(null, sourceControllerId, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<UUID> possibleTargets(UUID sourceControllerId, Game game) {
|
||||
return this.possibleTargets(null, sourceControllerId, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTargetedName(Game game) {
|
||||
StringBuilder sb = new StringBuilder("");
|
||||
for (UUID targetId : this.getTargets()) {
|
||||
Permanent permanent = game.getPermanent(targetId);
|
||||
if (permanent != null) {
|
||||
sb.append(permanent.getLogName()).append(" ");
|
||||
} else {
|
||||
Card card = game.getExile().getCard(targetId, game);
|
||||
if (card != null) {
|
||||
sb.append(card.getLogName()).append(" ");
|
||||
}
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue