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

77 lines
1.5 KiB
C
Raw Permalink Normal View History

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 */
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);
void setPlayer(bool first);
2016-03-06 21:51:07 +00:00
// OPERATEURS (SURCHARGE)
friend ostream& operator<<(ostream& o, Piece& p);
2016-03-06 21:51:07 +00:00
// ABSTRACT
virtual string getchar();
2016-03-06 21:51:07 +00:00
2016-03-06 21:51:07 +00:00
protected:
bool _player;
2016-03-06 21:51:07 +00:00
PIECE_TYPE _t;
int _x;
int _y;
};
/* [n] Inclusion du corps
=========================================================*/
#include "Piece.cpp"
2016-03-06 21:51:07 +00:00
#endif