@Override
 public CurrentServerGCWZonePercent clone() {
   try {
     CurrentServerGCWZonePercent object = (CurrentServerGCWZonePercent) super.clone();
     object.setPosition(getPosition());
     return object;
   } catch (CloneNotSupportedException e) {
     e.printStackTrace();
     return null;
   }
 }
Beispiel #2
0
  public void adjustZone(String planet, String zone, String faction, int amount) {
    synchronized (objectMutex) {
      CurrentServerGCWZonePercent zoneObject = zoneMap().get(planet).get(zone).clone();
      BigDecimal newPercent =
          new BigDecimal(
              Double.toString(
                  ((((double) amount) / ((double) zoneObject.getGCWPoints())) * ((double) 100.0))),
              MathContext.DECIMAL128);

      switch (faction) {
        case "rebel":
          {
            newPercent =
                newPercent
                    .multiply(zoneObject.getPercent())
                    .divide((new BigDecimal("100.0", MathContext.DECIMAL128)));
            zoneMap()
                .get(planet)
                .get(zone)
                .setPercent(
                    ((zoneObject.getPercent().subtract(newPercent).intValue() < 0)
                        ? (new BigDecimal("0.0", MathContext.DECIMAL128))
                        : (zoneObject.getPercent().subtract(newPercent))));
            zoneMap().get(planet).get(zone).addGCWPoints(amount);
            break;
          }
        case "imperial":
          {
            newPercent =
                newPercent
                    .multiply(
                        ((new BigDecimal("100.0", MathContext.DECIMAL128)
                            .subtract(zoneObject.getPercent()))))
                    .divide((new BigDecimal("100.0", MathContext.DECIMAL128)));
            zoneMap()
                .get(planet)
                .get(zone)
                .setPercent(
                    ((zoneObject.getPercent().subtract(newPercent).intValue() > 100)
                        ? (new BigDecimal("100.0", MathContext.DECIMAL128))
                        : (zoneObject.getPercent().add(newPercent))));
            zoneMap().get(planet).get(zone).addGCWPoints(amount);
            break;
          }
      }
    }
  }
Beispiel #3
0
  public void addZone(
      String planet, String zone, float x, float z, float radius, int weight, int type) {
    CurrentServerGCWZonePercent zoneObject;

    if (!zoneMap().containsKey(planet)) {
      zoneMap().put(planet, new TreeMap<String, CurrentServerGCWZonePercent>());
      object
          .getCurrentServerGCWTotalPercentMap()
          .put(planet, new CurrentServerGCWZonePercent(new Point2D(0, 0), 0, 0, 0));
      object
          .getCurrentServerGCWTotalHistoryMap()
          .put(
              planet,
              new CurrentServerGCWZoneHistory(
                  object.getCurrentServerGCWTotalPercentMap().get(planet).clone()));
      object.getOtherServerGCWTotalPercentMap().put("SWG", new OtherServerGCWZonePercent(planet));
    }

    if (zoneMap().get(planet).containsKey(zone)) {
      zoneObject = zoneMap().get(planet).get(zone);

      if (zoneObject.getPosition().x != x) {
        zoneObject.getPosition().x = x;
      }

      if (zoneObject.getPosition().z != z) {
        zoneObject.getPosition().z = z;
      }

      if (zoneObject.getRadius() != radius) {
        zoneObject.setRadius(radius);
      }

      if (zoneObject.getWeight().unscaledValue().intValue() != weight) {
        zoneObject.setWeight(weight);
      }

      if (zoneObject.getType() != type) {
        zoneObject.setType(type);
      }
    } else {
      zoneObject = new CurrentServerGCWZonePercent(new Point2D(x, z), radius, weight, type);

      zoneMap().get(planet).put(zone, zoneObject);

      if (!planet.equals("galaxy")) {
        object
            .getCurrentServerGCWZonePercentMap()
            .put(zone, zoneMap().get(planet).get(zone).clone());
        object
            .getCurrentServerGCWZoneHistoryMap()
            .put(zone, new CurrentServerGCWZoneHistory(zoneMap().get(planet).get(zone).clone()));
        object.getOtherServerGCWZonePercentMap().put("SWG", new OtherServerGCWZonePercent(zone));
      }
    }
  }
 public CurrentServerGCWZoneHistory(CurrentServerGCWZonePercent zone) {
   this.percent = zone.getPercent().intValue();
   this.lastUpdateTime = zone.getLastUpdateTime();
 }