-
Notifications
You must be signed in to change notification settings - Fork 1
/
NonProperty.cc
141 lines (111 loc) · 3.98 KB
/
NonProperty.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#include "NonProperty.h"
#include <cstdlib>
#include <time.h>
#include <random>
NonProperty::NonProperty (std::string name, int position) : Building(name, position) {}
NonProperty::~NonProperty() {}
void RimCup::giveCup(Player & p) {
p.addCup();
ActiveCup++;
}
void RimCup::receiveCup(Player & p) {
p.removeCup();
ActiveCup--;
}
Tuition::Tuition(std::string name, int position) : NonProperty{name, position} {}
Tuition::~Tuition() {}
void Tuition::accept(Player & p) {
throw TuitionException("Tuition");
}
TimHortons::TimHortons(std::string name, int position) : NonProperty{name, position} {}
TimHortons::~TimHortons() {}
void TimHortons::accept(Player & p) {}
GoToTims::GoToTims(std::string name, int position) : NonProperty{name, position} {}
GoToTims::~GoToTims() {}
void GoToTims::accept(Player & p) {
throw TimHortonsException("Go to Tims");
}
SLC::SLC(std::string name, int position, std::shared_ptr<RimCup> r) : NonProperty{name, position}, rimCup{r} {}
SLC::~SLC(){}
void SLC::accept(Player & p) {
// random numebr generation algorithm
std::random_device r;
std::default_random_engine e1(r());
std::uniform_int_distribution<int> uniform_dist(1, 100);
int a = uniform_dist(e1);
// models the 1% chance of recieving the Roll Up the rim cup
if (a == 44) {
rimCup->giveCup(p);
throw getRimCup("Got a rim cup");
// models the variety of consequence when landing on SLC
} else {
srand (time(NULL));
int num = rand() % 24;
if (num >= 0 && num <= 2) {
throw SLCException("You reached SLC", -3);
} else if (num >= 3 && num <= 6) {
throw SLCException("You reached SLC", -2);
} else if (num >= 7 && num <= 10) {
throw SLCException("You reached SLC", -1);
} else if (num >= 11 && num <= 13) {
throw SLCException("You reached SLC", 1);
} else if (num >= 14 && num <= 17) {
throw SLCException("You reached SLC", 2);
} else if (num >= 18 && num <= 21) {
throw SLCException("You reached SLC", 3);
} else if (num == 22) {
throw SLCException("You reached SLC", 8);
} else {
throw SLCException("You reached SLC", -2);
}
}
}
OSAP::OSAP(std::string name, int position) : NonProperty{name, position} {}
OSAP::~OSAP(){}
void OSAP::accept(Player & p) {
p.addMoney(200);
}
CoopFee::CoopFee(std::string name, int position) : NonProperty{name, position} {}
CoopFee::~CoopFee(){}
void CoopFee::accept(Player & p) {
p.giveMoney(nullptr, 150);
}
Goose::Goose(std::string name, int position) : NonProperty{name, position} {}
Goose::~Goose(){}
void Goose::accept(Player & p) {
// prints message
throw GooseException("Attacked by geese!");
}
NeedlesHall::NeedlesHall(std::string name, int position, std::shared_ptr<RimCup> r) : NonProperty{name, position}, rimCup{r} {}
NeedlesHall::~NeedlesHall(){}
void NeedlesHall::accept(Player & p) {
// random numebr generation algorithm
std::random_device r;
std::default_random_engine e1(r());
std::uniform_int_distribution<int> uniform_dist(1, 100);
int a = uniform_dist(e1);
// models the 1% chance of recieving the Roll Up the rim cup
if (a == 44) {
rimCup->giveCup(p);
throw getRimCup("Got a rim cup");
// models the variety of consequences when landing on Needles Hall
} else {
srand (time(NULL));
int num = rand() % 18;
if (num == 0) {
throw NeedlesHallException("You reached Needles hall", -200);
} else if (num >= 1 && num <= 2) {
throw NeedlesHallException("You reached Needles hall", -100);
} else if (num >= 3 && num <= 5) {
throw NeedlesHallException("You reached Needles hall", -50);
} else if (num >= 6 && num <= 11) {
throw NeedlesHallException("You reached Needles hall", 25);
} else if (num >= 12 && num <= 14) {
throw NeedlesHallException("You reached Needles hall", 50);
} else if (num >= 15 && num <= 16) {
throw NeedlesHallException("You reached Needles hall", 100);
} else {
throw NeedlesHallException("You reached Needles hall", 200);
}
}
}