Browse Source

refactoring: renamed unused vars for future use

remotes/origin/encounter
János 2 years ago
parent
commit
15f117fd48
  1. 4
      src/c/encounter.c
  2. 4
      src/c/encounter.h
  3. 30
      test/c/test_encounter.c

4
src/c/encounter.c

@ -132,7 +132,7 @@ int getEnemyDamage(enemy* enemy)
return enemy->damage; return enemy->damage;
} }
int getEnemyAttack(enemy* enemy)
int getEnemyMaxHealth(enemy* enemy)
{ {
return enemy->attack;
return enemy->maxHealth;
} }

4
src/c/encounter.h

@ -7,7 +7,7 @@ typedef struct enemy{
int health; int health;
int damage; int damage;
int armor; int armor;
int attack;
int maxHealth;
} enemy; } enemy;
@ -30,7 +30,7 @@ void setEnemyDamage(enemy* enemy, int newdamage);
//setEnemyArmor(&enemy.armor, armor); //setEnemyArmor(&enemy.armor, armor);
void setEnemyArmor(enemy* enemy, int newarmor); void setEnemyArmor(enemy* enemy, int newarmor);
//Function to get the value of Data in a struct, needs a pointer to the struct //Function to get the value of Data in a struct, needs a pointer to the struct
int getEnemyAttack(enemy* enemy);
int getEnemyMaxHealth(enemy* enemy);
int getEnemyHealth(enemy* enemy); int getEnemyHealth(enemy* enemy);
int getEnemyArmor(enemy* enemy); int getEnemyArmor(enemy* enemy);
int getEnemyDamage(enemy* enemy); int getEnemyDamage(enemy* enemy);

30
test/c/test_encounter.c

