90 lines
2.4 KiB
C++
90 lines
2.4 KiB
C++
|
#ifndef CREATURELIB_EXECUTINGATTACK_HPP
|
||
|
#define CREATURELIB_EXECUTINGATTACK_HPP
|
||
|
|
||
|
#include <cstdint>
|
||
|
#include <vector>
|
||
|
#include <unordered_map>
|
||
|
#include "Creature.hpp"
|
||
|
|
||
|
namespace CreatureLib::Battling {
|
||
|
class ExecutingAttack {
|
||
|
public:
|
||
|
class HitData{
|
||
|
bool _critical = false;
|
||
|
uint8_t _basePower = 0;
|
||
|
float _effectiveness = 1;
|
||
|
uint32_t _damage = 0;
|
||
|
public:
|
||
|
HitData(){}
|
||
|
|
||
|
inline bool IsCritical() const{ return _critical;}
|
||
|
inline uint8_t GetBasePower() const{ return _basePower;}
|
||
|
inline float GetEffectiveness() const{ return _effectiveness;}
|
||
|
inline uint32_t GetDamage() const{ return _damage;}
|
||
|
|
||
|
inline void SetCritical(bool value) {_critical = value;}
|
||
|
inline void SetBasePower(uint8_t value) { _basePower = value; }
|
||
|
inline void SetEffectiveness(float value) {_effectiveness = value;}
|
||
|
inline void OverrideDamage(uint32_t value) {_damage = value;}
|
||
|
};
|
||
|
|
||
|
class TargetData {
|
||
|
bool _isHit = true;
|
||
|
std::vector<HitData> _hits;
|
||
|
public:
|
||
|
TargetData(uint8_t numberOfHits) : _hits(numberOfHits)
|
||
|
{
|
||
|
for (uint8_t i = 0; i < numberOfHits; i++){
|
||
|
_hits[i] = HitData();
|
||
|
}
|
||
|
}
|
||
|
TargetData(){}
|
||
|
|
||
|
HitData& GetHit(uint8_t index){
|
||
|
return _hits[index];
|
||
|
}
|
||
|
|
||
|
HitData* GetHitPtr(uint8_t index){
|
||
|
return &_hits[index];
|
||
|
}
|
||
|
|
||
|
uint8_t GetNumberOfHits(){
|
||
|
return _hits.size();
|
||
|
}
|
||
|
|
||
|
bool IsHit(){
|
||
|
return _isHit;
|
||
|
}
|
||
|
|
||
|
};
|
||
|
|
||
|
private:
|
||
|
std::unordered_map<Creature*, TargetData> _targets;
|
||
|
Creature* _user;
|
||
|
LearnedAttack* _attack;
|
||
|
public:
|
||
|
|
||
|
TargetData& GetAttackDataForTarget(Creature* creature){
|
||
|
return _targets[creature];
|
||
|
}
|
||
|
|
||
|
bool IsCreatureTarget(Creature* creature){
|
||
|
return _targets.find(creature) != _targets.end();
|
||
|
}
|
||
|
|
||
|
const std::unordered_map<Creature*, TargetData>& GetTargets(){
|
||
|
return _targets;
|
||
|
}
|
||
|
|
||
|
Creature* GetUser(){
|
||
|
return _user;
|
||
|
}
|
||
|
|
||
|
LearnedAttack* GetAttack(){
|
||
|
return _attack;
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
|
||
|
#endif //CREATURELIB_EXECUTINGATTACK_HPP
|