From b5236dad9c523c34d1b2a022e3e6aed0b9536c6a Mon Sep 17 00:00:00 2001 From: Kai Kehres Date: Thu, 26 Jan 2023 15:57:12 +0100 Subject: [PATCH] prod: created struct weapon and getter setter for attack and Durability --- src/c/character.c | 16 ++++++++++++++++ src/c/character.h | 14 +++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/c/character.c b/src/c/character.c index 02254ec..f5f96ec 100644 --- a/src/c/character.c +++ b/src/c/character.c @@ -106,6 +106,22 @@ char* getCharacterName (Character *character) { 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) { switch (stat) { diff --git a/src/c/character.h b/src/c/character.h index d50b076..3f74401 100644 --- a/src/c/character.h +++ b/src/c/character.h @@ -3,9 +3,13 @@ typedef struct { int strength,dexterity,intelligence,healthPoints,manaPoints,level,exp,maxExp; - int attack,armor,maxHealthPoints,gold; + int attack,armor,maxHealthPoints,gold,items[10]; char name [50]; } Character; +typedef struct { + int attack,durability; + char name [50]; +} Weapon; enum { 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); +int getWaponAttack (Weapon *weapon); + +void setWeaponAttack (Weapon *weapon, int newAttack); + +int getWeaponDurability (Weapon *weapon); + +int setWeaponDurability (Weapon *weapon, int newDurability); + #endif \ No newline at end of file