Browse Source

prod/test: created new files spell.c /.h and test_spell.c and function spellFireball

remotes/origin/nextcycle
Kai Kehres 2 years ago
parent
commit
40fcf6746c
  1. 10
      src/c/spell.c
  2. 6
      src/c/spell.h
  3. 38
      test/c/test_spell.c

10
src/c/spell.c

@ -0,0 +1,10 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "character.h"
int spellFireball(Character *character) {
int damage = 10 + (getCharacterIntelligence(character) / 2);
return damage;
}

6
src/c/spell.h

@ -0,0 +1,6 @@
#ifndef SPELL_H
#define SPELL_H
int spellFireball(Character *character);
#endif

38
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
Loading…
Cancel
Save