Exemplo n.º 1
0
 /**
  * Turns the majority of the given percentage of floor cells into water cells, represented by '~'.
  * Water will be clustered into a random number of pools, with more appearing if needed to fill
  * the percentage. Each pool will have randomized volume that should fill or get very close to
  * filling the requested percentage, unless the pools encounter too much tight space. If this
  * DungeonGenerator previously had addWater called, the latest call will take precedence. If
  * islandSpacing is greater than 1, then this will place islands of floor, '.', surrounded by
  * shallow water, ',', at about the specified distance with Euclidean measurement.
  *
  * @param percentage the percentage of floor cells to fill with water
  * @param islandSpacing if greater than 1, islands will be placed randomly this many cells apart.
  * @return this DungeonGenerator; can be chained
  */
 public DungeonGenerator addWater(int percentage, int islandSpacing) {
   if (percentage < 0) percentage = 0;
   if (percentage > 100) percentage = 100;
   if (fx.containsKey(FillEffect.WATER)) fx.remove(FillEffect.WATER);
   fx.put(FillEffect.WATER, percentage);
   if (fx.containsKey(FillEffect.ISLANDS)) fx.remove(FillEffect.ISLANDS);
   if (islandSpacing > 1) fx.put(FillEffect.ISLANDS, islandSpacing);
   return this;
 }
Exemplo n.º 2
0
 /**
  * Turns the given percentage of open area floor cells into trap cells, represented by '^'.
  * Corridors that have no possible way to move around a trap will not receive traps, ever. If this
  * DungeonGenerator previously had addTraps called, the latest call will take precedence.
  *
  * @param percentage the percentage of valid cells to fill with traps; should be no higher than 5
  *     unless the dungeon floor is meant to be a kill screen or minefield.
  * @return this DungeonGenerator; can be chained
  */
 public DungeonGenerator addTraps(int percentage) {
   if (percentage < 0) percentage = 0;
   if (percentage > 100) percentage = 100;
   if (fx.containsKey(FillEffect.TRAPS)) fx.remove(FillEffect.TRAPS);
   fx.put(FillEffect.TRAPS, percentage);
   return this;
 }
Exemplo n.º 3
0
 /**
  * Turns the given percentage of floor cells not already adjacent to walls into wall cells,
  * represented by '#'. If this DungeonGenerator previously had addBoulders called, the latest call
  * will take precedence.
  *
  * @param percentage the percentage of floor cells not adjacent to walls to fill with boulders.
  * @return this DungeonGenerator; can be chained
  */
 public DungeonGenerator addBoulders(int percentage) {
   if (percentage < 0) percentage = 0;
   if (percentage > 100) percentage = 100;
   if (fx.containsKey(FillEffect.BOULDERS)) fx.remove(FillEffect.BOULDERS);
   fx.put(FillEffect.BOULDERS, percentage);
   return this;
 }
Exemplo n.º 4
0
 /**
  * Turns the majority of the given percentage of floor cells into water cells, represented by '~'.
  * Water will be clustered into a random number of pools, with more appearing if needed to fill
  * the percentage. Each pool will have randomized volume that should fill or get very close to
  * filling the requested percentage, unless the pools encounter too much tight space. If this
  * DungeonGenerator previously had addWater called, the latest call will take precedence. No
  * islands will be placed with this variant, but the edge of the water will be shallow,
  * represented by ','.
  *
  * @param percentage the percentage of floor cells to fill with water
  * @return this DungeonGenerator; can be chained
  */
 public DungeonGenerator addWater(int percentage) {
   if (percentage < 0) percentage = 0;
   if (percentage > 100) percentage = 100;
   if (fx.containsKey(FillEffect.WATER)) fx.remove(FillEffect.WATER);
   fx.put(FillEffect.WATER, percentage);
   return this;
 }
