diff --git a/src/c/character.c b/src/c/character.c index d529731..2409dab 100644 --- a/src/c/character.c +++ b/src/c/character.c @@ -13,6 +13,10 @@ int getCharacterHealthPoints (Character *character) { return character->healthPoints; } +void addCharacterHealthPoints (Character *character, int addedHealthPoints) { + character->healthPoints += addedHealthPoints; +} + void setCharacterStrength (Character *character, int newStrength) { character->strength = newStrength; } diff --git a/src/c/character.h b/src/c/character.h index 80b6dd1..0c18944 100644 --- a/src/c/character.h +++ b/src/c/character.h @@ -10,6 +10,8 @@ void setCharacterHealthPoints (Character *character, int newHealthPoints); int getCharacterHealthPoints (Character *character); +void addCharacterHealthPoints (Character *character, int addedHealthPoints); + void setCharacterStrength (Character *character, int newStrength); int getCharacterStrength (Character *character); diff --git a/test/c/test_character.c b/test/c/test_character.c index e216d43..71b43ec 100644 --- a/test/c/test_character.c +++ b/test/c/test_character.c @@ -30,6 +30,13 @@ void test_setCharacterHealthPoints(void) void test_getCharacterHealthPoints (void) { TEST_ASSERT_EQUAL_INT(15,testCharacter2.healthPoints); } + +void test_addCharacterHealthPoints (void) { + addCharacterHealthPoints(&testCharacter2,5); + TEST_ASSERT_EQUAL_INT(20,testCharacter2.healthPoints); + +} + void test_setCharacterStrenght(void) { TEST_ASSERT_EQUAL_INT(0,testCharacter.strength); setCharacterStrength(&testCharacter,50);