diff --git a/Chess/dep/ChessContext.cpp b/Chess/dep/ChessContext.cpp index 7bc706e..5b60fd0 100644 --- a/Chess/dep/ChessContext.cpp +++ b/Chess/dep/ChessContext.cpp @@ -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) =========================================================*/ diff --git a/Chess/dep/Pieces/Fou.cpp b/Chess/dep/Pieces/Fou.cpp index cc3b5da..3655447 100644 --- a/Chess/dep/Pieces/Fou.cpp +++ b/Chess/dep/Pieces/Fou.cpp @@ -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'; } diff --git a/Chess/dep/Pieces/Fou.h b/Chess/dep/Pieces/Fou.h index fbfa43d..54322b0 100644 --- a/Chess/dep/Pieces/Fou.h +++ b/Chess/dep/Pieces/Fou.h @@ -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(); }; diff --git a/Chess/dep/Pieces/PieceFactory.cpp b/Chess/dep/Pieces/PieceFactory.cpp index b9a2f8e..7852812 100644 --- a/Chess/dep/Pieces/PieceFactory.cpp +++ b/Chess/dep/Pieces/PieceFactory.cpp @@ -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; diff --git a/Chess/dep/Player.cpp b/Chess/dep/Player.cpp index 9a64621..d58c5f6 100644 --- a/Chess/dep/Player.cpp +++ b/Chess/dep/Player.cpp @@ -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; diff --git a/Chess/exe b/Chess/exe index 9eb1124..ec04027 100755 Binary files a/Chess/exe and b/Chess/exe differ diff --git a/Chess/main.o b/Chess/main.o index 4a4430b..e5d33af 100644 Binary files a/Chess/main.o and b/Chess/main.o differ diff --git a/Chess/makefile b/Chess/makefile index d9581f4..e18701b 100644 --- a/Chess/makefile +++ b/Chess/makefile @@ -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