@Override public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { Set<UUID> possibleTargets = new HashSet<>(); MageObject targetSource = game.getObject(sourceId); for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); if (player != null && !player.hasLeft() && filter.match(player, sourceId, sourceControllerId, game)) { if (isNotTarget() || player.canBeTargetedBy(targetSource, sourceControllerId, game)) { possibleTargets.add(playerId); } } } return possibleTargets; }
@Override public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { Set<UUID> possibleTargets = new HashSet<>(); MageObject targetSource = game.getObject(sourceId); for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); if (player != null && player.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(player, game)) { possibleTargets.add(playerId); } } for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT, sourceControllerId, game)) { if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(permanent, sourceId, sourceControllerId, game)) { possibleTargets.add(permanent.getId()); } } return possibleTargets; }
@Override public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { Set<UUID> possibleTargets = new HashSet<>(); MageObject targetSource = game.getObject(sourceId); for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); if (player != null && player.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(player, game)) { possibleTargets.add(playerId); } } for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, sourceControllerId, game)) { if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(permanent, sourceId, sourceControllerId, game)) { possibleTargets.add(permanent.getId()); } } return possibleTargets; }
@Override public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { Set<UUID> possibleTargets = new HashSet<>(); MageObject targetSource = game.getObject(sourceId); for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); if (player != null && (notTarget || player.canBeTargetedBy(targetSource, sourceControllerId, game)) && filter.match(player, game)) { possibleTargets.add(playerId); } } for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_PLANESWALKER, sourceControllerId, game)) { if ((notTarget || permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) && filter.match(permanent, game)) { possibleTargets.add(permanent.getId()); } } return possibleTargets; }
@Override public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { Set<UUID> possibleTargets = new HashSet<>(); MageObject targetSource = game.getObject(sourceId); for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); if (player != null && (notTarget || player.canBeTargetedBy(targetSource, sourceControllerId, game)) && filter.getPlayerFilter().match(player, sourceId, sourceControllerId, game)) { possibleTargets.add(playerId); } } for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterPermanent(), sourceControllerId, game)) { if ((notTarget || permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) && filter.match(permanent, sourceId, sourceControllerId, game)) { possibleTargets.add(permanent.getId()); } } return possibleTargets; }
@Override public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { Set<UUID> possibleTargets = new HashSet<>(); MageObject targetSource = game.getObject(sourceId); for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); if (player != null && player.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.getPlayerFilter().match(player, sourceId, sourceControllerId, game)) { possibleTargets.add(playerId); } } for (Permanent permanent : game.getBattlefield().getActivePermanents(filter.getCreatureFilter(), sourceControllerId, game)) { if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.getCreatureFilter().match(permanent, sourceId, sourceControllerId, game)) { possibleTargets.add(permanent.getId()); } } return possibleTargets; }
/** * Checks if there are enough {@link Player} that can be chosen. Should only * be used for Ability targets since this checks for protection, shroud etc. * * @param sourceId - the target event source * @param sourceControllerId - controller of the target event source * @param game * @return - true if enough valid {@link Player} exist */ @Override public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { int count = 0; MageObject targetSource = game.getObject(sourceId); for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); if (player != null && !player.hasLeft() && filter.match(player, sourceId, sourceControllerId, game)) { if (player.canBeTargetedBy(targetSource, sourceControllerId, game)) { count++; if (count >= this.minNumberOfTargets) { return true; } } } } return false; }
@Override public boolean canTarget(UUID id, Ability source, Game game) { Player player = game.getPlayer(id); if (player != null) { if (source != null) { return (isNotTarget() || player.canBeTargetedBy(game.getObject(source.getSourceId()), source.getControllerId(), game)) && filter.match(player, source.getSourceId(), source.getControllerId(), game); } else { return filter.match(player, game); } } return false; }
@Override public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { Set<UUID> possibleTargets = new HashSet<>(); MageObject targetSource = game.getObject(sourceId); for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); if (player != null && player.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.getPlayerFilter().match(player, sourceId, sourceControllerId, game)) { possibleTargets.add(playerId); } } for (Permanent permanent : game.getBattlefield().getActivePermanents(filter.getCreatureFilter(), sourceControllerId, game)) { if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.getCreatureFilter().match(permanent, sourceId, sourceControllerId, game)) { possibleTargets.add(permanent.getId()); } } for (Permanent planeswalker : game.getBattlefield().getActivePermanents(filter.getPlaneswalkerFilter(), sourceControllerId, game)) { if (planeswalker.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.getPlaneswalkerFilter().match(planeswalker, sourceId, sourceControllerId, game)) { possibleTargets.add(planeswalker.getId()); } } return possibleTargets; }
@Override public boolean canTarget(UUID id, Ability source, Game game) { Player player = game.getPlayer(id); MageObject targetSource = game.getObject(attackerId); if (player != null) { return (notTarget || player.canBeTargetedBy(targetSource, (source == null ? null : source.getControllerId()), game)) && filter.match(player, game); } Permanent permanent = game.getPermanent(id); // planeswalker if (permanent != null) { //Could be targeting due to combat decision to attack a player or planeswalker. UUID controllerId = null; if (source != null) { controllerId = source.getControllerId(); } return (notTarget || permanent.canBeTargetedBy(targetSource, controllerId, game)) && filter.match(permanent, game); } return false; }
@Override public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { int count = 0; MageObject targetSource = game.getObject(sourceId); for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); if (player != null && player.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(player, game)) { count++; if (count >= this.minNumberOfTargets) { return true; } } } for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, sourceControllerId, game)) { if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(permanent, sourceId, sourceControllerId, game)) { count++; if (count >= this.minNumberOfTargets) { return true; } } } return false; }
@Override public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { int count = 0; MageObject targetSource = game.getObject(sourceId); Player controller = game.getPlayer(sourceControllerId); if (controller != null && targetSource != null) { for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); if (player != null && controller.getLife() < player.getLife() && !player.hasLeft() && filter.match(player, sourceId, sourceControllerId, game) && player.canBeTargetedBy(targetSource, sourceControllerId, game)) { count++; if (count >= this.minNumberOfTargets) { return true; } } } } return false; }
@Override public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { int count = 0; MageObject targetSource = game.getObject(sourceId); for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); if (player != null && player.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(player, game)) { count++; if (count >= this.minNumberOfTargets) { return true; } } } for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT, sourceControllerId, game)) { if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(permanent, sourceId, sourceControllerId, game)) { count++; if (count >= this.minNumberOfTargets) { return true; } } } return false; }
@Override public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { int count = 0; MageObject targetSource = game.getObject(sourceId); for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); if (player != null && (notTarget || player.canBeTargetedBy(targetSource, sourceControllerId, game)) && filter.match(player, game)) { count++; if (count >= this.minNumberOfTargets) { return true; } } } for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_PLANESWALKER, sourceControllerId, game)) { if ((notTarget || permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) && filter.match(permanent, game)) { count++; if (count >= this.minNumberOfTargets) { return true; } } } return false; }
@Override public boolean canTarget(UUID objectId, Ability source, Game game) { Permanent permanent = game.getPermanent(objectId); Player player = game.getPlayer(objectId); if (source != null) { MageObject targetSource = source.getSourceObject(game); if (permanent != null) { return permanent.canBeTargetedBy(targetSource, source.getControllerId(), game) && filter.match(permanent, source.getSourceId(), source.getControllerId(), game); } if (player != null) { return player.canBeTargetedBy(targetSource, source.getControllerId(), game) && filter.match(player, game); } } if (permanent != null) { return filter.match(permanent, game); } return player != null && filter.match(player, game); }
@Override public boolean canTarget(UUID objectId, Ability source, Game game) { Permanent permanent = game.getPermanent(objectId); Player player = game.getPlayer(objectId); if (source != null) { MageObject targetSource = source.getSourceObject(game); if (permanent != null) { return permanent.canBeTargetedBy(targetSource, source.getControllerId(), game) && filter.match(permanent, source.getSourceId(), source.getControllerId(), game); } if (player != null) { return player.canBeTargetedBy(targetSource, source.getControllerId(), game) && filter.match(player, game); } } if (permanent != null) { return filter.match(permanent, game); } return player != null && filter.match(player, game); }
@Override public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { int count = 0; MageObject targetSource = game.getObject(sourceId); Player controller = game.getPlayer(sourceControllerId); if (controller != null && targetSource != null) { for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); if (player != null && game.getBattlefield().countAll(StaticFilters.FILTER_PERMANENT_CREATURE, sourceControllerId, game) < game.getBattlefield().countAll(StaticFilters.FILTER_PERMANENT_CREATURE, playerId, game) && !player.hasLeft() && filter.match(player, sourceId, sourceControllerId, game) && player.canBeTargetedBy(targetSource, sourceControllerId, game)) { count++; if (count >= this.minNumberOfTargets) { return true; } } } } return false; }
@Override public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) { Permanent permanent = game.getPermanent(id); Player player = game.getPlayer(id); if (source != null) { MageObject targetSource = game.getObject(source.getSourceId()); if (permanent != null) { return permanent.canBeTargetedBy(targetSource, source.getControllerId(), game) && filter.match(permanent, source.getSourceId(), source.getControllerId(), game); } if (player != null) { return player.canBeTargetedBy(targetSource, source.getControllerId(), game) && filter.match(player, game); } } if (permanent != null) { return filter.match(permanent, game); } return player != null && filter.match(player, game); }
@Override public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) { Permanent permanent = game.getPermanent(id); Player player = game.getPlayer(id); if (source != null) { MageObject targetSource = game.getObject(source.getSourceId()); if (permanent != null) { return permanent.canBeTargetedBy(targetSource, source.getControllerId(), game) && filter.match(permanent, source.getSourceId(), source.getControllerId(), game); } if (player != null) { return player.canBeTargetedBy(targetSource, source.getControllerId(), game) && filter.match(player, game); } } if (permanent != null) { return filter.match(permanent, game); } return player != null && filter.match(player, game); }
@Override public boolean canTarget(UUID id, Ability source, Game game) { Permanent permanent = game.getPermanent(id); Player player = game.getPlayer(id); if (source != null) { MageObject targetSource = game.getObject(source.getSourceId()); if (permanent != null) { if (!isNotTarget()) { if (!permanent.canBeTargetedBy(game.getObject(source.getId()), source.getControllerId(), game) || !permanent.canBeTargetedBy(game.getObject(source.getSourceId()), source.getControllerId(), game)) { return false; } } return filter.match(permanent, source.getSourceId(), source.getControllerId(), game); } if (player != null) { if (!isNotTarget()) { if (!player.canBeTargetedBy(targetSource, source.getControllerId(), game) || !filter.match(player, source.getSourceId(), source.getControllerId(), game)) { return false; } } return filter.match(player, game); } } if (permanent != null) { return filter.match(permanent, game); } return player != null && filter.match(player, game); }