summaryrefslogtreecommitdiff
path: root/src/Model/Grid.hpp
blob: 51168a966da9d58f696ebc820e738b9004701309 (plain)
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
#ifndef	DEF_GRID
#define	DEF_GRID

/* Grid.h
 * Defines the class Grid
 * A grid contains a table of cells the game will be set on
 * Creators : krilius, manzerbredes
 * Date : 29/04/2015 */

#include <iostream>
#include <sstream>
#include <vector>
#include <tuple>

class Grid
{
	private:
		//Members
		int m_size;
		std::vector<std::vector<int> > m_grid;
		int m_lastMoveScore;

		//Private methods
		int maxStrLenInGrid();

	public:
		//Constructor and Destructor
		Grid();
		~Grid();

		//Defragment and merge methods
		std::vector<int> rightDefragment(std::vector<int> line);
		std::vector<int> leftDefragment(std::vector<int> line);
		std::vector<int> rightMerge(std::vector<int> line);
		std::vector<int> leftMerge(std::vector<int> line);

		//Swipe methods
		bool swipeRight();
		bool swipeLeft();
		bool swipeUp();
		bool swipeDown();

		//Helpers
		bool isFull();
		bool isOver();
		bool isEmpty(int i, int j);
		std::tuple<int, int> getRandomEmptyCellCoord();
		bool compareLines(std::vector<int> line1, std::vector<int> line2);
		std::vector<int> reverseLine(std::vector<int> line);
		std::string description();

		//Getters and Setters
		bool setCell(std::tuple<int, int> coord, int value);
		bool setCell(int i, int j, int value);
		std::vector<int> getCol(int col);
		void setCol(int col, std::vector<int> colVect);
		int getLastMoveScore();
};


#endif