2016-03-08 22:39:21 +00:00
|
|
|
// #include "Piece.h"
|
2016-03-08 20:06:36 +00:00
|
|
|
|
2016-03-09 14:44:38 +00:00
|
|
|
Piece::Piece(PIECE_TYPE t, int x, int y) : _t(t), _x(x), _y(y), _player(true){
|
2016-03-06 21:51:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// GETTERS
|
|
|
|
PIECE_TYPE Piece::gett() const{ return _t; }
|
|
|
|
|
|
|
|
int Piece::getx() const{ return _x; }
|
|
|
|
int Piece::gety() const{ return _y; }
|
|
|
|
|
2016-03-08 18:23:35 +00:00
|
|
|
// DECODE DES COORDONNES DE LA FORME "A7" VERS (x,y)
|
|
|
|
void Piece::decode(char *s, int* xy){
|
|
|
|
xy[0] = (s[0] - 'A');
|
|
|
|
xy[1] = 8 - (s[1] - '0');
|
|
|
|
}
|
|
|
|
|
2016-03-06 21:51:07 +00:00
|
|
|
// SETTERS
|
|
|
|
void Piece::move(const int x, const int y){
|
|
|
|
_x = x;
|
|
|
|
_y = y;
|
|
|
|
}
|
|
|
|
|
2016-03-09 14:44:38 +00:00
|
|
|
void Piece::setPlayer(bool first){
|
|
|
|
_player = first;
|
|
|
|
}
|
|
|
|
|
2016-03-06 21:51:07 +00:00
|
|
|
// OPERATEURS (SURCHARGE)
|
2016-03-09 14:44:38 +00:00
|
|
|
ostream& operator<<(ostream& o, Piece& p){
|
|
|
|
return o << p.getchar() << " at (" << p._x << "," << p._y << ")";
|
2016-03-06 21:51:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ABTRACT
|
2016-03-09 14:30:03 +00:00
|
|
|
string Piece::getchar(){ return "?"; }
|