-
Notifications
You must be signed in to change notification settings - Fork 0
/
potion.cc
44 lines (35 loc) · 1.03 KB
/
potion.cc
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
#include "potion.h"
#include "player.h"
void BoostDef::effect(std::shared_ptr<Player> pc) {
pc->setDef(pc->getDef() + 5);
}
void BoostAtk::effect(std::shared_ptr<Player> pc) {
pc->setAtk(pc->getAtk() + 5);
}
void RestorHP::effect(std::shared_ptr<Player> pc) {
int newHP = (pc->getHP() + 10) <= pc->getMaxHP() ? (pc->getHP() + 10) : pc->getMaxHP();
pc->setHP(newHP);
}
void PoisonHP::effect(std::shared_ptr<Player> pc) {
if(pc->getRace() == "Elves"){
int newHP = (pc->getHP() + 10) <= pc->getMaxHP() ? (pc->getHP() + 10) : pc->getMaxHP();
pc->setHP(newHP);
} else {
int newHP = (pc->getHP() - 10) >= 0 ? (pc->getHP() - 10) : 0;
pc->setHP(newHP);
}
}
void WoundAtk::effect(std::shared_ptr<Player> pc) {
if(pc->getRace() == "Elves"){
pc->setAtk(pc->getAtk() + 5);
} else {
pc->setAtk(pc->getAtk() - 5 >= 0 ? pc->getAtk() - 5 : 0);
}
}
void WoundDef::effect(std::shared_ptr<Player> pc) {
if(pc->getRace() == "Elves"){
pc->setDef(pc->getDef() + 5);
} else {
pc->setDef(pc->getDef() - 5 >= 0 ? pc->getDef() - 5 : 0);
}
}