This repository has been archived by the owner on Aug 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TextedEngine.cpp
102 lines (88 loc) · 2.23 KB
/
TextedEngine.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
/*
TextedEngine.cpp
This file contains the GameEngine
Copyright Entertainmasters 2022 - 2023.
Author(s):
~~~~~~~~~~~~~~~~~~~~~~~~
Copy05 (https://github.com/Copy05)
*/
#include "TextedEngine.h"
TextedEngine::TextedEngine(std::string Friend) {
this->Friend = Friend;
Configuration();
}
TextedEngine::TextedEngine(std::string Player, std::string Friend)
{
this->Player = Player;
this->Friend = Friend;
}
TextedEngine::~TextedEngine()
{
exit(0);
}
void TextedEngine::Configuration()
{
Flush();
std::string PlayerName;
std::cout << "Please Enter your name: ";
std::getline(std::cin, PlayerName);
this->Player = PlayerName;
}
void TextedEngine::YourMessage(std::string str, int interval)
{
SetConsoleTextAttribute(h, 12);
std::cout << Player << ": ";
SetConsoleTextAttribute(h, 15);
std::cout << str << std::endl;
Sleep(interval * 1000);
}
void TextedEngine::FriendsMessage(std::string str, int interval)
{
SetConsoleTextAttribute(h, 9);
std::cout << Friend << ": ";
SetConsoleTextAttribute(h, 15);
std::cout << str << std::endl;
Sleep(interval * 1000);
}
void TextedEngine::PrintChoices(std::string choice1, std::string choice2, std::string choice3)
{
std::cout << "[1] " + choice1 << "\n[2] " + choice2 << "\n[3] " + choice3 << std::endl;
}
void TextedEngine::SimpleChoice(std::string choice1, std::string choice2, std::string choice3, std::string res1, std::string res2, std::string res3, std::string failchoice, std::string failres)
{
int choice;
PrintChoices(choice1, choice2, choice3);
std::cin >> choice;
switch (choice) {
case 1:
YourMessage(choice1, 2);
FriendsMessage(res1, 1);
break;
case 2:
YourMessage(choice2, 2);
FriendsMessage(res2, 1);
break;
case 3:
YourMessage(choice3, 2);
FriendsMessage(res3, 1);
break;
default:
YourMessage(failchoice, 1);
FriendsMessage(failres, 1);
break;
}
Flush();
}
int TextedEngine::ReturnIntChoice(std::string choice1, std::string choice2, std::string choice3, int choiceInt)
{
PrintChoices(choice1, choice2, choice3);
std::cin >> choiceInt;
return choiceInt;
}
int TextedEngine::ReturnIntChoice(std::string choice1, std::string choice2, std::string choice3)
{
int choiceInt;
PrintChoices(choice1, choice2, choice3);
std::cin >> choiceInt;
return choiceInt;
}