From 40fcf6746ce9e89e4c62a72ccda6919480a9d279 Mon Sep 17 00:00:00 2001 From: Kai Kehres Date: Sun, 29 Jan 2023 11:44:27 +0100 Subject: [PATCH] prod/test: created new files spell.c /.h and test_spell.c and function spellFireball --- src/c/spell.c | 10 ++++++++++ src/c/spell.h | 6 ++++++ test/c/test_spell.c | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 src/c/spell.c create mode 100644 src/c/spell.h create mode 100644 test/c/test_spell.c diff --git a/src/c/spell.c b/src/c/spell.c new file mode 100644 index 0000000..ea368b2 --- /dev/null +++ b/src/c/spell.c @@ -0,0 +1,10 @@ +#include +#include +#include + +#include "character.h" + +int spellFireball(Character *character) { + int damage = 10 + (getCharacterIntelligence(character) / 2); + return damage; +} \ No newline at end of file diff --git a/src/c/spell.h b/src/c/spell.h new file mode 100644 index 0000000..bc7b657 --- /dev/null +++ b/src/c/spell.h @@ -0,0 +1,6 @@ +#ifndef SPELL_H +#define SPELL_H + +int spellFireball(Character *character); + +#endif \ No newline at end of file diff --git a/test/c/test_spell.c b/test/c/test_spell.c new file mode 100644 index 0000000..a8d4ab0 --- /dev/null +++ b/test/c/test_spell.c @@ -0,0 +1,38 @@ +#ifdef TEST +#include "unity.h" +#include "character.h" +#include "spell.h" + +Character testCharacter; +Character testCharacter2; + +void setUp(void) +{ + testCharacter.healthPoints = 0; + testCharacter2.healthPoints = 15; + testCharacter.strength = 0; + testCharacter2.strength = 5; + testCharacter.dexterity = 0; + testCharacter2.dexterity = 5; + testCharacter.intelligence = 0; + testCharacter2.intelligence = 7; + testCharacter.level = 0; + testCharacter2.level = 5; + testCharacter.exp = 50; + testCharacter2.exp = 110; + testCharacter.maxExp = 100; + testCharacter2.maxExp = 100; + testCharacter.attack = 5; + testCharacter2.weaponClass = SWORD; +} + +void tearDown(void) +{ +} + +void test_spellFireball(void) +{ + TEST_ASSERT_EQUAL_INT(10,spellFireball(&testCharacter)); + TEST_ASSERT_EQUAL_INT(13,spellFireball(&testCharacter2)); +} +#endif // TEST \ No newline at end of file