-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathminion.cc
67 lines (56 loc) · 2.6 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
#include "card.h"
#include "minion.h"
#include <string>
#include <iostream>
using namespace std;
Minion::Minion(string name, int cost, int attack, int defense) : Card{name, cost, attack, defense}, enchantment{nullptr} {}
Minion::Minion(string name, int cost, int attack, int defense, string ability_txt) : Card{name, cost, attack, defense, ability_txt, 0}, enchantment{nullptr} {}
Minion::Minion(string name, int cost, int attack, int defense, string ability_txt, int ability_cost) : Card{name, cost, attack, defense, ability_txt, ability_cost}, enchantment{nullptr} {}
Minion::Minion(string name, int cost, int attack, int defense, string ability_txt, vector<string> triggers) : Card{name, cost, attack, defense, ability_txt, triggers}, enchantment{nullptr} {}
Minion::Minion(string name, int cost, int attack, int defense, string ability_txt, int ability_cost, vector<string> ability) : Card{name, cost, attack, defense, ability_txt, ability_cost}, ability{ability}, enchantment{nullptr} {}
Minion::Minion(string name, int cost, int attack, int defense, string ability_txt, vector<string> triggers, vector<string> ability) : Card{name, cost, attack, defense, ability_txt, triggers}, ability{ability}, enchantment{nullptr} {}
int Minion::getStrength() {
if (!enchantment) return attack;
return enchantment->change_strength(attack);
}
int Minion::getDefense() {
if (!enchantment) return defense;
return enchantment->change_defense(defense);
}
int Minion::get_actions() {
if (!enchantment) return actions;
return enchantment->change_actions(actions);
}
int Minion::getAbilityCost() {
if (!enchantment) return ability_cost;
return enchantment->change_ability_cost(ability_cost);
}
string Minion::getType() { return "Minion"; }
card_template_t Minion::display() {
if (ability_txt == "") {
return display_minion_no_ability(getName(), getCost(), getStrength(), getDefense());
} else if (ability_cost == 0) {
return display_minion_triggered_ability(getName(), getCost(), getStrength(), getDefense(), ability_txt);
} else {
return display_minion_activated_ability(getName(), getCost(), getStrength(), getDefense(), ability_cost, ability_txt);
}
}
vector<string> Minion::ability_type() {
if (ability.size() > 0) return ability;
else return {"None"};
}
void Minion::setEnchantment(Enchantment *e) {
if (!enchantment) enchantment = e;
else enchantment->setEnchantment(e);
}
Enchantment *Minion::getEnchantment() {
if (!enchantment) return nullptr;
else return enchantment;
}
bool Minion::removeEnchantment() {
if (!enchantment) return false;
if (!enchantment->removeEnchantment()) {
enchantment = nullptr;
}
return true;
}