diff --git a/Chess/dep/ChessContext.cpp b/Chess/dep/ChessContext.cpp index 640612a..7bc706e 100644 --- a/Chess/dep/ChessContext.cpp +++ b/Chess/dep/ChessContext.cpp @@ -1,4 +1,4 @@ -#include "ChessContext.h" +// #include "ChessContext.h" /* [1] Initialisation de la partie =========================================================*/ @@ -15,13 +15,6 @@ void ChessContext::init(){ /* [0] Constructeur =========================================================*/ ChessContext::ChessContext(){ - _p1 = new Player(true); - _p2 = new Player(false); - - _turn = '1'; - - _p1->initPieces(); - _p2->initPieces(); } diff --git a/Chess/dep/ChessContext.h b/Chess/dep/ChessContext.h index eb30bdb..aeeb6fd 100644 --- a/Chess/dep/ChessContext.h +++ b/Chess/dep/ChessContext.h @@ -33,6 +33,6 @@ /* [n] Inclusion du corps =========================================================*/ - // #include "ChessContext.cpp" + #include "ChessContext.cpp" #endif \ No newline at end of file diff --git a/Chess/dep/term.h.gch b/Chess/dep/ChessContext.h.gch similarity index 54% rename from Chess/dep/term.h.gch rename to Chess/dep/ChessContext.h.gch index a274654..c1ce40e 100644 Binary files a/Chess/dep/term.h.gch and b/Chess/dep/ChessContext.h.gch differ diff --git a/Chess/dep/Pieces/Cavalier.cpp b/Chess/dep/Pieces/Cavalier.cpp index d6b3469..da0cf95 100644 --- a/Chess/dep/Pieces/Cavalier.cpp +++ b/Chess/dep/Pieces/Cavalier.cpp @@ -1,11 +1,11 @@ -#include "Cavalier.h" +// #include "Cavalier.h" Cavalier::Cavalier(int x, int y) : Piece(CAVALIER, x, y) { } // ABSTRACT -bool Cavalier::can(const ChessContext& ctx, int x, int y){ +bool Cavalier::can(int x, int y){ return true; } diff --git a/Chess/dep/Pieces/Cavalier.h b/Chess/dep/Pieces/Cavalier.h index 07154a3..59b511a 100644 --- a/Chess/dep/Pieces/Cavalier.h +++ b/Chess/dep/Pieces/Cavalier.h @@ -19,13 +19,13 @@ Cavalier(int x, int y); // ABSTRACT - bool can(const ChessContext& ctx, int x, int y); + bool can(int x, int y); char getchar(); }; /* [n] Inclusion du corps =========================================================*/ - // #include "Cavalier.cpp" + #include "Cavalier.cpp" #endif \ No newline at end of file diff --git a/Chess/dep/Pieces/Fou.cpp b/Chess/dep/Pieces/Fou.cpp index fc20e98..cc3b5da 100644 --- a/Chess/dep/Pieces/Fou.cpp +++ b/Chess/dep/Pieces/Fou.cpp @@ -1,11 +1,11 @@ -#include "Fou.h" +// #include "Fou.h" Fou::Fou(int x, int y) : Piece(FOU, x, y) { } // ABSTRACT -bool Fou::can(const ChessContext& ctx, int x, int y){ +bool Fou::can(int x, int y){ bool inDiag = abs( _x-x ) == abs( _y-y ); // Si deplacement pas en diagonale, on retourne faux @@ -15,8 +15,8 @@ bool Fou::can(const ChessContext& ctx, int x, int y){ 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; + // 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; diff --git a/Chess/dep/Pieces/Fou.h b/Chess/dep/Pieces/Fou.h index daf3b04..fbfa43d 100644 --- a/Chess/dep/Pieces/Fou.h +++ b/Chess/dep/Pieces/Fou.h @@ -19,13 +19,13 @@ Fou(int x, int y); // ABSTRACT - bool can(const ChessContext& ctx, int x, int y); + bool can(int x, int y); char getchar(); }; /* [n] Inclusion du corps =========================================================*/ - // #include "Fou.cpp" + #include "Fou.cpp" #endif \ No newline at end of file diff --git a/Chess/dep/Pieces/Piece.cpp b/Chess/dep/Pieces/Piece.cpp index a397f3c..9b93df5 100644 --- a/Chess/dep/Pieces/Piece.cpp +++ b/Chess/dep/Pieces/Piece.cpp @@ -1,4 +1,4 @@ -#include "Piece.h" +// #include "Piece.h" Piece::Piece(PIECE_TYPE t, int x, int y) : _t(t), _x(x), _y(y){ } @@ -27,5 +27,6 @@ ostream& operator<<(ostream& o, const Piece& p){ } // ABTRACT -bool Piece::can(const ChessContext& ctx, int x, int y){ return false; } +bool Piece::can(int x, int y){ return false; } +bool Piece::can(ChessContext *c, int x, int y){ return false; } char Piece::getchar(){ return '?'; } \ No newline at end of file diff --git a/Chess/dep/Pieces/Piece.h b/Chess/dep/Pieces/Piece.h index 08bc0c9..dc3a6d5 100644 --- a/Chess/dep/Pieces/Piece.h +++ b/Chess/dep/Pieces/Piece.h @@ -11,7 +11,7 @@ #include /* (2) Externes */ - #include "../ChessContext.h" + class ChessContext; /* (3) Namespace */ using namespace std; @@ -59,9 +59,11 @@ friend ostream& operator<<(ostream& o, const Piece& p); // ABSTRACT - virtual bool can(const ChessContext& ctx, int x, int y); + virtual bool can(int x, int y); + virtual bool can(ChessContext *c, int x, int y); virtual char getchar(); + protected: PIECE_TYPE _t; int _x; @@ -70,6 +72,6 @@ /* [n] Inclusion du corps =========================================================*/ - // #include "Piece.cpp" + #include "Piece.cpp" #endif \ No newline at end of file diff --git a/Chess/dep/Pieces/Piece.h.gch b/Chess/dep/Pieces/Piece.h.gch index f8ead6d..9657ea6 100644 Binary files a/Chess/dep/Pieces/Piece.h.gch and b/Chess/dep/Pieces/Piece.h.gch differ diff --git a/Chess/dep/Pieces/PieceFactory.cpp b/Chess/dep/Pieces/PieceFactory.cpp index 2e4f640..b9a2f8e 100644 --- a/Chess/dep/Pieces/PieceFactory.cpp +++ b/Chess/dep/Pieces/PieceFactory.cpp @@ -1,4 +1,4 @@ -#include "PieceFactory.h" +// #include "PieceFactory.h" Piece& PieceFactory::create(PIECE_TYPE t, int x, int y){ Piece *p; diff --git a/Chess/dep/Pieces/PieceFactory.h b/Chess/dep/Pieces/PieceFactory.h index 2713c1c..86ead46 100644 --- a/Chess/dep/Pieces/PieceFactory.h +++ b/Chess/dep/Pieces/PieceFactory.h @@ -5,6 +5,8 @@ /* [1] Libs =========================================================*/ /* (1) Externes */ + #include "../term.h" + #include "Roi.h" #include "Reine.h" #include "Cavalier.h" @@ -25,6 +27,6 @@ /* [n] Inclusion du corps =========================================================*/ - // #include "PieceFactory.cpp" + #include "PieceFactory.cpp" #endif \ No newline at end of file diff --git a/Chess/dep/Pieces/Pion.cpp b/Chess/dep/Pieces/Pion.cpp index 6065f6c..dca32c5 100644 --- a/Chess/dep/Pieces/Pion.cpp +++ b/Chess/dep/Pieces/Pion.cpp @@ -1,10 +1,11 @@ +// #include "Pion.h" Pion::Pion(int x, int y) : Piece(PION, x, y) { } // ABSTRACT -bool Pion::can(const ChessContext& ctx, const int x, const int y) const{ +bool Pion::can(int x, int y){ return true; } diff --git a/Chess/dep/Pieces/Pion.h b/Chess/dep/Pieces/Pion.h index 272f556..8d6f3a1 100644 --- a/Chess/dep/Pieces/Pion.h +++ b/Chess/dep/Pieces/Pion.h @@ -19,7 +19,7 @@ Pion(int x, int y); // ABSTRACT - bool can(const ChessContext& ctx, const int x, const int y) const; + bool can(int x, int y); char getchar(); }; diff --git a/Chess/dep/Pieces/Reine.cpp b/Chess/dep/Pieces/Reine.cpp index 6562630..a002362 100644 --- a/Chess/dep/Pieces/Reine.cpp +++ b/Chess/dep/Pieces/Reine.cpp @@ -1,11 +1,11 @@ -#include "Reine.h" +// #include "Reine.h" Reine::Reine(int x, int y) : Piece(REINE, x, y) { } // ABSTRACT -bool Reine::can(const ChessContext& ctx, int x, int y){ +bool Reine::can(int x, int y){ return true; } diff --git a/Chess/dep/Pieces/Reine.h b/Chess/dep/Pieces/Reine.h index 38daebe..2fbafd6 100644 --- a/Chess/dep/Pieces/Reine.h +++ b/Chess/dep/Pieces/Reine.h @@ -19,13 +19,13 @@ Reine(int x, int y); // ABSTRACT - bool can(const ChessContext& ctx, int x, int y); + bool can(int x, int y); char getchar(); }; /* [n] Inclusion du corps =========================================================*/ - // #include "Reine.cpp" + #include "Reine.cpp" #endif \ No newline at end of file diff --git a/Chess/dep/Pieces/Roi.cpp b/Chess/dep/Pieces/Roi.cpp index 0160f76..f228334 100644 --- a/Chess/dep/Pieces/Roi.cpp +++ b/Chess/dep/Pieces/Roi.cpp @@ -1,11 +1,11 @@ -#include "Roi.h" +// #include "Roi.h" Roi::Roi(int x, int y) : Piece(ROI, x, y) { } // ABSTRACT -bool Roi::can(const ChessContext& ctx, int x, int y){ +bool Roi::can(int x, int y){ return true; } diff --git a/Chess/dep/Pieces/Roi.h b/Chess/dep/Pieces/Roi.h index 3075732..a542c1b 100644 --- a/Chess/dep/Pieces/Roi.h +++ b/Chess/dep/Pieces/Roi.h @@ -19,13 +19,13 @@ Roi(int x, int y); // ABSTRACT - bool can(const ChessContext& ctx, int x, int y); + bool can(int x, int y); char getchar(); }; /* [n] Inclusion du corps =========================================================*/ - // #include "Roi.cpp" + #include "Roi.cpp" #endif \ No newline at end of file diff --git a/Chess/dep/Pieces/Tour.cpp b/Chess/dep/Pieces/Tour.cpp index 223a0d6..b5f2407 100644 --- a/Chess/dep/Pieces/Tour.cpp +++ b/Chess/dep/Pieces/Tour.cpp @@ -1,11 +1,11 @@ -#include "Tour.h" +// #include "Tour.h" Tour::Tour(int x, int y) : Piece(TOUR, x, y) { } // ABSTRACT -bool Tour::can(const ChessContext& ctx, int x, int y){ +bool Tour::can(int x, int y){ return true; } diff --git a/Chess/dep/Pieces/Tour.h b/Chess/dep/Pieces/Tour.h index f849e6f..5553cb0 100644 --- a/Chess/dep/Pieces/Tour.h +++ b/Chess/dep/Pieces/Tour.h @@ -19,13 +19,13 @@ Tour(int x, int y); // ABSTRACT - bool can(const ChessContext& ctx, int x, int y); + bool can(int x, int y); char getchar(); }; /* [n] Inclusion du corps =========================================================*/ - // #include "Tour.cpp" + #include "Tour.cpp" #endif \ No newline at end of file diff --git a/Chess/dep/Player.cpp b/Chess/dep/Player.cpp index 2735459..9a64621 100644 --- a/Chess/dep/Player.cpp +++ b/Chess/dep/Player.cpp @@ -1,4 +1,4 @@ -#include "Player.h" +// #include "Player.h" // CONSTRUCTEUR Player::Player(bool first) : _first(first){ diff --git a/Chess/dep/Player.h b/Chess/dep/Player.h index e61086e..bddb4e6 100644 --- a/Chess/dep/Player.h +++ b/Chess/dep/Player.h @@ -40,6 +40,6 @@ /* [n] Inclusion du corps =========================================================*/ - // #include "Player.cpp" + #include "Player.cpp" #endif \ No newline at end of file diff --git a/Chess/dep/term.cpp b/Chess/dep/term.cpp index a6a551f..23604c6 100644 --- a/Chess/dep/term.cpp +++ b/Chess/dep/term.cpp @@ -1,3 +1,4 @@ +// #include "term.h" /* [1] Operations terminal =========================================================*/ diff --git a/Chess/exe b/Chess/exe new file mode 100755 index 0000000..9eb1124 Binary files /dev/null and b/Chess/exe differ diff --git a/Chess/main.cpp b/Chess/main.cpp index fbd0269..4b5eaa2 100644 --- a/Chess/main.cpp +++ b/Chess/main.cpp @@ -4,8 +4,7 @@ =========================================================*/ int main(){ ChessContext ctx; - - cout << typeid(ctx).name() << endl; + // On initialise la partie ctx.init(); @@ -143,7 +142,7 @@ void game_routine(ChessContext& ctx){ /* [4] On verifie qu'il peut atteindre la destination =========================================================*/ - cout << "Can move to dest : " << toMove->can(ctx, dest[0], dest[1]) << endl; + cout << "Can move to dest : " << toMove->can(dest[0], dest[1]) << endl; /* [5] On gere le deplacement diff --git a/Chess/main.h b/Chess/main.h index d6e9b79..f3d246b 100644 --- a/Chess/main.h +++ b/Chess/main.h @@ -9,7 +9,6 @@ #include #include #include - #include /* (2) Externes */ #include "dep/term.h" diff --git a/Chess/main.o b/Chess/main.o new file mode 100644 index 0000000..4a4430b Binary files /dev/null and b/Chess/main.o differ diff --git a/Chess/makefile b/Chess/makefile index 127516f..d9581f4 100644 --- a/Chess/makefile +++ b/Chess/makefile @@ -1,20 +1,94 @@ +.PHONY: init, clean, mrproper + # INIT > STRUCTURE DE FICHIERS POUR LES EXECUTABLES -begin: +init: clean mkdir dep.o - mkdir dep.o/Pieces.o + mkdir dep.o/Pieces - -# TERM < OPERATION SUR LE TERMINAL -dep/term.o: dep/term.cpp - g++ -c dep/term.h -o term.o - - - - - - - - -# RESET > SUPPRESSION DE LA STRUCTURE DE FICHIERS +# RESET > SUPPRESSION DES FICHIERS clean: - rm -r dep.o \ No newline at end of file + touch init.o + rm -r *.o + +# RESET FOR REBUILD > SUPPRESSION DE L'EXECUTABLE +mrproper: + rm exe + + + + + + + + + + +# EXECUTABLE > DEPENDANCES DE L'EXECUTABLE +all: init main.o + g++ main.o -o exe + +# AMORCE > PROGRAMME PRINCIPAL +main.o: main.cpp dep/term.h dep/ChessContext.h + g++ -c $< -o main.o + + + + + + + +# ############################################### +# #### HAUT NIVEAU GESTION TERMINAL LINUX #### +# ############################################### +# # TERM < OPERATION SUR LE TERMINAL +# dep.o/term.o: dep/term.cpp +# g++ -c $< -o dep.o/term.o + + + +# ############################################### +# #### CONTEXTE DU JEU D'ECHEC #### +# ############################################### +# # CONTEXTE > CONTEXTE DU JEU D'ECHEC +# dep.o/ChessContext.o: dep/ChessContext.cpp dep.o/term.o dep.o/Player.o +# g++ -c $< -o dep.o/ChessContext.o + +# # JOUEUR > JOUEUR DU JEU D'ECHEC +# dep.o/Player.o: dep/Player.cpp dep.o/term.o dep.o/Pieces/PieceFactory.o +# g++ -c $< -o dep.o/Player.o + + +# ############################################### +# #### PIECES DU JEU D'ECHEC #### +# ############################################### +# # PIECES > ENGLOBE LES PIECES DU JEU +# dep.o/Pieces/Piece.o: dep/Pieces/Piece.cpp +# g++ -c $< -o dep.o/Pieces/Piece.o + +# # USINE A PIECES > FACTORY_PATTERN POUR L'INSTANCIATION DE PIECES +# dep.o/Pieces/PieceFactory.o: dep/Pieces/PieceFactory.cpp dep.o/term.o dep.o/Pieces/Roi.o dep.o/Pieces/Reine.o dep.o/Pieces/Cavalier.o dep.o/Pieces/Fou.o dep.o/Pieces/Tour.o dep.o/Pieces/Pion.o +# g++ -c $< -o dep.o/Pieces/PieceFactory.o + +# # ROI > UN TYPE DE PIECE DU JEU D'ECHECS +# dep.o/Pieces/Roi.o: dep/Pieces/Roi.cpp dep.o/Pieces/Piece.o +# g++ -c $< -o dep.o/Pieces/Roi.o + +# # REINE > UN TYPE DE PIECE DU JEU D'ECHECS +# dep.o/Pieces/Reine.o: dep/Pieces/Reine.cpp dep.o/Pieces/Piece.o +# g++ -c $< -o dep.o/Pieces/Reine.o + +# # CAVALIER > UN TYPE DE PIECE DU JEU D'ECHECS +# dep.o/Pieces/Cavalier.o: dep/Pieces/Cavalier.cpp dep.o/Pieces/Piece.o +# g++ -c $< -o dep.o/Pieces/Cavalier.o + +# # FOU > UN TYPE DE PIECE DU JEU D'ECHECS +# dep.o/Pieces/Fou.o: dep/Pieces/Fou.cpp dep.o/Pieces/Piece.o +# g++ -c $< -o dep.o/Pieces/Fou.o + +# # TOUR > UN TYPE DE PIECE DU JEU D'ECHECS +# dep.o/Pieces/Tour.o: dep/Pieces/Tour.cpp dep.o/Pieces/Piece.o +# g++ -c $< -o dep.o/Pieces/Tour.o + +# # PION > UN TYPE DE PIECE DU JEU D'ECHECS +# dep.o/Pieces/Pion.o: dep/Pieces/Pion.cpp dep.o/Pieces/Piece.o +# g++ -c $< -o dep.o/Pieces/Pion.o \ No newline at end of file