Beispiel #1
0
  // read all defense missile from given defense destructor
  protected void readDefenseDestructorFromGivenDestructor(Element destructor) {
    NamedNodeMap attributes = destructor.getAttributes();
    String id = "";
    String type;

    Attr attr = (Attr) attributes.item(0);

    String name = attr.getNodeName();

    // if it's iron dome
    if (name.equals("id")) {
      id = attr.getNodeValue();

      // update id's in the war
      IdGenerator.updateIronDomeId(id);
      // add to war
      war.addIronDome(id);

      NodeList destructdMissiles = destructor.getElementsByTagName("destructdMissile");
      readDefensDestructoreMissiles(destructdMissiles, id);

      // if it's launcher destructor
    } else {
      if (name.equals("type")) {
        type = attr.getNodeValue();

        // add to war
        id = war.addDefenseLauncherDestructor(type);

        NodeList destructedLanuchers = destructor.getElementsByTagName("destructedLanucher");
        readDefensDestructoreMissiles(destructedLanuchers, id);
      }
    }
  }
 public LauncherDestructor(String type, String id, War w, WarStatistics statistics) {
   allListeners = new LinkedList<WarEventListener>();
   this.id = id;
   this.type = Utils.capitalize(type);
   this.statistics = statistics;
   this.warName = w.getWarName();
   this.w = w;
 }
Beispiel #3
0
  // read enemy launchers and their missiles form XML
  protected void readEnemyLaunchers() {
    NodeList launchers = root.getElementsByTagName("launcher");

    for (int i = 0; i < launchers.getLength(); i++) {
      Element tempLauncher = (Element) launchers.item(i);

      String idLauncher = tempLauncher.getAttribute("id");
      boolean isHidden = Boolean.parseBoolean(tempLauncher.getAttribute("isHidden"));

      // add to the war
      war.addEnemyLauncher(idLauncher, isHidden);
      IdGenerator.updateEnemyLauncherId(idLauncher);

      NodeList missiles = tempLauncher.getElementsByTagName("missile");

      // read all missiles
      readMissilesForGivenLauncher(missiles, idLauncher);
    }

    // update the id's in the war
    IdGenerator.updateFinalEnemyMissileId();
    IdGenerator.updateFinalEnemyLauncherId();
  }
 public void setW(War w) {
   this.w = w;
   if (this.w != null) {
     w.addLauncherDestructor(this);
   }
 }