-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbraincurses.h
55 lines (44 loc) · 1.38 KB
/
braincurses.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
/* braincurses.h
* Copyright © 2002, Brian Derr <[email protected]>
*/
#ifndef BRAINCURSES_H
#define BRAINCURSES_H
#include <ncurses.h>
#include <string>
#include <unordered_map>
#include <vector>
#include "code.h"
const int kInputLength = 7;
const std::string kGameName = "BrainCurses";
const std::string kCodeWindow = "code";
const std::string kGuessWindow = "guess";
const std::string kHeaderWindow = "header";
const std::string kInfoWindow = "info";
const std::string kInputWindow = "input";
const std::string kMarkerWindow = "marker";
const std::string kWatermarkWindow = "watermark";
class Braincurses {
public:
Braincurses(int code_length, int guesses);
bool GameOverPlayAgain(bool winner);
bool Initialized() const { return initialized_; };
bool PlayGame();
private:
void CleanUpWindow(WINDOW* window);
WINDOW *CreateWindow(int height, int width, int starty, int startx);
void DisplayCode(bool colored);
void DisplayGuess(int y, std::vector<int> guess);
void DisplayMarkers(int y, std::vector<int> correct);
std::vector<int> GetInput();
void InitializeNcurses();
bool IsWinner(std::vector<int> guess);
bool PlayAgain();
void PrepareBoard();
void WipeBoard();
Code code_;
int guesses_;
bool initialized_;
std::unordered_map<std::string, WINDOW*> windows_;
};
void endwin_handler(void);
#endif // BRAINCURSES_H