-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |