Exemplo n.º 1
0
 public boolean updateState(Landscape scape) {
   while (this.country.getWealth() > 0) {
     // hire generals
     for (Object c : this.country.CityToList()) {
       // if city has not already hired generals:
       if (!((City) c).ALREADY_HIRED_GENERAL)
         new General(
             ((City) c).getX(),
             ((City) c).getY(),
             "Nomen" + SimObject.rand.nextInt(60),
             this.country);
       ((City) c).ALREADY_HIRED_GENERAL = true;
     }
     // "enrich" generals with soldiers
     for (Object g : this.country.GeneralToList()) {
       ((General) g)
           .addSoldiers(Soldiers.ALL_UNITS.get(SimObject.rand.nextInt(Soldiers.ALL_UNITS.size())));
       // if general hasnt moved yet
       if (((General) g).size() >= 19 && !((General) g).HAS_MOVED) {
         // select a random enemy city as enemy:
         int selection = SimObject.rand.nextInt(2);
         City c =
             (City)
                 this.enemy[selection]
                     .CityToList()
                     .get(SimObject.rand.nextInt(this.enemy[selection].CityToList().size()));
         ((General) g).setEnemy(c);
         ((General) g).destino_x = c.x;
         ((General) g).destino_y = c.y;
         // make general move to location
         // while((int)((General)g).x!=(int)(((General)g).destino_x) &&
         // (int)((General)g).y!=(int)(((General)g).destino_y)){
         // ((General)g).moveToDestination();
         // }
         new Running.GeneralToLocation((General) g);
       }
     }
     break; // TODO:break out of the while loop?
   }
   Running.windows.repaint();
   return (this.isAlive && !(this.defeat) && this.country.isAlive);
 }