Skip to content

Commit

Permalink
weapon
Browse files Browse the repository at this point in the history
  • Loading branch information
jonylu7 committed Mar 25, 2024
1 parent b8a1991 commit a858d4f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 23 deletions.
16 changes: 3 additions & 13 deletions include/Unit/AttackAndDamageUnit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand All @@ -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
31 changes: 21 additions & 10 deletions include/Unit/Weapon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand All @@ -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

0 comments on commit a858d4f

Please sign in to comment.