示例#1
0
 @Test
 public void testOwnerNPC() {
   //  NPC Owner
   Owner NPCOwner = new Owner(0, NobleLevel.COMMONER, 0, "NPC1", 0, true, "");
   boolean expected = true;
   boolean actual = NPCOwner.isNPC();
   //		readSettledata(1);
   //		readSettledata(2);
   assertEquals("Owner ist ein NPC ", expected, actual);
 }
示例#2
0
  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);
        }
      }
    }
  }
示例#3
0
  @Override
  public void execute() {
    //		playerName = "";
    boolean isNPC = false;
    if ((playerName == "")) {
      playerName = ConfigBasis.NPC_0;
      isNPC = true;
    }
    Owner owner = rModel.getOwners().getOwnerName(playerName);
    if (owner == null) {
      Owner fOwner = rModel.getOwners().getOwner(0);
      if (fOwner == null) {
        owner = Owner.initDefaultOwner();
      } else {
        owner = fOwner;
      }
    }
    LocationData position;
    SuperRegion sRegion = rModel.getServer().getSuperRegion(superRegionName);
    if (sRegion == null) {
      System.out.println("[REALMS]  SuperRegion not found on create settlement !");
      return;
    }
    sRegion.setBalance(10000.0);
    position =
        new LocationData(
            sRegion.getLocation().getWorld().getName(),
            sRegion.getLocation().getX(),
            sRegion.getLocation().getY(),
            sRegion.getLocation().getZ());

    Settlement settlement =
        new Settlement(
            owner.getId(), position, settleType, superRegionName, biome); // , rModel.getLogList());
    rModel.getSettlements().addSettlement(settlement);
    //		System.out.println(superRegionName+" : "+settlement.getId());
    for (Region region : rModel.getServer().getRegionInSuperRegion(superRegionName)) {
      int regionId = region.getID();
      String hsRegionType = region.getType();
      BuildPlanType buildingType = rModel.getConfig().regionToBuildingType(hsRegionType);
      //			Building building = new Building(
      //					buildingType,
      //					hsRegion,
      //					new LocationData(
      //					region.getLocation().getWorld().getName(),
      //					region.getLocation().getX(),
      //					region.getLocation().getY(),
      //					region.getLocation().getZ()),
      //					settlement.getId()
      //					);
      //			rModel.getBuildings().addBuilding(building);
      //			rModel.getData().writeBuilding(building);
      if ((BuildPlanType.getBuildGroup(buildingType) < 900)
          && (BuildPlanType.getBuildGroup(buildingType) >= 10)) {
        if (rModel.getData().getBuildings().containRegion(regionId) == false) {
          Building building =
              new Building(
                  buildingType,
                  regionId,
                  new LocationData(
                      region.getLocation().getWorld().getName(),
                      region.getLocation().getX(),
                      region.getLocation().getY(),
                      region.getLocation().getZ()),
                  settlement.getId(),
                  0);
          rModel.getBuildings().addBuilding(building);
          rModel.getData().writeBuilding(building);
          System.out.println(
              "[REALMS] Modell Settle "
                  + building.getBuildingType()
                  + ":"
                  + building.getId()
                  + ":"
                  + building.getHsRegion());
        } else {
          Building building = rModel.getData().getBuildings().getBuildingByRegion(regionId);
          if ((building.getSettleId() == 0) && (building.getLehenId() == 0)) {
            building.setSettleId(settlement.getId());
            rModel.getData().writeBuilding(building);
            System.out.println(
                "[REALMS] Model Settle "
                    + building.getBuildingType()
                    + ":"
                    + building.getId()
                    + ":"
                    + building.getHsRegion());
          }
        }
      } else {
        System.out.println(
            "[REALMS] Model Settle wrong Building Group"
                + BuildPlanType.getBuildGroup(buildingType));
      }
    }
    // make not dynamic initialization

    settlement.setBuildingList(rModel.getBuildings().getSubList(settlement.getId()));
    settlement.initSettlement(rModel.getData().getPriceList());

    // minimum settler on create
    settlement.getResident().setSettlerCount(settlement.getResident().getSettlerMax() / 2);

    settlement
        .getWarehouse()
        .depositItemValue("WHEAT", settlement.getResident().getSettlerMax() * 2);
    settlement
        .getWarehouse()
        .depositItemValue("BREAD", settlement.getResident().getSettlerMax() * 2);
    settlement
        .getWarehouse()
        .depositItemValue("WOOD_HOE", settlement.getResident().getSettlerMax());
    settlement
        .getWarehouse()
        .depositItemValue("WOOD_AXE", settlement.getResident().getSettlerMax());
    settlement
        .getWarehouse()
        .depositItemValue("WOOD_PICKAXE", settlement.getResident().getSettlerMax());
    settlement.getWarehouse().depositItemValue("LOG", settlement.getResident().getSettlerMax());
    settlement.getWarehouse().depositItemValue("WOOD", settlement.getResident().getSettlerMax());
    settlement.getWarehouse().depositItemValue("STICK", settlement.getResident().getSettlerMax());
    settlement
        .getWarehouse()
        .depositItemValue("COBBLESTONE", settlement.getResident().getSettlerMax());
    settlement.getWarehouse().depositItemValue("SOIL", 64);
    settlement.getWarehouse().depositItemValue("WATER", settlement.getResident().getSettlerMax());
    settlement
        .getBank()
        .depositKonto(
            (double) (settlement.getResident().getSettlerCount() * 10),
            "CREATE",
            settlement.getId());
    System.out.println(
        "[REALMS] Model Write Settlement: "
            + settlement.getName()
            + " Activ:"
            + settlement.isActive()
            + " Enable:"
            + settlement.isEnabled());
    rModel.getData().writeSettlement(settlement);
  }