@Test public void testHasRequiredEnergy() { WorldObject performer = createPerformer(2); performer.setProperty(Constants.ENERGY, 1000); assertEquals(true, Actions.LIGHTNING_BOLT_ATTACK_ACTION.hasRequiredEnergy(performer)); performer.setProperty(Constants.ENERGY, 0); assertEquals(false, Actions.LIGHTNING_BOLT_ATTACK_ACTION.hasRequiredEnergy(performer)); }
@Test public void testIsValidTarget() { World world = new MockWorld(new MockTerrain(TerrainType.GRASLAND), new WorldImpl(10, 10, null, null)); WorldObject performer = createPerformer(2); WorldObject target = createPerformer(3); assertEquals( false, Actions.LIGHTNING_BOLT_ATTACK_ACTION.isValidTarget(performer, target, world)); performer.setProperty( Constants.KNOWN_SPELLS, Arrays.asList(Actions.LIGHTNING_BOLT_ATTACK_ACTION)); target.setProperty(Constants.HIT_POINTS, 10); target.setProperty(Constants.ARMOR, 10); assertEquals( true, Actions.LIGHTNING_BOLT_ATTACK_ACTION.isValidTarget(performer, target, world)); }
@Test public void testDistance() { World world = new WorldImpl(1, 1, null, null); WorldObject performer = createPerformer(2); WorldObject target = createPerformer(3); assertEquals( 0, Actions.LIGHTNING_BOLT_ATTACK_ACTION.distance(performer, target, Args.EMPTY, world)); }
@Test public void testIsActionPossible() { World world = new MockWorld(new MockTerrain(TerrainType.GRASLAND), new WorldImpl(10, 10, null, null)); WorldObject performer = createPerformer(2); WorldObject target = createPerformer(3); assertEquals( true, Actions.LIGHTNING_BOLT_ATTACK_ACTION.isActionPossible( performer, target, Args.EMPTY, world)); }
@Test public void testExecute() { World world = new MockWorld(new MockTerrain(TerrainType.GRASLAND), new WorldImpl(10, 10, null, null)); WorldObject performer = createPerformer(2); WorldObject target = createPerformer(3); target.setProperty(Constants.HIT_POINTS, 10 * Item.COMBAT_MULTIPLIER); target.setProperty(Constants.HIT_POINTS_MAX, 10 * Item.COMBAT_MULTIPLIER); Actions.LIGHTNING_BOLT_ATTACK_ACTION.execute(performer, target, Args.EMPTY, world); assertEquals(5 * Item.COMBAT_MULTIPLIER, target.getProperty(Constants.HIT_POINTS).intValue()); }
@Test public void testExecuteWater() { World world = new MockWorld(new MockTerrain(TerrainType.WATER), new WorldImpl(10, 10, null, null)); WorldObject performer = createPerformer(2); WorldObject target = createPerformer(3); performer.setProperty(Constants.HIT_POINTS, 10); performer.setProperty(Constants.HIT_POINTS_MAX, 10); target.setProperty(Constants.HIT_POINTS, 10); target.setProperty(Constants.HIT_POINTS_MAX, 10); world.addWorldObject(performer); world.addWorldObject(target); Actions.LIGHTNING_BOLT_ATTACK_ACTION.execute(performer, target, Args.EMPTY, world); assertEquals(5, performer.getProperty(Constants.HIT_POINTS).intValue()); assertEquals(0, target.getProperty(Constants.HIT_POINTS).intValue()); }