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"
|
// #include "ChessContext.h"
|
||||||
|
|
||||||
|
/* [0] Constructeur
|
||||||
|
=========================================================*/
|
||||||
|
ChessContext::ChessContext(){
|
||||||
|
setfont(GREEN, BOLD);
|
||||||
|
cout << "[+] ChessContext" << endl;
|
||||||
|
setfont();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* [1] Initialisation de la partie
|
/* [1] Initialisation de la partie
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
void ChessContext::init(){
|
void ChessContext::init(){
|
||||||
|
@ -12,11 +21,6 @@ void ChessContext::init(){
|
||||||
_p2->initPieces();
|
_p2->initPieces();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* [0] Constructeur
|
|
||||||
=========================================================*/
|
|
||||||
ChessContext::ChessContext(){
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* [2] Renvoie le pion qui est en case (x, y)
|
/* [2] Renvoie le pion qui est en case (x, y)
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
|
|
|
@ -15,12 +15,26 @@ bool Fou::can(int x, int y){
|
||||||
int xstep = ( x-_x ) / abs( x-_x );
|
int xstep = ( x-_x ) / abs( x-_x );
|
||||||
int ystep = ( y-_y ) / abs( y-_y );
|
int ystep = ( y-_y ) / abs( y-_y );
|
||||||
|
|
||||||
// for( int i = _x+xstep, j = _y+ystep ; i != x && j != y ; i+=xstep, j+=ystep )
|
return true;
|
||||||
// if( ctx._p1->at(i, j) != NULL ) return false;
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*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;
|
return true;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
char Fou::getchar(){
|
char Fou::getchar(){
|
||||||
return 'F';
|
return 'F';
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
/* (2) Externes */
|
/* (2) Externes */
|
||||||
#include "Piece.h"
|
#include "Piece.h"
|
||||||
|
class ChessContext;
|
||||||
|
|
||||||
/* (3) Namespace */
|
/* (3) Namespace */
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
@ -20,6 +21,7 @@
|
||||||
|
|
||||||
// ABSTRACT
|
// ABSTRACT
|
||||||
bool can(int x, int y);
|
bool can(int x, int y);
|
||||||
|
//bool can(ChessContext *c, int x, int y);
|
||||||
char getchar();
|
char getchar();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,7 +15,7 @@ Piece& PieceFactory::create(PIECE_TYPE t, int x, int y){
|
||||||
/* DEBUG */
|
/* DEBUG */
|
||||||
setfont(SKYBLUE, NORMAL);
|
setfont(SKYBLUE, NORMAL);
|
||||||
|
|
||||||
cout << "\t[+] " << p->gett() << " at (" << p->getx() << "," << p->gety() << ")";
|
cout << " [+] " << p->gett() << " at (" << p->getx() << "," << p->gety() << ")";
|
||||||
|
|
||||||
setfont();
|
setfont();
|
||||||
cout << endl;
|
cout << endl;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
Player::Player(bool first) : _first(first){
|
Player::Player(bool first) : _first(first){
|
||||||
setfont(GREEN, BOLD);
|
setfont(GREEN, BOLD);
|
||||||
|
|
||||||
cout << "[+] Player " << (_first?1:2);
|
cout << " [+] Player " << (_first?1:2);
|
||||||
|
|
||||||
setfont();
|
setfont();
|
||||||
cout << endl;
|
cout << endl;
|
||||||
|
@ -33,7 +33,7 @@ void Player::addPiece(Piece& p){
|
||||||
/* DEBUG */
|
/* DEBUG */
|
||||||
setfont(BLUE, ITALIC);
|
setfont(BLUE, ITALIC);
|
||||||
|
|
||||||
cout << "\t\t[+] linked to Player " << (_first?1:2);
|
cout << " [+] linked to Player " << (_first?1:2);
|
||||||
|
|
||||||
setfont();
|
setfont();
|
||||||
cout << endl;
|
cout << endl;
|
||||||
|
|
BIN
Chess/main.o
BIN
Chess/main.o
Binary file not shown.
|
@ -24,7 +24,8 @@ mrproper:
|
||||||
|
|
||||||
|
|
||||||
# EXECUTABLE > DEPENDANCES DE L'EXECUTABLE
|
# EXECUTABLE > DEPENDANCES DE L'EXECUTABLE
|
||||||
all: init main.o
|
all: init main.o clean
|
||||||
|
rm -r dep.o
|
||||||
g++ main.o -o exe
|
g++ main.o -o exe
|
||||||
|
|
||||||
# AMORCE > PROGRAMME PRINCIPAL
|
# AMORCE > PROGRAMME PRINCIPAL
|
||||||
|
|
Loading…
Reference in New Issue