-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMosaic.cpp
76 lines (67 loc) · 1.81 KB
/
Mosaic.cpp
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
#include "Mosaic.h"
Mosaic::Mosaic(){
initMosaicPattern();
}
Mosaic::~Mosaic(){
for(int i=0; i<5; i++){
for(int j=0; j<5; j++){
delete mosaicArray[i][j];
}
}
}
Tile*** Mosaic::getMosaic(){
return mosaicArray;
}
void Mosaic::setMosaicTile(int row, int column, Colour colour){
mosaicArray[row][column]->setColour(colour);
}
//displays the mosiac, this is controlled by the player class now but is kept in due to it may be
//needed later on in enhancements.
void Mosaic::displayMosaic(){
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < 5; j++)
{
if(islower(mosaicArray[i][j]->getColour()))
{
mosaicArray[i][j]->setColour(NO_TILE);
}
}
}
}
//creates the mosiac according to the games pattern, used to guide the tile to the right position on the mosaic.
void Mosaic::initMosaicPattern(){
std::string pattern = "byrullbyruulbyrrulbyyrulb";
int counter = 0;
for (int i = 0; i < 5; i++){
this->mosaicArray[i] = new Tile*[5];
for(int j = 0; j<5; j++){
this->mosaicArray[i][j] = new Tile(pattern[counter]);
counter++;
}
}
}
bool Mosaic::hasFullRow(){
bool full = false;
for(int row = 0; row < 5; row++){
int count = 0;
for(int column = 0; column<5; column++){
if(isupper(mosaicArray[row][column]->getColour())){
count++;
}
if (count == 4){
full = true;
}
}
}
return full;
}
bool Mosaic::checkRowForTile(int row, Colour colourToCheck){
bool found = false;
for(int column = 0; column<5; column++){
if(mosaicArray[row-1][column]->getColour() == colourToCheck){
found = true;
}
}
return found;
}