Browse Source

prod: created function dodge

remotes/origin/nextcycle
Kai Kehres 2 years ago
parent
commit
896b0934c8
  1. 1
      src/c/character.c
  2. 9
      src/c/encounter.c
  3. 1
      src/c/encounter.h
  4. 5
      src/c/spell.c
  5. 2
      src/c/spell.h
  6. 8
      test/c/test_spell.c

1
src/c/character.c

@ -335,7 +335,6 @@ int checkStatus (Character *character) {
break;
}
}
void setCharacterManaPoints (Character *character, int newManaPoints) {
character->manaPoints = newManaPoints;
}

9
src/c/encounter.c

@ -5,6 +5,7 @@
#include "character.h"
#include "encounter.h"
#include "spell.h"
#include "playerinput.h"
#include "helper.h"
@ -237,4 +238,12 @@ int createRandomEnemy(enemy* enemy)
break;
}
return enemyType;
}
bool dodge (Character *character, enemy* enemy) {
if (randomIntRange(1,20) + character->dexterity > 15)
{
return true;
}
return false;
}

1
src/c/encounter.h

@ -23,6 +23,7 @@ void enemyDamaged(enemy* enemy, Character* character);
bool enemyChoosesHeal(enemy* enemy);
int switchTurns(int currentTurn);
int fight(Character *character, enemy* enemy);
bool dodge (Character *character, enemy* enemy);

5
src/c/spell.c

@ -7,6 +7,7 @@
SpellEffect spellFireball(Character *character) {
SpellEffect fireball;
fireball.id = 0;
fireball.damage = 10 + (getCharacterIntelligence(character) / 2);
fireball.healing = 0;
fireball.manaCost = 10;
@ -17,6 +18,7 @@ SpellEffect spellFireball(Character *character) {
SpellEffect spellHeal(Character *character) {
SpellEffect heal;
heal.id = 1;
heal.damage = 0;
heal.healing = 10 + (getCharacterIntelligence(character) / 3);
heal.manaCost = 10;
@ -27,6 +29,7 @@ SpellEffect spellHeal(Character *character) {
SpellEffect spellLightning(Character *character) {
SpellEffect lightning;
lightning.id = 2;
lightning.damage = 10 + (getCharacterIntelligence(character) / 2);
lightning.healing = 0;
lightning.manaCost = 10;
@ -37,6 +40,7 @@ SpellEffect spellLightning(Character *character) {
SpellEffect spellRegeneration (Character *character) {
SpellEffect regeneration;
regeneration.id = 3;
regeneration.damage = 0;
regeneration.healing = 5 + (getCharacterIntelligence(character) / 4);
regeneration.manaCost = 10;
@ -47,6 +51,7 @@ SpellEffect spellRegeneration (Character *character) {
SpellEffect spellFreeze(Character *character) {
SpellEffect freeze;
freeze.id = 4;
freeze.damage = 0;
freeze.healing = 0;
freeze.manaCost = 10;

2
src/c/spell.h

@ -3,7 +3,7 @@
typedef struct {
int damage, healing, manaCost, effect, effectDuration;
int id,damage, healing, manaCost, effect, effectDuration;
} SpellEffect;
enum {

8
test/c/test_spell.c

@ -32,10 +32,10 @@ void tearDown(void)
void test_spellFireball(void)
{
int result = spellFireball(&testCharacter).damage;
TEST_ASSERT_EQUAL_INT(10,result);
result = spellFireball(&testCharacter2).damage;
TEST_ASSERT_EQUAL_INT(13,result);
SpellEffect result = spellFireball(&testCharacter);
TEST_ASSERT_EQUAL_INT(10,result.damage);
result = spellFireball(&testCharacter2);
TEST_ASSERT_EQUAL_INT(13,result.damage);
}
void test_spellHeal(void)

Loading…
Cancel
Save