From 1e32d9cce661675153e48f80feee99d4953b0e95 Mon Sep 17 00:00:00 2001 From: Kai Kehres Date: Sun, 29 Jan 2023 14:11:48 +0100 Subject: [PATCH] prod: created new function checkStatus --- src/c/character.c | 40 ++++++++++++++++++++++++++++++++++++++++ src/c/character.h | 2 ++ src/c/spell.h | 1 - 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/c/character.c b/src/c/character.c index 3f52d2d..9c46cf7 100644 --- a/src/c/character.c +++ b/src/c/character.c @@ -3,6 +3,7 @@ #include #include "character.h" +#include "spell.h" Character character; @@ -294,4 +295,43 @@ Item * getItemInInventory (Character *character, int inventorySlot) { } else { return character->inventory[inventorySlot]; } +} + +int checkStatus (Character *character) { + switch (character->status) + { + case SPELL_EFFECT_NONE: + break; + case SPELL_EFFECT_BURN: + setCharacterStatusDuration(character,getCharacterStatusDuration(character)-1); + if (getCharacterStatusDuration == 0) { + setCharacterStatus(character,SPELL_EFFECT_NONE); + } + return getCharacterStatus(character); + break; + case SPELL_EFFECT_FREEZE: + setCharacterStatusDuration(character,getCharacterStatusDuration(character)-1); + if (getCharacterStatusDuration == 0) { + setCharacterStatus(character,SPELL_EFFECT_NONE); + } + return getCharacterStatus(character); + break; + case SPELL_EFFECT_STUN: + setCharacterStatusDuration(character,getCharacterStatusDuration(character)-1); + if (getCharacterStatusDuration == 0) { + setCharacterStatus(character,SPELL_EFFECT_NONE); + } + return getCharacterStatus(character); + break; + case SPELL_EFFECT_REGENERATION: + setCharacterStatusDuration(character,getCharacterStatusDuration(character)-1); + if (getCharacterStatusDuration == 0) { + setCharacterStatus(character,SPELL_EFFECT_NONE); + } + return getCharacterStatus(character); + break; + default: + return getCharacterStatus(character); + break; + } } \ No newline at end of file diff --git a/src/c/character.h b/src/c/character.h index 62cc4c7..2c8a708 100644 --- a/src/c/character.h +++ b/src/c/character.h @@ -134,4 +134,6 @@ int getCharacterStatus (Character *character); void setCharacterStatusDuration (Character *character, int newStatusDuration); int getCharacterStatusDuration (Character *character); + +int checkStatus (Character *character); #endif \ No newline at end of file diff --git a/src/c/spell.h b/src/c/spell.h index 0c31a09..d9711cd 100644 --- a/src/c/spell.h +++ b/src/c/spell.h @@ -1,7 +1,6 @@ #ifndef SPELL_H #define SPELL_H -#include "character.h" typedef struct { int damage, healing, manaCost, effect, effectDuration;