-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgameroom.cpp
136 lines (114 loc) · 3.66 KB
/
gameroom.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
#include <iostream>
#include <string>
#include <sstream>
#include <fstream>
#include <chrono>
#include <thread>
#include <stdlib.h>
#include "gameroom.h"
#include "introduction.h"
#include "casinowar.h"
#include "horserace.h"
#include "keno.h"
// constructor
Gameroom::Gameroom(){
};
// kicks off gameroom
void Gameroom::run_gameroom()
{
welcome();
}
// brings user back to menu with all game options
void Gameroom::return_to_games_menu()
{
game_options();
}
// generates a slow displaying welcome message
void Gameroom::welcome()
{
system("clear");
int text_display_delay = 1800;
int next_func_delay = 4000;
std::cout << "\n\n\n\n\n\n\n\n\n\n";
std::this_thread::sleep_for(std::chrono::milliseconds(text_display_delay));
std::cout << " WELCOME TO THE GAME FLOOR" << std::endl;
std::this_thread::sleep_for(std::chrono::milliseconds(text_display_delay));
std::cout << " THIS IS WHERE ALL THE GAMES ARE HELD" << std::endl;
std::this_thread::sleep_for(std::chrono::milliseconds(text_display_delay));
std::cout << " HAVE FUN AND RELAX, BUT REMEMBER, THE HOUSE ALWAYS WINS." << std::endl;
std::this_thread::sleep_for(std::chrono::milliseconds(next_func_delay));
game_options();
}
// displays the current games implemented and prompts user to select one
void Gameroom::game_options()
{
system("clear");
bool is_valid_input;
std::string users_input;
Introduction token_access_obj;
int tokens = token_access_obj.get_tokens();
std::cin.clear();
//std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); // Clear the input buffer
do
{
for(int spaces = 0; spaces < 71 - std::to_string(tokens).length(); spaces++){
std::cout << " ";
}
std::cout << "TOKENS: " << tokens << std::endl;
std::cout << "\n\n\n\n\n\n\n";
std::cout << " GAME FLOOR"<< std::endl;
std::cout << "\n";
std::cout << " 1: CASINO WAR" << std::endl;
std::cout << " 2: HORSE RACE"<< std::endl;
std::cout << " 3: KENO"<< std::endl;
std::cout << "\n";
std::cout << " SELECT AN OPTION: ";
std::getline(std::cin, users_input);
is_valid_input = validate_input(users_input);
system("clear");
} while (!is_valid_input);
direct_game_flow(users_input);
}
// validates the users input
bool Gameroom::validate_input(std::string users_input)
{
// clear console
system("clear");
int time = 3000;
// Check if digit is one of the available options
if (users_input == ("1") || users_input == ("2") || users_input == ("3"))
{
return true;
}
else
{
std::cout << "\n\n\n\n\n\n\n\n\n\n\n";
std::cout << " PLEASE ENTER A VALID RESPONSE";
std::cout << "\n";
std::this_thread::sleep_for(std::chrono::milliseconds(time));
return false;
}
}
// directs user to the game of their choice
void Gameroom::direct_game_flow(std::string users_input)
{
int game_one = 1;
int game_two = 2;
int game_three = 3;
int user_converted_input = std::stoi(users_input);
if (user_converted_input == (game_one))
{
CasinoWar casino_war;
casino_war.run_casino_war();
}
else if (user_converted_input == (game_two))
{
HorseRace horse_race;
horse_race.run_horse_race();
}
else if (user_converted_input == game_three)
{
Keno keno;
keno.run_keno();
}
}