diff --git a/include/Unit/AttackAndDamageUnit.hpp b/include/Unit/AttackAndDamageUnit.hpp index 8bf82e99..295b9a04 100644 --- a/include/Unit/AttackAndDamageUnit.hpp +++ b/include/Unit/AttackAndDamageUnit.hpp @@ -4,21 +4,15 @@ #ifndef PRACTICALTOOLSFORSIMPLEDESIGN_ATTACKANDDAMAGEUNIT_HPP #define PRACTICALTOOLSFORSIMPLEDESIGN_ATTACKANDDAMAGEUNIT_HPP - +#include "Weapon.hpp" class AttackAndDamageUnit { public: AttackAndDamageUnit() {} virtual ~AttackAndDamageUnit() {} int getHP() { return m_HP; } - int getArmorRate() { return m_ArmorRate; } - int getSoftAttack() { return m_SoftAttack; } - int getHardAttack() { return m_HardAttack; } void setHP(int hp) { m_HP = hp; } - void setArmorRate(int armor) { m_ArmorRate = armor; } - void setSoftAttack(int softattack) { m_SoftAttack = softattack; } - void setHardAttack(int hardattack) { m_SoftAttack = hardattack; } void takeDamage(int softattack, int hardattack) { @@ -30,18 +24,14 @@ class AttackAndDamageUnit { // check withinrange // cd time - target->takeDamage(m_SoftAttack, m_HardAttack); + target->takeDamage(m_Weapon.getSoftAttack(), m_Weapon.getHardAttack()); return; } private: int m_HP; + Weapon m_Weapon; float m_ArmorRate; - int m_SoftAttack; - int m_HardAttack; - float m_AttackRange; - - float cd; // count as seconds }; #endif // PRACTICALTOOLSFORSIMPLEDESIGN_ATTACKANDDAMAGEUNIT_HPP diff --git a/include/Unit/Weapon.hpp b/include/Unit/Weapon.hpp index 5b1baf13..0878f49f 100644 --- a/include/Unit/Weapon.hpp +++ b/include/Unit/Weapon.hpp @@ -7,26 +7,35 @@ enum class WeaponType { COLT_45, M16, + Fireball, + Art_75mm, + Art_90mm, + Art_105mm, + Art_120mm, + Nuke, + Grenade }; class Weapon { public: Weapon() {} + Weapon(float firerate, float firerange, float softattack, float hardattack, + WeaponType weapon) {} ~Weapon() {} // Getter and setter methods for m_fireRate - static float getFireRate() { return m_fireRate; } + static float getFireRate() { return m_FireRate; } - static void setFireRate(float fireRate) { m_fireRate = fireRate; } + static void setFireRate(float fireRate) { m_FireRate = fireRate; } // Getter and setter methods for m_fireRange - static float getFireRange() { return m_fireRange; } + static float getFireRange() { return m_FireRange; } - static void setFireRange(float fireRange) { m_fireRange = fireRange; } + static void setFireRange(float fireRange) { m_FireRange = fireRange; } - // Getter and setter methods for m_softAttack - static float getSoftAttack() { return m_softAttack; } + // Getter and setter methods for m_SoftAttack + static float getSoftAttack() { return m_SoftAttack; } - static void setSoftAttack(float softAttack) { m_softAttack = softAttack; } + static void setSoftAttack(float softAttack) { m_SoftAttack = softAttack; } // Getter and setter methods for m_HardAttack static float getHardAttack() { return m_HardAttack; } @@ -39,11 +48,13 @@ class Weapon { void setType(WeaponType type) { m_Type = type; } private: - static float m_fireRate; - static float m_fireRange; - static float m_softAttack; + static float m_FireRate; + static float m_FireRange; + static float m_SoftAttack; static float m_HardAttack; WeaponType m_Type; }; +const Weapon COLT_45(180, 5.75, 100, 100, WeaponType::COLT_45); + #endif // PRACTICALTOOLSFORSIMPLEDESIGN_WEAPON_HPP