mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 11:32:00 -08:00
fixed issue 242 - check all modes for targets
This commit is contained in:
parent
ac70150512
commit
6d4c3aa8d9
7 changed files with 26 additions and 6 deletions
|
|
@ -63,7 +63,7 @@ public class EntomberExarch extends CardImpl<EntomberExarch> {
|
||||||
this.power = new MageInt(2);
|
this.power = new MageInt(2);
|
||||||
this.toughness = 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 ability = new EntersBattlefieldTriggeredAbility(new ReturnToHandTargetEffect(), false);
|
||||||
ability.addTarget(new TargetCardInYourGraveyard(new FilterCreatureCard()));
|
ability.addTarget(new TargetCardInYourGraveyard(new FilterCreatureCard()));
|
||||||
Mode mode = new Mode();
|
Mode mode = new Mode();
|
||||||
|
|
@ -84,7 +84,7 @@ public class EntomberExarch extends CardImpl<EntomberExarch> {
|
||||||
}
|
}
|
||||||
|
|
||||||
class EntomberExarchEffect extends OneShotEffect<EntomberExarchEffect> {
|
class EntomberExarchEffect extends OneShotEffect<EntomberExarchEffect> {
|
||||||
private static final FilterCard filter = new FilterCard();
|
private static final FilterCard filter = new FilterCard("noncreature card");
|
||||||
|
|
||||||
static {
|
static {
|
||||||
filter.getNotCardType().add(CardType.CREATURE);
|
filter.getNotCardType().add(CardType.CREATURE);
|
||||||
|
|
|
||||||
|
|
@ -321,7 +321,10 @@ public interface Ability extends Serializable {
|
||||||
public void reset(Game game);
|
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);
|
public boolean checkIfClause(Game game);
|
||||||
|
|
||||||
|
|
@ -337,5 +340,7 @@ public interface Ability extends Serializable {
|
||||||
public void addMode(Mode mode);
|
public void addMode(Mode mode);
|
||||||
|
|
||||||
public Modes getModes();
|
public Modes getModes();
|
||||||
|
|
||||||
|
public boolean canChooseTarget(Game game);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -414,6 +414,15 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> implements Ability {
|
||||||
public Modes getModes() {
|
public Modes getModes() {
|
||||||
return modes;
|
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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
|
||||||
|
|
@ -152,7 +152,7 @@ public abstract class ActivatedAbilityImpl<T extends ActivatedAbilityImpl<T>> ex
|
||||||
return false;
|
return false;
|
||||||
//20091005 - 602.5d/602.5e
|
//20091005 - 602.5d/602.5e
|
||||||
if (timing == TimingRule.INSTANT || game.canPlaySorcery(playerId)) {
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ public class SpellAbility extends ActivatedAbilityImpl<SpellAbility> {
|
||||||
object.getAbilities().containsKey(FlashAbility.getInstance().getId()) ||
|
object.getAbilities().containsKey(FlashAbility.getInstance().getId()) ||
|
||||||
game.getContinuousEffects().asThough(sourceId, AsThoughEffectType.CAST, game) ||
|
game.getContinuousEffects().asThough(sourceId, AsThoughEffectType.CAST, game) ||
|
||||||
game.canPlaySorcery(playerId))) {
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -305,6 +305,7 @@ public class StackAbility implements StackObject, Ability {
|
||||||
@Override
|
@Override
|
||||||
public void newId() {}
|
public void newId() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Ability getStackAbility() {
|
public Ability getStackAbility() {
|
||||||
return ability;
|
return ability;
|
||||||
}
|
}
|
||||||
|
|
@ -321,4 +322,9 @@ public class StackAbility implements StackObject, Ability {
|
||||||
public Modes getModes() {
|
public Modes getModes() {
|
||||||
return ability.getModes();
|
return ability.getModes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canChooseTarget(Game game) {
|
||||||
|
return ability.canChooseTarget(game);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -577,7 +577,7 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
|
||||||
//20091005 - 603.3c, 603.3d
|
//20091005 - 603.3c, 603.3d
|
||||||
int bookmark = game.bookmarkState();
|
int bookmark = game.bookmarkState();
|
||||||
TriggeredAbility ability = (TriggeredAbility) source.copy();
|
TriggeredAbility ability = (TriggeredAbility) source.copy();
|
||||||
if (ability.getTargets().canChoose(ability.getSourceId(), playerId, game)) {
|
if (ability.canChooseTarget(game)) {
|
||||||
game.getStack().push(new StackAbility(ability, playerId));
|
game.getStack().push(new StackAbility(ability, playerId));
|
||||||
if (ability.activate(game, false)) {
|
if (ability.activate(game, false)) {
|
||||||
game.removeBookmark(bookmark);
|
game.removeBookmark(bookmark);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue