initial commit
[COMP345---Clone.git] / Weapon.cpp
blobeee75db3860e426985cbe9e5c1a9deed4c468177
1 //!@file Weapon.cpp
2 //! @brief Implementation of weapon equipment
3 //!
4 //! This class represents the weapon that is equipped or carried by a character
5 //! This class validates the weapon and assigns its stats
6 #include "Weapon.h"
10 //! Default weapon constructor sets stats to 1
11 Weapon::Weapon()
13 atk = 1;
14 dmg = 1;
15 level = 1;
16 setName("weapon");
19 //! Weapon constructor sets stats.
20 //! @param w_atk: the attack to be set
21 //! @param w_dmg the value of damage to be set
22 //! @param w_level the level to be set to
23 Weapon::Weapon(int w_atk, int w_dmg, int w_level)
25 atk = w_atk;
26 dmg = w_dmg;
27 level = w_level;
28 setName("weapon");
31 //! Weapon constructor sets stats based on level.
32 //! @param w_level the level which designates stat values
33 Weapon::Weapon(int w_level)
35 name = "weapon";
36 level = w_level;
37 levelUpEquipment(w_level);
41 Weapon::~Weapon()
45 //! Validates the weapon
46 //! Weapon has an attack attribute that must be between 1 and 5
47 //! Weapon has an damage attribute that must be between 1 and 5
48 bool Weapon::validateEquipment()
50 if (atk < 1 || atk > 5 ||
51 dmg < 1 || dmg > 5)
52 return false;
53 else
54 return true;
57 //! Sets the weapon stats to the given level
58 void Weapon::levelUpEquipment(int w_level)
60 atk = w_level;
61 dmg = w_level;
62 level = w_level;