use of mage.abilities.effects.AsThoughEffectImpl in project mage by magefree.
the class WordOfCommandTestFlashEffect method checkPlayability.
private boolean checkPlayability(Card card, Player targetPlayer, Game game, Ability source) {
// check for card playability
boolean canPlay = false;
if (card.isLand(game)) {
// we can't use getPlayableObjects(game) in here because it disallows playing lands outside the main step // TODO: replace to getPlayable() checks with disable step condition?
if (targetPlayer.canPlayLand() && game.getActivePlayerId().equals(targetPlayer.getId())) {
for (Ability ability : card.getAbilities(game)) {
if (ability instanceof PlayLandAbility) {
if (!game.getContinuousEffects().preventedByRuleModification(GameEvent.getEvent(GameEvent.EventType.PLAY_LAND, ability.getSourceId(), ability, targetPlayer.getId()), ability, game, true)) {
canPlay = true;
}
}
}
}
} else {
// Word of Command allows the chosen card to be played "as if it had flash" so we need to invoke such effect to bypass the check
AsThoughEffectImpl effect2 = new WordOfCommandTestFlashEffect();
game.addEffect(effect2, source);
if (targetPlayer.getPlayableObjects(game, Zone.HAND).containsObject(card.getId())) {
canPlay = true;
}
for (AsThoughEffect eff : game.getContinuousEffects().getApplicableAsThoughEffects(AsThoughEffectType.CAST_AS_INSTANT, game)) {
if (eff instanceof WordOfCommandTestFlashEffect) {
eff.discard();
break;
}
}
}
return canPlay;
}
Aggregations