Esempio n. 1
0
 protected boolean chooseRandom(Target target, Game game) {
   Set<UUID> possibleTargets = target.possibleTargets(playerId, game);
   if (possibleTargets.isEmpty()) return !target.isRequired();
   if (!target.isRequired()) {
     if (rnd.nextInt(possibleTargets.size() + 1) == 0) {
       return false;
     }
   }
   if (possibleTargets.size() == 1) {
     target.add(possibleTargets.iterator().next(), game);
     return true;
   }
   Iterator<UUID> it = possibleTargets.iterator();
   int targetNum = rnd.nextInt(possibleTargets.size());
   UUID targetId = it.next();
   for (int i = 0; i < targetNum; i++) {
     targetId = it.next();
   }
   target.add(targetId, game);
   return true;
 }
Esempio n. 2
0
 protected boolean chooseRandomTarget(Target target, Ability source, Game game) {
   Set<UUID> possibleTargets =
       target.possibleTargets(source == null ? null : source.getSourceId(), playerId, game);
   if (possibleTargets.isEmpty()) return false;
   if (!target.isRequired()) {
     if (rnd.nextInt(possibleTargets.size() + 1) == 0) {
       return false;
     }
   }
   if (possibleTargets.size() == 1) {
     target.addTarget(possibleTargets.iterator().next(), source, game);
     return true;
   }
   Iterator<UUID> it = possibleTargets.iterator();
   int targetNum = rnd.nextInt(possibleTargets.size());
   UUID targetId = it.next();
   for (int i = 0; i < targetNum; i++) {
     targetId = it.next();
   }
   target.addTarget(targetId, source, game);
   return true;
 }