diff --git a/Chess/dep/Grid.cpp b/Chess/dep/Grid.cpp new file mode 100644 index 0000000..e69de29 diff --git a/Chess/dep/Grid.h b/Chess/dep/Grid.h new file mode 100644 index 0000000..2037835 --- /dev/null +++ b/Chess/dep/Grid.h @@ -0,0 +1,37 @@ +#ifndef DEF_GRID + + #define DEF_GRID + + /* [1] Libs + =========================================================*/ + /* (1) Internes */ + #include + #include + #include + + /* (2) Externes */ + #include "term.h" + #include "Pieces/PieceFactory.h" + + /* (3) Namespace */ + using namespace std; + + + /* [2] Definition + =========================================================*/ + class Grid{ + public: + Grid(const int w=8, const int h=8); + + // GETTERS + Piece pieceAt(const int x, const int y) const; + + private: + // vector _cells; + }; + + /* [n] Inclusion du corps + =========================================================*/ + #include "Grid.cpp" + +#endif \ No newline at end of file diff --git a/Chess/dep/Pieces/Cavalier.cpp b/Chess/dep/Pieces/Cavalier.cpp new file mode 100644 index 0000000..774178a --- /dev/null +++ b/Chess/dep/Pieces/Cavalier.cpp @@ -0,0 +1,13 @@ + +Cavalier::Cavalier(int x, int y) : Piece(CAVALIER, x, y) { + +} + +// ABSTRACT +bool Cavalier::can(const int x, const int y) const{ + return true; +} + +char Cavalier::getchar(){ + return 'P'; +} diff --git a/Chess/dep/Pieces/Cavalier.h b/Chess/dep/Pieces/Cavalier.h new file mode 100644 index 0000000..d2941bc --- /dev/null +++ b/Chess/dep/Pieces/Cavalier.h @@ -0,0 +1,31 @@ +#ifndef DEF_CAVALIER + + #define DEF_CAVALIER + + /* [1] Libs + =========================================================*/ + /* (1) Internes */ + + /* (2) Externes */ + #include "Piece.h" + + /* (3) Namespace */ + using namespace std; + + /* [2] Definition + =========================================================*/ + class Cavalier : public Piece{ + public: + Cavalier(int x, int y); + + // ABSTRACT + bool can(const int x, const int y) const; + char getchar(); + + }; + + /* [n] Inclusion du corps + =========================================================*/ + #include "Cavalier.cpp" + +#endif \ No newline at end of file diff --git a/Chess/dep/Pieces/Fou.cpp b/Chess/dep/Pieces/Fou.cpp new file mode 100644 index 0000000..46ab666 --- /dev/null +++ b/Chess/dep/Pieces/Fou.cpp @@ -0,0 +1,13 @@ + +Fou::Fou(int x, int y) : Piece(FOU, x, y) { + +} + +// ABSTRACT +bool Fou::can(const int x, const int y) const{ + return true; +} + +char Fou::getchar(){ + return 'P'; +} diff --git a/Chess/dep/Pieces/Fou.h b/Chess/dep/Pieces/Fou.h new file mode 100644 index 0000000..926d788 --- /dev/null +++ b/Chess/dep/Pieces/Fou.h @@ -0,0 +1,31 @@ +#ifndef DEF_FOU + + #define DEF_FOU + + /* [1] Libs + =========================================================*/ + /* (1) Internes */ + + /* (2) Externes */ + #include "Piece.h" + + /* (3) Namespace */ + using namespace std; + + /* [2] Definition + =========================================================*/ + class Fou : public Piece{ + public: + Fou(int x, int y); + + // ABSTRACT + bool can(const int x, const int y) const; + char getchar(); + + }; + + /* [n] Inclusion du corps + =========================================================*/ + #include "Fou.cpp" + +#endif \ No newline at end of file diff --git a/Chess/dep/Pieces/Piece.cpp b/Chess/dep/Pieces/Piece.cpp new file mode 100644 index 0000000..7c552c3 --- /dev/null +++ b/Chess/dep/Pieces/Piece.cpp @@ -0,0 +1,23 @@ +Piece::Piece(PIECE_TYPE t, int x, int y) : _t(t), _x(x), _y(y){ +} + +// GETTERS +PIECE_TYPE Piece::gett() const{ return _t; } + +int Piece::getx() const{ return _x; } +int Piece::gety() const{ return _y; } + +// SETTERS +void Piece::move(const int x, const int y){ + _x = x; + _y = y; +} + +// OPERATEURS (SURCHARGE) +ostream& operator<<(ostream& o, const Piece& p){ + return o << p._t << " at (" << p._x << "," << p._y << ")"; +} + +// ABTRACT +bool Piece::can(const int x, const 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 new file mode 100644 index 0000000..ad3ba45 --- /dev/null +++ b/Chess/dep/Pieces/Piece.h @@ -0,0 +1,72 @@ +#ifndef DEF_PIECE + + #define DEF_PIECE + + /* [1] Libs + =========================================================*/ + /* (1) Internes */ + #include + #include + #include + + /* (2) Externes */ + + /* (3) Namespace */ + using namespace std; + + /* [2] Enumerations + =========================================================*/ + enum PIECE_TYPE{ + ROI, + REINE, + CAVALIER, + TOUR, + FOU, + PION + }; + ostream& operator<<(ostream& o, const PIECE_TYPE& t){ + switch(t){ + case ROI: return o << "Roi"; break; + case REINE: return o << "Reine"; break; + case CAVALIER: return o << "Cavalier"; break; + case FOU: return o << "Fou"; break; + case TOUR: return o << "Tour"; break; + case PION: return o << "Pion"; break; + } + + return o << "UNKNOWN"; + } + + + /* [2] Definition + =========================================================*/ + class Piece{ + public: + Piece(PIECE_TYPE t, int x, int y); + + // GETTERS + PIECE_TYPE gett() const; + int getx() const; + int gety() const; + + // SETTERS + void move(const int x, const int y); + + // OPERATEURS (SURCHARGE) + friend ostream& operator<<(ostream& o, const Piece& p); + + // ABSTRACT + virtual bool can(const int x, const int y); + virtual char getchar(); + + protected: + PIECE_TYPE _t; + int _x; + int _y; + }; + + /* [n] Inclusion du corps + =========================================================*/ + #include "Piece.cpp" + +#endif \ No newline at end of file diff --git a/Chess/dep/Pieces/PieceFactory.cpp b/Chess/dep/Pieces/PieceFactory.cpp new file mode 100644 index 0000000..13e81e4 --- /dev/null +++ b/Chess/dep/Pieces/PieceFactory.cpp @@ -0,0 +1,14 @@ +Piece& PieceFactory::create(PIECE_TYPE t, int x, int y){ + Piece *p; + + switch(t){ + case ROI: p = new Roi(x, y); break; + case REINE: p = new Reine(x, y); break; + case CAVALIER: p = new Cavalier(x, y); break; + case FOU: p = new Fou(x, y); break; + case TOUR: p = new Tour(x, y); break; + case PION: p = new Pion(x, y); break; + } + + return *p; +} diff --git a/Chess/dep/Pieces/PieceFactory.h b/Chess/dep/Pieces/PieceFactory.h new file mode 100644 index 0000000..f98f685 --- /dev/null +++ b/Chess/dep/Pieces/PieceFactory.h @@ -0,0 +1,30 @@ +#ifndef DEF_PIECEFACTORY + + #define DEF_PIECEFACTORY + + /* [1] Libs + =========================================================*/ + /* (1) Externes */ + #include "Roi.h" + #include "Reine.h" + #include "Cavalier.h" + #include "Tour.h" + #include "Fou.h" + #include "Pion.h" + + /* (2) Namespace */ + using namespace std; + + /* [2] Definition + =========================================================*/ + class PieceFactory{ + public: + static Piece& create(PIECE_TYPE t, int x, int y); + + }; + + /* [n] Inclusion du corps + =========================================================*/ + #include "PieceFactory.cpp" + +#endif \ No newline at end of file diff --git a/Chess/dep/Pieces/Pion.cpp b/Chess/dep/Pieces/Pion.cpp new file mode 100644 index 0000000..38c6add --- /dev/null +++ b/Chess/dep/Pieces/Pion.cpp @@ -0,0 +1,13 @@ + +Pion::Pion(int x, int y) : Piece(PION, x, y) { + +} + +// ABSTRACT +bool Pion::can(const int x, const int y) const{ + return true; +} + +char Pion::getchar(){ + return 'P'; +} diff --git a/Chess/dep/Pieces/Pion.h b/Chess/dep/Pieces/Pion.h new file mode 100644 index 0000000..bff2dcc --- /dev/null +++ b/Chess/dep/Pieces/Pion.h @@ -0,0 +1,31 @@ +#ifndef DEF_PION + + #define DEF_PION + + /* [1] Libs + =========================================================*/ + /* (1) Internes */ + + /* (2) Externes */ + #include "Piece.h" + + /* (3) Namespace */ + using namespace std; + + /* [2] Definition + =========================================================*/ + class Pion : public Piece{ + public: + Pion(int x, int y); + + // ABSTRACT + bool can(const int x, const int y) const; + char getchar(); + + }; + + /* [n] Inclusion du corps + =========================================================*/ + #include "Pion.cpp" + +#endif \ No newline at end of file diff --git a/Chess/dep/Pieces/Reine.cpp b/Chess/dep/Pieces/Reine.cpp new file mode 100644 index 0000000..d33f8bb --- /dev/null +++ b/Chess/dep/Pieces/Reine.cpp @@ -0,0 +1,13 @@ + +Reine::Reine(int x, int y) : Piece(REINE, x, y) { + +} + +// ABSTRACT +bool Reine::can(const int x, const int y) const{ + return true; +} + +char Reine::getchar(){ + return 'P'; +} diff --git a/Chess/dep/Pieces/Reine.h b/Chess/dep/Pieces/Reine.h new file mode 100644 index 0000000..7915bc2 --- /dev/null +++ b/Chess/dep/Pieces/Reine.h @@ -0,0 +1,31 @@ +#ifndef DEF_REINE + + #define DEF_REINE + + /* [1] Libs + =========================================================*/ + /* (1) Internes */ + + /* (2) Externes */ + #include "Piece.h" + + /* (3) Namespace */ + using namespace std; + + /* [2] Definition + =========================================================*/ + class Reine : public Piece{ + public: + Reine(int x, int y); + + // ABSTRACT + bool can(const int x, const int y) const; + char getchar(); + + }; + + /* [n] Inclusion du corps + =========================================================*/ + #include "Reine.cpp" + +#endif \ No newline at end of file diff --git a/Chess/dep/Pieces/Roi.cpp b/Chess/dep/Pieces/Roi.cpp new file mode 100644 index 0000000..7717f4b --- /dev/null +++ b/Chess/dep/Pieces/Roi.cpp @@ -0,0 +1,13 @@ + +Roi::Roi(int x, int y) : Piece(ROI, x, y) { + +} + +// ABSTRACT +bool Roi::can(const int x, const int y) const{ + return true; +} + +char Roi::getchar(){ + return 'R'; +} diff --git a/Chess/dep/Pieces/Roi.h b/Chess/dep/Pieces/Roi.h new file mode 100644 index 0000000..2bad8be --- /dev/null +++ b/Chess/dep/Pieces/Roi.h @@ -0,0 +1,31 @@ +#ifndef DEF_Roi + + #define DEF_Roi + + /* [1] Libs + =========================================================*/ + /* (1) Internes */ + + /* (2) Externes */ + #include "Piece.h" + + /* (3) Namespace */ + using namespace std; + + /* [2] Definition + =========================================================*/ + class Roi : public Piece{ + public: + Roi(int x, int y); + + // ABSTRACT + bool can(const int x, const int y) const; + char getchar(); + + }; + + /* [n] Inclusion du corps + =========================================================*/ + #include "Roi.cpp" + +#endif \ No newline at end of file diff --git a/Chess/dep/Pieces/Tour.cpp b/Chess/dep/Pieces/Tour.cpp new file mode 100644 index 0000000..76d8aab --- /dev/null +++ b/Chess/dep/Pieces/Tour.cpp @@ -0,0 +1,13 @@ + +Tour::Tour(int x, int y) : Piece(TOUR, x, y) { + +} + +// ABSTRACT +bool Tour::can(const int x, const int y) const{ + return true; +} + +char Tour::getchar(){ + return 'P'; +} diff --git a/Chess/dep/Pieces/Tour.h b/Chess/dep/Pieces/Tour.h new file mode 100644 index 0000000..b490532 --- /dev/null +++ b/Chess/dep/Pieces/Tour.h @@ -0,0 +1,31 @@ +#ifndef DEF_TOUR + + #define DEF_TOUR + + /* [1] Libs + =========================================================*/ + /* (1) Internes */ + + /* (2) Externes */ + #include "Piece.h" + + /* (3) Namespace */ + using namespace std; + + /* [2] Definition + =========================================================*/ + class Tour : public Piece{ + public: + Tour(int x, int y); + + // ABSTRACT + bool can(const int x, const int y) const; + char getchar(); + + }; + + /* [n] Inclusion du corps + =========================================================*/ + #include "Tour.cpp" + +#endif \ No newline at end of file diff --git a/Chess/dep/term.cpp b/Chess/dep/term.cpp new file mode 100644 index 0000000..a6a551f --- /dev/null +++ b/Chess/dep/term.cpp @@ -0,0 +1,10 @@ + +/* [1] Operations terminal +=========================================================*/ +void clear(){ // efface l'ecran + cout << "\033[H\033[2J"; +} + +void setfont(const TERM_COLOR c, const TERM_STYLE s){ + cout << "\033[" << s << ";" << c << "m"; +} \ No newline at end of file diff --git a/Chess/dep/term.h b/Chess/dep/term.h new file mode 100644 index 0000000..5237c47 --- /dev/null +++ b/Chess/dep/term.h @@ -0,0 +1,47 @@ +#ifndef DEF_TERM + + #define DEF_TERM + + /* [1] Libs + =========================================================*/ + /* (1) internes */ + #include + + /* (2) Namespace */ + using namespace std; + + + /* [2] Enumerations et structures + =========================================================*/ + enum TERM_COLOR{ + DEFAULT = 0, + + DARKBLUE = 30, + RED = 31, + GREEN = 32, + YELLOW = 33, + BLUE = 34, + PURPLE = 35, + SKYBLUE = 36 + }; + + enum TERM_STYLE{ + NORMAL = 0, + BOLD = 1, + ITALIC = 3, + UNDERLINE = 4, + DASHED = 9, + + BACKGROUND = 7 + }; + + /* [3] Methodes + =========================================================*/ + void clear(); + void setfont(const TERM_COLOR c=DEFAULT, const TERM_STYLE s=NORMAL); + + /* [n] Inclusion du corps + =========================================================*/ + #include "term.cpp" + +#endif \ No newline at end of file diff --git a/Chess/e b/Chess/e new file mode 100755 index 0000000..9abe399 Binary files /dev/null and b/Chess/e differ diff --git a/Chess/main.cpp b/Chess/main.cpp new file mode 100644 index 0000000..5d4cfd8 --- /dev/null +++ b/Chess/main.cpp @@ -0,0 +1,22 @@ +#include "main.h" + +/* [0] Point d'amorcage +=========================================================*/ +int main(){ + Piece *a = new Roi(1, 12); + Piece *b = new Pion(1, 12); + + + setfont(RED); + cout << *a << endl; + + setfont(SKYBLUE); + cout << *b << endl; + cout << *b << endl; + + + setfont(); + return 0; +} + + diff --git a/Chess/main.h b/Chess/main.h new file mode 100644 index 0000000..e855e20 --- /dev/null +++ b/Chess/main.h @@ -0,0 +1,28 @@ +#ifndef DEF_HEADER + + #define DEF_HEADER + + /* [1] Libs + =========================================================*/ + /* (1) internes */ + #include + #include + #include + + /* (2) Externes */ + #include "dep/term.h" + #include "dep/Grid.h" + + /* (3) Namespace */ + using namespace std; + + + /* [2] Enumerations et structures + =========================================================*/ + + + /* [3] Methodes + =========================================================*/ + int main(); + +#endif \ No newline at end of file