diff --git a/Chessboard.cpp b/Chessboard.cpp index 7b53f1f..49f68fa 100644 --- a/Chessboard.cpp +++ b/Chessboard.cpp @@ -2,7 +2,6 @@ // Created by hamac on 18.12.2024. // -#include "Chessboard.h" #include "Utils.cpp" #include #include @@ -28,47 +27,48 @@ class Chessboard { const std::string middleIntersection = "┼"; // White pieces - const std::string whiteSquare = "\u25A1"; - const std::string whiteKing = "\u2654"; - const std::string whiteQueen = "\u2655"; - const std::string whiteRook = "\u2656"; - const std::string whiteBischop = "\u2657"; - const std::string whiteKnight = "\u2658"; - const std::string whitePawn = "\u2659"; + const std::string whiteSquare = "□"; + const std::string whiteKing = "♔"; + const std::string whiteQueen = "♕"; + const std::string whiteRook = "♖"; + const std::string whiteBischop = "♗"; + const std::string whiteKnight = "♘"; + const std::string whitePawn = "♙"; // Black pieces - const std::string blackSquare = "\u25A0"; - const std::string blackKing = "\u265A"; - const std::string blackQueen = "\u265B"; - const std::string blackRook = "\u265C"; - const std::string blackBischop = "\u265D"; - const std::string blackKnight = "\u265E"; - const std::string blackPawn = "\u265F"; + const std::string blackSquare = "■"; + const std::string blackKing = "♚"; + const std::string blackQueen = "♛"; + const std::string blackRook = "♜"; + const std::string blackBischop = "♝"; + const std::string blackKnight = "♞"; + const std::string blackPawn = "♟"; /* class fields */ std::vector> currentBoard; // Starting formatting std::vector> startBoard = { - {'R', 'N', 'B', 'Q', 'K', 'B', 'N', 'R'}, - {'P', 'P', 'P', 'P', 'P', 'P', 'P', 'P'}, - {'x', 'w', 'x', 'w', 'x', 'w', 'x', 'w'}, - {'w', 'x', 'w', 'x' ,'w', 'x', 'w', 'x'}, - {'x', 'w', 'x', 'w', 'x', 'w', 'x', 'w'}, - {'w', 'x', 'w', 'x' ,'w', 'x', 'w', 'x'}, - {'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p'}, - {'r', 'n', 'b', 'q', 'k', 'b', 'n', 'r'}, + {'r', 'n', 'b', 'q', 'k', 'b', 'n', 'r'}, + {'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p'}, + {'w', 'x', 'w', 'x' ,'w', 'x', 'w', 'x'}, + {'x', 'w', 'x', 'w', 'x', 'w', 'x', 'w'}, + {'w', 'x', 'w', 'x' ,'w', 'x', 'w', 'x'}, + {'x', 'w', 'x', 'w', 'x', 'w', 'x', 'w'}, + {'P', 'P', 'P', 'P', 'P', 'P', 'P', 'P'}, + {'R', 'N', 'B', 'Q', 'K', 'B', 'N', 'R'}, }; + // ToDo: Mathematisch sicherlich weg rationalisierbar std::vector> emptyBoard = { - {'x', 'w', 'x', 'w', 'x', 'w', 'x', 'w'}, - {'w', 'x', 'w', 'x' ,'w', 'x', 'w', 'x'}, - {'x', 'w', 'x', 'w', 'x', 'w', 'x', 'w'}, - {'w', 'x', 'w', 'x' ,'w', 'x', 'w', 'x'}, - {'x', 'w', 'x', 'w', 'x', 'w', 'x', 'w'}, - {'w', 'x', 'w', 'x' ,'w', 'x', 'w', 'x'}, - {'x', 'w', 'x', 'w', 'x', 'w', 'x', 'w'}, - {'w', 'x', 'w', 'x' ,'w', 'x', 'w', 'x'} + {'w', 'x', 'w', 'x' ,'w', 'x', 'w', 'x'}, + {'x', 'w', 'x', 'w', 'x', 'w', 'x', 'w'}, + {'w', 'x', 'w', 'x' ,'w', 'x', 'w', 'x'}, + {'x', 'w', 'x', 'w', 'x', 'w', 'x', 'w'}, + {'w', 'x', 'w', 'x' ,'w', 'x', 'w', 'x'}, + {'x', 'w', 'x', 'w', 'x', 'w', 'x', 'w'}, + {'w', 'x', 'w', 'x' ,'w', 'x', 'w', 'x'}, + {'x', 'w', 'x', 'w', 'x', 'w', 'x', 'w'} }; // Saves turn order; true = white and false = black @@ -206,24 +206,10 @@ class Chessboard { // Angabe mit Menü Optionen als Zahlen // Figuren wählen mit Schachnotation - int getCorrectPiece(char pieceIdentifier) { + char getCorrectPiece(char pieceIdentifier) { bool isWhite = getTurnOrder(); - - static const std::unordered_map pieceMap = { - {'P', 200}, - {'K', 205}, - {'Q', 204}, - {'N', 202}, - {'R', 201}, - {'B', 203} - }; - - int piece = pieceMap.find(pieceIdentifier)->second; - - if (isWhite) { - return piece - 100; - } - return piece; + if (!isWhite) return pieceIdentifier + 32; + return pieceIdentifier; } std::pair convertPosition(const std::string &pos) { @@ -271,8 +257,6 @@ class Chessboard { std::vector> board = getBoard(); - getCorrectPiece(board[oldCoords.first][oldCoords.second]); - board[oldCoords.first][oldCoords.second] = getEmptyBoard()[oldCoords.first][oldCoords.second]; board[newCoords.first][newCoords.second] = getCorrectPiece(splitMove[0][0]); diff --git a/Chessboard.h b/Chessboard.h deleted file mode 100644 index 4078422..0000000 --- a/Chessboard.h +++ /dev/null @@ -1,8 +0,0 @@ -// -// Created by hamac on 18.12.2024. -// - -#ifndef CHESSBOARD_H -#define CHESSBOARD_H - -#endif //CHESSBOARD_H diff --git a/Chesspieces.h b/Chesspieces.h deleted file mode 100644 index 75c8350..0000000 --- a/Chesspieces.h +++ /dev/null @@ -1,27 +0,0 @@ -// -// Created by hamac on 18.12.2024. -// - -#include -#include - -#ifndef CHESSPIECES_H -#define CHESSPIECES_H - -#endif //CHESSPIECES_H - -class Chesspiece { -private: - char color; - std::string position; - virtual std::vector calcAvaibleMoves() {} - -public: - std::string getPosition(); - void setPosition(std::string position); - - char getColor(); - void setColor(char color); - - std::vector getPositions(); -}; diff --git a/Pawn.cpp b/Pawn.cpp new file mode 100644 index 0000000..ba558b2 --- /dev/null +++ b/Pawn.cpp @@ -0,0 +1,3 @@ +// +// Created by hamac on 19.12.2024. +//