Corrections mais tjs pb dans implementation avec utilisation d'un ChessContext meme en pointeur

This commit is contained in:
xdrm-brackets 2016-03-08 23:53:11 +01:00
parent d6a4152ac4
commit 8c2f003941
8 changed files with 42 additions and 21 deletions

View File

@ -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)
=========================================================*/

View File

@ -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';
}

View File

@ -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();
};

View File

@ -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;

View File

@ -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/exe

Binary file not shown.

Binary file not shown.

View File

@ -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