Browse Source

prod: created struct weapon and getter setter for attack and Durability

remotes/origin/thirdcycle
Kai Kehres 2 years ago
parent
commit
b5236dad9c
  1. 16
      src/c/character.c
  2. 14
      src/c/character.h

16
src/c/character.c

@ -106,6 +106,22 @@ char* getCharacterName (Character *character) {
return character->name; return character->name;
} }
int getWaponAttack (Weapon *weapon) {
return weapon->attack;
}
void setWeaponAttack (Weapon *weapon, int newAttack) {
weapon->attack = newAttack;
}
int getWeaponDurability (Weapon *weapon) {
return weapon->durability;
}
int setWeaponDurability (Weapon *weapon, int newDurability) {
weapon->durability = newDurability;
}
void increaseStat (Character *character, int stat, int amount) { void increaseStat (Character *character, int stat, int amount) {
switch (stat) switch (stat)
{ {

14
src/c/character.h

@ -3,9 +3,13 @@
typedef struct { typedef struct {
int strength,dexterity,intelligence,healthPoints,manaPoints,level,exp,maxExp; int strength,dexterity,intelligence,healthPoints,manaPoints,level,exp,maxExp;
int attack,armor,maxHealthPoints,gold;
int attack,armor,maxHealthPoints,gold,items[10];
char name [50]; char name [50];
} Character; } Character;
typedef struct {
int attack,durability;
char name [50];
} Weapon;
enum { enum {
STRENGTH = 1, DEXTERITY = 2, INTELLIGENCE = 3, HEALTHPOINTS = 4, MANAPOINTS = 5, LEVEL = 6, EXP = 7, MAXEXP = 8 STRENGTH = 1, DEXTERITY = 2, INTELLIGENCE = 3, HEALTHPOINTS = 4, MANAPOINTS = 5, LEVEL = 6, EXP = 7, MAXEXP = 8
@ -65,4 +69,12 @@ void setCharacterName (Character *character, char newName[]);
char* getCharacterName (Character *character); char* getCharacterName (Character *character);
int getWaponAttack (Weapon *weapon);
void setWeaponAttack (Weapon *weapon, int newAttack);
int getWeaponDurability (Weapon *weapon);
int setWeaponDurability (Weapon *weapon, int newDurability);
#endif #endif
Loading…
Cancel
Save