Browse Source

player can now get gold after a fight

remotes/origin/encIntegration
János 2 years ago
parent
commit
85979f40ae
  1. 9
      src/c/character.c
  2. 6
      src/c/character.h
  3. 5
      src/c/encounter.c
  4. 21
      src/c/encounter.h

9
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)
{

6
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

5
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;
}

21
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);

Loading…
Cancel
Save