Closed jamesdonkin closed 2 weeks ago
Hey @User1035 have a read of the 'files changed' DIFF and see what I've done - you maybe haven't encountered Classes much, or object orientation - have a look then I can talk you through tomorrow before merging the pull request?
It basically does the same as before (with a new spear) but with a cleaner structure.
Extracted the weapon and character logic into separate files and classes and added a spear weapon.
New 'Weapons' module - this contains a class called Weapon which has the basic weapon data and functionality - durability, damage, and methods to reduce or improve these, and also methods to get the weapon name, and a longer exciting description for use when entering the dungeon.
New 'Character' module - this contains a very basic character info - current health, and the weapon being used. It has methods to injure (reduce health) or heal (adds health).
Changed the main game file to remove the various variables tracking health, weapon_dur, weapon_dam, and instead use an instance of the class Character with a Weapon.
Also replaced the many checks of health <=0 or > 0 with methods 'is_alive' and 'is_dead' to make it more readable.