diff --git a/Chess/Chess.todo.md b/Chess/Chess.todo.md index d9d1ebe..846cc8b 100644 --- a/Chess/Chess.todo.md +++ b/Chess/Chess.todo.md @@ -4,9 +4,9 @@ A FAIRE - [ ] Timeout pour le jeu - [ ] IA -- [ ] Changer l'unicode en fonction du joueur FAIT ==== - [x] Caracteres unicode pour les pieces -- [x] Methode pour texte multicolore \ No newline at end of file +- [x] Methode pour texte multicolore +- [x] Changer l'unicode en fonction du joueur \ No newline at end of file diff --git a/Chess/dep/Pieces/Cavalier.cpp b/Chess/dep/Pieces/Cavalier.cpp index ca7a3d5..fd468ff 100644 --- a/Chess/dep/Pieces/Cavalier.cpp +++ b/Chess/dep/Pieces/Cavalier.cpp @@ -6,6 +6,5 @@ Cavalier::Cavalier(int x, int y) : Piece(CAVALIER, x, y) { // ABSTRACT string Cavalier::getchar(){ - return "\u265E"; - return "\u2658"; + return (_player) ? "\u265E" : "\u2658"; } diff --git a/Chess/dep/Pieces/Fou.cpp b/Chess/dep/Pieces/Fou.cpp index 9774a01..8cf2f62 100644 --- a/Chess/dep/Pieces/Fou.cpp +++ b/Chess/dep/Pieces/Fou.cpp @@ -6,6 +6,5 @@ Fou::Fou(int x, int y) : Piece(FOU, x, y) { // ABSTRACT string Fou::getchar(){ - return "\u265D"; - return "\u2657"; + return (_player) ? "\u265D" : "\u2657"; } diff --git a/Chess/dep/Pieces/Piece.cpp b/Chess/dep/Pieces/Piece.cpp index fe5507c..5d3c530 100644 --- a/Chess/dep/Pieces/Piece.cpp +++ b/Chess/dep/Pieces/Piece.cpp @@ -1,6 +1,6 @@ // #include "Piece.h" -Piece::Piece(PIECE_TYPE t, int x, int y) : _t(t), _x(x), _y(y){ +Piece::Piece(PIECE_TYPE t, int x, int y) : _t(t), _x(x), _y(y), _player(true){ } // GETTERS @@ -21,9 +21,13 @@ void Piece::move(const int x, const int y){ _y = y; } +void Piece::setPlayer(bool first){ + _player = first; +} + // OPERATEURS (SURCHARGE) -ostream& operator<<(ostream& o, const Piece& p){ - return o << p._t << " at (" << p._x << "," << p._y << ")"; +ostream& operator<<(ostream& o, Piece& p){ + return o << p.getchar() << " at (" << p._x << "," << p._y << ")"; } // ABTRACT diff --git a/Chess/dep/Pieces/Piece.h b/Chess/dep/Pieces/Piece.h index c66c318..e878b43 100644 --- a/Chess/dep/Pieces/Piece.h +++ b/Chess/dep/Pieces/Piece.h @@ -54,15 +54,17 @@ // SETTERS void move(const int x, const int y); - + void setPlayer(bool first); + // OPERATEURS (SURCHARGE) - friend ostream& operator<<(ostream& o, const Piece& p); + friend ostream& operator<<(ostream& o, Piece& p); // ABSTRACT virtual string getchar(); protected: + bool _player; PIECE_TYPE _t; int _x; int _y; diff --git a/Chess/dep/Pieces/Pion.cpp b/Chess/dep/Pieces/Pion.cpp index 968faca..58f8cb1 100644 --- a/Chess/dep/Pieces/Pion.cpp +++ b/Chess/dep/Pieces/Pion.cpp @@ -6,6 +6,5 @@ Pion::Pion(int x, int y) : Piece(PION, x, y) { // ABSTRACT string Pion::getchar(){ - return "\u265F"; - return "\u2659"; + return (_player) ? "\u265F" : "\u2659"; } diff --git a/Chess/dep/Pieces/Reine.cpp b/Chess/dep/Pieces/Reine.cpp index 9dc55bc..58b2d6e 100644 --- a/Chess/dep/Pieces/Reine.cpp +++ b/Chess/dep/Pieces/Reine.cpp @@ -6,6 +6,5 @@ Reine::Reine(int x, int y) : Piece(REINE, x, y) { // ABSTRACT string Reine::getchar(){ - return "\u265B"; - return "\u2655"; + return (_player) ? "\u265B" : "\u2655"; } diff --git a/Chess/dep/Pieces/Roi.cpp b/Chess/dep/Pieces/Roi.cpp index 046e569..a281fa5 100644 --- a/Chess/dep/Pieces/Roi.cpp +++ b/Chess/dep/Pieces/Roi.cpp @@ -6,6 +6,5 @@ Roi::Roi(int x, int y) : Piece(ROI, x, y) { // ABSTRACT string Roi::getchar(){ - return "\u265A"; - return "\u2654"; + return (_player) ? "\u265A" : "\u2654"; } diff --git a/Chess/dep/Pieces/Tour.cpp b/Chess/dep/Pieces/Tour.cpp index 8899247..4f80725 100644 --- a/Chess/dep/Pieces/Tour.cpp +++ b/Chess/dep/Pieces/Tour.cpp @@ -6,6 +6,5 @@ Tour::Tour(int x, int y) : Piece(TOUR, x, y) { // ABSTRACT string Tour::getchar(){ - return "\u265C"; - return "\u2656"; + return (_player) ? "\u265C" : "\u2656"; } diff --git a/Chess/dep/Player.cpp b/Chess/dep/Player.cpp index 46ef7a6..7efd2a9 100644 --- a/Chess/dep/Player.cpp +++ b/Chess/dep/Player.cpp @@ -28,6 +28,9 @@ Piece* Player::at(const int x, const int y){ } // SETTERS void Player::addPiece(Piece& p){ + // On definit a la piece si c'est P1 ou P2 + p.setPlayer(_first); + _pieces.push_back( &p ); /* DEBUG */ diff --git a/Chess/exe b/Chess/exe index 297db68..6143e11 100755 Binary files a/Chess/exe and b/Chess/exe differ diff --git a/Chess/main.cpp b/Chess/main.cpp index e917f07..fd1cf40 100644 --- a/Chess/main.cpp +++ b/Chess/main.cpp @@ -9,8 +9,10 @@ int main(){ // Message d'accueil clear_screen(); - cout << "Bievenue sur " << endl; - sleep(1); + multicolor("Bievenue sur Chess Colorful Console Game", BOLD); + cout << endl << endl; + cout << "by " << endl; + sleep(3); // On initialise la partie ctx.init(); @@ -173,7 +175,6 @@ void chess_input(int* origin, int* dest){ cout << "Piece a deplacer (XN) : "; cin >> coord; Piece::decode(coord, origin); - cout << endl; cout << "Deplacer vers (XN) : "; cin >> coord; diff --git a/Chess/main.o b/Chess/main.o index 842c88b..a1d3818 100644 Binary files a/Chess/main.o and b/Chess/main.o differ