-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGreenCard.cpp
74 lines (57 loc) · 2.13 KB
/
GreenCard.cpp
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
//Kanellaki Maria Anna - 1115201400060
//Matanis Panagiotis - 1115201400297
#include <iostream>
#include "GreenCard.hpp"
#include "Follower.hpp"
#include "Item.hpp"
GreenCard::GreenCard(string n, int t) : Card{n, t}
{
name = n;
type = Type(t);
tapped = false;
}
int GreenCard::addBonus(int money, int honour) //if bought adds bonuses and returns new amount of money of player, else returns same amount
{ //casts to follower or item to have access to cards' data
if (type == FOLLOWER)
{
Follower *temp = reinterpret_cast<Follower*>(this);
if (money < temp->getEffectCost())
{
cout << "Not enough money"<<endl;
return money;
}
if (honour < temp->getMinimumHonor())
{
cout << "Not honourable enough"<<endl;
return money;
}
cout << "Do you want to upgrade your card "<< name <<"?" << endl;
cout << "Cost: "<< temp->getEffectCost() <<endl << "Bonus: "<< temp->getEffectBonus()<<endl;
cout <<"Enter y for yes, n for no"<< endl;
string ans;
cin >> ans;
if (ans != "n")
return money;
//add bonuses to card stats
temp->setAttackBonus(temp->getAttackBonus() + temp->getEffectCost());
temp->setDefenseBonus(temp->getDefenseBonus() + temp->getEffectBonus());
return money-temp->getEffectCost();
}
else
{
Item *temp = reinterpret_cast<Item*>(this);
if (money < cost || honour < minimumHonor)
return money;
cout << "Do you want to upgrade your card "<< name <<"?" << endl;
cout << "Cost: "<< temp->getEffectCost() <<endl << "Bonus: "<< temp->getEffectBonus()<<endl;
cout <<"Enter y for yes, n for no"<< endl;
string ans;
cin >> ans;
if (ans != "n")
return money;
//add bonuses to card stats
temp->setAttackBonus(temp->getAttackBonus() + temp->getEffectCost());
temp->setDefenseBonus(temp->getDefenseBonus() + temp->getEffectBonus());
return money-temp->getEffectCost();
}
}