2016-03-08 20:06:36 +00:00
|
|
|
#include "Piece.h"
|
|
|
|
|
2016-03-06 21:51:07 +00:00
|
|
|
Piece::Piece(PIECE_TYPE t, int x, int y) : _t(t), _x(x), _y(y){
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
// OPERATEURS (SURCHARGE)
|
|
|
|
ostream& operator<<(ostream& o, const Piece& p){
|
|
|
|
return o << p._t << " at (" << p._x << "," << p._y << ")";
|
|
|
|
}
|
|
|
|
|
|
|
|
// ABTRACT
|
2016-03-08 18:23:35 +00:00
|
|
|
bool Piece::can(const ChessContext& ctx, int x, int y){ return false; }
|
2016-03-06 21:51:07 +00:00
|
|
|
char Piece::getchar(){ return '?'; }
|