diff --git a/src/c/encounter.c b/src/c/encounter.c index 9bd8a89..d6b8710 100644 --- a/src/c/encounter.c +++ b/src/c/encounter.c @@ -39,3 +39,11 @@ int getEnemyHealth(enemy enemy){ //gibt health zurück, benötigt keine adress pointer return enemy.health; } + +void *setEnemyDamage(int *num, int damage){ + *num = damage; +} + +int getEnemyDamage(enemy enemy){ + return enemy.damage; +} diff --git a/src/c/encounter.h b/src/c/encounter.h index 4dd6bf3..6fbedfe 100644 --- a/src/c/encounter.h +++ b/src/c/encounter.h @@ -5,12 +5,18 @@ typedef struct { int health; + int damage; } enemy; + +bool playerAlive(int health); +int playerHealth(int health, int damage); + //setEnemyHealth(&enemy.health, health); void *setEnemyHealth(int *num, int health); int getEnemyHealth(enemy enemy); -bool playerAlive(int health); -int playerHealth(int health, int damage); +//setEnemyDamage(&enemy.damage, damage); +void *setEnemyDamage(int *num, int damage); +int getEnemyDamage(enemy enemy); #endif \ No newline at end of file diff --git a/test/c/test_encounter.c b/test/c/test_encounter.c index eb40728..cc57da1 100644 --- a/test/c/test_encounter.c +++ b/test/c/test_encounter.c @@ -63,6 +63,19 @@ void test_getEnemyHealth(void){ TEST_ASSERT_EQUAL(health, getEnemyHealth(test)); } +void test_setEnemyDamage(void){ + int damage = 4, result; + enemy test = {50, damage*2}; + setEnemyDamage(&test.damage, damage); + TEST_ASSERT_EQUAL(damage, test.damage); +} + +void test_getEnemyDamage(void){ + int damage = 4, result; + enemy test = {50, damage}; + result = getEnemyDamage(test); + TEST_ASSERT_EQUAL(damage, result); +} #endif // TEST