test_class.file: omicron-core/src/test/java/com/lyndir/omicron/api/MobilityModuleTest.java
test_class.identifier: MobilityModuleTest
test_class.superclass: extends AbstractTest
test_case.body: @Test
      public void testCostForLevelingToLevel()
              throws Exception {
  
          MobilityModule module = MobilityModule.createWithStandardResourceCost()
                                                .movementSpeed( 0 )
                                                .movementCost( ImmutableMap.<LevelType, Double>of() )
                                                .levelingCost(
                                                        ImmutableMap.of( LevelType.GROUND, 1d, LevelType.SKY, 2d ) );
          createUnit( testUnitType( "Leveler", module ) );
  
          assertEquals( 0d, module.costForLevelingToLevel( LevelType.GROUND ) );
          assertEquals( 1d, module.costForLevelingToLevel( LevelType.SKY ) );
          assertEquals( 3d, module.costForLevelingToLevel( LevelType.SPACE ) );
      }
test_case.class_method_signature: MobilityModuleTest.testCostForLevelingToLevel()
test_case.full_signature: @Test public void testCostForLevelingToLevel()
test_case.identifier: testCostForLevelingToLevel
test_case.invocations: levelingCost movementCost movementSpeed createWithStandardResourceCost of of createUnit testUnitType assertEquals costForLevelingToLevel assertEquals costForLevelingToLevel assertEquals costForLevelingToLevel
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testCostForLevelingToLevel()
focal_class.declarator: movementSpeed
focal_class.modifier: private final
focal_class.original_string: private final int movementSpeed;
focal_class.type: int
focal_class.var_name: movementSpeed
focal_class.declarator: movementCost = Collections.synchronizedMap( new EnumMap<>( LevelType.class ) )
focal_class.modifier: private final
focal_class.original_string: private final Map<LevelType, Double> movementCost = Collections.synchronizedMap( new EnumMap<>( LevelType.class ) );
focal_class.type: Map<LevelType, Double>
focal_class.var_name: movementCost
focal_class.declarator: levelingCost = Collections.synchronizedMap( new EnumMap<>( LevelType.class ) )
focal_class.modifier: private final
focal_class.original_string: private final Map<LevelType, Double> levelingCost = Collections.synchronizedMap( new EnumMap<>( LevelType.class ) );
focal_class.type: Map<LevelType, Double>
focal_class.var_name: levelingCost
focal_class.declarator: remainingSpeed
focal_class.modifier: private
focal_class.original_string: private double remainingSpeed;
focal_class.type: double
focal_class.var_name: remainingSpeed
focal_class.file: omicron-core/src/main/java/com/lyndir/omicron/api/MobilityModule.java
focal_class.identifier: MobilityModule
focal_class.interfaces: implements IMobilityModule, IMobilityModuleController
focal_class.class_method_signature: MobilityModule.MobilityModule(final ImmutableResourceCost resourceCost, final int movementSpeed, final Map<LevelType, Double> movementCost,
                               final Map<LevelType, Double> levelingCost)
focal_class.full_signature: protected  MobilityModule(final ImmutableResourceCost resourceCost, final int movementSpeed, final Map<LevelType, Double> movementCost,
                               final Map<LevelType, Double> levelingCost)
focal_class.identifier: MobilityModule
focal_class.modifiers: protected
focal_class.parameters: (final ImmutableResourceCost resourceCost, final int movementSpeed, final Map<LevelType, Double> movementCost,
                               final Map<LevelType, Double> levelingCost)
focal_class.signature:  MobilityModule(final ImmutableResourceCost resourceCost, final int movementSpeed, final Map<LevelType, Double> movementCost,
                               final Map<LevelType, Double> levelingCost)
