Browse Source

Player can now flee from combat

remotes/origin/encounter
János 2 years ago
parent
commit
43024c9e19
  1. 2
      src/c/encounter.c
  2. 14
      test/c/test_encounter.c

2
src/c/encounter.c

@ -72,6 +72,8 @@ int fight(int playerH, int playerDamage, int playerArmor, int playerAttack, enem
case 'h':
playerH = playerHealth(playerH, -10, playerArmor);
break;
case 'f':
return 2;
}
}

14
test/c/test_encounter.c

@ -237,4 +237,18 @@ void test_FightPlayerHeals_thenAttacks_Wins(void)
TEST_ASSERT_EQUAL(1, result);
}
void test_FightPlayerFlees(void)
{
//arrange
int playerHealth = 10, playerDamage = 10, playerArmor = 4, playerAttack = 10;
int enemyHealth = 11, enemyDamage = 4, enemyArmor = 4, enemyAttack = 5;
int result;
//act
enemy test = {enemyHealth, enemyDamage, enemyArmor, enemyAttack};
playerInput_ExpectAndReturn('f');
result = fight(playerHealth, playerDamage, playerArmor, playerAttack, &test);
//assert
TEST_ASSERT_EQUAL(2, result);
}
#endif // TEST
Loading…
Cancel
Save