diff --git a/src/c/encounter.c b/src/c/encounter.c index 29678c8..5ee3f85 100644 --- a/src/c/encounter.c +++ b/src/c/encounter.c @@ -30,7 +30,7 @@ int playerHealth(int health, int damage){ } int enemyDamaged(enemy enemy, int damage){ - int armor = getEnemyArmor(enemy); + int armor = getEnemyInt(&enemy.armor); int damagedealt = damage - armor; if(damagedealt < 1){ damagedealt = 1; @@ -47,27 +47,14 @@ void *setEnemyHealth(int *num, int health){ //return health; } -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; -} - void *setEnemyArmor(int *num, int armor){ *num = armor; } -int getEnemyArmor(enemy enemy){ - return enemy.armor; -} - int getEnemyInt(int *structParam){ return *structParam; } diff --git a/src/c/encounter.h b/src/c/encounter.h index 0beafea..d6ddb68 100644 --- a/src/c/encounter.h +++ b/src/c/encounter.h @@ -21,13 +21,11 @@ int enemyDamaged(enemy enemy, int damage); //setEnemyHealth(&enemy.health, health); void *setEnemyHealth(int *num, int health); -int getEnemyHealth(enemy enemy); + //setEnemyDamage(&enemy.damage, damage); void *setEnemyDamage(int *num, int damage); -int getEnemyDamage(enemy enemy); //setEnemyArmor(&enemy.armor, armor); void *setEnemyArmor(int *num, int damage); -int getEnemyArmor(enemy enemy); //Function to get the value of Data in a struct, needs a pointer to the struct int getEnemyInt(int *structParam); diff --git a/test/c/test_encounter.c b/test/c/test_encounter.c index e68f866..f6782dd 100644 --- a/test/c/test_encounter.c +++ b/test/c/test_encounter.c @@ -59,7 +59,7 @@ void test_getEnemyHealth(void){ int health = 50, result; //act enemy test = {health}; - result = getEnemyHealth(test); + result = getEnemyInt(&test.health); //assert TEST_ASSERT_EQUAL(health, result); } @@ -74,7 +74,7 @@ void test_setEnemyDamage(void){ void test_getEnemyDamage(void){ int damage = 4, result; enemy test = {50, damage}; - result = getEnemyDamage(test); + result = getEnemyInt(&test.damage); TEST_ASSERT_EQUAL(damage, result); } @@ -82,7 +82,7 @@ void test_get_setEnemyArmor(void){ int armor = 4, result; enemy test = {50, 4, armor*2}; setEnemyArmor(&test.armor, armor); - result = getEnemyArmor(test); + result = getEnemyInt(&test.armor); TEST_ASSERT_EQUAL(armor, result); }