@Override public boolean canTarget(UUID id, Ability source, Game game) { Player player = game.getPlayer(id); if (player != null) { if (source != null) { return player.canBeTargetedBy(game.getObject(source.getSourceId()), game) && filter.match(player, source.getSourceId(), source.getControllerId(), game); } else { return filter.match(player, game); } } return false; }
public TargetPlayer( int minNumTargets, int maxNumTargets, boolean notTarget, FilterPlayer filter) { this.minNumberOfTargets = minNumTargets; this.maxNumberOfTargets = maxNumTargets; this.filter = filter; this.targetName = filter.getMessage(); this.notTarget = notTarget; }
@Override public boolean canTarget(UUID id, Game game) { Player player = game.getPlayer(id); if (player != null) { return filter.match(player, game); } return false; }
@Override public Set<UUID> possibleTargets(UUID sourceControllerId, Game game) { Set<UUID> possibleTargets = new HashSet<UUID>(); for (UUID playerId : game.getPlayer(sourceControllerId).getInRange()) { Player player = game.getPlayer(playerId); if (player != null && !player.hasLeft() && filter.match(player, game)) { possibleTargets.add(playerId); } } return possibleTargets; }
/** * Checks if there are enough {@link Player} that can be selected. Should not be used for Ability * targets since this does not check for protection, shroud etc. * * @param sourceControllerId - controller of the select event * @param game * @return - true if enough valid {@link Player} exist */ @Override public boolean canChoose(UUID sourceControllerId, Game game) { int count = 0; for (UUID playerId : game.getPlayer(sourceControllerId).getInRange()) { Player player = game.getPlayer(playerId); if (player != null && !player.hasLeft() && filter.match(player, game)) { count++; if (count >= this.minNumberOfTargets) return true; } } return false; }
@Override public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { Set<UUID> possibleTargets = new HashSet<UUID>(); MageObject targetSource = game.getObject(sourceId); for (UUID playerId : game.getPlayer(sourceControllerId).getInRange()) { Player player = game.getPlayer(playerId); if (player != null && !player.hasLeft() && filter.match(player, sourceId, sourceControllerId, game)) { if (player.canBeTargetedBy(targetSource, game)) possibleTargets.add(playerId); } } return possibleTargets; }
static { filter.add(new PlayerPredicate(TargetController.OPPONENT)); }