-
Notifications
You must be signed in to change notification settings - Fork 0
/
grid.h
61 lines (49 loc) · 1.77 KB
/
grid.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
#ifndef _GRID_H_
#define _GRID_H_
#include <vector>
#include <iostream>
#include <memory>
#include "type.h"
#include "cell.h"
#include "blockholder.h"
#include "hintgenerator.h"
#include "textdisplay.h"
#include "graphicsdisplay.h"
#include "score.h"
class Grid : public std::enable_shared_from_this<Grid> {
// the game board
std::vector<std::vector <Cell>> board;
// other classes inside of grid, forward declaration
BlockHolder theHolder;
TextDisplay td;
ScoreCounter score;
std::unique_ptr <GraphicsDisplay> gd = nullptr;
// fields that help to run the program
bool showHint = false; // determine if the hint should be show
bool rowCleared = false; // determine if the row has be cleared
Level difficultyLevel = Level::lvl0; // determine current difficult level
std::string defaultLoadPath = "sequence.txt"; // the file of blocks for lvl0
// private methods
void eliminateRow();
void updateBoard();
public:
Grid(Level d = Level::lvl0);
void init(std::string defaultPath = "sequence.txt", Level level = Level::lvl0);
Block & getNextBlock();
Block & getCurrentBlock();
void setupGraphic();
void update(); // update() the board (may eliminate lines)
//void updateBoard();
void clear(); // clear() clear the board
void hint(); // hint() give the best solution of current block
Block getHint();
bool gameOver(); // gameOver() determine if the game is over
void changeLevel(int num);
void mutate(Move cmd, const int num = 1);
void changeShape(Shape s);
std::shared_ptr<Difficulty> getDifficulty();
void setLoadPath(std::string path);
std::string getDefaultLoadPath();
friend std::ostream &operator<<(std::ostream &out, Grid &g);
};
#endif /* grid_hpp */