From 9c611496b99b76869257948237e392452fa90999 Mon Sep 17 00:00:00 2001 From: Kai Kehres Date: Thu, 26 Jan 2023 16:07:01 +0100 Subject: [PATCH] prod: getter and setter for weaponClass --- src/c/character.c | 10 +++++++++- src/c/character.h | 7 +++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/c/character.c b/src/c/character.c index f5f96ec..86627f8 100644 --- a/src/c/character.c +++ b/src/c/character.c @@ -106,7 +106,7 @@ char* getCharacterName (Character *character) { return character->name; } -int getWaponAttack (Weapon *weapon) { +int getWeaponAttack (Weapon *weapon) { return weapon->attack; } @@ -122,6 +122,14 @@ int setWeaponDurability (Weapon *weapon, int 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) { switch (stat) { diff --git a/src/c/character.h b/src/c/character.h index 3f74401..0c083a1 100644 --- a/src/c/character.h +++ b/src/c/character.h @@ -3,7 +3,7 @@ typedef struct { 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]; } Character; typedef struct { @@ -11,6 +11,9 @@ typedef struct { char name [50]; } Weapon; +enum { + SWORD = 1, BOW = 2, STAFF = 3 +}; enum { 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); -int getWaponAttack (Weapon *weapon); +int getWeaponAttack (Weapon *weapon); void setWeaponAttack (Weapon *weapon, int newAttack);