-
Notifications
You must be signed in to change notification settings - Fork 1
/
tile.cpp
36 lines (28 loc) · 931 Bytes
/
tile.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
#include "tile.h"
Tile::Tile(const QList<int>& edgeSockets) {
m_edgeSockets = edgeSockets;
socketsPerSide = m_edgeSockets.length() / 4;
}
Tile::Tile(const Tile ©This) : QObject(nullptr) {
m_edgeSockets = copyThis.m_edgeSockets;
socketsPerSide = copyThis.socketsPerSide;
}
bool Tile::checkEdge(const int& side,const QList<int>& otherEdge) {
QList<int> thisEdge = getEdgeSockets(side);
for (int i = 0; i < otherEdge.length(); i++) {
if (thisEdge.at(i) != otherEdge.at(i))
return false;
}
return true;
}
QList<int> Tile::getEdgeSockets(const int& sideIndex) const{
int startIndex = socketsPerSide * sideIndex;
QList<int> edgeSockets = m_edgeSockets.mid(startIndex, socketsPerSide);
// Remove Corners
edgeSockets.pop_front();
edgeSockets.pop_back();
return edgeSockets;
}
int Tile::getCornerSocket(const int& whichOne) const {
return m_edgeSockets.at(whichOne * socketsPerSide);
}