@Override public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) { return game.getBattlefield().contains(filter, sourceId, game, 1); }
@Override public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) { return game.getBattlefield().contains(filter, controllerId, game, 1); }
@Override public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) { return !game.getBattlefield().contains(filter, 1, game); }
@Override public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) { return game.getBattlefield().contains(filter, controllerId, 1, game); }
@Override public boolean apply(Game game, Ability source) { return game.getBattlefield().contains(filter, source.getControllerId(), 3, game); }
@Override public boolean checkTrigger(GameEvent event, Game game) { return game.getBattlefield().contains(filter, this.getControllerId(), game, 1); }
@Override public boolean applies(Permanent permanent, Ability source, Game game) { if (permanent.getId().equals(source.getSourceId())) { return game.getBattlefield().contains(StaticFilters.FILTER_ENCHANTMENT_PERMANENT, 1, game); } return false; } }
@Override public boolean applies(GameEvent event, Ability source, Game game) { return event.getSourceId().equals(source.getSourceId()) && !game.getBattlefield().contains(filter, event.getPlayerId(), 1, game); }
@Override public boolean apply(Permanent input, Game game) { FilterPermanent filter = new FilterNonlandPermanent(); filter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, input.getConvertedManaCost())); return !game.getBattlefield().contains(filter, 1, game); }
@Override public boolean applies(GameEvent event, Ability source, Game game) { if ((event.getType() == GameEvent.EventType.WINS && game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) || (event.getType() == GameEvent.EventType.LOSES && event.getPlayerId().equals(source.getControllerId()))) { if (game.getBattlefield().contains(filter, source.getControllerId(), 1, game)) { return true; } } return false; }
for (SubType subtype : permanent.getSubtype(game)) { if (subtype.getSubTypeSet() == SubTypeSet.CreatureType) { if (game.getBattlefield().contains(new FilterControlledCreaturePermanent(subtype, subtype.toString()), sourceControllerId, game, 2)) { possibleTargets.add(permanent.getId());
if (game.getBattlefield().contains(filterFirstStrike, source.getControllerId(), 1, game)) { game.addEffect(new GainAbilityControlledEffect(FirstStrikeAbility.getInstance(), Duration.EndOfTurn, filterCreatures), source); if (game.getBattlefield().contains(filterFlying, source.getControllerId(), 1, game)) { game.addEffect(new GainAbilityControlledEffect(FlyingAbility.getInstance(), Duration.EndOfTurn, filterCreatures), source); if (game.getBattlefield().contains(filterDeathtouch, source.getControllerId(), 1, game)) { game.addEffect(new GainAbilityControlledEffect(DeathtouchAbility.getInstance(), Duration.EndOfTurn, filterCreatures), source); if (game.getBattlefield().contains(filterDoubleStrike, source.getControllerId(), 1, game)) { game.addEffect(new GainAbilityControlledEffect(DoubleStrikeAbility.getInstance(), Duration.EndOfTurn, filterCreatures), source); if (game.getBattlefield().contains(filterHaste, source.getControllerId(), 1, game)) { game.addEffect(new GainAbilityControlledEffect(HasteAbility.getInstance(), Duration.EndOfTurn, filterCreatures), source); if (game.getBattlefield().contains(filterHexproof, source.getControllerId(), 1, game)) { game.addEffect(new GainAbilityControlledEffect(HexproofAbility.getInstance(), Duration.EndOfTurn, filterCreatures), source); if (game.getBattlefield().contains(filterIndestructible, source.getControllerId(), 1, game)) { game.addEffect(new GainAbilityControlledEffect(IndestructibleAbility.getInstance(), Duration.EndOfTurn, filterCreatures), source); if (game.getBattlefield().contains(filterLifelink, source.getControllerId(), 1, game)) { game.addEffect(new GainAbilityControlledEffect(LifelinkAbility.getInstance(), Duration.EndOfTurn, filterCreatures), source); if (game.getBattlefield().contains(filterMenace, source.getControllerId(), 1, game)) { game.addEffect(new GainAbilityControlledEffect(new MenaceAbility(), Duration.EndOfTurn, filterCreatures), source); if (game.getBattlefield().contains(filterReach, source.getControllerId(), 1, game)) { game.addEffect(new GainAbilityControlledEffect(ReachAbility.getInstance(), Duration.EndOfTurn, filterCreatures), source);
@Override public boolean canTarget(UUID id, Ability source, Game game) { if (super.canTarget(id, game)) { Permanent targetPermanent = game.getPermanent(id); if (targetPermanent != null) { if (this.getTargets().isEmpty()) { for (Permanent permanent : game.getBattlefield().getActivePermanents(filterUntapped, source.getControllerId(), game)) { for (SubType subtype : permanent.getSubtype(game)) { if (subtype.getSubTypeSet() == SubTypeSet.CreatureType) { if (game.getBattlefield().contains(new FilterControlledCreaturePermanent(subtype, subtype.toString()), source.getControllerId(), game, 2)) { return true; } } } } } else { Permanent firstTarget = game.getPermanent(this.getTargets().get(0)); if (firstTarget != null && firstTarget.shareSubtypes(targetPermanent, game)) { return true; } } } } return false; }
@Override public boolean apply(Game game, Ability source) { if (game.getBattlefield().contains(filterFlying, source.getControllerId(), 1, game)) { game.addEffect(new GainAbilityControlledEffect(FlyingAbility.getInstance(), Duration.EndOfTurn, filterCreatures), source); if (game.getBattlefield().contains(filterFear, source.getControllerId(), 1, game)) { game.addEffect(new GainAbilityControlledEffect(FearAbility.getInstance(), Duration.EndOfTurn, filterCreatures), source); if (game.getBattlefield().contains(filterFirstStrike, source.getControllerId(), 1, game)) { game.addEffect(new GainAbilityControlledEffect(FirstStrikeAbility.getInstance(), Duration.EndOfTurn, filterCreatures), source); if (game.getBattlefield().contains(filterDoubleStrike, source.getControllerId(), 1, game)) { game.addEffect(new GainAbilityControlledEffect(DoubleStrikeAbility.getInstance(), Duration.EndOfTurn, filterCreatures), source); if (game.getBattlefield().contains(filterTrample, source.getControllerId(), 1, game)) { game.addEffect(new GainAbilityControlledEffect(TrampleAbility.getInstance(), Duration.EndOfTurn, filterCreatures), source); if (game.getBattlefield().contains(filterVigilance, source.getControllerId(), 1, game)) { game.addEffect(new GainAbilityControlledEffect(VigilanceAbility.getInstance(), Duration.EndOfTurn, filterCreatures), source);
@Override public boolean applies(GameEvent event, Ability source, Game game) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { if (controller.getHand().isEmpty()) { int numberPerms = new PermanentsOnBattlefieldCount(new FilterControlledPermanent()).calculate(game, source, this); if (numberPerms == 1) { if (game.getBattlefield().contains(filter, source.getControllerId(), 1, game)) { if (!wonAlready) { wonAlready = true; controller.won(game); } } } } } return false; }
@Override public void addSpecialAction(Ability source, Game game, ManaCost unpaid) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null && game.getBattlefield().contains(filterUntapped, controller.getId(), 1, game)) { if (source.getAbilityType() == AbilityType.SPELL) { SpecialAction specialAction = new ConvokeSpecialAction(unpaid);
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); MageObject sourceObject = source.getSourceObject(game); if (controller != null && sourceObject != null) { Cards cardsToReveal = new CardsImpl(); controller.revealCards(sourceObject.getIdName(), cardsToReveal, game); // Check battlefield if (!game.getBattlefield().contains(filterPermanent, source.getControllerId(), game, 1)) { return true; } if (controller.getHand().getCards(filterCard, source.getSourceId(), controller.getId(), game).isEmpty()) { return true; } if (controller.getGraveyard().getCards(filterCard, source.getSourceId(), controller.getId(), game).isEmpty()) { return true; } Cards cardsToCheck = new CardsImpl(); cardsToCheck.addAll(game.getExile().getAllCards(game)); if (cardsToCheck.count(filterCard, source.getSourceId(), controller.getId(), game) == 0) { return true; } controller.won(game); return true; } return false; } }
private void handleBaseEffect(Game game, Ability source, Player opponent, String iteration) { if (opponent.getHand().size() > 1) { if (opponent.chooseUse(outcome, "Choose your " + iteration + " punishment.", null, "Discard two cards", "Choose another option", source, game)) { opponent.discard(2, false, source, game); return; } } if (game.getBattlefield().contains(filter, opponent.getId(), 1, game)) { if (opponent.chooseUse(outcome, "Choose your " + iteration + " punishment.", null, "Sacrifice a creature or planeswalker", "Lose 5 life", source, game)) { TargetPermanent target = new TargetPermanent(1, 1, filter, true); if (target.choose(Outcome.Sacrifice, opponent.getId(), source.getId(), game)) { for (UUID targetId : target.getTargets()) { Permanent permanent = game.getPermanent(targetId); if (permanent != null) { permanent.sacrifice(source.getSourceId(), game); } } return; } } } opponent.loseLife(5, game, false); } }
@Override public void addSpecialAction(Ability source, Game game, ManaCost unpaid) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null && game.getBattlefield().contains(filterUntapped, controller.getId(), 1, game)) { if (source.getAbilityType() == AbilityType.SPELL && unpaid.getMana().getGeneric() > 0) { SpecialAction specialAction = new ImproviseSpecialAction(unpaid); specialAction.setControllerId(source.getControllerId()); specialAction.setSourceId(source.getSourceId()); // create filter for possible artifacts to tap FilterControlledArtifactPermanent filter = new FilterControlledArtifactPermanent(); filter.add(Predicates.not(TappedPredicate.instance)); Target target = new TargetControlledPermanent(1, unpaid.getMana().getGeneric(), filter, true); target.setTargetName("artifact to Improvise"); specialAction.addTarget(target); if (specialAction.canActivate(source.getControllerId(), game).canActivate()) { game.getState().getSpecialActions().add(specialAction); } } } }
@Override public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) { if (game.getBattlefield().contains(filter, blocker.getControllerId(), 1, game) && null == game.getContinuousEffects().asThough(blocker.getId(), AsThoughEffectType.BLOCK_LANDWALK, source, blocker.getControllerId(), game)) { switch (filter.getMessage()) { case "plains": return null != game.getContinuousEffects().asThough(blocker.getId(), AsThoughEffectType.BLOCK_PLAINSWALK, source, blocker.getControllerId(), game); case "island": return null != game.getContinuousEffects().asThough(blocker.getId(), AsThoughEffectType.BLOCK_ISLANDWALK, source, blocker.getControllerId(), game); case "swamp": return null != game.getContinuousEffects().asThough(blocker.getId(), AsThoughEffectType.BLOCK_SWAMPWALK, source, blocker.getControllerId(), game); case "mountain": return null != game.getContinuousEffects().asThough(blocker.getId(), AsThoughEffectType.BLOCK_MOUNTAINWALK, source, blocker.getControllerId(), game); case "forest": return null != game.getContinuousEffects().asThough(blocker.getId(), AsThoughEffectType.BLOCK_FORESTWALK, source, blocker.getControllerId(), game); default: return false; } } return true; }