-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCharacter.hpp
More file actions
102 lines (83 loc) · 2.83 KB
/
Character.hpp
File metadata and controls
102 lines (83 loc) · 2.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#pragma once
#include <string>
#include <vector>
#include <memory>
#include "StatBlock.hpp"
#include "StatType.hpp"
#include "Resource.hpp"
// Forward declarations
class Battle;
class Skill;
class StatusEffect;
class Buff;
class Party;
enum class StatType;
enum class TickTiming;
class Character : public std::enable_shared_from_this<Character> {
private:
std::string name;
int level;
StatBlock baseStats;
int hp;
Resource mana;
int weight;
int maxWeight;
bool defending;
std::vector<std::shared_ptr<Skill>> skills;
std::vector<std::shared_ptr<StatusEffect>> statuses;
std::vector<std::shared_ptr<Buff>> buffs;
Party* ownerParty;
public:
Character(std::string charName, int charLevel, StatBlock stats,
int startWeight = 0, int weightLimit = 100);
virtual ~Character() = default;
// Getters (const for read-only access - encapsulation)
const std::string& getName() const;
int getHP() const;
int getMaxHP() const;
int getLevel() const;
int getWeight() const;
int getMaxWeight() const;
int getMana() const;
int getMaxMana() const;
bool isDefending() const;
Party* getOwnerParty() const;
const std::vector<std::shared_ptr<Skill>>& getSkills() const;
const StatBlock& getBaseStats() const;
bool isAlive() const;
bool isOverencumbered() const;
// Setters (validation - encapsulation)
void setOwnerParty(Party* party);
void setDefending(bool def);
void setLevel(int lvl);
void addWeight(int amount);
void removeWeight(int amount);
void increaseAttack(int amount);
// Core operations (abstraction)
void takeDamage(int amount);
void heal(int amount);
void consumeMana(int amount);
void restoreMana(int amount);
void addSkill(std::shared_ptr<Skill> s);
void removeSkill(const std::shared_ptr<Skill>& s);
void applyStatus(Battle& battle, std::shared_ptr<StatusEffect> status);
void applyBuff(Battle& battle, std::shared_ptr<Buff> buff);
void tickStatuses(Battle& battle, TickTiming when);
void tickBuffs(Battle& battle);
void tickCooldowns();
bool canAct() const;
void checkOverencumbered();
// Stat computation (base + buffs + status mods) - abstraction
int getFinalStat(StatType type) const;
// Calculate modified attack with buffs
int getModifiedAttack() const;
// Calculate modified defense with buffs
int getModifiedDefense() const;
// Apply nerf effect (percentage health reduction)
void applyNerf(int percentage, Battle& battle);
// Pure virtual - different behavior for player/opponent characters (polymorphism)
virtual void onTurnStart(Battle& battle) = 0;
virtual void onTurnEnd(Battle& battle) = 0;
// Additional virtual methods
virtual bool isPlayerControlled() const = 0;
};