mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08: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
|
|
@ -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…
Add table
Add a link
Reference in a new issue