Ejemplo n.º 1
0
 /** start the regiment run for each regiment for 1 tick */
 private void regimentManagerRun() {
   if (this.getData().getRegiments() == null) {
     return;
   }
   for (Regiment regiment : this.getData().getRegiments().values()) {
     regiment.run(this);
   }
 }
Ejemplo n.º 2
0
  private ModelStatus initProductionQueue(String worldName) {
    //		System.out.println("Init Production");
    for (Settlement settle : this.getData().getSettlements().values()) {
      if (settle.isEnabled() && (settle.getPosition().getWorld().equalsIgnoreCase(worldName))) {
        productionQueue.add(settle);
      }
    }
    for (Lehen lehen : data.getLehen().values()) {
      if (lehen.isEnabled() && (lehen.getPosition().getWorld().equalsIgnoreCase(worldName))) {
        lehenProductionQueue.add(lehen);
      }
    }

    for (Regiment regiment : this.getData().getRegiments().values()) {
      if (regiment.isEnabled() && (regiment.getPosition().getWorld().equalsIgnoreCase(worldName))) {
        regimentProductionQueue.add(regiment);
      }
    }
    return ModelStatus.MODEL_PRODUCTION;
  }
Ejemplo n.º 3
0
  /**
   * <pre>
   * run the production cycle for the settlement, lehen and regiments
   * for each tick only 1 settlement are calculated
   * first all settlement , then all lehen and then all regiment
   *
   * @return ModelStatus : MODEL_PRODUCTION | MODEL_ENABLED
   * </pre>
   */
  private ModelStatus nextProductionQueue() {
    int lSize = productionQueue.size();
    if (productionQueue.isEmpty() == false) {
      Settlement settle = productionQueue.get(0);
      settle.getMsg().clear();
      settle
          .getMsg()
          .add("[REALMS] Settle production:" + settle.getId() + ":" + lSize + ":" + this.dayOfWeek);
      settle.getReputations().resetDaily();
      settle.getMsg().add("settler max");
      settle.setSettlerMax();
      settle.getMsg().add("Building enable");
      settle.checkBuildingsEnabled(server);
      settle.getMsg().add("worker needed");
      settle.setWorkerNeeded();
      settle.getMsg().add("happiness");
      settle.doResident(data);
      settle.getMsg().add("produce");
      settle.doProduce(server, data, this.dayOfWeek);
      settle.getMsg().add("UnitTrain");
      settle.doUnitTrain(unitFactory);
      data.writeSettlement(settle);

      productionQueue.remove(0);
      messageData.log("remove 0");
      return ModelStatus.MODEL_PRODUCTION;
    }

    lSize = lehenProductionQueue.size();
    if (lehenProductionQueue.isEmpty() == false) {
      Lehen lehen = lehenProductionQueue.get(0);
      //			lehen.getMsg().clear();
      lehen
          .getMsg()
          .add(
              "[REALMS] lehen produce:"
                  + lehen.getName()
                  + ":"
                  + lehen.getId()
                  + " Settle:"
                  + lehen.getSupportId()
                  + " day"
                  + this.dayOfWeek);
      lehen.doProduce(server, data, this.dayOfWeek);
      lehen.getMsg().add("Lehen happiness");
      lehen.doResident(data);
      lehen.doUnitTrain(unitFactory);
      data.writeLehen(lehen);
      lehenProductionQueue.remove(0);
      return ModelStatus.MODEL_PRODUCTION;
    }

    if (regimentProductionQueue.isEmpty() == false) {
      Regiment regiment = regimentProductionQueue.get(0);
      regiment.getMsg().clear();
      regiment.getMsg().add("[REALMS] regiment production ");
      regiment.doProduce(server, data);
      data.writeRegiment(regiment);
      regimentProductionQueue.remove(0);
      return ModelStatus.MODEL_PRODUCTION;
    }
    System.out.println("[REALMS] production ended");
    return ModelStatus.MODEL_ENABLED;
  }