-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathminion.cc
103 lines (75 loc) · 1.94 KB
/
minion.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
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
103
#include "minion.h"
#include <string>
#include "player.h"
#include <iostream>
using namespace std;
Minion::Minion(string name, string type, string des, int cost, Player* owner, int Attack, int defense, int abCost): Card{name,type,des,cost,owner},Attack{Attack}, defense{defense}, originalAtk{Attack}, originalDef{defense}, abCost{abCost} {}
Minion::~Minion() {}
int Minion::getAttack() const { return Attack; }
void Minion::setAttack(int i) { Attack = i; }
void Minion::attack(shared_ptr<Card> c) {
if (actionpts > 0) {
c->beAttacked(Attack);
this->beAttacked(c->getAttack());
--actionpts;
} else {
cout << "Not enought Action Pts" << endl;
}
}
void Minion::attack(Player *p) {
if (actionpts > 0) {
p->beAttacked(Attack);
--actionpts;
} else {
cout << "Not enought Action Pts" << endl;
}
}
void Minion::beAttacked(int i) {
defense -= i;
if (defense <= 0) {
owner->goToGrave(shared_from_this());
}
}
int Minion::getDefence() const { return defense; }
void Minion::inspect() {}
int Minion::getRitualCharge()const {}
void Minion::setRitualCharge(int i) {}
void Minion::popEnchant() {
int size = buffs.size() - 1;
auto m = dynamic_pointer_cast<Enchantment>(buffs[size]);
m -> deactivate(shared_from_this());
buffs.pop_back();
}
void Minion::setDefence(int i) { defense = i; }
void Minion::addEnchant(shared_ptr<Card> target) {
buffs.emplace_back(target);
auto m = dynamic_pointer_cast<Enchantment>(target);
m->activate(shared_from_this());
}
int Minion::getRitualCost()
{
return 0;
}
vector<shared_ptr<Card>> Minion::getEnchants() { return buffs; }
int Minion::getAbCost() { return abCost; }
void Minion::setActPts(int i)
{
maxactpts = i;
}
void Minion::incActPts() {
++actionpts;
}
int Minion::getActPts() const {
return actionpts;
}
int Minion::getMaxActPts() const {
return maxactpts;
}
void Minion::silence()
{
isSilence = true;
}
void Minion::setAbCost(int i)
{
abCost = i;
}