コード例 #1
0
ファイル: Crew.java プロジェクト: rhubarbselleven/megamek
  /**
   * Returns a string of all the option "codes" for this pilot, for a given group, using sep as the
   * separator
   */
  public String getOptionList(String sep, String grpKey) {
    StringBuffer adv = new StringBuffer();

    if (null == sep) {
      sep = "";
    }

    for (Enumeration<IOptionGroup> i = options.getGroups(); i.hasMoreElements(); ) {
      IOptionGroup group = i.nextElement();
      if (!group.getKey().equalsIgnoreCase(grpKey)) {
        continue;
      }
      for (Enumeration<IOption> j = group.getOptions(); j.hasMoreElements(); ) {
        IOption option = j.nextElement();

        if (option.booleanValue()) {
          if (adv.length() > 0) {
            adv.append(sep);
          }

          adv.append(option.getName());
          if ((option.getType() == IOption.STRING)
              || (option.getType() == IOption.CHOICE)
              || (option.getType() == IOption.INTEGER)) {
            adv.append(" ").append(option.stringValue());
          }
        }
      }
    }

    return adv.toString();
  }
コード例 #2
0
ファイル: Crew.java プロジェクト: rhubarbselleven/megamek
  public void clearOptions() {
    for (Enumeration<IOptionGroup> i = options.getGroups(); i.hasMoreElements(); ) {
      IOptionGroup group = i.nextElement();

      for (Enumeration<IOption> j = group.getOptions(); j.hasMoreElements(); ) {
        IOption option = j.nextElement();

        option.clearValue();
      }
    }
  }
コード例 #3
0
ファイル: Crew.java プロジェクト: rhubarbselleven/megamek
  /** Returns the options of the given category that this pilot has */
  public Enumeration<IOption> getOptions(String grpKey) {
    for (Enumeration<IOptionGroup> i = options.getGroups(); i.hasMoreElements(); ) {
      IOptionGroup group = i.nextElement();

      if (group.getKey().equalsIgnoreCase(grpKey)) {
        return group.getOptions();
      }
    }

    // no pilot advantages -- return an empty Enumeration
    return new Vector<IOption>().elements();
  }
コード例 #4
0
ファイル: Crew.java プロジェクト: rhubarbselleven/megamek
  public void clearOptions(String grpKey) {
    for (Enumeration<IOptionGroup> i = options.getGroups(); i.hasMoreElements(); ) {
      IOptionGroup group = i.nextElement();

      if (!group.getKey().equalsIgnoreCase(grpKey)) {
        continue;
      }

      for (Enumeration<IOption> j = group.getOptions(); j.hasMoreElements(); ) {
        IOption option = j.nextElement();

        option.clearValue();
      }
    }
  }
コード例 #5
0
ファイル: Crew.java プロジェクト: rhubarbselleven/megamek
  public int countOptions() {
    int count = 0;

    for (Enumeration<IOptionGroup> i = options.getGroups(); i.hasMoreElements(); ) {
      IOptionGroup group = i.nextElement();
      for (Enumeration<IOption> j = group.getOptions(); j.hasMoreElements(); ) {
        IOption option = j.nextElement();

        if (option.booleanValue()) {
          count++;
        }
      }
    }

    return count;
  }
コード例 #6
0
ファイル: Crew.java プロジェクト: rhubarbselleven/megamek
  public int countOptions(String grpKey) {
    int count = 0;

    for (Enumeration<IOptionGroup> i = options.getGroups(); i.hasMoreElements(); ) {
      IOptionGroup group = i.nextElement();

      if (!group.getKey().equalsIgnoreCase(grpKey)) {
        continue;
      }

      for (Enumeration<IOption> j = group.getOptions(); j.hasMoreElements(); ) {
        IOption option = j.nextElement();

        if (option != null && option.booleanValue()) {
          count++;
        }
      }
    }

    return count;
  }
コード例 #7
0
  /** updates fields for the unit */
  public void setEntity(Entity en) {

    if (en instanceof Infantry) {
      pilotL.setString(Messages.getString("PilotMapSet.pilotLAntiMech"));
    } else {
      pilotL.setString(Messages.getString("PilotMapSet.pilotL"));
    }
    nameL.setString(en.getCrew().getName());
    nickL.setString(en.getCrew().getNickname());
    pilotR.setString(Integer.toString(en.getCrew().getPiloting()));
    gunneryR.setString(Integer.toString(en.getCrew().getGunnery()));

    if (null != getPortrait(en.getCrew())) {
      portraitArea.setIdleImage(getPortrait(en.getCrew()));
    }

    if ((en.getGame() != null) && en.getGame().getOptions().booleanOption("rpg_gunnery")) {
      gunneryLR.setString(Integer.toString(en.getCrew().getGunneryL()));
      gunneryMR.setString(Integer.toString(en.getCrew().getGunneryM()));
      gunneryBR.setString(Integer.toString(en.getCrew().getGunneryB()));
      gunneryL.setVisible(false);
      gunneryR.setVisible(false);
      gunneryLL.setVisible(true);
      gunneryLR.setVisible(true);
      gunneryML.setVisible(true);
      gunneryMR.setVisible(true);
      gunneryBL.setVisible(true);
      gunneryBR.setVisible(true);
    } else {
      gunneryLL.setVisible(false);
      gunneryLR.setVisible(false);
      gunneryML.setVisible(false);
      gunneryMR.setVisible(false);
      gunneryBL.setVisible(false);
      gunneryBR.setVisible(false);
      gunneryL.setVisible(true);
      gunneryR.setVisible(true);
    }
    if ((en.getGame() != null) && en.getGame().getOptions().booleanOption("toughness")) {
      toughBR.setString(Integer.toString(en.getCrew().getToughness()));
    } else {
      toughBL.setVisible(false);
      toughBR.setVisible(false);
    }
    if ((en.getGame() != null)
        && en.getGame().getOptions().booleanOption("individual_initiative")) {
      initBR.setString(Integer.toString(en.getCrew().getInitBonus()));
    } else {
      initBL.setVisible(false);
      initBR.setVisible(false);
    }
    if ((en.getGame() != null) && en.getGame().getOptions().booleanOption("command_init")) {
      commandBR.setString(Integer.toString(en.getCrew().getCommandBonus()));
    } else {
      commandBL.setVisible(false);
      commandBR.setVisible(false);
    }
    hitsR.setString(en.getCrew().getStatusDesc());
    for (int i = 0; i < advantagesR.length; i++) {
      advantagesR[i].setString(""); // $NON-NLS-1$
    }
    int i = 0;
    for (Enumeration<IOptionGroup> advGroups = en.getCrew().getOptions().getGroups();
        advGroups.hasMoreElements(); ) {
      if (i >= (N_ADV - 1)) {
        advantagesR[i++].setString(Messages.getString("PilotMapSet.more"));
        break;
      }
      IOptionGroup advGroup = advGroups.nextElement();
      if (en.getCrew().countOptions(advGroup.getKey()) > 0) {
        advantagesR[i++].setString(advGroup.getDisplayableName());
        for (Enumeration<IOption> advs = advGroup.getOptions(); advs.hasMoreElements(); ) {
          if (i >= (N_ADV - 1)) {
            advantagesR[i++].setString("  " + Messages.getString("PilotMapSet.more"));
            break;
          }
          IOption adv = advs.nextElement();
          if (adv.booleanValue()) {
            advantagesR[i++].setString("  " + adv.getDisplayableNameWithValue());
          }
        }
      }
    }
  }