1 #include "GameMatrix.h"
3 GameMatrix::~GameMatrix(){
9 GameMatrix
* GameMatrix::_instance
=0;
10 int GameMatrix::EmptyPoint
=-1;
12 GameMatrix
* GameMatrix::create(int d1
, int d2
, int numPlayers
)
15 _instance
= new GameMatrix(d1
,d2
,numPlayers
);
20 void GameMatrix::destroy()
28 GameMatrix
* GameMatrix::instance()
33 bool GameMatrix::check(Point p
)
35 int x
= p
.x(); int y
= p
.y(); int z
= p
.z();
36 bool test
=_instance
->elementAt( x
, y
, z
)==EmptyPoint
;
37 if(!test
) cout
<<"test failed\n";//da togliere
41 int& GameMatrix::elementAt(int x
, int y
, int z
)
44 return _matrix
[x
*dim
*dim
+ y
*dim
+ z
];
47 bool GameMatrix::add(Move m
)// fatta senza considerare casi di vittoria
49 Point p
= m
.coord();//mi ritorna l' oggetto Point di Move
52 int x
= p
.x(); int y
= p
.y(); int z
= p
.z() ;
53 elementAt(x
,y
,z
)=m
.playerId();//setto il valora all'id del giocatore
55 _lastRound
.pop_back();
56 _lastRound
.push_front(p
);
63 void GameMatrix::clear(Point p
)//setto a -1 il valore del Point
65 this->elementAt(p
.x(),p
.y(),p
.z()) = EmptyPoint
;
68 int GameMatrix::numberOfPlayers()
70 return _lastRound
.size();//size() metodo const
73 void GameMatrix::setLastRound(QList
<Point
> round
)
78 bool GameMatrix::isFull()
80 return (_freeCounter
==0);