Browse Source

Added a way to read values out of the enemy struct

remotes/origin/encounter
János 2 years ago
parent
commit
0e98febc24
  1. 1
      src/c/encounter.c
  2. 1
      src/c/encounter.h
  3. 9
      test/c/test_encounter.c

1
src/c/encounter.c

@ -36,5 +36,6 @@ void *setEnemyHealth(int *num, int health){
}
int getEnemyHealth(enemy enemy){
//gibt health zurück, benötigt keine adress pointer
return enemy.health;
}

1
src/c/encounter.h

@ -9,6 +9,7 @@ typedef struct {
//setEnemyHealth(&enemy.health, health);
void *setEnemyHealth(int *num, int health);
int getEnemyHealth(enemy enemy);
bool playerAlive(int health);
int playerHealth(int health, int damage);

9
test/c/test_encounter.c

@ -54,6 +54,15 @@ void test_setEnemyHealth(void){
TEST_ASSERT_EQUAL(health, test.health);
}
void test_getEnemyHealth(void){
//arrange
int health = 50;
//act
enemy test = {health};
//assert
TEST_ASSERT_EQUAL(health, getEnemyHealth(test));
}
#endif // TEST
Loading…
Cancel
Save