-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisenchant.cc
More file actions
79 lines (77 loc) · 2.72 KB
/
Copy pathdisenchant.cc
File metadata and controls
79 lines (77 loc) · 2.72 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
#include <iostream>
#include <sstream>
#include "board.h"
#include "disenchant.h"
#include "enchantment.h"
using namespace std;
Disenchant::Disenchant() : Spell{"Disenchant", 1,
"Destroy the top enchantment on target minion"} {}
void Disenchant::use(shared_ptr<Board> myBoard, int p, string t, shared_ptr<Board> oBoard)
{
std::istringstream iss{t};
int i;
iss >> i;
if (p == myBoard->owner)
{
if (myBoard->minions[i - 1]->enchants.empty())
return;
std::shared_ptr<Minion> aminion = myBoard->minions[i - 1];
std::shared_ptr<Enchantment> enchant = static_pointer_cast<Enchantment>(myBoard->minions[i - 1]->enchants.back());
if (enchant->getName() == "Giant Strength")
{
aminion->setAtk(aminion->getAtk() - 2);
aminion->setDef(aminion->getDef() - 2);
}
else if (enchant->getName() == "Haste")
{
aminion->setModAct(aminion->getModAct() - 1);
aminion->setAct(aminion->getAct() - 1);
}
else if (enchant->getName() == "Enrage")
{
aminion->setAtk(aminion->getAtk() / 2);
aminion->setDef(aminion->getDef() / 2);
}
else if (enchant->getName() == "Magic Fatigue")
{
cerr << "here is good?" << endl;
aminion->setACost(aminion->getACost() - 2);
}
else if (enchant->getName() == "Silence")
{
aminion->hasAbility = true;
}
myBoard->minions[i - 1]->enchants.pop_back();
}
else
{
if (oBoard->minions[i - 1]->enchants.empty())
return;
std::shared_ptr<Minion> otherMinion = oBoard->minions[i - 1];
std::shared_ptr<Enchantment> otherEnchant = static_pointer_cast<Enchantment>(oBoard->minions[i - 1]->enchants.back());
if (otherEnchant->getName() == "Giant Strength")
{
otherMinion->setAtk(otherMinion->getAtk() - 2);
otherMinion->setDef(otherMinion->getDef() - 2);
}
else if (otherEnchant->getName() == "Haste")
{
otherMinion->setModAct(otherMinion->getModAct() - 1);
otherMinion->setAct(otherMinion->getAct() - 1);
}
else if (otherEnchant->getName() == "Enrage")
{
otherMinion->setAtk(otherMinion->getAtk() / 2);
otherMinion->setDef(otherMinion->getDef() / 2);
}
else if (otherEnchant->getName() == "Magic Fatigue")
{
otherMinion->setACost(otherMinion->getACost() - 2);
}
else if (otherEnchant->getName() == "Silence")
{
otherMinion->hasAbility = true;
}
oBoard->minions[i - 1]->enchants.pop_back();
}
}