diff --git a/ChessUtils.cpp b/ChessUtils.cpp index c4998fb..3df7a7b 100644 --- a/ChessUtils.cpp +++ b/ChessUtils.cpp @@ -17,7 +17,7 @@ std::vector ChessUtils::split(const std::string &s, char delim) { } return elems; } - +//a4 std::pair ChessUtils::convertPosition(const std::string &pos) { int y = pos[pos.size()-2] - 'a'; int x = ChessUtils::fileConvertion.find((pos[pos.size()-1] - '0')-1)->second; diff --git a/Chessboard.cpp b/Chessboard.cpp index a4680a1..f567ab0 100644 --- a/Chessboard.cpp +++ b/Chessboard.cpp @@ -228,6 +228,8 @@ void Chessboard::move(std::string move) { board[oldCoords.first][oldCoords.second] = getEmptyBoard()[oldCoords.first][oldCoords.second]; board[newCoords.first][newCoords.second] = getCorrectPiece(splitMove[0][0]); + //e4-e5 + Chessboard::draw(board); // Notation @@ -244,12 +246,14 @@ void Chessboard::move(std::string move) { // Special: // 0-0 short castle // 0-0-0 long castle - // en passond: write square where pawn lands + // en passant: write square where pawn lands + // Umwandlung: g8=R,Q,N,B (Wo gehst du hin = Was wirst du) // capture: x // check: + // checkmate: # // draw/stalemate: 1/2-1/2 + } // This method saves the current board state diff --git a/Chesspiece.cpp b/Chesspiece.cpp index d9d10ae..45fd884 100644 --- a/Chesspiece.cpp +++ b/Chesspiece.cpp @@ -4,19 +4,19 @@ #include "Chesspiece.h" -Chesspiece::Chesspiece(char color, char identifier) - : color(color), identifier(identifier) {} +Chesspiece::Chesspiece(char color, std::pair position) + : color(color), position(position) {} std::pair Chesspiece::getPosition() { return this->position; }; void Chesspiece::setPosition(std::pair position) { this->position = position; - calcAvaibleMoves(); + Chesspiece::calcAvaibleMoves(); // Brett -> Auswahl Figuren -> Züge gewählte } char Chesspiece::getColor() { return color; } void Chesspiece::setColor(char color) { color = color; } -std::vector Chesspiece::getPositions() { return positions; } +std::vector Chesspiece::getAvaibleMoves() { return avaibleMoves; } bool Chesspiece::checkNotation(std::string notation) { std::regex pattern("R^([KQRNBP]?)([a-h][1-8])[-x]([a-h][1-8])([+#]?)$"); diff --git a/Chesspiece.h b/Chesspiece.h index 8763bad..2b4784a 100644 --- a/Chesspiece.h +++ b/Chesspiece.h @@ -18,15 +18,16 @@ private: /* fields */ // ToDo: von char auf enum Color {W, B} umstellen char color; - char identifier; + char identifier; // P,K,... std::pair position; - std::vector positions; + // std::vector> + std::vector avaibleMoves; /* methods */ virtual std::vector calcAvaibleMoves() = 0; public: - Chesspiece(char color, char identifier); + Chesspiece(char color, std::pair position); virtual ~Chesspiece() = default; @@ -36,7 +37,7 @@ public: char getColor(); void setColor(char color); - std::vector getPositions(); + std::vector getAvaibleMoves(); bool checkNotation(std::string notation); }; diff --git a/Pawn.cpp b/Pawn.cpp index 2d78a17..3a75b8b 100644 --- a/Pawn.cpp +++ b/Pawn.cpp @@ -11,8 +11,10 @@ std::vector Pawn::calcAvaibleMoves() { std::pair pos = Chesspiece::getPosition(); std::vector moves; - if (this->firstMove) { + //current + if (this->firstMove) { + //vector[8] => MoveList(1-1;2-2+) //moves. } @@ -21,7 +23,4 @@ std::vector Pawn::calcAvaibleMoves() { return moves; } -Pawn::Pawn(char color, std::pair position): Chesspiece(color, 'P') { - setPosition(position); - setColor(color); -} +Pawn::Pawn(char color, std::pair position): Chesspiece(color, position) {} \ No newline at end of file diff --git a/README.md b/README.md index 752893f..2fd5ce4 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ 6. Springer 3. Fancy User Interface 4. Speicherung des Spielbretts +5. Unentschieden anbieten +6. Aufgegeben ### Spielbrett @@ -49,12 +51,20 @@ - Movement: Vertikal und Horizontal - Springer: - Movement: L-Bewegung (2 nach vorn + 1 nach links oder rechts); Krake +- Spezial Moves: + - Rochade -> Kurz/Lang + - En Passant + - Stalemate + - Bauer: 2 Felder + - Umwandeln ## Optional wenn Lust und Zeit? 1. Bedienung per Maus 2. Multiplayer 3. Historie der Spielzüge +4. Gravejard der geschlagenen Figuren +5. König platzieren -> Anzeigen wer gewinnt # Gedankensammlung - Initialisierung: diff --git a/main.cpp b/main.cpp index 415a465..858a667 100644 --- a/main.cpp +++ b/main.cpp @@ -9,9 +9,9 @@ int main() { //Pawn pawn('w', {1,6}); Chessboard chessboard; - chessboard.init(); - /*chessboard.draw(); - chessboard.move("Pb2-b3");*/ + //chessboard.init(); + chessboard.draw(); + /*chessboard.move("Pb2-b3");*/ return 0; } diff --git a/main.exe b/main.exe index 05c9780..c0685dd 100644 Binary files a/main.exe and b/main.exe differ