-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMenu.h
132 lines (127 loc) · 4.65 KB
/
Menu.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
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
#ifndef _MENU_H
#define _MENU_H
#include "io_utils.h"
#include "MissionBank.h"
#include <string>
#pragma once
using namespace std;
enum { EASY = '1', HARD = '2', EXTREME = '3' };
enum { INSTRUCTIONS = '1', START='2', EXIT_START = '9' };
enum { EXIT_MID = '1', MAIN_MENU='2', RESUME='3', RESTART_MISSION='4', NEW_MISSION='5', RESTART_GAME='6', REWIND='7', ESC = 27 };
enum {Plus=0,Minus,Mult,Div};
class TheSnakesGame;
//class Mission;
class MissionBank;
class Menu {
TheSnakesGame *game;
MissionBank **m;
Color txtColor=WHITE;
char screen[5][82] = {
// 10 20 30 40 50 60 70
//01234567890123456789012345678901234567890123456789012345678901234567890123456789
"--------------------------------------------------------------------------------",// 0
"| SCORE | MAG |",// 1
"| SNAKE 1: | 5 |",// 2
"| SNAKE 2: | 5 |",// 3
"--------------------------------------------------------------------------------",// 4
};
char *startMenu[3] = {
"(1) Instructions",
"(2) Start",
"(9) Exit",
}; //string instructions
char *level[3] = {
"(1) Easy",
"(2) Hard",
"(3) Extreme",
}; //string levels
char *inGameMenu[7] = {
"(1) Exit",
"(2) Main Menu",
"(3) Resume",
"(4) Restart Mission",
"(5) New Mission",
"(6) Restart Game",
"(7) Replay last"
}; //menu items
char *missions[8] = {
"Look for: Prime number",
"Look for: Number divisible by 4",
"Look for: Product of 7",
"Look for: Squared Integer",
"Look for: Divided by 7 remainder is 3",
"Look for the number 13^2",
"Look for: Palindrome number",
}; // string missions
char *missionsBank[8] = {
}; // string missions
char *instructions = {
"Two snakes battling over mathematical superiority.\nControl the greed $ snake with 'wxad' shoot by 'z',\nthe more calculated # snake with 'ijkl' shoot by 'n'.\nThe snake have each mission 5 bullets,\nIf one of the bullets hit the other snake, he gets another bullet,\nBullets hitting the numbers conceal them, \nComplete missions to score points and eventually win.\nBeware, wrong solutions will result in the other players point.\nThe first to get to 12 points win the Game!\nGood luck and may Sir Isaac Newton be with you!"
}; //humoristic instructions
char *snakeWonMission[2] = {
"Snake 1 won this round",
"Snake 2 won this round",
};
char *Num60Menu[2] = {
"There is no correct number ,good try!!!",
"The yellow numbers were possible answers,try better",
};
char *REP[2] = {
"Starting next mission!!!",
"Good Luck !! ",
};
char *victoryMenu[2] = {
"congratulation:) snake 1 won the game!!!",
"congratulation:) snake 2 won the game!!!",
};
public:
Menu(TheSnakesGame *_game, MissionBank **_m) : game(_game) ,m(_m){}
void setG(TheSnakesGame *_game)
{
game = _game;
}
void print(Color c);
void setColor(Color c) {
txtColor = c;
}
void edit(int x, int y, char *str);//edit the menu
void clear();//clear everytthing within the menu
void newMission(int numMission, bool needUpdate = true);//print the new mission in the menu
void displayStartMenu();
void displayInstructions() {
gotoxy(0, 5);
cout << instructions;
displayStartMenu();
}
void wait2Secs();
void eraseInstructions();
int displayIngameMenu(bool finishMission = false);//print the menu options
void displayWinningMenu(int num);//display the snake that won the mission
void displayVictoryMenu(int num);//display the snake that won the game
void displayNumMenu(bool num);//display all the numbers that are correct answers mark
void updateScoreBoard(int score1, int score2);//manage the score board - same as the snakes length
//self explanatory function names
char* castingOP(int op);// 0='+' , 1='-' ,2='*' , 3='/'
char* makeString(char* s1, char* s2, char* s3, char* s4, char* s5, char* s6);//make the mission string that need to display on the screen
void mathExe();//7 -
char* getM7()
{
return missions[7];
}
void PickNums(int &place, int nums[], char* operator1, char * operator2);//get random numbers and random operators
bool CheckValidation(int nums[], int place, char* operator1, char* operator2);//check if there is a correct answer in the range(1-169) to the random mission
void setMission(int i)
{
m[i]->makeValidExe();
missionsBank[i] = m[i]->getMission();
}
void setBank(MissionBank ** _m)
{
m = _m;
}
auto getMenu() {
return screen;
}
void Menu::pickDifficulty();
};
#endif