fixed issue 242 - check all modes for targets

This commit is contained in:
BetaSteward 2011-09-05 22:02:50 -04:00
parent ac70150512
commit 6d4c3aa8d9
7 changed files with 26 additions and 6 deletions

View file

@ -63,7 +63,7 @@ public class EntomberExarch extends CardImpl<EntomberExarch> {
this.power = new MageInt(2);
this.toughness = new MageInt(2);
// When Entomber Exarch enters the battlefield, choose one <EFBFBD> Return target creature card from your graveyard to your hand; or target opponent reveals his or her hand, you choose a noncreature card from it, then that player discards that card.
// When Entomber Exarch enters the battlefield, choose one - Return target creature card from your graveyard to your hand; or target opponent reveals his or her hand, you choose a noncreature card from it, then that player discards that card.
Ability ability = new EntersBattlefieldTriggeredAbility(new ReturnToHandTargetEffect(), false);
ability.addTarget(new TargetCardInYourGraveyard(new FilterCreatureCard()));
Mode mode = new Mode();
@ -84,7 +84,7 @@ public class EntomberExarch extends CardImpl<EntomberExarch> {
}
class EntomberExarchEffect extends OneShotEffect<EntomberExarchEffect> {
private static final FilterCard filter = new FilterCard();
private static final FilterCard filter = new FilterCard("noncreature card");
static {
filter.getNotCardType().add(CardType.CREATURE);

View file

@ -321,7 +321,10 @@ public interface Ability extends Serializable {
public void reset(Game game);
/**
* TODO: Determine what this is used for, current implementations always return true.
* Overridden by triggered abilities with intervening if clauses - rule 20110715 - 603.4
*
* @param game
* @return Whether or not the intervening if clause is satisfied
*/
public boolean checkIfClause(Game game);
@ -337,5 +340,7 @@ public interface Ability extends Serializable {
public void addMode(Mode mode);
public Modes getModes();
public boolean canChooseTarget(Game game);
}

View file

@ -414,6 +414,15 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> implements Ability {
public Modes getModes() {
return modes;
}
@Override
public boolean canChooseTarget(Game game) {
for (Mode mode: modes.values()) {
if (mode.getTargets().canChoose(sourceId, controllerId, game))
return true;
}
return false;
}
@Override
public String toString() {

View file

@ -152,7 +152,7 @@ public abstract class ActivatedAbilityImpl<T extends ActivatedAbilityImpl<T>> ex
return false;
//20091005 - 602.5d/602.5e
if (timing == TimingRule.INSTANT || game.canPlaySorcery(playerId)) {
if (costs.canPay(sourceId, controllerId, game) && getTargets().canChoose(sourceId, playerId, game)) {
if (costs.canPay(sourceId, controllerId, game) && canChooseTarget(game)) {
return true;
}
}

View file

@ -61,7 +61,7 @@ public class SpellAbility extends ActivatedAbilityImpl<SpellAbility> {
object.getAbilities().containsKey(FlashAbility.getInstance().getId()) ||
game.getContinuousEffects().asThough(sourceId, AsThoughEffectType.CAST, game) ||
game.canPlaySorcery(playerId))) {
if (costs.canPay(sourceId, controllerId, game) && getTargets().canChoose(this.getId(), playerId, game)) {
if (costs.canPay(sourceId, controllerId, game) && canChooseTarget(game)) {
return true;
}
}

View file

@ -305,6 +305,7 @@ public class StackAbility implements StackObject, Ability {
@Override
public void newId() {}
@Override
public Ability getStackAbility() {
return ability;
}
@ -321,4 +322,9 @@ public class StackAbility implements StackObject, Ability {
public Modes getModes() {
return ability.getModes();
}
@Override
public boolean canChooseTarget(Game game) {
return ability.canChooseTarget(game);
}
}

View file

@ -577,7 +577,7 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
//20091005 - 603.3c, 603.3d
int bookmark = game.bookmarkState();
TriggeredAbility ability = (TriggeredAbility) source.copy();
if (ability.getTargets().canChoose(ability.getSourceId(), playerId, game)) {
if (ability.canChooseTarget(game)) {
game.getStack().push(new StackAbility(ability, playerId));
if (ability.activate(game, false)) {
game.removeBookmark(bookmark);