Exemplo n.º 5
0
 /**
  * Turns the given percentage of viable doorways into doors, represented by '+' for doors that
  * allow travel along the x-axis and '/' for doors that allow travel along the y-axis. If
  * doubleDoors is true, 2-cell-wide openings will be considered viable doorways and will fill one
  * cell with a wall, the other a door. If this DungeonGenerator previously had addDoors called,
  * the latest call will take precedence.
  *
  * @param percentage the percentage of valid openings to corridors to fill with doors; should be
  *     between 10 and 20 if you want doors to appear more than a few times, but not fill every
  *     possible opening.
  * @param doubleDoors true if you want two-cell-wide openings to receive a door and a wall; false
  *     if only one-cell-wide openings should receive doors. Usually, this should be true.
  * @return this DungeonGenerator; can be chained
  */
 public DungeonGenerator addDoors(int percentage, boolean doubleDoors) {
   if (percentage < 0) percentage = 0;
   if (percentage > 100) percentage = 100;
   if (doubleDoors) percentage *= -1;
   if (fx.containsKey(FillEffect.DOORS)) fx.remove(FillEffect.DOORS);
   fx.put(FillEffect.DOORS, percentage);
   return this;
 }
  @Override
  public final EnumMap<InterceptorType, CommandInterceptor> buildInterceptorChain() {
    EnumMap<InterceptorType, CommandInterceptor> interceptors = buildDefaultInterceptorChain();

    // State transfer
    interceptors.put(
        InterceptorType.STATE_TRANSFER,
        createInterceptor(
            new TotalOrderStateTransferLockInterceptor(),
            TotalOrderStateTransferLockInterceptor.class));

    // Custom interceptor
    interceptors.put(
        InterceptorType.CUSTOM_INTERCEPTOR_BEFORE_TX_INTERCEPTOR,
        createInterceptor(new TotalOrderInterceptor(), TotalOrderInterceptor.class));

    // No locking
    interceptors.remove(InterceptorType.LOCKING);

    // Wrapper
    if (configuration.locking().isolationLevel() == IsolationLevel.SERIALIZABLE) {
      interceptors.put(
          InterceptorType.WRAPPER,
          createInterceptor(
              new TotalOrderGMUEntryWrappingInterceptor(),
              TotalOrderGMUEntryWrappingInterceptor.class));
    } else if (needsVersionAwareComponents()) {
      interceptors.put(
          InterceptorType.WRAPPER,
          createInterceptor(
              new TotalOrderVersionedEntryWrappingInterceptor(),
              TotalOrderVersionedEntryWrappingInterceptor.class));
    }

    // No deadlock
    interceptors.remove(InterceptorType.DEADLOCK);

    // Clustering
    switch (configuration.clustering().cacheMode()) {
      case REPL_SYNC:
        if (configuration.locking().isolationLevel() == IsolationLevel.SERIALIZABLE) {
          interceptors.put(
              InterceptorType.CLUSTER,
              createInterceptor(
                  new TotalOrderGMUReplicationInterceptor(),
                  TotalOrderGMUReplicationInterceptor.class));
        } else if (needsVersionAwareComponents()) {
          interceptors.put(
              InterceptorType.CLUSTER,
              createInterceptor(
                  new TotalOrderVersionedReplicationInterceptor(),
                  TotalOrderVersionedReplicationInterceptor.class));
        } else {
          interceptors.put(
              InterceptorType.CLUSTER,
              createInterceptor(
                  new TotalOrderReplicationInterceptor(), TotalOrderReplicationInterceptor.class));
        }
        break;
      case DIST_SYNC:
        if (configuration.locking().isolationLevel() == IsolationLevel.SERIALIZABLE) {
          interceptors.put(
              InterceptorType.CLUSTER,
              createInterceptor(
                  new TotalOrderGMUDistributionInterceptor(),
                  TotalOrderGMUDistributionInterceptor.class));
        } else if (needsVersionAwareComponents()) {
          interceptors.put(
              InterceptorType.CLUSTER,
              createInterceptor(
                  new TotalOrderVersionedDistributionInterceptor(),
                  TotalOrderVersionedDistributionInterceptor.class));
        } else {
          interceptors.put(
              InterceptorType.CLUSTER,
              createInterceptor(
                  new TotalOrderDistributionInterceptor(),
                  TotalOrderDistributionInterceptor.class));
        }
        break;
    }

    if (log.isTraceEnabled()) {
      log.tracef("Building interceptor chain for Total Order protocol %s", interceptors);
    }

    return interceptors;
  }
 public void removeIDGenerator(IDGenerator generator) {
   idGenerators.remove(generator.getName());
 }
 public void removeHL7OrderSPSStatus(HL7OrderSPSStatus rule) {
   hl7OrderSPSStatuses.remove(rule.getSPSStatus());
 }