-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInterface.hpp
222 lines (187 loc) · 7.75 KB
/
Interface.hpp
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
//------------------------------------------------------------------------------
// Interface.h
//
// Authors: Tutors
//
//------------------------------------------------------------------------------
//
#ifndef INCLUDE_INTERFACE_H
#define INCLUDE_INTERFACE_H
#pragma once
#include <string>
#include <vector>
#include <map>
#include <functional>
//------------------------------------------------------------------------------
namespace Oop
{
class Player;
class CreatureCard;
//----------------------------------------------------------------------------
// Interface Class
// This class provides an API to either use the Web-GUI or
// the command-line-interface
//
class Interface
{
private:
const static std::string MAP_GAME;
const static std::string MAP_HAND;
const static std::string MAP_SEPERATOR;
const static std::string MIDFIELD_SEPERATOR;
const static std::string CARD_SEPERATOR;
const static std::string PLAYER_PADDING;
const static std::vector<std::string> CARD_EMTPY;
static void printHandCards(const Oop::Player* player, bool show_hand_cards);
static void printPlayerInfo(const Oop::Player* player);
static void printGamefieldCards(const Oop::Player* player);
static std::string getAsStringWithPad(int value);
public:
//------------------------------------------------------------------------
// Standard constructor
//
Interface();
//------------------------------------------------------------------------
// Destructor
//
virtual ~Interface() noexcept;
//------------------------------------------------------------------------
// Deleted copy constructor
//
Interface(const Interface& original) = delete;
//------------------------------------------------------------------------
// Deleted assignment operator
//
Interface& operator=(const Interface& original) = delete;
//------------------------------------------------------------------------
// Enumeration of all supported output formats
//
enum OutputType {DEBUG, ERROR, WARNING, INFO};
//------------------------------------------------------------------------
// Constants
// "All" strings required for the desired outputs (to minimize typos)
//
// OutputType: ERROR
const static std::string ERROR_WRONG_ARGUMENTS;
const static std::string ERROR_INVALID_CONFIG;
const static std::string ERROR_BAD_ALLOC;
const static std::string ERROR_FRAMEWORK;
// OutputType: WARNING
const static std::string WARNING_INVALID_NAME;
const static std::string WARNING_UNKNOWN_COMMAND;
const static std::string WARNING_WRONG_PARAMETER;
const static std::string WARNING_WRONG_PARAM_COUNT;
const static std::string WARNING_NOT_ENOUGH_MANA;
const static std::string WARNING_EXECUTION_NOT_POSSIBLE;
const static std::string WARNING_SHIELD_MONSTER;
const static std::string WARNING_REBIRTH_UNSUCCESSFUL;
// OutputType: INFO
const static std::string PLAYER_1_NAME;
const static std::string PLAYER_2_NAME;
const static std::vector<std::string> INFO_HELP_MSGS;
const static std::string TARGET_TRAITOR_SPELL;
const static std::string SET_TRAITOR_SPELL;
// command types
const static std::string COMMAND_HELP;
const static std::string COMMAND_ATTACK;
const static std::string COMMAND_SET;
const static std::string COMMAND_CAST;
const static std::string COMMAND_SACRIFICE;
const static std::string COMMAND_STATE;
const static std::string COMMAND_FINISH;
const static std::string COMMAND_QUIT;
// spell cards strings and others
const static std::string INFO_ROUND;
const static std::string INFO_CURRENT_PLAYER;
const static std::string ENDLINE_PART_ONE;
const static std::string ENDLINE_PART_TWO;
const static std::string STRING_HEALER;
const static std::string STRING_REBIRTH;
const static std::string STRING_DRACULA;
const static std::string STRING_RELIEF;
const static std::string STRING_TRAITOR;
// protocol types and there colors
const static std::map<const OutputType, const std::string> PROTOCOL;
const static std::map<const OutputType, const std::string> COLOR_TEXT;
const static std::string COLOR_END;
// fixed values throughout the game
const static int MAX_NAME_LENGTH;
const static int MIN_LETTERS_NAME;
const static int MAX_LETTERS_NAME;
const static int MAX_MANA;
const static int MAX_MANA_GAIN;
const static int MAX_HAND_CARDS;
const static int NUM_OF_BOARD_LINES;
const static int NUM_OF_GAMEFIELD_CARDS = 7;
//------------------------------------------------------------------------
// The in funciton
// Getting the user input from the chosen interface
// Should be used instead of std::cin
// @return std::string one line of input
//
std::string in() const;
//------------------------------------------------------------------------
// The out funciton
// Writes an output to the chosen interface
// Should be used instead of std::cout
// @param type the output type of the message
// @param msg the actual message to print
//
void out(const OutputType type, const std::string msg) const;
//------------------------------------------------------------------------
// The gamefield-out function
// Writes the current gamefield to the chosen Interface
//
// @param the current player
// @param the opponent of the current player
//
void out(const Player* current_player, const Player* opponent_player) const;
//------------------------------------------------------------------------
// The read Player Name function
// Asks the Player to choose a name and reads the following input.
//
// @param bool the player ID (0/1)
//
// @return string containing the name of the player
//
std::string readPlayerName(bool player);
//------------------------------------------------------------------------
// The ask Player function
// Prints the message on the screen without \n at the end and returns the
// input
//
// @return string containing the answer
//
std::string askPlayer(const std::string msg);
//------------------------------------------------------------------------
// The ask Player function
// Prints the message with output type on the screen without \n at the end
// and returns the input
//
// @return string containing the answer
//
std::string askPlayer(const OutputType type, const std::string msg);
//------------------------------------------------------------------------
// The print command prompt function
// Prints the name of the current player as command prompt
//
// @param player_name the name of the current player
//
void printCommandPrompt(const std::string player_name);
//------------------------------------------------------------------------
// The log function
// Writes debug messages to the chosen interface
// (Automatically disabled in RELEASE mode)
// @param msg the debug message to be printed
//
void log(const std::string msg) const;
//------------------------------------------------------------------------
// The error functions
// Prints error messages to the chosen interface.
// Must only be used before ending the game with an error
// @param msg the error message to be printed
//
void error(const std::string msg);
};
}
#endif