Corrections mais tjs pb dans implementation avec utilisation d'un ChessContext meme en pointeur
This commit is contained in:
parent
d6a4152ac4
commit
8c2f003941
|
@ -1,5 +1,14 @@
|
|||
// #include "ChessContext.h"
|
||||
|
||||
/* [0] Constructeur
|
||||
=========================================================*/
|
||||
ChessContext::ChessContext(){
|
||||
setfont(GREEN, BOLD);
|
||||
cout << "[+] ChessContext" << endl;
|
||||
setfont();
|
||||
}
|
||||
|
||||
|
||||
/* [1] Initialisation de la partie
|
||||
=========================================================*/
|
||||
void ChessContext::init(){
|
||||
|
@ -12,11 +21,6 @@ void ChessContext::init(){
|
|||
_p2->initPieces();
|
||||
}
|
||||
|
||||
/* [0] Constructeur
|
||||
=========================================================*/
|
||||
ChessContext::ChessContext(){
|
||||
}
|
||||
|
||||
|
||||
/* [2] Renvoie le pion qui est en case (x, y)
|
||||
=========================================================*/
|
||||
|
|
|
@ -8,20 +8,34 @@ Fou::Fou(int x, int y) : Piece(FOU, x, y) {
|
|||
bool Fou::can(int x, int y){
|
||||
bool inDiag = abs( _x-x ) == abs( _y-y );
|
||||
|
||||
// Si deplacement pas en diagonale, on retourne faux
|
||||
if( !inDiag ) return false;
|
||||
|
||||
// On verifie que la diagonale est degagee
|
||||
int xstep = ( x-_x ) / abs( x-_x );
|
||||
int ystep = ( y-_y ) / abs( y-_y );
|
||||
|
||||
// for( int i = _x+xstep, j = _y+ystep ; i != x && j != y ; i+=xstep, j+=ystep )
|
||||
// if( ctx._p1->at(i, j) != NULL ) return false;
|
||||
|
||||
|
||||
return true;
|
||||
// Si deplacement pas en diagonale, on retourne faux
|
||||
if( !inDiag ) return false;
|
||||
|
||||
// On verifie que la diagonale est degagee
|
||||
int xstep = ( x-_x ) / abs( x-_x );
|
||||
int ystep = ( y-_y ) / abs( y-_y );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*bool Fou::can(ChessContext *c, int x, int y){
|
||||
bool inDiag = abs( _x-x ) == abs( _y-y );
|
||||
|
||||
// Si deplacement pas en diagonale, on retourne faux
|
||||
if( !inDiag ) return false;
|
||||
|
||||
// On verifie que la diagonale est degagee
|
||||
int xstep = ( x-_x ) / abs( x-_x );
|
||||
int ystep = ( y-_y ) / abs( y-_y );
|
||||
|
||||
for( int i = _x+xstep, j = _y+ystep ; i != x && j != y ; i+=xstep, j+=ystep )
|
||||
if( c->_p1->at(i, j) != NULL ) return false;
|
||||
|
||||
|
||||
return true;
|
||||
}*/
|
||||
|
||||
char Fou::getchar(){
|
||||
return 'F';
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
/* (2) Externes */
|
||||
#include "Piece.h"
|
||||
class ChessContext;
|
||||
|
||||
/* (3) Namespace */
|
||||
using namespace std;
|
||||
|
@ -20,6 +21,7 @@
|
|||
|
||||
// ABSTRACT
|
||||
bool can(int x, int y);
|
||||
//bool can(ChessContext *c, int x, int y);
|
||||
char getchar();
|
||||
|
||||
};
|
||||
|
|
|
@ -15,7 +15,7 @@ Piece& PieceFactory::create(PIECE_TYPE t, int x, int y){
|
|||
/* DEBUG */
|
||||
setfont(SKYBLUE, NORMAL);
|
||||
|
||||
cout << "\t[+] " << p->gett() << " at (" << p->getx() << "," << p->gety() << ")";
|
||||
cout << " [+] " << p->gett() << " at (" << p->getx() << "," << p->gety() << ")";
|
||||
|
||||
setfont();
|
||||
cout << endl;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
Player::Player(bool first) : _first(first){
|
||||
setfont(GREEN, BOLD);
|
||||
|
||||
cout << "[+] Player " << (_first?1:2);
|
||||
cout << " [+] Player " << (_first?1:2);
|
||||
|
||||
setfont();
|
||||
cout << endl;
|
||||
|
@ -33,7 +33,7 @@ void Player::addPiece(Piece& p){
|
|||
/* DEBUG */
|
||||
setfont(BLUE, ITALIC);
|
||||
|
||||
cout << "\t\t[+] linked to Player " << (_first?1:2);
|
||||
cout << " [+] linked to Player " << (_first?1:2);
|
||||
|
||||
setfont();
|
||||
cout << endl;
|
||||
|
|
BIN
Chess/main.o
BIN
Chess/main.o
Binary file not shown.
|
@ -24,7 +24,8 @@ mrproper:
|
|||
|
||||
|
||||
# EXECUTABLE > DEPENDANCES DE L'EXECUTABLE
|
||||
all: init main.o
|
||||
all: init main.o clean
|
||||
rm -r dep.o
|
||||
g++ main.o -o exe
|
||||
|
||||
# AMORCE > PROGRAMME PRINCIPAL
|
||||
|
|
Loading…
Reference in New Issue