Skip to content

Commit

Permalink
attack and damage
Browse files Browse the repository at this point in the history
  • Loading branch information
jonylu7 committed Mar 23, 2024
1 parent a4d0444 commit ae90c3b
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions include/Unit/AttackAndDamageUnit.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//
// Created by 盧威任 on 3/22/24.
//

#ifndef PRACTICALTOOLSFORSIMPLEDESIGN_ATTACKANDDAMAGEUNIT_HPP
#define PRACTICALTOOLSFORSIMPLEDESIGN_ATTACKANDDAMAGEUNIT_HPP
#include "Avatar.hpp"
class AttackAndDameageUnit {
public:
AttackAndDameageUnit() {}
~AttackAndDameageUnit() {}

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) {

m_HP -= (100 - m_ArmorRate) * (1 / 100) * softattack +
m_ArmorRate * (1 / 100) * hardattack;
}

void ForceAttackUnit(std::shared_ptr<AttackAndDameageUnit> target) {
// check withinrange
// cd time
target->takeDamage(m_SoftAttack, m_HardAttack);
return;
}

private:
int m_HP;
float m_ArmorRate;
int m_SoftAttack;
int m_HardAttack;
float m_AttackRange;
int cd;
};

#endif // PRACTICALTOOLSFORSIMPLEDESIGN_ATTACKANDDAMAGEUNIT_HPP

0 comments on commit ae90c3b

Please sign in to comment.