2016-03-08 18:23:35 +00:00
|
|
|
#ifndef DEF_PIECE_H
|
2016-03-06 21:51:07 +00:00
|
|
|
|
2016-03-08 18:23:35 +00:00
|
|
|
#define DEF_PIECE_H
|
2016-03-06 21:51:07 +00:00
|
|
|
|
|
|
|
/* [1] Libs
|
|
|
|
=========================================================*/
|
|
|
|
/* (1) Internes */
|
|
|
|
#include <iostream>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2016-03-08 18:23:35 +00:00
|
|
|
#include <stdlib.h>
|
2016-03-06 21:51:07 +00:00
|
|
|
|
|
|
|
/* (2) Externes */
|
2016-03-08 22:39:21 +00:00
|
|
|
class ChessContext;
|
2016-03-06 21:51:07 +00:00
|
|
|
|
|
|
|
/* (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";
|
|
|
|
}
|
|
|
|
|
2016-03-08 20:06:36 +00:00
|
|
|
//
|
2016-03-06 21:51:07 +00:00
|
|
|
/* [2] Definition
|
|
|
|
=========================================================*/
|
|
|
|
class Piece{
|
|
|
|
public:
|
|
|
|
Piece(PIECE_TYPE t, int x, int y);
|
|
|
|
|
|
|
|
// GETTERS
|
|
|
|
PIECE_TYPE gett() const;
|
|
|
|
int getx() const;
|
|
|
|
int gety() const;
|
2016-03-08 18:23:35 +00:00
|
|
|
static void decode(char *s, int* xy);
|
2016-03-06 21:51:07 +00:00
|
|
|
|
|
|
|
// SETTERS
|
|
|
|
void move(const int x, const int y);
|
2016-03-09 14:44:38 +00:00
|
|
|
void setPlayer(bool first);
|
|
|
|
|
2016-03-06 21:51:07 +00:00
|
|
|
// OPERATEURS (SURCHARGE)
|
2016-03-09 14:44:38 +00:00
|
|
|
friend ostream& operator<<(ostream& o, Piece& p);
|
2016-03-06 21:51:07 +00:00
|
|
|
|
|
|
|
// ABSTRACT
|
2016-03-09 14:30:03 +00:00
|
|
|
virtual string getchar();
|
2016-03-06 21:51:07 +00:00
|
|
|
|
2016-03-08 22:39:21 +00:00
|
|
|
|
2016-03-06 21:51:07 +00:00
|
|
|
protected:
|
2016-03-09 14:44:38 +00:00
|
|
|
bool _player;
|
2016-03-06 21:51:07 +00:00
|
|
|
PIECE_TYPE _t;
|
|
|
|
int _x;
|
|
|
|
int _y;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* [n] Inclusion du corps
|
|
|
|
=========================================================*/
|
2016-03-08 22:39:21 +00:00
|
|
|
#include "Piece.cpp"
|
2016-03-06 21:51:07 +00:00
|
|
|
|
|
|
|
#endif
|