diff --git a/.gitignore b/.gitignore index 7893b49..9ee5328 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ build/gcov builld/logs build/temp build/test -.vscode \ No newline at end of file +.vscode +encounter_test.sh \ No newline at end of file diff --git a/src/c/encounter.c b/src/c/encounter.c index 5ee3f85..2956c58 100644 --- a/src/c/encounter.c +++ b/src/c/encounter.c @@ -4,6 +4,7 @@ #include #include "encounter.h" + /*Gegner mit AC, damagedealt = damage-AC, kann nicht kleiner 1 sein evtl. lair bonus der dem gegner ein wenig mehr/weniger damage erlaubt gegner erhalten eine zufällige menge Gold, die beim tod an den spieler gegeben werden @@ -58,3 +59,9 @@ void *setEnemyArmor(int *num, int armor){ int getEnemyInt(int *structParam){ return *structParam; } + + +int switchTurns(int currentTurn){ + currentTurn = currentTurn % 2 + 1; + return currentTurn; +} \ No newline at end of file diff --git a/src/c/encounter.h b/src/c/encounter.h index d6ddb68..185688d 100644 --- a/src/c/encounter.h +++ b/src/c/encounter.h @@ -14,7 +14,8 @@ typedef struct { bool playerAlive(int health); int playerHealth(int health, int damage); int enemyDamaged(enemy enemy, int damage); - +int switchTurns(int currentTurn); +int charInputToIntReturn(); //Getter/Setter Funktionen diff --git a/test/c/test_encounter.c b/test/c/test_encounter.c index f6782dd..4641b76 100644 --- a/test/c/test_encounter.c +++ b/test/c/test_encounter.c @@ -4,6 +4,7 @@ #include "encounter.h" + void setUp(void){ } @@ -21,6 +22,15 @@ void test_isPlayerAlive_healthGreaterZero(void) TEST_ASSERT_TRUE(playerAlive(health)); } +void test_isPlayerAlive_healthLowerZero(void) +{ + //arrange + int health = -1; + //act + //assert + TEST_ASSERT_TRUE(playerAlive(health)); +} + void test_playerIsDamaged(void) { //arrange @@ -117,7 +127,8 @@ void test_PlayerAttacksEnemy_DoesMinDamage(void) } //A better way to get the value of a struct, REFACTORING if it works -void test_getterWithParams(void){ +void test_getterWithParams(void) +{ int health = 50, armor = 4, damage = 4, attack = 5; enemy test = {health, damage, armor, attack}; TEST_ASSERT_EQUAL(health, getEnemyInt(&test.health)); @@ -125,4 +136,15 @@ void test_getterWithParams(void){ TEST_ASSERT_EQUAL(damage, getEnemyInt(&test.damage)); TEST_ASSERT_EQUAL(attack, getEnemyInt(&test.attack)); } +void test_switchingTurns(void) +{ + //arrange + int currentTurn = 0, result; + //act + result = switchTurns(currentTurn); + //assert + TEST_ASSERT_EQUAL(1,result); +} + + #endif // TEST