Exemple #1
0
 @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;
 }
Exemple #2
0
 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;
 }
Exemple #3
0
 @Override
 public boolean canTarget(UUID id, Game game) {
   Player player = game.getPlayer(id);
   if (player != null) {
     return filter.match(player, game);
   }
   return false;
 }
Exemple #4
0
 @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;
 }
Exemple #5
0
 /**
  * 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;
 }
Exemple #6
0
 @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;
 }
Exemple #7
0
 static {
   filter.add(new PlayerPredicate(TargetController.OPPONENT));
 }