@Override public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) { if (targetId != null && blocker.getId().equals(targetId)) { return true; } return false; } }
@Override public UUID chooseAttackerOrder(List<Permanent> attackers, Game game) { //TODO: improve this return attackers.iterator().next().getId(); }
@Override public UUID chooseBlockerOrder(List<Permanent> blockers, CombatGroup combatGroup, List<UUID> blockerOrder, Game game) { //TODO: improve this return blockers.iterator().next().getId(); }
public FixedTargets(List<Permanent> permanents, Game game) { for (Permanent permanent : permanents) { MageObjectReference mor = new MageObjectReference(permanent.getId(), permanent.getZoneChangeCounter(game), game); targets.add(mor); } this.initialized = true; }
@Override public boolean applies(Permanent permanent, Ability source, Game game) { if (permanent.getId().equals(source.getSourceId())) { if (!game.getBattlefield().getActivePermanents(filter, source.getControllerId(), permanent.getId(), game).isEmpty()) { return false; } return true; } return false; } }
@Override public boolean applies(GameEvent event, Ability source, Game game) { if (event.getTargetId().equals(source.getSourceId())) { Permanent sourcePermanent = ((EntersTheBattlefieldEvent) event).getTarget(); game.getState().setValue(sourcePermanent.getId().toString() + "devoured", null); return true; } return false; }
@Override public boolean applies(Permanent permanent, Ability source, Game game) { if (permanent.getId().equals(source.getSourceId())) { if (game.getBattlefield().countAll(filter, source.getControllerId(), game) > 0) { return false; } return true; } // do not apply to other creatures. return false; } }
@Override public boolean applies(Permanent permanent, Ability source, Game game) { Permanent attachment = game.getPermanent(source.getSourceId()); return attachment != null && attachment.getAttachedTo() != null && permanent.getId().equals(attachment.getAttachedTo()); } }
@Override public boolean applies(Permanent permanent, Ability source, Game game) { Permanent attachment = game.getPermanent(source.getSourceId()); return attachment != null && attachment.getAttachedTo() != null && permanent.getId().equals(attachment.getAttachedTo()); }
@Override public boolean applies(Permanent permanent, Ability source, Game game) { if (permanent.getId().equals(source.getSourceId())) { if (game.getBattlefield().countAll(StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT, source.getControllerId(), game) > 0) { return false; } return true; } // do not apply to other creatures. return false; } }
@Override public boolean apply(Game game, Ability source) { for (Permanent permanent : game.getBattlefield().getAllActivePermanents()) { if (!permanent.getId().equals(source.getSourceId())) { permanent.moveToExile(null, null, source.getSourceId(), game); } } return true; } }
@Override public boolean applies(GameEvent event, Ability source, Game game) { if (!this.used && super.applies(event, source, game)) { Permanent targetCreature = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); return targetCreature != null && targetCreature.getId().equals(event.getSourceId()); } return false; }
@Override public void init(Ability source, Game game) { super.init(source, game); if (this.affectedObjectsSet) { for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { if (!(excludeSource && perm.getId().equals(source.getSourceId()))) { affectedObjectList.add(new MageObjectReference(perm, game)); } } } }
@Override public boolean applies(Permanent permanent, Ability source, Game game) { Permanent attachment = game.getPermanent(source.getSourceId()); if (attachment != null && attachment.getAttachedTo() != null && permanent.getId().equals(attachment.getAttachedTo())) { String key = source.getSourceId().toString() + attachment.getZoneChangeCounter(game) + keyString + game.getTurnNum() + permanent.getControllerId(); return game.getState().getValue(key) == null; } return false; }
@Override public boolean checkTrigger(GameEvent event, Game game) { Permanent equipment = game.getPermanent(sourceId); if (equipment != null && equipment.getAttachedTo() != null) { Permanent equipped = game.getPermanent(equipment.getAttachedTo()); if (equipped.getId().equals(event.getTargetId())) { getEffects().get(1).setTargetPointer(new FixedTarget(equipped, game)); return true; } } return false; }
@Override public boolean checkTrigger(GameEvent event, Game game) { if (game.getOpponents(controllerId).contains(event.getPlayerId())) { Permanent permanent = game.getPermanent(event.getSourceId()); if (permanent != null && permanent.isLand()) { getEffects().get(0).setTargetPointer(new FixedTarget(permanent.getId())); return true; } } return false; }
@Override public boolean checkTrigger(GameEvent event, Game game) { if (((DamagedPlaneswalkerEvent) event).isCombatDamage() && getSourceId().equals(event.getTargetId())) { Permanent sourceOfDamage = game.getPermanent(event.getSourceId()); if (sourceOfDamage != null && sourceOfDamage.isCreature()) { Effect effect = this.getEffects().get(0); effect.setTargetPointer(new FixedTarget(sourceOfDamage.getId())); return true; } } return false; }
@Override public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) { return blocker.getAbilities().containsKey(ShadowAbility.getInstance().getId()) || null != game.getContinuousEffects().asThough(blocker.getId(), AsThoughEffectType.BLOCK_SHADOW, source, blocker.getControllerId(), game); }
@Override public boolean apply(Game game, Ability source) { boolean ret = false; for(Permanent enchantment : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_ENCHANTMENT_PERMANENT, source.getControllerId(), source.getControllerId(), game)) { ContinuousEffect gainControl = new GainControlTargetEffect(Duration.EndOfGame); gainControl.setTargetPointer(new FixedTarget(enchantment.getId())); game.addEffect(gainControl, source); ret = true; } return ret; } }