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

34 lines
703 B
C++
Raw Permalink Normal View History

// #include "Piece.h"
2016-03-08 20:06:36 +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;
}
void Piece::setPlayer(bool first){
_player = first;
}
2016-03-06 21:51:07 +00:00
// OPERATEURS (SURCHARGE)
ostream& operator<<(ostream& o, Piece& p){
return o << p.getchar() << " at (" << p._x << "," << p._y << ")";
2016-03-06 21:51:07 +00:00
}
// ABTRACT
string Piece::getchar(){ return "?"; }