-
Notifications
You must be signed in to change notification settings - Fork 0
/
MoneyManager.cpp
73 lines (54 loc) · 2.09 KB
/
MoneyManager.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
using namespace std;
#include "MoneyManager.h"
#include<iostream>
#include<fstream>
int MoneyManager::totalMoney = 50;
int MoneyManager::rodPrice = 2;
int MoneyManager::gunPrice = 10;
int MoneyManager::netPrice = 30;
int MoneyManager::lightningPrice = 50;
int MoneyManager::bpPrice = 80;
int MoneyManager::goldfishPrice = 5;
int MoneyManager::seahorsePrice = 8;
int MoneyManager::sharkPrice = 12;
int MoneyManager::octopusPrice = 16;
int MoneyManager::tritonPrice = 20;
int MoneyManager::totalPoints = 0;
bool MoneyManager::hasMoney(Tower * tow) {
int towPrice;
//These next lines check what type of Tower tow is then set the correct price.
if (tow->type=="Gun") towPrice=gunPrice;
else if (tow->type=="Rod") towPrice=rodPrice;
else if (tow->type=="Net") towPrice=netPrice;
else if (tow->type=="BP") towPrice=bpPrice;
else if (tow->type=="Lightning") towPrice=lightningPrice;
cout << "Money: " << totalMoney << ". Buying:" << towPrice << endl;
if (totalMoney >= towPrice) return true;
else return false;
}
void MoneyManager::takeMoney(Tower * tow) {
int towPrice;
//These next lines check what type of Tower tow is then take the amount away
if (tow->type=="Gun") towPrice =gunPrice;
else if (tow->type=="Rod") towPrice =rodPrice;
else if (tow->type=="Net") towPrice =netPrice;
else if (tow->type=="BP") towPrice =bpPrice;
else if (tow->type=="Lightning") towPrice =lightningPrice;
cout << "Money:" << totalMoney << ". Bought:" << towPrice << endl;
MoneyManager::totalMoney -= towPrice;
}
void MoneyManager::addMoney(Enemy * en) {
int enAdd;
//These next lines check what type of Tower tow is then take the amount away
if (en->type=="Octopus") enAdd =octopusPrice;
else if (en->type=="Shark") enAdd =sharkPrice;
else if (en->type=="Goldfish") enAdd =goldfishPrice;
else if (en->type=="Triton") enAdd =tritonPrice;
else if (en->type=="Seahorse") enAdd =seahorsePrice;
cout << "Money:" << totalMoney << ". Earned:" << enAdd << endl;
MoneyManager::totalMoney += enAdd;
MoneyManager::totalPoints += enAdd*10;
}
void MoneyManager::addMoney(int reward) {
totalMoney+=reward;
}