Exemple #1
0
 /**
  * link the persistent data to the dateStorage
  *
  * @return
  */
 public boolean initModel() {
   boolean isDone = config.initConfigData();
   caseBooks = data.getCaseBooks();
   owners = data.getOwners();
   buildings = data.getBuildings();
   //		settlements = data.getSettlements();
   kingdoms = data.getKingdoms();
   isInit = isDone;
   return isInit;
 }
Exemple #2
0
 private void lehenManagerRun() {
   for (Lehen lehen : data.getLehen().values()) {
     lehen.lehenManager().run(this, lehen);
     lehen.buildManager().run(this, lehen.getWarehouse(), lehen);
     lehen.tradeManager().run(this, lehen);
   }
 }
Exemple #3
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;
  }
Exemple #4
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;
  }