Example #1
0
 private void fireReloadAttackPlansEvent(
     java.awt.event.MouseEvent evt) { // GEN-FIRST:event_fireReloadAttackPlansEvent
   DefaultComboBoxModel model = new DefaultComboBoxModel(AttackManager.getSingleton().getGroups());
   jAttackPlan.setModel(model);
   jAttack.setModel(
       new DefaultComboBoxModel(
           AttackManager.getSingleton().getAllElements((String) model.getElementAt(0)).toArray()));
 } // GEN-LAST:event_fireReloadAttackPlansEvent
Example #2
0
 private void fireAttackPlanSelectionChangedEvent(
     java.awt.event.ItemEvent evt) { // GEN-FIRST:event_fireAttackPlanSelectionChangedEvent
   if (evt.getStateChange() == ItemEvent.SELECTED) {
     jAttack.setModel(
         new DefaultComboBoxModel(
             AttackManager.getSingleton()
                 .getAllElements((String) jAttackPlan.getModel().getSelectedItem())
                 .toArray()));
     jAmount.setText(
         Integer.toString(
             AttackManager.getSingleton()
                 .getAllElements((String) jAttackPlan.getModel().getSelectedItem())
                 .size()));
   }
 } // GEN-LAST:event_fireAttackPlanSelectionChangedEvent
Example #3
0
  private void generateSOS() {
    String plan = (String) jAttackPlan.getSelectedItem();
    int amount = Math.min(UIHelper.parseIntFromField(jAmount, 1), jAttack.getItemCount());
    SOSRequest sos = null;
    Tribe t = null;
    for (int i = 0; i < amount; i++) {
      Attack a = AttackManager.getSingleton().getManagedElement(plan, i);
      if (sos == null) {
        sos = new SOSRequest(a.getTarget().getTribe());
        t = a.getTarget().getTribe();
      }

      if (t != null && a.getTarget().getTribe().getId() == t.getId()) {
        TargetInformation info = sos.addTarget(a.getTarget());
        if (info.getTroops().isEmpty()) {
          Hashtable<UnitHolder, Integer> troops = getDefendingTroops();

          Enumeration<UnitHolder> keys = troops.keys();
          while (keys.hasMoreElements()) {
            UnitHolder key = keys.nextElement();
            info.addTroopInformation(key, troops.get(key));
          }
          info.setWallLevel(20);
        }
        if (jIncludeTypes.isSelected()) {
          info.addAttack(
              a.getSource(),
              a.getArriveTime(),
              a.getUnit(),
              a.getType() == Attack.FAKE_TYPE,
              a.getUnit().getPlainName().equals("snob"));
        } else {
          info.addAttack(a.getSource(), a.getArriveTime());
        }
      } else {
        System.err.println(
            "Tribe "
                + a.getTarget().getTribe()
                + "does not fit request tribe "
                + sos.getDefender());
      }
    }

    /**
     * [b]Dorf:[/b] [coord]112|87[/coord] [b]Wallstufe:[/b] 20 [b]Verteidiger:[/b] 23011 22928 0 266
     * 0 814 0 0 0
     *
     * <p>bäääng! [coord]282|306[/coord] --> Ankunftszeit: 11.10.11 14:37:57
     * [player]MrBlue76[/player]
     *
     * <p>[b]Dorf:[/b] [coord]114|84[/coord] [b]Wallstufe:[/b] 20 [b]Verteidiger:[/b] 9079 9080 0
     * 100 0 300 0 0 0
     *
     * <p>bäääng! [coord]318|272[/coord] --> Ankunftszeit: 11.10.11 14:42:49
     * [player]MrBlue76[/player] bäääng! [coord]211|345[/coord] --> Ankunftszeit: 11.10.11 16:45:37
     * [player]MrBlue76[/player]
     */
    Enumeration<Village> targets = sos.getTargets();
    StringBuilder b = new StringBuilder();
    SimpleDateFormat df;
    if (de.tor.tribes.util.ServerSettings.getSingleton().isMillisArrival()) {
      df = new SimpleDateFormat("dd.MM.yy HH:mm:ss:SSS");
    } else {
      df = new SimpleDateFormat("dd.MM.yy HH:mm:ss");
    }
    while (targets.hasMoreElements()) {
      Village target = targets.nextElement();
      b.append("[b]Dorf:[/b] ").append(target.toBBCode()).append("\n");
      TargetInformation ti = sos.getTargetInformation(target);
      b.append("[b]Wallstufe:[/b] ").append(ti.getWallLevel()).append("\n");
      b.append("[b]Verteidiger:[/b] ");
      for (UnitHolder unit : DataHolder.getSingleton().getUnits()) {
        b.append(ti.getTroops().get(unit)).append(" ");
      }
      b.append("\n\n");
      for (TimedAttack a : ti.getAttacks()) {
        if (jIncludeTypes.isSelected()) {
          if (a.isPossibleFake()) {
            b.append("Fake, ");
          } else {
            if (a.getUnit() != null) {
              if (a.getUnit().getPlainName().equals("axe")) {
                b.append("Axt, ");
              } else if (a.getUnit().getPlainName().equals("light")) {
                b.append("LKAV, ");
              } else if (a.getUnit().getPlainName().equals("snob")) {
                b.append("AG, ");
              } else if (a.getUnit().getPlainName().equals("heavy")) {
                b.append("SKAV, ");
              } else if (a.getUnit().getPlainName().equals("sword")) {
                b.append("Schwert, ");
              } else if (a.getUnit().getPlainName().equals("catapult")) {
                b.append("Kata, ");
              }
            }
          }
        }
        b.append(a.getSource().getName())
            .append(" ")
            .append(a.getSource().toBBCode())
            .append(" --> Ankunftszeit: ")
            .append(df.format(new Date(a.getlArriveTime())))
            .append(" ")
            .append(a.getSource().getTribe().toBBCode())
            .append("\n");
      }
      b.append("\n");
    }
    sendToClipboard(b.toString());
  }