Ejemplo n.º 1
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;
          }
      }
    }
  }
 public CurrentServerGCWZoneHistory(CurrentServerGCWZonePercent zone) {
   this.percent = zone.getPercent().intValue();
   this.lastUpdateTime = zone.getLastUpdateTime();
 }