private boolean allEnemiesDead(final List<FfEnemy> list) { boolean isEnemyAlive = false; for (final FfEnemy enemy : list) { isEnemyAlive |= enemy.getStamina() > 0; } return !isEnemyAlive; }
public void testExecutePostHandlerShouldKillEnemiesAndAddMarkerItem() { // GIVEN final ImmutableMap<String, Enemy> enemiesMap = ImmutableMap.of("7", (Enemy) captain, "8", elvira); expect(resolvationData.getEnemies()).andReturn(enemiesMap); captain.setStamina(0); elvira.setStamina(0); expect(resolvationData.getCharacterHandler()).andReturn(characterHandler); expect(characterHandler.getItemHandler()).andReturn(itemHandler); expect(resolvationData.getCharacter()).andReturn(character); expect(itemHandler.addItem(character, "4001", 1)).andReturn(1); mockControl.replay(); // WHEN underTest.executePostHandler(command, resolvationData, results, data); // THEN }
private void fixEnemy() { notSelectedEnemy.setStaminaAutoDamage(0); notSelectedEnemy.setStaminaDamageWhileInactive(0); selectedEnemy.setStaminaAutoDamage(0); selectedEnemy.setKillableByNormal(true); selectedEnemy.setKillableByMagical(true); selectedEnemy.setKillableByBlessed(true); selectedEnemy.setStamina(3); selectedEnemy.setDamageAbsorptionEdged(0); }
public void testResolveRoundWhenSingleMagicalEnemyIsHitWithMagicalWeaponShouldCauseDamageAndReturnRoundResultWithWin() { // GIVEN enemies.add(selectedEnemy); command.getResolvedEnemies().addAll(enemies); selectedEnemy.setKillableByNormal(false); selectedEnemy.setKillableByBlessed(false); expect(interactionHandler.peekLastFightCommand(character, "enemyId")).andReturn("9"); expect(generator.getRandomNumber(2)).andReturn(SELF_ATTACK_STRENGTH_ROLL); expect(attributeHandler.resolveValue(character, "attackStrength")).andReturn(0); expect(generator.getRandomNumber(2)).andReturn(ENEMY_ATTACK_STRENGTH_ROLL); expect(attributeHandler.resolveValue(character, "skill")).andReturn(10); expect(diceResultRenderer.render(6, SELF_ATTACK_STRENGTH_ROLL)) .andReturn(SELF_ATTACK_STRENGTH_RENDER); expectText( "page.ff.label.fight.single.attackStrength.self", new Object[] {SELF_ATTACK_STRENGTH_RENDER, 17}); logger.debug("Attack strength for self: {}", 17); expect(diceResultRenderer.render(6, ENEMY_ATTACK_STRENGTH_ROLL)) .andReturn(ENEMY_ATTACK_STRENGTH_RENDER); expectText( "page.ff.label.fight.single.attackStrength.enemy", new Object[] {"Goblin", ENEMY_ATTACK_STRENGTH_RENDER, 15}); logger.debug("Attack strength for {}: {}", "Goblin", 15); final FfItem weapon = new FfItem("7", "Sword", ItemType.weapon1); weapon.setMagical(true); weapon.setStaminaDamage(3); expect(itemHandler.getEquippedWeapon(character)).andReturn(weapon).times(2); expect(attributeHandler.resolveValue(character, "baseStaminaDamage")).andReturn(0); expectText("page.ff.label.fight.single.successfulAttack", new Object[] {"Goblin"}); mockControl.replay(); // WHEN final FightRoundResult[] returned = underTest.resolveRound(command, resolvationData, beforeRoundResult); // THEN Assert.assertEquals(returned.length, 1); Assert.assertEquals(returned[0], FightRoundResult.WIN); }
private void setUpEnemy() { selectedEnemy = new FfEnemy(); selectedEnemy.setId("9"); selectedEnemy.setName("Goblin"); selectedEnemy.setSkill(8); notSelectedEnemy = new FfEnemy(); notSelectedEnemy.setName("Orc"); notSelectedEnemy.setId("33"); notSelectedEnemy.setStamina(9); }