From 89a76a1a36a1d23eb58936f7a825e56a42f6702a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1nos?= Date: Wed, 25 Jan 2023 19:46:22 +0100 Subject: [PATCH] player gets exp after combat --- src/c/encounter.c | 8 ++++++++ src/c/encounter.h | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/src/c/encounter.c b/src/c/encounter.c index 54a5067..0f96c8c 100644 --- a/src/c/encounter.c +++ b/src/c/encounter.c @@ -119,6 +119,7 @@ int fight(Character *character, enemy* enemy) } if (playerAlive(getCharacterHealthPoints(character))) { + setCharacterExp(character, getCharacterExp(character) + getEnemyExp(enemy)); return 1; } else @@ -201,4 +202,11 @@ int getEnemyHealPotions(enemy* enemy) void setEnemyHealPotions(enemy* enemy, int newPotions) { enemy->healPotions = newPotions; +} + +int getEnemyExp(enemy* enemy){ + return enemy->exp; +} +void setEnemyExp(enemy* enemy, int newExp){ + enemy->exp = newExp; } \ No newline at end of file diff --git a/src/c/encounter.h b/src/c/encounter.h index e5ca6d2..5e1eef8 100644 --- a/src/c/encounter.h +++ b/src/c/encounter.h @@ -9,6 +9,7 @@ typedef struct enemy{ int armor; int maxHealth; int healPotions; + int exp; } enemy; @@ -42,4 +43,7 @@ int getEnemyDamage(enemy* enemy); int getEnemyHealPotions(enemy* enemy); void setEnemyHealPotions(enemy* enemy, int newPotions); +int getEnemyExp(enemy* enemy); +void setEnemyExp(enemy* enemy, int newExp); + #endif \ No newline at end of file