@Override public boolean canTransform(Ability source, Game game) { if (transformable) { for (Map.Entry<RestrictionEffect, Set<Ability>> entry : game.getContinuousEffects().getApplicableRestrictionEffects(this, game).entrySet()) { RestrictionEffect effect = entry.getKey(); for (Ability ability : entry.getValue()) { if (!effect.canTransform(this, ability, game)) { return false; } } } } return transformable; }
/** * Checks by restriction effects if the permanent can use activated * abilities * * @param game * @return true - permanent can use activated abilities */ @Override public boolean canUseActivatedAbilities(Game game) { for (Map.Entry<RestrictionEffect, Set<Ability>> entry : game.getContinuousEffects().getApplicableRestrictionEffects(this, game).entrySet()) { RestrictionEffect effect = entry.getKey(); for (Ability ability : entry.getValue()) { if (!effect.canUseActivatedAbilities(this, ability, game)) { return false; } } } return true; }
private boolean canAttackCheckRestrictionEffects(UUID defenderId, Game game) { //20101001 - 508.1c for (Map.Entry<RestrictionEffect, Set<Ability>> effectEntry : game.getContinuousEffects().getApplicableRestrictionEffects(this, game).entrySet()) { if (!effectEntry.getKey().canAttack(game)) { return false; } for (Ability ability : effectEntry.getValue()) { if (!effectEntry.getKey().canAttack(this, defenderId, ability, game)) { return false; } } } return true; }
Map<RestrictionEffect, Set<Ability>> attackerResEffects = game.getContinuousEffects().getApplicableRestrictionEffects(attacker, game); for (Map.Entry<RestrictionEffect, Set<Ability>> entry : attackerResEffects.entrySet()) { log.error(prefix+" " + entry.getKey()); Map<RestrictionEffect, Set<Ability>> blockerResEffects = game.getContinuousEffects().getApplicableRestrictionEffects(blocker, game); for (Map.Entry<RestrictionEffect, Set<Ability>> entry : blockerResEffects.entrySet()) { log.error(prefix+" " + entry.getKey());
@Override public boolean canBlockAny(Game game) { if (tapped && null == game.getState().getContinuousEffects().asThough(this.getId(), AsThoughEffectType.BLOCK_TAPPED, null, this.getControllerId(), game)) { return false; } //20101001 - 509.1b for (Map.Entry<RestrictionEffect, Set<Ability>> entry : game.getContinuousEffects().getApplicableRestrictionEffects(this, game).entrySet()) { RestrictionEffect effect = entry.getKey(); for (Ability ability : entry.getValue()) { if (!effect.canBlock(null, this, ability, game)) { return false; } } } return true; }
for (Map.Entry<RestrictionEffect, Set<Ability>> entry : game.getContinuousEffects().getApplicableRestrictionEffects(permanent, game).entrySet()) { for (Ability ability : entry.getValue()) { if (!entry.getKey().canBlock(attacker, permanent, ability, game)) { for (Map.Entry<RestrictionEffect, Set<Ability>> restrictionEntry : game.getContinuousEffects().getApplicableRestrictionEffects(attacker, game).entrySet()) { for (Ability ability : restrictionEntry.getValue()) { if (!(restrictionEntry.getKey() instanceof CantBeBlockedUnlessAllEffect)
for (Map.Entry<RestrictionEffect, Set<Ability>> entry : game.getContinuousEffects().getApplicableRestrictionEffects(this, game).entrySet()) { for (Ability ability : entry.getValue()) { if (!entry.getKey().canBlock(attacker, this, ability, game)) { for (Map.Entry<RestrictionEffect, Set<Ability>> restrictionEntry : game.getContinuousEffects().getApplicableRestrictionEffects(attacker, game).entrySet()) { for (Ability ability : restrictionEntry.getValue()) { if (!restrictionEntry.getKey().canBeBlocked(attacker, this, ability, game)) {
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(playerId)) { boolean untap = true; for (RestrictionEffect effect : game.getContinuousEffects().getApplicableRestrictionEffects(permanent, game).keySet()) { untap &= effect.canBeUntapped(permanent, null, game); for (RestrictionEffect effect : game.getContinuousEffects().getApplicableRestrictionEffects(permanent, game).keySet()) { untap &= effect.canBeUntapped(permanent, null, game);
Permanent blockingCreature = game.getPermanent(blockingCreatureId); if (blockingCreature != null) { for (Map.Entry<RestrictionEffect, Set<Ability>> entry : game.getContinuousEffects().getApplicableRestrictionEffects(blockingCreature, game).entrySet()) { RestrictionEffect effect = entry.getKey(); for (Ability ability : entry.getValue()) { Permanent attackingCreature = game.getPermanent(attackingCreatureId); if (attackingCreature != null) { for (Map.Entry<RestrictionEffect, Set<Ability>> entry : game.getContinuousEffects().getApplicableRestrictionEffects(attackingCreature, game).entrySet()) { RestrictionEffect effect = entry.getKey(); for (Ability ability : entry.getValue()) {
for (Map.Entry<RestrictionEffect, Set<Ability>> entry : game.getContinuousEffects().getApplicableRestrictionEffects(attackingCreature, game).entrySet()) { RestrictionEffect effect = entry.getKey(); for (Ability ability : entry.getValue()) {
@Override public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { Boolean applied = (Boolean) game.getState().getValue(source.getSourceId() + "applied"); if (applied == null) { applied = Boolean.FALSE; } if (!applied && layer == Layer.RulesEffects) { if (!game.isActivePlayer(source.getControllerId()) && game.getStep().getType() == PhaseStep.UNTAP) { game.getState().setValue(source.getSourceId() + "applied", true); Permanent land = game.getPermanent(source.getSourceId()); boolean untap = true; for (RestrictionEffect effect : game.getContinuousEffects().getApplicableRestrictionEffects(land, game).keySet()) { untap &= effect.canBeUntapped(land, source, game); } if (untap) { land.untap(game); } } } else if (applied && layer == Layer.RulesEffects) { if (game.getStep().getType() == PhaseStep.END_TURN) { game.getState().setValue(source.getSourceId() + "applied", false); } } return true; }
@Override public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { Boolean applied = (Boolean) game.getState().getValue(source.getSourceId() + "applied"); if (applied == null) { applied = Boolean.FALSE; } if (!applied && layer == Layer.RulesEffects) { if (!source.isControlledBy(game.getActivePlayerId()) && game.getStep().getType() == PhaseStep.UNTAP) { game.getState().setValue(source.getSourceId() + "applied", true); for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) { boolean untap = true; for (RestrictionEffect effect : game.getContinuousEffects().getApplicableRestrictionEffects(permanent, game).keySet()) { untap &= effect.canBeUntapped(permanent, source, game); } if (untap) { permanent.untap(game); } } } } else if (applied && layer == Layer.RulesEffects) { if (game.getStep().getType() == PhaseStep.END_TURN) { game.getState().setValue(source.getSourceId() + "applied", false); } } return true; }
@Override public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { Boolean applied = (Boolean) game.getState().getValue(source.getSourceId() + "applied"); if (applied == null) { applied = Boolean.FALSE; } if (!applied && layer == Layer.RulesEffects) { if (!game.isActivePlayer(source.getControllerId()) && game.getStep().getType() == PhaseStep.UNTAP) { game.getState().setValue(source.getSourceId() + "applied", true); for (Permanent artifact : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) { boolean untap = true; for (RestrictionEffect effect : game.getContinuousEffects().getApplicableRestrictionEffects(artifact, game).keySet()) { untap &= effect.canBeUntapped(artifact, source, game); } if (untap) { artifact.untap(game); } } } } else if (applied && layer == Layer.RulesEffects) { if (game.getStep().getType() == PhaseStep.END_TURN) { game.getState().setValue(source.getSourceId() + "applied", false); } } return true; }
@Override public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { Boolean applied = (Boolean) game.getState().getValue(source.getSourceId() + "applied"); if (applied == null) { applied = Boolean.FALSE; } if (!applied && layer == Layer.RulesEffects) { if (!source.isControlledBy(game.getActivePlayerId()) && game.getStep() != null && game.getStep().getType() == PhaseStep.UNTAP) { game.getState().setValue(source.getSourceId() + "applied", true); Permanent permanent = (Permanent) game.getPermanent(source.getSourceId()); if (permanent != null) { boolean untap = true; for (RestrictionEffect effect : game.getContinuousEffects().getApplicableRestrictionEffects(permanent, game).keySet()) { untap &= effect.canBeUntapped(permanent, source, game); } if (untap) { permanent.untap(game); } } } } else if (applied && layer == Layer.RulesEffects) { if (game.getStep() != null && game.getStep().getType() == PhaseStep.END_TURN) { game.getState().setValue(source.getSourceId() + "applied", false); } } return true; }