forked from sgtechICT1009/ict1009-team22-2022-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayableCharacter.cpp
More file actions
69 lines (55 loc) · 1.49 KB
/
Copy pathPlayableCharacter.cpp
File metadata and controls
69 lines (55 loc) · 1.49 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
#include "PlayableCharacter.h"
PlayableCharacter::PlayableCharacter() {
}
PlayableCharacter::PlayableCharacter(string name, int maxHealth, int damage, int speed) {
this->name = name;
this->maxHealth = maxHealth;
this->health = maxHealth;
this->damage = damage;
this->speed = speed;
this->initiative = 0;
}
string PlayableCharacter::getName() {
return this->name;
}
int PlayableCharacter::getMaxHealth() {
return this->maxHealth;
}
int PlayableCharacter::getHealth() {
return this->health;
}
void PlayableCharacter::setHealth(int health) {
this->health = health;
}
int PlayableCharacter::getDamage() {
return this->damage;
}
void PlayableCharacter::setDamage(int damage) {
this->damage = damage;
}
int PlayableCharacter::getSpeed() {
return this->speed;
}
void PlayableCharacter::setSpeed(int speed) {
this->speed = speed;
}
int PlayableCharacter::getInitiative() {
return this->initiative;
}
void PlayableCharacter::setInitiative(int speed) {
//this->initiative = rand() % 8 + this->speed;
if (speed == -1) {
this->initiative = 0;
} else {
this->initiative += speed;
if (this->initiative > 100) {
this->initiative = 100;
}
}
}
void PlayableCharacter::attack(PlayableCharacter* pc) {
pc->setHealth(pc->getHealth() - this->damage);
}
void PlayableCharacter::makeDecision(vector<PlayableCharacter*>& ownParty, vector<PlayableCharacter*>& enemyParty) {
this->attack(enemyParty[0]);
}