diff --git a/src/c/character.c b/src/c/character.c index 344b0e1..2d1d317 100644 --- a/src/c/character.c +++ b/src/c/character.c @@ -90,6 +90,15 @@ int getCharacterArmor (Character *character){ return character->armor; } +void setCharacterGold (Character *character, int newGold){ + character->gold = newGold; +} + +int getCharacterGold (Character *character){ + return character->gold; +} + + void increaseStat (Character *character, int stat, int amount) { switch (stat) { diff --git a/src/c/character.h b/src/c/character.h index acae866..808c8d0 100644 --- a/src/c/character.h +++ b/src/c/character.h @@ -2,7 +2,7 @@ #define CHARACTER_H typedef struct { - int strength,dexterity,intelligence,healthPoints,manaPoints,level,exp,maxExp,attack,armor,maxHealthPoints; + int strength,dexterity,intelligence,healthPoints,manaPoints,level,exp,maxExp,attack,armor,maxHealthPoints,gold; char name [50]; } Character; @@ -54,5 +54,9 @@ void setCharacterArmor (Character *character, int newArmor); int getCharacterArmor (Character *character); +void setCharacterGold (Character *character, int newGold); + +int getCharacterGold (Character *character); + void levelUp (Character *character); #endif \ No newline at end of file diff --git a/src/c/encounter.c b/src/c/encounter.c index 873d9f7..80559ba 100644 --- a/src/c/encounter.c +++ b/src/c/encounter.c @@ -121,6 +121,7 @@ int fight(Character *character, enemy* enemy) if (playerAlive(getCharacterHealthPoints(character))) { setCharacterExp(character, getCharacterExp(character) + getEnemyExp(enemy)); + setCharacterGold(character, getCharacterGold(character) + getEnemyGold(enemy)); return 1; } else @@ -199,4 +200,8 @@ int getEnemyExp(enemy* enemy){ } void setEnemyExp(enemy* enemy, int newExp){ enemy->exp = newExp; +} + +int getEnemyGold(enemy* enemy){ + return enemy->gold; } \ No newline at end of file diff --git a/src/c/encounter.h b/src/c/encounter.h index 5e1eef8..4a2c1ff 100644 --- a/src/c/encounter.h +++ b/src/c/encounter.h @@ -10,6 +10,7 @@ typedef struct enemy{ int maxHealth; int healPotions; int exp; + int gold; } enemy; @@ -22,23 +23,21 @@ bool enemyChoosesHeal(enemy* enemy); int switchTurns(int currentTurn); int fight(Character *character, enemy* enemy); -//Funktionen die Mathematische Berechnungen durchführen -int map(int x, int in_min, int in_max, int out_min, int out_max); -int randomIntRange(int min, int max); -//Getter/Setter Funktionen -//setEnemyHealth(&enemy, health); -void setEnemyHealth(enemy* enemy, int newhealth); -//setEnemyDamage(&enemy.damage, damage); -void setEnemyDamage(enemy* enemy, int newdamage); -//setEnemyArmor(&enemy.armor, armor); -void setEnemyArmor(enemy* enemy, int newarmor); -//Function to get the value of Data in a struct, needs a pointer to the struct +//Getter/Setter Funktionen int getEnemyMaxHealth(enemy* enemy); + +int getEnemyGold(enemy* enemy); + int getEnemyHealth(enemy* enemy); +void setEnemyHealth(enemy* enemy, int newhealth); + int getEnemyArmor(enemy* enemy); +void setEnemyArmor(enemy* enemy, int newarmor); + int getEnemyDamage(enemy* enemy); +void setEnemyDamage(enemy* enemy, int newdamage); int getEnemyHealPotions(enemy* enemy); void setEnemyHealPotions(enemy* enemy, int newPotions);