-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathUtils.h
93 lines (87 loc) · 2.61 KB
/
Utils.h
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
#pragma once
#include <set>
#include <iterator>
#include "StepSegment.h"
#include <string>
#include <iostream>
enum class BoardSymbols {
END_POINT = 'E',
LEGEND = '&',
BIG_SHIP = '#',
SMALL_SHIP = '@',
BLANK = ' ',
WALL = 'W',
HORIZONTAL_GHOST = '$',
VERTICAL_GHOST = '!',
WANDERING_GHOST = '%',
};
enum class GhostsTypes {
HORIZONTAL_GHOST_TYPE = 'H',
VERTICAL_GHOST_TYPE = 'V',
WANDERING_GHOST_TYPE = 'W',
};
enum class PrintPoints {
MESSAGE_X = 40,
MESSAGE_Y = 10,
ACTIVE_SHIP_X = 13,
TIMER_X = 34, LIVES_X = 50,
SCREEN_X = 65
};
enum class GameMode {
REGULAR = 0,
SAVE = 1,
LOAD = 2,
SILENT = 3
};
struct Keys {
constexpr static char ESC = 27;
constexpr static char FINISH_FILE = '*';
constexpr static char Up = 'w';
constexpr static char Right = 'd';
constexpr static char Down = 'x';
constexpr static char Left = 'a';
constexpr static char BigShip = 'b';
constexpr static char SmallShip = 's';
constexpr static char StartNewGame = '1';
constexpr static char PlayFirstScreen = '1';
constexpr static char PlaySpecificScreen = '2';
constexpr static char Instructions = '8';
constexpr static char Exit = '9';
constexpr static char Yes = 'y';
constexpr static char No = 'n';
};
// get x and y and set the cursor at this point on the screen
void gotoxy(int x, int y);
// Clearing the screen
void clrscr();
// Hiding the cursor from the screen
void hide_cursor();
// Printing the main menu
void printMainMenu(char& userChoice);
// Presnting the game instrucions and asks the user if he wants to play in color
bool presentInstructions();
// Printing winning message
void printWinMessage(bool finishLastScreen);
// Printing losing message
void printLoseMessage(const char* deathReason);
// Printing an exit message
void printExitMessage();
// Print a message to screen when the player entered invalid input to the cmd
void printInvalidCmdInput();
// Print error due to an incompatibility between the saved files to the running game
void printGameLoadError();
// return true if the parameter exists in set
bool isExistInSet(std::set<int> setToCheck, int num);
// get the common indexes that exist in both sets
std::set<int> getIndexesInBothSets(std::set<int> set1, std::set<int> set2);
// get set1 minus set2
std::set<int> reduceSets(std::set<int> set1, std::set<int> set2);
// Checks if arr has ch in it
bool isArrayIncludesChar(char* arr, int size, char ch);
// Returns random number in range
int getRandomInRange(int min, int max);
StepSegment readSegment(std::fstream& stepsFile);
std::vector<int> readGhosts(std::fstream& stepsFile);
void printGameResultError(std::string message);
void printPassTest();
void printFailTest();