@Override public int calculate(Game game, Ability sourceAbility, Effect effect) { int amount = game.getBattlefield().countAll(filter, sourceAbility.getControllerId(), game) / 2; return amount; }
@Override public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) { UUID attackingPlayerId = attacker.getControllerId(); if (attackingPlayerId != null) { return game.getBattlefield().countAll(new FilterControlledCreaturePermanent(), source.getControllerId(), game) > game.getBattlefield().countAll(new FilterControlledCreaturePermanent(), attackingPlayerId, game); } return true; }
@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 checkTrigger(GameEvent event, Game game) { int inputValue = game.getBattlefield().countAll(filter, getControllerId(), game); return ComparisonType.compare(inputValue, type, value); }
@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 canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) { Player player = game.getPlayer(blocker.getControllerId()); if (player != null) { if (game.getBattlefield().countAll(filter, player.getId(), game) > 0) { return false; } } return true; }
@Override public boolean apply(Game game, Ability source) { int numPermanents = game.getBattlefield().countAll(new FilterPermanent(), player.getId(), game); for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { if (numPermanents > game.getBattlefield().countAll(new FilterPermanent(), playerId, game)) { return true; } } return false; }
@Override public boolean checkInterveningIfClause(Game game) { FilterPermanent filter = new FilterPermanent(); filter.add(new ColorPredicate(ObjectColor.BLACK)); if (game.getBattlefield().countAll(filter, this.controllerId, game) >= 1) { return true; } return false; }
@Override public boolean checkInterveningIfClause(Game game) { UUID defendingPlayerId = game.getCombat().getDefendingPlayerId(getSourceId(), game); return defendingPlayerId != null && game.getBattlefield().countAll(filter, defendingPlayerId, game) < 1; }
@Override public boolean apply(Game game, Ability source) { UUID defendingPlayer = game.getCombat().getDefenderId(source.getSourceId()); return defendingPlayer != null && game.getBattlefield().countAll(filter, defendingPlayer, game) > 0; } }
@Override public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) { Player player = game.getPlayer(blocker.getControllerId()); if (player != null) { if (game.getBattlefield().countAll(filter, player.getId(), game) > 0) { return false; } } return true; }
@Override public boolean apply(Game game, Ability source) { int numYourLands = game.getBattlefield().countAll(new FilterLandPermanent(), source.getControllerId(), game); int numOpponentLands = game.getBattlefield().countAll(new FilterLandPermanent(), this.getTargetPointer().getFirst(game, source), game); new SearchLibraryPutInHandEffect(new TargetCardInLibrary(0, (numOpponentLands > numYourLands ? 2 : 1), filter), true).apply(game, source); return true; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { if (game.getBattlefield().countAll(new FilterCreaturePermanent(SubType.DEMON, "Demon"), source.getControllerId(), game) < 1) { controller.loseLife(1, game, false); } return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Player targetPlayer = game.getPlayer(source.getFirstTarget()); if (targetPlayer != null) { int amount = 2 * game.getBattlefield().countAll(filter, targetPlayer.getId(), game); targetPlayer.damage(amount, source.getSourceId(), game, false, true); return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(game.getActivePlayerId()); if (player != null) { int damage = game.getBattlefield().countAll(filter, game.getActivePlayerId(), game); player.damage(damage, source.getSourceId(), game, false, true); return true; } return false; }
@Override public boolean apply(Game game, Ability source) { FilterControlledPermanent filter = new FilterControlledPermanent(); Player player = game.getPlayer(source.getControllerId()); int permanentsInPlay = game.getBattlefield().countAll(filter, source.getControllerId(), game); if (player != null) { player.setLife(permanentsInPlay, game, source); return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { int creaturesControlled = game.getBattlefield().countAll(StaticFilters.FILTER_PERMANENT_CREATURE, controller.getId(), game); controller.drawCards(creaturesControlled, game); controller.loseLife(creaturesControlled, game, false); return true; } return false; } }
@Override public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) { if (sourceId.equals(source.getSourceId()) && source.isControlledBy(affectedControllerId)) { Card card = game.getCard(source.getSourceId()); if (card != null && game.getState().getZone(source.getSourceId()) == Zone.GRAVEYARD) { if (game.getBattlefield().countAll(filter, source.getControllerId(), game) > 0) { return true; } } } return false; }
@Override public boolean checkInterveningIfClause(Game game) { // if you control both this creature and another creature and both are unpaired if (game.getBattlefield().countAll(filter, getControllerId(), game) > 0) { Permanent sourcePermanent = game.getPermanent(getSourceId()); if (sourcePermanent != null && sourcePermanent.isControlledBy(getControllerId()) && sourcePermanent.getPairedCard() == null) { return true; } } return false; }
@Override public boolean apply(Game game, Ability source) { FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("Eldrazi Spawn"); filter.add(new SubtypePredicate(SubType.ELDRAZI)); filter.add(new SubtypePredicate(SubType.SPAWN)); EldraziSpawnToken token = new EldraziSpawnToken(); int count = game.getBattlefield().countAll(filter, source.getControllerId(), game) > 0 ? 3 : 1; token.putOntoBattlefield(count, game, source.getSourceId(), source.getControllerId()); return true; } }