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

31 lines
698 B
C++

#include "Piece.h"
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; }
// 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;
}
// OPERATEURS (SURCHARGE)
ostream& operator<<(ostream& o, const Piece& p){
return o << p._t << " at (" << p._x << "," << p._y << ")";
}
// ABTRACT
bool Piece::can(const ChessContext& ctx, int x, int y){ return false; }
char Piece::getchar(){ return '?'; }