Browse Source

prod: getter and setter for weaponClass

remotes/origin/thirdcycle
Kai Kehres 2 years ago
parent
commit
9c611496b9
  1. 10
      src/c/character.c
  2. 7
      src/c/character.h

10
src/c/character.c

@ -106,7 +106,7 @@ char* getCharacterName (Character *character) {
return character->name; return character->name;
} }
int getWaponAttack (Weapon *weapon) {
int getWeaponAttack (Weapon *weapon) {
return weapon->attack; return weapon->attack;
} }
@ -122,6 +122,14 @@ int setWeaponDurability (Weapon *weapon, int newDurability) {
weapon->durability = newDurability; weapon->durability = newDurability;
} }
void setWeaponClass (Character* character, int weaponClass) {
character->weapon = weaponClass;
}
int getWeaponClass (Character* character) {
return character->weapon;
}
void increaseStat (Character *character, int stat, int amount) { void increaseStat (Character *character, int stat, int amount) {
switch (stat) switch (stat)
{ {

7
src/c/character.h

@ -3,7 +3,7 @@
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,items[10];
int attack,armor,maxHealthPoints,gold,items[10],weapon;
char name [50]; char name [50];
} Character; } Character;
typedef struct { typedef struct {
@ -11,6 +11,9 @@ typedef struct {
char name [50]; char name [50];
} Weapon; } Weapon;
enum {
SWORD = 1, BOW = 2, STAFF = 3
};
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
}; };
@ -69,7 +72,7 @@ void setCharacterName (Character *character, char newName[]);
char* getCharacterName (Character *character); char* getCharacterName (Character *character);
int getWaponAttack (Weapon *weapon);
int getWeaponAttack (Weapon *weapon);
void setWeaponAttack (Weapon *weapon, int newAttack); void setWeaponAttack (Weapon *weapon, int newAttack);

Loading…
Cancel
Save