-
Notifications
You must be signed in to change notification settings - Fork 0
/
BoardGame.cpp
168 lines (143 loc) · 3.55 KB
/
BoardGame.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
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#include<string>
#include<ctime>
#include<cstdlib>
#include "BoardGame.h"
void BoardGame::setupgame(int numofplayers, int playtime, std::string id) {
playerTurn = 1;
numOfPlayers = numofplayers;
playTime = playtime;
ID = id;
srand((unsigned int)time(NULL));
for (int i = 0; i < numofplayers; i++)
{
playerLocs.push_back(1);
Avatars.push_back("Player " + std::to_string(i + 1));
}
}
void BoardGame::setPlayers(int playerNum, std::string name) {
Avatars[playerNum - 1] = name;
}
std::string BoardGame::getPlayers(int playerNum) {
return Avatars[playerNum - 1];
}
std::string BoardGame::getID() {
return ID;
}
int BoardGame::getPlayerLoc(int playerNum) {
return playerLocs[playerNum - 1];
}
int BoardGame::getPlayerTurn()
{
return playerTurn;
}
int BoardGame::rollDice()
{
return rand() % 11 + 2;
}
void BoardGame::moveGamePiece(int playerNum, int resultOfRoll)
{
if (playerNum == playerTurn)
{
playerLocs[playerNum - 1] += resultOfRoll;
}
}
void BoardGame::endTurn(int playerNum)
{
if (playerNum == playerTurn)
{
playerTurn += 1;
if (playerTurn > numOfPlayers)
{
playerTurn = 1;
}
}
}
int BoardGame::getWinner()
{
for (int i = 0; i < numOfPlayers; i++)
{
if (playerLocs[i] >= 45)
{
return i + 1;
}
}
return 0; //this means no winner yet, keep playing game
}
void BoardGame::setupaccount(std::string email, std::string username, std::string password) {
Email = email;
UserName = username;
Password = password;
}
std::string BoardGame::getuseraccount() {
return Account;
}
void BoardGame::populateAvatars(std::vector<std::string>& avatars) {
std::vector<std::string>::iterator iter;
for (iter = avatars.begin(); iter != avatars.end(); iter++) {
Avatars.push_back(*iter);
}
}
void BoardGame::setupavatar(std::string account) {
Account = account;
}
std::string BoardGame::getavatar() {
return Avatars[rand() % Avatars.size()];
}
void BoardGame::populateITpeople(std::vector<std::string>& itnames)
{
std::vector<std::string>::iterator iter;
for (iter = itnames.begin(); iter != itnames.end(); iter++) {
ITnames.push_back(*iter);
}
}
void BoardGame::setmessagebox(std::string account) {
Account = account;
}
std::string BoardGame::getmessagebox() {
return messagebox;
}
void BoardGame::askforhelp(std::string message) {
Message = message;
}
std::string BoardGame::getanswer() {
return answer;
}
std::string BoardGame::optiontogethelper() {
return optiontogethelp;
}
std::string BoardGame::gethelper() {
return ITnames[rand() % ITnames.size()];
}
std::string BoardGame::getoutofmessagebox() {
return optiontoleavemb;
}
void BoardGame::populateRewards(std::vector<std::string>& rewards)
{
std::vector<std::string>::iterator iter;
for (iter = rewards.begin(); iter != rewards.end(); iter++) {
Rewards.push_back(*iter);
}
}
void BoardGame::setupreward(std::string Winner) {
winner = Winner;
}
std::string BoardGame::getreward() {
std::vector<std::string>::iterator iter;
for (iter = Avatars.begin(); iter != Avatars.end(); iter++) {
if (*iter == winner) {
rewards = Rewards[rand() % Rewards.size()];
}
}
return rewards;
}
std::string BoardGame::generateReport() {
return "This is a report of all the moves";
}
std::string BoardGame::generateReport(std::string startDate)
{
return "This is a report from startDate to now";
}
std::string BoardGame::generateReport(std::string startDate, std::string endDate)
{
return "This is a report from startDate to endDate";
}