@ -158,19 +158,19 @@ void test_PlayerAttacksEnemy_DoesMinDamage(void)
void test_getterWithParams(void) void test_getterWithParams(void)
{ {
// arrange // arrange
int health = 50, armor = 4, damage = 4, attack = 5;
int healthResult, armorResult, damageResult, attackResult;
enemy test = {health, damage, armor, attack};
int health = 50, armor = 4, damage = 4, maxHealth = 5;
int healthResult, armorResult, damageResult, maxHealthResult;
enemy test = {health, damage, armor, maxHealth};
// act // act
healthResult = getEnemyHealth(&test); healthResult = getEnemyHealth(&test);
armorResult = getEnemyArmor(&test); armorResult = getEnemyArmor(&test);
damageResult = getEnemyDamage(&test); damageResult = getEnemyDamage(&test);
attackResult = getEnemyAttack(&test);
maxHealthResult = getEnemyMaxHealth(&test);
// assert // assert
TEST_ASSERT_EQUAL(health, healthResult); TEST_ASSERT_EQUAL(health, healthResult);
TEST_ASSERT_EQUAL(armor, armorResult); TEST_ASSERT_EQUAL(armor, armorResult);
TEST_ASSERT_EQUAL(damage, damageResult); TEST_ASSERT_EQUAL(damage, damageResult);
TEST_ASSERT_EQUAL(attack, attackResult);
TEST_ASSERT_EQUAL(maxHealth, maxHealthResult);
} }
void test_switchingTurns(void) void test_switchingTurns(void)
{ {
@ -186,11 +186,11 @@ void test_FightPlayerWins(void)
{ {
// arange // arange
int playerHealth = 100, playerDamage = 10, playerArmor = 4, playerAttack = 5; int playerHealth = 100, playerDamage = 10, playerArmor = 4, playerAttack = 5;
int enemyHealth = 1, enemyDamage = 4, enemyArmor = 4, enemyAttack = 5;
int enemyHealth = 1, enemyDamage = 4, enemyArmor = 4, enemyMaxHealth = 5;
int result; int result;
// aCt // aCt
playerInput_ExpectAndReturn('a'); playerInput_ExpectAndReturn('a');
enemy test = {enemyHealth, enemyDamage, enemyArmor, enemyAttack};
enemy test = {enemyHealth, enemyDamage, enemyArmor, enemyMaxHealth};
result = fight(playerHealth, playerDamage, playerArmor, playerAttack, &test); result = fight(playerHealth, playerDamage, playerArmor, playerAttack, &test);
// assert // assert
TEST_ASSERT_EQUAL(1, result); TEST_ASSERT_EQUAL(1, result);
@ -200,11 +200,11 @@ void test_FightEnemyWins(void)
{ {
// arange // arange
int playerHealth = 1, playerDamage = 10, playerArmor = 4, playerAttack = 5; int playerHealth = 1, playerDamage = 10, playerArmor = 4, playerAttack = 5;
int enemyHealth = 100, enemyDamage = 4, enemyArmor = 4, enemyAttack = 5;
int enemyHealth = 100, enemyDamage = 4, enemyArmor = 4, enemyMaxHealth = 5;
int result; int result;
// act // act
playerInput_ExpectAndReturn('a'); playerInput_ExpectAndReturn('a');
enemy test = {enemyHealth, enemyDamage, enemyArmor, enemyAttack};
enemy test = {enemyHealth, enemyDamage, enemyArmor, enemyMaxHealth};
result = fight(playerHealth, playerDamage, playerArmor, playerAttack, &test); result = fight(playerHealth, playerDamage, playerArmor, playerAttack, &test);
// assert // assert
TEST_ASSERT_EQUAL(0, result); TEST_ASSERT_EQUAL(0, result);
@ -214,11 +214,11 @@ void test_FightPlayerChoosesAttack(void)
{ {
// arrange // arrange
int playerHealth = 100, playerDamage = 10, playerArmor = 4, playerAttack = 5; int playerHealth = 100, playerDamage = 10, playerArmor = 4, playerAttack = 5;
int enemyHealth = 6, enemyDamage = 4, enemyArmor = 4, enemyAttack = 5;
int enemyHealth = 6, enemyDamage = 4, enemyArmor = 4, enemyMaxHealth = 5;
int result; int result;
// act // act
playerInput_ExpectAndReturn('a'); playerInput_ExpectAndReturn('a');
enemy test = {enemyHealth, enemyDamage, enemyArmor, enemyAttack};
enemy test = {enemyHealth, enemyDamage, enemyArmor, enemyMaxHealth};
fight(playerHealth, playerDamage, playerArmor, playerAttack, &test); fight(playerHealth, playerDamage, playerArmor, playerAttack, &test);
result = getEnemyHealth(&test); result = getEnemyHealth(&test);
// assert // assert
@ -229,10 +229,10 @@ void test_FightPlayerHeals_thenAttacks_Wins(void)
{ {
//arrange //arrange
int playerHealth = 2, playerDamage = 10, playerArmor = 4, playerAttack = 10; int playerHealth = 2, playerDamage = 10, playerArmor = 4, playerAttack = 10;
int enemyHealth = 11, enemyDamage = 4, enemyArmor = 4, enemyAttack = 5;
int enemyHealth = 11, enemyDamage = 4, enemyArmor = 4, enemyMaxHealth = 5;
int result; int result;
//act //act
enemy test = {enemyHealth, enemyDamage, enemyArmor, enemyAttack};
enemy test = {enemyHealth, enemyDamage, enemyArmor, enemyMaxHealth};
playerInput_ExpectAndReturn('h'); playerInput_ExpectAndReturn('h');
playerInput_ExpectAndReturn('a'); playerInput_ExpectAndReturn('a');
playerInput_ExpectAndReturn('a'); playerInput_ExpectAndReturn('a');
@ -245,10 +245,10 @@ void test_FightPlayerFlees(void)
{ {
//arrange //arrange
int playerHealth = 10, playerDamage = 10, playerArmor = 4, playerAttack = 10; int playerHealth = 10, playerDamage = 10, playerArmor = 4, playerAttack = 10;
int enemyHealth = 11, enemyDamage = 4, enemyArmor = 4, enemyAttack = 5;
int enemyHealth = 11, enemyDamage = 4, enemyArmor = 4, enemyMaxHealth = 5;
int result; int result;
//act //act
enemy test = {enemyHealth, enemyDamage, enemyArmor, enemyAttack};
enemy test = {enemyHealth, enemyDamage, enemyArmor, enemyMaxHealth};
playerInput_ExpectAndReturn('f'); playerInput_ExpectAndReturn('f');
result = fight(playerHealth, playerDamage, playerArmor, playerAttack, &test); result = fight(playerHealth, playerDamage, playerArmor, playerAttack, &test);
//assert //assert

Loading…
Cancel
Save