|
|
@ -185,12 +185,12 @@ void test_switchingTurns(void) |
|
|
|
void test_FightPlayerWins(void) |
|
|
|
{ |
|
|
|
// arange |
|
|
|
int playerHealth = 100, playerDamage = 10, playerArmor = 4, playerAttack = 5; |
|
|
|
int playerHealth = 100, playerDamage = 10, playerArmor = 4, playerMaxHealth = 100; |
|
|
|
int enemyHealth = 1, enemyDamage = 4, enemyArmor = 4, enemyMaxHealth = 5; |
|
|
|
int result; |
|
|
|
// act |
|
|
|
//strength,dexterity,intelligence,healthPoints,manaPoints,level,exp,maxExp,attack,armor,maxHealthPoints; |
|
|
|
Character testChar = {10,10,10,playerHealth,100,1,0,100,playerDamage,playerArmor,100}; |
|
|
|
Character testChar = {10,10,10,playerHealth,100,1,0,100,playerDamage,playerArmor,playerMaxHealth}; |
|
|
|
playerInputChar_ExpectAndReturn('a'); |
|
|
|
enemy test = {enemyHealth, enemyDamage, enemyArmor, enemyMaxHealth}; |
|
|
|
result = fight(&testChar, &test); |
|
|
@ -201,11 +201,11 @@ void test_FightPlayerWins(void) |
|
|
|
void test_FightEnemyWins(void) |
|
|
|
{ |
|
|
|
// arange |
|
|
|
int playerHealth = 1, playerDamage = 10, playerArmor = 4, playerAttack = 5; |
|
|
|
int playerHealth = 1, playerDamage = 10, playerArmor = 4, playerMaxHealth = 5; |
|
|
|
int enemyHealth = 100, enemyDamage = 4, enemyArmor = 4, enemyMaxHealth = 100; |
|
|
|
int result; |
|
|
|
// act |
|
|
|
Character testChar = {10,10,10,playerHealth,100,1,0,100,playerDamage,playerArmor,100}; |
|
|
|
Character testChar = {10,10,10,playerHealth,100,1,0,100,playerDamage,playerArmor,playerMaxHealth}; |
|
|
|
playerInputChar_ExpectAndReturn('a'); |
|
|
|
randomInt_ExpectAndReturn(1); |
|
|
|
enemy test = {enemyHealth, enemyDamage, enemyArmor, enemyMaxHealth}; |
|
|
@ -217,11 +217,11 @@ void test_FightEnemyWins(void) |
|
|
|
void test_FightPlayerChoosesAttack(void) |
|
|
|
{ |
|
|
|
// arrange |
|
|
|
int playerHealth = 100, playerDamage = 10, playerArmor = 4, playerAttack = 5; |
|
|
|
int playerHealth = 100, playerDamage = 10, playerArmor = 4, playerMaxHealth = 5; |
|
|
|
int enemyHealth = 6, enemyDamage = 4, enemyArmor = 4, enemyMaxHealth = 100; |
|
|
|
int result; |
|
|
|
// act |
|
|
|
Character testChar = {10,10,10,playerHealth,100,1,0,100,playerDamage,playerArmor,100}; |
|
|
|
Character testChar = {10,10,10,playerHealth,100,1,0,100,playerDamage,playerArmor,playerMaxHealth}; |
|
|
|
playerInputChar_ExpectAndReturn('a'); |
|
|
|
enemy test = {enemyHealth, enemyDamage, enemyArmor, enemyMaxHealth}; |
|
|
|
fight(&testChar, &test); |
|
|
@ -233,11 +233,11 @@ void test_FightPlayerChoosesAttack(void) |
|
|
|
void test_FightPlayerHeals_thenAttacks_Wins(void) |
|
|
|
{ |
|
|
|
// arrange |
|
|
|
int playerHealth = 2, playerDamage = 10, playerArmor = 4, playerAttack = 10; |
|
|
|
int playerHealth = 2, playerDamage = 10, playerArmor = 4, playerMaxHealth = 10; |
|
|
|
int enemyHealth = 11, enemyDamage = 4, enemyArmor = 4, enemyMaxHealth = 100; |
|
|
|
int result; |
|
|
|
// act |
|
|
|
Character testChar = {10,10,10,playerHealth,100,1,0,100,playerDamage,playerArmor,100}; |
|
|
|
Character testChar = {10,10,10,playerHealth,100,1,0,100,playerDamage,playerArmor,playerMaxHealth}; |
|
|
|
enemy test = {enemyHealth, enemyDamage, enemyArmor, enemyMaxHealth}; |
|
|
|
playerInputChar_ExpectAndReturn('h'); |
|
|
|
randomInt_ExpectAndReturn(1); |
|
|
@ -252,11 +252,11 @@ void test_FightPlayerHeals_thenAttacks_Wins(void) |
|
|
|
void test_FightPlayerFlees(void) |
|
|
|
{ |
|
|
|
// arrange |
|
|
|
int playerHealth = 10, playerDamage = 10, playerArmor = 4, playerAttack = 10; |
|
|
|
int playerHealth = 10, playerDamage = 10, playerArmor = 4, playerMaxHealth = 10; |
|
|
|
int enemyHealth = 11, enemyDamage = 4, enemyArmor = 4, enemyMaxHealth = 100; |
|
|
|
int result; |
|
|
|
// act |
|
|
|
Character testChar = {10,10,10,playerHealth,100,1,0,100,playerDamage,playerArmor,100}; |
|
|
|
Character testChar = {10,10,10,playerHealth,100,1,0,100,playerDamage,playerArmor,playerMaxHealth}; |
|
|
|
enemy test = {enemyHealth, enemyDamage, enemyArmor, enemyMaxHealth}; |
|
|
|
playerInputChar_ExpectAndReturn('f'); |
|
|
|
result = fight(&testChar, &test); |
|
|
@ -367,15 +367,15 @@ void test_enemyChoosesHeal_ThenAttackWins(void) |
|
|
|
//arange |
|
|
|
int result; |
|
|
|
int enemyHealth = 6, enemyDamage = 10, enemyArmor = 5, enemyMaxHealth = 100; |
|
|
|
int playerHealth = 10, playerDamage = 10, playerArmor = 5, playerAttack = 10; |
|
|
|
enemy test2 = {enemyHealth, enemyDamage, enemyArmor, enemyMaxHealth}; |
|
|
|
int playerHealth = 10, playerDamage = 10, playerArmor = 5, playerMaxHealth = 10; |
|
|
|
enemy test = {enemyHealth, enemyDamage, enemyArmor, enemyMaxHealth}; |
|
|
|
//act |
|
|
|
Character testChar = {10,10,10,playerHealth,100,1,0,100,playerDamage,playerArmor,100}; |
|
|
|
Character testChar = {10,10,10,playerHealth,100,1,0,100,playerDamage,playerArmor,playerMaxHealth}; |
|
|
|
playerInputChar_ExpectAndReturn('a'); |
|
|
|
randomInt_ExpectAndReturn(39); //39%20 = 19 , 19 + 1 = 20 |
|
|
|
playerInputChar_ExpectAndReturn('a'); |
|
|
|
randomInt_ExpectAndReturn(0); //0%20 = 0 , 0 + 1 = 1 |
|
|
|
result = fight(&testChar, &test2); |
|
|
|
result = fight(&testChar, &test); |
|
|
|
//assert |
|
|
|
TEST_ASSERT_EQUAL(0, result); |
|
|
|
|
|
|
|