lab.cpp/Chess/dep/Pieces/Piece.cpp

34 lines
703 B
C++

// #include "Piece.h"
Piece::Piece(PIECE_TYPE t, int x, int y) : _t(t), _x(x), _y(y), _player(true){
}
// GETTERS
PIECE_TYPE Piece::gett() const{ return _t; }
int Piece::getx() const{ return _x; }
int Piece::gety() const{ return _y; }
// 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');
}
// SETTERS
void Piece::move(const int x, const int y){
_x = x;
_y = y;
}
void Piece::setPlayer(bool first){
_player = first;
}
// OPERATEURS (SURCHARGE)
ostream& operator<<(ostream& o, Piece& p){
return o << p.getchar() << " at (" << p._x << "," << p._y << ")";
}
// ABTRACT
string Piece::getchar(){ return "?"; }