public boolean replaceEvent(GameEvent event, Ability targetAbility, Game game) { if (effects.preventedByRuleModification(event, targetAbility, game, false)) { return true; } return effects.replaceEvent(event, game); }
protected void playLand(Game game) { log.debug("playLand"); Set<Card> lands = new LinkedHashSet<>(); for (Card landCard : hand.getCards(new FilterLandCard(), game)) { // remove lands that can not be played if (game.getContinuousEffects().preventedByRuleModification(GameEvent.getEvent(GameEvent.EventType.PLAY_LAND, landCard.getId(), landCard.getId(), playerId), null, game, true)) { break; } lands.add(landCard); } while (!lands.isEmpty() && this.canPlayLand()) { if (lands.size() == 1) { this.playLand(lands.iterator().next(), game, false); } else { playALand(lands, game); } } }
@Override public boolean cantBeAttachedBy(MageObject source, Game game) { for (ProtectionAbility ability : this.getAbilities(game).getProtectionAbilities()) { if (!(source.hasSubtype(SubType.AURA, game) && !ability.removesAuras()) && !source.getId().equals(ability.getAuraIdNotToBeRemoved()) && !ability.canTarget(source, game)) { return true; } } return game.getContinuousEffects().preventedByRuleModification(GameEvent.getEvent(EventType.STAY_ATTACHED, objectId, source.getId(), null), null, game, false); }
SpellAbility ability = card.getSpellAbility(); if (ability != null && ability.canActivate(playerId, game).canActivate() && game.getContinuousEffects().preventedByRuleModification(GameEvent.getEvent(GameEvent.EventType.CAST_SPELL, ability.getSourceId(), ability.getSourceId(), playerId), ability, game, true)) { if (card.getCardType().contains(CardType.INSTANT) || card.hasAbility(FlashAbility.getInstance().getId(), game)) {
private boolean checkPlayability(Card card, Player targetPlayer, Game game, Ability source) { // check for card playability boolean canPlay = false; if (card.isLand()) { // we can't use getPlayableInHand(game) in here because it disallows playing lands outside the main step if (targetPlayer.canPlayLand() && game.getActivePlayerId().equals(targetPlayer.getId())) { canPlay = true; for (Ability ability : card.getAbilities(game)) { if (!game.getContinuousEffects().preventedByRuleModification(GameEvent.getEvent(GameEvent.EventType.PLAY_LAND, ability.getSourceId(), ability.getSourceId(), 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.getPlayableInHand(game).contains(card.getId())) { canPlay = true; } for (AsThoughEffect eff : game.getContinuousEffects().getApplicableAsThoughEffects(AsThoughEffectType.CAST_AS_INSTANT, game)) { if (eff instanceof WordOfCommandTestFlashEffect) { eff.discard(); break; } } } return canPlay; } }
switch (ability.getAbilityType()) { case PLAY_LAND: if (game.getContinuousEffects().preventedByRuleModification(GameEvent.getEvent(GameEvent.EventType.PLAY_LAND, ability.getSourceId(), ability.getSourceId(), playerId), ability, game, true)) { break;
if (ability instanceof ActivatedAbility) { if (!(ability instanceof PlayLandAbility) || !game.getContinuousEffects().preventedByRuleModification(GameEvent.getEvent(GameEvent.EventType.PLAY_LAND, ability.getSourceId(), ability.getSourceId(), playerId), ability, game, true)) { if (canPlay((ActivatedAbility) ability, availableMana, card, game)) { playable.add(ability);
if (event == null || !game.getContinuousEffects().preventedByRuleModification(event, ability, game, false)) { if (object != null) { boolean controllerSet = false;
if (game.getContinuousEffects().preventedByRuleModification( GameEvent.getEvent(GameEvent.EventType.CAST_SPELL, this.getId(), this.getSourceId(), playerId), this, game, true)) { return ActivationStatus.getFalse();
if (game.getContinuousEffects().preventedByRuleModification(GameEvent.getEvent(EventType.TARGET, this.getId(), source.getId(), sourceControllerId), null, game, true)) { return false;