-
Notifications
You must be signed in to change notification settings - Fork 2
/
quadris_model.h
80 lines (75 loc) · 1.79 KB
/
quadris_model.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
#ifndef _QUADRIS_MODEL_H_
#define _QUADRIS_MODEL_H_
#include <string>
#include <iostream>
#include <fstream>
#include <memory>
#include "block.h"
#include "info.h"
#include "textdisplay.h"
#include "graphicsdisplay.h"
class QuadrisModel {
public:
QuadrisModel(bool, int, std::string, int, bool);
void down(int m);
void right(int m);
void left(int m);
void drop(int m);
void clockwise(int m);
void cclockwise(int m);
void levelUp(int m);
void levelDown(int m);
bool isOver();
bool setSeqFile(std::string);
void setRandom(bool);
bool swapType(BlockType);
void hold();
int getScore();
void getHint();
void automate(int);
void clearHint();
private:
void clearRows();
std::vector<Block> blocks;
std::vector<Info> positions;
int level;
static int high_score;
int score;
int seed;
bool block_random;
bool seed_set;
Block current_block;
BlockType next_block;
Block hint_block;
std::ifstream file_in;
bool lost;
int drops_without_clear;
void nextBlock();
bool canDown();
bool canRight();
bool canLeft();
bool canClock();
bool canCclock();
bool isOpen(int, int);
bool canMove(int, int);
void updatePositions();
void updateScore(int);
void clearBlocks();
void drawLegend();
double getRandom();
int blockColour(BlockType);
vector<vector<int>> blockPosns(BlockType);
BlockType held_block;
std::shared_ptr<TextDisplay> td;
std::shared_ptr<GraphicsDisplay> gd;
int totHeight(vector<vector<int>>);
int holes(vector<vector<int>>);
int bumpiness(vector<vector<int>>);
int completeRows(vector<vector<int>>);
int colHeight(vector<vector<int>>, int);
Block suggestedBlock();
bool hold_on;
friend std::ostream &operator<<(std::ostream &out, const QuadrisModel &model);
};
std::ostream &printBlock(std::ostream&, BlockType);
#endif