72 lines
1.4 KiB
C
72 lines
1.4 KiB
C
|
#ifndef DEF_PIECE
|
||
|
|
||
|
#define DEF_PIECE
|
||
|
|
||
|
/* [1] Libs
|
||
|
=========================================================*/
|
||
|
/* (1) Internes */
|
||
|
#include <iostream>
|
||
|
#include <string>
|
||
|
#include <vector>
|
||
|
|
||
|
/* (2) Externes */
|
||
|
|
||
|
/* (3) Namespace */
|
||
|
using namespace std;
|
||
|
|
||
|
/* [2] Enumerations
|
||
|
=========================================================*/
|
||
|
enum PIECE_TYPE{
|
||
|
ROI,
|
||
|
REINE,
|
||
|
CAVALIER,
|
||
|
TOUR,
|
||
|
FOU,
|
||
|
PION
|
||
|
};
|
||
|
ostream& operator<<(ostream& o, const PIECE_TYPE& t){
|
||
|
switch(t){
|
||
|
case ROI: return o << "Roi"; break;
|
||
|
case REINE: return o << "Reine"; break;
|
||
|
case CAVALIER: return o << "Cavalier"; break;
|
||
|
case FOU: return o << "Fou"; break;
|
||
|
case TOUR: return o << "Tour"; break;
|
||
|
case PION: return o << "Pion"; break;
|
||
|
}
|
||
|
|
||
|
return o << "UNKNOWN";
|
||
|
}
|
||
|
|
||
|
|
||
|
/* [2] Definition
|
||
|
=========================================================*/
|
||
|
class Piece{
|
||
|
public:
|
||
|
Piece(PIECE_TYPE t, int x, int y);
|
||
|
|
||
|
// GETTERS
|
||
|
PIECE_TYPE gett() const;
|
||
|
int getx() const;
|
||
|
int gety() const;
|
||
|
|
||
|
// SETTERS
|
||
|
void move(const int x, const int y);
|
||
|
|
||
|
// OPERATEURS (SURCHARGE)
|
||
|
friend ostream& operator<<(ostream& o, const Piece& p);
|
||
|
|
||
|
// ABSTRACT
|
||
|
virtual bool can(const int x, const int y);
|
||
|
virtual char getchar();
|
||
|
|
||
|
protected:
|
||
|
PIECE_TYPE _t;
|
||
|
int _x;
|
||
|
int _y;
|
||
|
};
|
||
|
|
||
|
/* [n] Inclusion du corps
|
||
|
=========================================================*/
|
||
|
#include "Piece.cpp"
|
||
|
|
||
|
#endif
|