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); } }
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; }
private double getChildSum(Lehen lehen) { double childSum = 0; for (Lehen child : getData().getLehen().getChildList(lehen.getId()).values()) { double tax = child.getSales() * ConfigBasis.SALES_TAX / 100.0; childSum = childSum + tax; child.getBank().depositKonto(child.getSales(), "ME", 0); child.getBank().withdrawKonto(tax, "ME", 0); child.setSales(0.0); } return childSum; }
private void doFeudalTax() { for (Settlement settle : getData().getSettlements().values()) { double umsatzTax = settle.getSales(); double settlerTax = settle.getTaxSum(); settle.setSales(0.0); settle.setTaxSum(0.0); Owner owner = getData().getOwners().getOwner(settle.getOwnerId()); int lehenId = settle.getTributId(); int kingdomId = 0; Lehen tributLehen = getData().getLehen().getLehen(lehenId); if (tributLehen != null) { kingdomId = tributLehen.getKingdomId(); tributLehen.depositSales((umsatzTax)); } else if (owner != null) { kingdomId = owner.getKingdomId(); owner.depositSales((umsatzTax)); } Lehen kingLehen = getData().getLehen().getKingdomRoot(kingdomId); if (kingLehen != null) { kingLehen.depositSales((settlerTax)); } } for (Kingdom kingdom : getData().getKingdoms().values()) { if (kingdom.getId() > 0) { Lehen root = getData().getLehen().getKingdomRoot(kingdom.getId()); if (root != null) { for (Lehen lehen : getData().getLehen().getChildList(root.getId()).values()) { for (Lehen child : getData().getLehen().getChildList(lehen.getId()).values()) { double childsum = getChildSum(child); child.depositSales(childsum); } double sum = getChildSum(lehen); lehen.depositSales(sum); } double rootSum = getChildSum(root); root.getBank().depositKonto(rootSum, "TAX", 0); root.getBank().depositKonto(root.getSales(), "TAX", 0); root.setSales(0.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; }