示例#1
0
 @Override
 public Mode chooseMode(Modes modes, Ability source, Game game) {
   Iterator<Mode> it = modes.values().iterator();
   Mode mode = it.next();
   if (modes.size() == 1) return mode;
   int modeNum = rnd.nextInt(modes.values().size());
   for (int i = 0; i < modeNum; i++) {
     mode = it.next();
   }
   return mode;
 }
 @Override
 public Mode chooseMode(Modes modes, Ability source, Game game) {
   if (this.isHuman()) {
     Iterator<Mode> it = modes.getAvailableModes(source, game).iterator();
     Mode mode = it.next();
     if (modes.size() == 1) {
       return mode;
     }
     int modeNum = rnd.nextInt(modes.getAvailableModes(source, game).size());
     for (int i = 0; i < modeNum; i++) {
       mode = it.next();
     }
     return mode;
   }
   return super.chooseMode(modes, source, game);
 }
示例#3
0
  private void updateTargets(Game game, StackAbility ability) {
    List<String> names = new ArrayList<>();
    for (Mode mode : ability.getModes().getSelectedModes()) {
      if (mode.getTargets().size() > 0) {
        setTargets(mode.getTargets());
      } else {
        List<UUID> targetList = new ArrayList<>();
        for (Effect effect : mode.getEffects()) {
          TargetPointer targetPointer = effect.getTargetPointer();
          if (targetPointer instanceof FixedTarget) {
            targetList.add(((FixedTarget) targetPointer).getTarget());
          }
        }
        if (targetList.size() > 0) {
          overrideTargets(targetList);

          for (UUID uuid : targetList) {
            MageObject mageObject = game.getObject(uuid);
            if (mageObject != null) {
              if ((mageObject instanceof Card) && ((Card) mageObject).isFaceDown(game)) {
                continue;
              }
              names.add(GameLog.getColoredObjectIdNameForTooltip(mageObject));
            }
          }
        }
      }
    }
    if (!names.isEmpty()) {
      getRules().add("<i>Related objects: " + names.toString() + "</i>");
    }
    // show for modal ability, which mode was choosen
    if (ability.isModal()) {
      Modes modes = ability.getModes();
      for (Mode mode : modes.getSelectedModes()) {
        this.rules.add(
            "<span color='green'><i>Chosen mode: "
                + mode.getEffects().getText(mode)
                + "</i></span>");
      }
    }
  }
示例#4
0
  private void updateTargets(Game game, StackAbility ability) {
    List<String> names = new ArrayList<>();
    for (UUID modeId : ability.getModes().getSelectedModes()) {
      ability.getModes().setMode(ability.getModes().get(modeId));
      if (ability.getTargets().size() > 0) {
        setTargets(ability.getTargets());
      } else {
        List<UUID> targetList = new ArrayList<>();
        for (Effect effect : ability.getEffects()) {
          TargetPointer targetPointer = effect.getTargetPointer();
          if (targetPointer instanceof FixedTarget) {
            targetList.add(((FixedTarget) targetPointer).getTarget());
          }
        }
        if (targetList.size() > 0) {
          overrideTargets(targetList);

          for (UUID uuid : targetList) {
            MageObject mageObject = game.getObject(uuid);
            if (mageObject != null) {
              names.add(mageObject.getLogName());
            }
          }
        }
      }
    }
    if (!names.isEmpty()) {
      getRules().add("<i>Targets: " + names.toString() + "</i>");
    }
    // show for modal ability, which mode was choosen
    if (ability.isModal()) {
      Modes modes = ability.getModes();
      for (UUID modeId : modes.getSelectedModes()) {
        modes.setMode(modes.get(modeId));
        this.rules.add(
            "<span color='green'><i>Chosen mode: "
                + ability.getEffects().getText(modes.get(modeId))
                + "</i></span>");
      }
    }
  }