public Permanent getPermanent(UUID permanentId) { if (permanentId != null && battlefield.containsPermanent(permanentId)) { Permanent permanent = battlefield.getPermanent(permanentId); // setZone(permanent.getId(), Zone.BATTLEFIELD); // shouldn't this be set anyway? (LevelX2) return permanent; } return null; }
@Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId()); if (permanent != null) { return permanent.isTapped(); } return false; } }
@Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId()); if (permanent != null) { return permanent.isAttacking(); } return false; }
@Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId()); if (permanent != null) { return !permanent.isTapped(); } return false; } }
@Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId()); if (permanent != null) { return !permanent.isTapped(); } return false; }
@Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId()); if (permanent != null) { return permanent.getTurnsOnBattlefield() == 0; } return false; }
@Override public boolean apply(Game game, Ability source) { if (controllerId == null) { controllerId = source.getControllerId(); } Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId()); return (permanent != null && Objects.equals(controllerId, source.getControllerId())); }
@Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId()); if (permanent != null) { return permanent.isBlocked(game); } return false; }
@Override public boolean applies(Permanent permanent, Ability source, Game game) { if (permanent.getId().equals(source.getSourceId())) { List<UUID> attachments = permanent.getAttachments(); for (UUID uuid : attachments) { Permanent attached = game.getBattlefield().getPermanent(uuid); if (attached.hasSubtype(SubType.EQUIPMENT, game)) { return false; } } return true; } // don't apply for all other creatures! return false; }
@Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId()); PalladiaMorsTheRuinerWatcher watcher = game.getState().getWatcher(PalladiaMorsTheRuinerWatcher.class); return permanent != null && !watcher.getDamagers().contains(new MageObjectReference(permanent, game)); }
@Override public boolean apply(Game game, Ability source) { Permanent target = game.getBattlefield().getPermanent(source.getFirstTarget()); if (target != null) { if (filter.match(target, source.getSourceId(), source.getControllerId(), game)) { return true; } } return false; } }
@Override public ActivationStatus canActivate(UUID playerId, Game game) { if (playerId.equals(caster)) { Permanent permanent = game.getBattlefield().getPermanent(this.getSourceId()); if (permanent != null) { if (filter.match(permanent, permanent.getId(), permanent.getControllerId(), game)) { return super.canActivate(playerId, game); } } } return ActivationStatus.getFalse(); }
@Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId()); if (permanent == null || !permanent.isAttacking()) { return false; } CombatGroup combatGroup = game.getCombat().findGroup(permanent.getId()); return combatGroup != null && combatGroup.getBlockers().size() > 1; }
@Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId()); if (permanent != null) { if (FILTER.match(permanent, permanent.getId(), permanent.getControllerId(), game)) { return true; } } return false; }
@Override public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) { Permanent sourcePermanent = game.getBattlefield().getPermanent(sourceId); if (sourcePermanent != null) { Permanent attachedTo = game.getPermanent(sourcePermanent.getAttachedTo()); if (attachedTo != null) { return attachedTo.getManaCost().canPay(ability, sourceId, controllerId, game); } } return false; }
@Override public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) { Permanent sourcePermanent = game.getBattlefield().getPermanent(sourceId); if (sourcePermanent != null) { Permanent attachedTo = game.getPermanent(sourcePermanent.getAttachedTo()); if (attachedTo != null) { paid = attachedTo.getManaCost().pay(ability, game, sourceId, controllerId, noMana); } } return paid; } }
@Override public ActivationStatus canActivate(UUID playerId, Game game) { Permanent sourcePermanent = game.getBattlefield().getPermanent(this.getSourceId()); if (sourcePermanent != null) { Permanent attachedTo = game.getPermanent(sourcePermanent.getAttachedTo()); if (attachedTo != null) { return super.canActivate(attachedTo.getControllerId(), game); } } return ActivationStatus.getFalse(); }
private UUID getSourceControllerId(UUID sourceId, Game game) { StackObject source = game.getStack().getStackObject(sourceId); if (source != null) { return source.getControllerId(); } Permanent permanent = game.getBattlefield().getPermanent(sourceId); if (permanent != null) { return permanent.getControllerId(); } // for effects like Deflecting Palm (could be wrong if card was played multiple times by different players) return game.getContinuousEffects().getControllerOfSourceId(sourceId); } }
@Override public boolean applies(GameEvent event, Ability source, Game game) { Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId()); if (permanent != null) { if (filter.match(permanent, permanent.getId(), permanent.getControllerId(), game)) { if (sourceObject.equals(new MageObjectReference(event.getSourceId(), game))) { redirectTarget = new TargetPermanent(); redirectTarget.add(source.getSourceId(), game); return event.getTargetId().equals(getTargetPointer().getFirst(game, source)); } } } return false; }
@Override public boolean checkTrigger(GameEvent event, Game game) { if (event.getPlayerId().equals(this.getControllerId())) { Spell spell = game.getStack().getSpell(event.getTargetId()); if (isControlledInstantOrSorcery(spell)) { Permanent permanent = game.getBattlefield().getPermanent(this.getSourceId()); if (permanent != null && permanent.getCounters(game).getCount(CounterType.QUEST) >= 2) { this.getEffects().get(0).setTargetPointer(new FixedTarget(spell.getId())); return true; } } } return false; }