focal_class.class_method_signature: MobilityModule.createWithStandardResourceCost()
focal_class.full_signature: static Builder0 createWithStandardResourceCost()
focal_class.identifier: createWithStandardResourceCost
focal_class.modifiers: static
focal_class.parameters: ()
focal_class.return: Builder0
focal_class.signature: Builder0 createWithStandardResourceCost()
focal_class.class_method_signature: MobilityModule.createWithExtraResourceCost(final ImmutableResourceCost resourceCost)
focal_class.full_signature: static Builder0 createWithExtraResourceCost(final ImmutableResourceCost resourceCost)
focal_class.identifier: createWithExtraResourceCost
focal_class.modifiers: static
focal_class.parameters: (final ImmutableResourceCost resourceCost)
focal_class.return: Builder0
focal_class.signature: Builder0 createWithExtraResourceCost(final ImmutableResourceCost resourceCost)
focal_class.class_method_signature: MobilityModule.getRemainingSpeed()
focal_class.full_signature: @Override public double getRemainingSpeed()
focal_class.identifier: getRemainingSpeed
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: double
focal_class.signature: double getRemainingSpeed()
focal_class.class_method_signature: MobilityModule.getMovementSpeed()
focal_class.full_signature: @Override public double getMovementSpeed()
focal_class.identifier: getMovementSpeed
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: double
focal_class.signature: double getMovementSpeed()
focal_class.class_method_signature: MobilityModule.costForMovingInLevel(final LevelType levelType)
focal_class.full_signature: @Override public double costForMovingInLevel(final LevelType levelType)
focal_class.identifier: costForMovingInLevel
focal_class.modifiers: @Override public
focal_class.parameters: (final LevelType levelType)
focal_class.return: double
focal_class.signature: double costForMovingInLevel(final LevelType levelType)
focal_class.class_method_signature: MobilityModule.costForLevelingToLevel(final LevelType levelType)
focal_class.full_signature: @Override public double costForLevelingToLevel(final LevelType levelType)
focal_class.identifier: costForLevelingToLevel
focal_class.modifiers: @Override public
focal_class.parameters: (final LevelType levelType)
focal_class.return: double
focal_class.signature: double costForLevelingToLevel(final LevelType levelType)
focal_class.class_method_signature: MobilityModule.leveling(final LevelType levelType)
focal_class.full_signature: @Override public Leveling leveling(final LevelType levelType)
focal_class.identifier: leveling
focal_class.modifiers: @Override public
focal_class.parameters: (final LevelType levelType)
focal_class.return: Leveling
focal_class.signature: Leveling leveling(final LevelType levelType)
focal_class.class_method_signature: MobilityModule.movement(final ITile target)
focal_class.full_signature: @Override public Movement movement(final ITile target)
focal_class.identifier: movement
focal_class.modifiers: @Override public
focal_class.parameters: (final ITile target)
focal_class.return: Movement
focal_class.signature: Movement movement(final ITile target)
focal_class.class_method_signature: MobilityModule.onReset()
focal_class.full_signature: @Override protected void onReset()
focal_class.identifier: onReset
focal_class.modifiers: @Override protected
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void onReset()
focal_class.class_method_signature: MobilityModule.onNewTurn()
focal_class.full_signature: @Override protected void onNewTurn()
focal_class.identifier: onNewTurn
focal_class.modifiers: @Override protected
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void onNewTurn()
focal_class.class_method_signature: MobilityModule.getController()
focal_class.full_signature: @Override public IMobilityModuleController getController()
focal_class.identifier: getController
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: IMobilityModuleController
focal_class.signature: IMobilityModuleController getController()
focal_class.class_method_signature: MobilityModule.getModule()
focal_class.full_signature: @Override public IMobilityModule getModule()
focal_class.identifier: getModule
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: IMobilityModule
focal_class.signature: IMobilityModule getModule()
focal_class.superclass: extends Module
focal_method.body: @Override
      public double costForLevelingToLevel(final LevelType levelType)
              throws NotAuthenticatedException, NotObservableException {
          assertObservable();
          Tile location = getGameObject().getLocation().get();
  
          // Level up until we reach the target level.
          double cost = 0;
          LevelType currentLevel = location.getLevel().getType();
          if (levelType == currentLevel)
              return 0;
          while (true) {
              Optional<LevelType> newLevel = currentLevel.up();
              if (!newLevel.isPresent())
                  break;
  
              Double currentLevelCost = levelingCost.get( EnumUtils.min( currentLevel, newLevel.get() ) );
              if (currentLevelCost == null)
                  // Cannot level to this level.
                  return Double.MAX_VALUE;
  
              currentLevel = newLevel.get();
              cost += currentLevelCost;
  
              if (currentLevel == levelType)
                  return cost;
          }
  
          // Level down until we reach the target level.
          cost = 0;
          currentLevel = location.getLevel().getType();
          while (true) {
              Optional<LevelType> newLevel = currentLevel.down();
              if (!newLevel.isPresent())
                  break;
  
              Double currentLevelCost = levelingCost.get( EnumUtils.min( currentLevel, newLevel.get() ) );
              if (currentLevelCost == null)
                  // Cannot level to this level.
                  return Double.MAX_VALUE;
  
              currentLevel = newLevel.get();
              cost += currentLevelCost;
  
              if (currentLevel == levelType)
                  return cost;
          }
  
          // Unreachable code.
          throw new IllegalArgumentException( "Unsupported level type: " + levelType );
      }
focal_method.class_method_signature: MobilityModule.costForLevelingToLevel(final LevelType levelType)
focal_method.full_signature: @Override public double costForLevelingToLevel(final LevelType levelType)
focal_method.identifier: costForLevelingToLevel
focal_method.invocations: assertObservable get getLocation getGameObject getType getLevel up isPresent get min get get getType getLevel down isPresent get min get get
focal_method.modifiers: @Override public
focal_method.parameters: (final LevelType levelType)
focal_method.return: double
focal_method.signature: double costForLevelingToLevel(final LevelType levelType)