Compare commits
2 Commits
de0cbf5a8b
...
85d22b4736
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
85d22b4736 | ||
|
|
d1286469c3 |
@@ -64,6 +64,40 @@ void ChessboardVisualizerGraphic::SetConsoleColor(Colors foreground, Colors back
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChessboardVisualizerGraphic::GenerateChessboard(Chessboard* chessboard) {
|
||||||
|
ClearTerminal();
|
||||||
|
|
||||||
|
GeneratePlayers(chessboard);
|
||||||
|
|
||||||
|
for (int rank = 8; rank >= 1; rank--) {
|
||||||
|
if (rank == 8) GenerateTopOrBottomBorder(true);
|
||||||
|
|
||||||
|
std::vector<std::string> temp;
|
||||||
|
|
||||||
|
for (int heightOfField = 0; heightOfField < 3; heightOfField++) {
|
||||||
|
for (char file = 'A'; file <= 'H'; file++) {
|
||||||
|
if (file == 'A') {
|
||||||
|
temp.push_back((heightOfField == 1) ? " " + std::to_string(rank) + " " : " ");
|
||||||
|
temp.push_back(ChessboardVisualizerGraphic::VERTICAL_LINE);
|
||||||
|
}
|
||||||
|
|
||||||
|
temp.push_back(GenerateBoardField(chessboard, file, rank, heightOfField));
|
||||||
|
|
||||||
|
if (file == 'H') {
|
||||||
|
this->SetConsoleColor(DEFAULT, DEFAULT);
|
||||||
|
temp.push_back(ChessboardVisualizerGraphic::VERTICAL_LINE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AddRowToBoard(temp);
|
||||||
|
temp.clear();
|
||||||
|
this->SetConsoleColor(DEFAULT, DEFAULT);
|
||||||
|
}
|
||||||
|
if (rank == 1) GenerateTopOrBottomBorder(false);
|
||||||
|
}
|
||||||
|
this->SetConsoleColor(DEFAULT, DEFAULT);
|
||||||
|
DrawFromVector();
|
||||||
|
}
|
||||||
|
|
||||||
void ChessboardVisualizerGraphic::Draw(Chessboard* chessboard) {
|
void ChessboardVisualizerGraphic::Draw(Chessboard* chessboard) {
|
||||||
ClearTerminal();
|
ClearTerminal();
|
||||||
|
|
||||||
@@ -95,28 +129,92 @@ void ChessboardVisualizerGraphic::Draw(Chessboard* chessboard) {
|
|||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChessboardVisualizerGraphic::GenerateTopOrBottomBorder(bool top) {
|
||||||
|
std::vector<std::string> temp;
|
||||||
|
|
||||||
|
temp.push_back(" ");
|
||||||
|
|
||||||
|
std::string left = (top) ? ChessboardVisualizerGraphic::TOP_LEFT_CORNER : ChessboardVisualizerGraphic::BOTTOM_LEFT_CORNER;
|
||||||
|
temp.push_back(left);
|
||||||
|
|
||||||
|
for (int i = 0; i < 8; i++) {
|
||||||
|
temp.push_back(ChessboardVisualizerGraphic::HORIZONTAL_LINE + ChessboardVisualizerGraphic::HORIZONTAL_LINE + ChessboardVisualizerGraphic::HORIZONTAL_LINE + ChessboardVisualizerGraphic::HORIZONTAL_LINE + ChessboardVisualizerGraphic::HORIZONTAL_LINE + ChessboardVisualizerGraphic::HORIZONTAL_LINE + ChessboardVisualizerGraphic::HORIZONTAL_LINE);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string right = (top) ? ChessboardVisualizerGraphic::TOP_RIGHT_CORNER : ChessboardVisualizerGraphic::BOTTOM_RIGHT_CORNER;
|
||||||
|
temp.push_back(right);
|
||||||
|
|
||||||
|
AddRowToBoard(temp);
|
||||||
|
if (!top) GenerateFiles();
|
||||||
|
}
|
||||||
|
|
||||||
void ChessboardVisualizerGraphic::DrawTopOrBottomBorder(bool top) {
|
void ChessboardVisualizerGraphic::DrawTopOrBottomBorder(bool top) {
|
||||||
std::cout << " ";
|
std::cout << " ";
|
||||||
|
|
||||||
std::string left = (top) ? ChessboardVisualizerGraphic::TOP_LEFT_CORNER : ChessboardVisualizerGraphic::BOTTOM_LEFT_CORNER;
|
std::string left = (top) ? ChessboardVisualizerGraphic::TOP_LEFT_CORNER : ChessboardVisualizerGraphic::BOTTOM_LEFT_CORNER;
|
||||||
std::string right = (top) ? ChessboardVisualizerGraphic::TOP_RIGHT_CORNER : ChessboardVisualizerGraphic::BOTTOM_RIGHT_CORNER;
|
|
||||||
std::cout << left;
|
std::cout << left;
|
||||||
|
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
std::cout << ChessboardVisualizerGraphic::HORIZONTAL_LINE << ChessboardVisualizerGraphic::HORIZONTAL_LINE << ChessboardVisualizerGraphic::HORIZONTAL_LINE << ChessboardVisualizerGraphic::HORIZONTAL_LINE << ChessboardVisualizerGraphic::HORIZONTAL_LINE << ChessboardVisualizerGraphic::HORIZONTAL_LINE << ChessboardVisualizerGraphic::HORIZONTAL_LINE;
|
std::cout << ChessboardVisualizerGraphic::HORIZONTAL_LINE << ChessboardVisualizerGraphic::HORIZONTAL_LINE << ChessboardVisualizerGraphic::HORIZONTAL_LINE << ChessboardVisualizerGraphic::HORIZONTAL_LINE << ChessboardVisualizerGraphic::HORIZONTAL_LINE << ChessboardVisualizerGraphic::HORIZONTAL_LINE << ChessboardVisualizerGraphic::HORIZONTAL_LINE;
|
||||||
}
|
}
|
||||||
std::cout << right << std::endl;
|
|
||||||
|
|
||||||
if (!top) {
|
std::string right = (top) ? ChessboardVisualizerGraphic::TOP_RIGHT_CORNER : ChessboardVisualizerGraphic::BOTTOM_RIGHT_CORNER;
|
||||||
for (char file = 'A'; file <= 'H'; file++) {
|
std::cout << right;
|
||||||
if (file == 'A') {
|
|
||||||
std::cout << " ";
|
std::cout << std::endl;
|
||||||
std::cout << " ";
|
if (!top) DrawFiles();
|
||||||
}
|
}
|
||||||
std::cout << " " << file << " ";
|
|
||||||
if (file == 'H') {
|
void ChessboardVisualizerGraphic::GenerateFiles() {
|
||||||
std::cout << " ";
|
std::vector<std::string> temp;
|
||||||
}
|
|
||||||
|
for (char file = 'A'; file <= 'H'; file++) {
|
||||||
|
if (file == 'A') {
|
||||||
|
temp.push_back(" ");
|
||||||
}
|
}
|
||||||
std::cout << std::endl;
|
|
||||||
|
temp.push_back(" " + std::string(1, file) + " ");
|
||||||
|
|
||||||
|
if (file == 'H') {
|
||||||
|
temp.push_back(" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AddRowToBoard(temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChessboardVisualizerGraphic::DrawFiles() {
|
||||||
|
for (char file = 'A'; file <= 'H'; file++) {
|
||||||
|
if (file == 'A') {
|
||||||
|
std::cout << " ";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << " " << file << " ";
|
||||||
|
|
||||||
|
if (file == 'H') {
|
||||||
|
std::cout << " ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::cout << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string ChessboardVisualizerGraphic::GenerateBoardField(Chessboard* chessboard, char file, int rank, int height) {
|
||||||
|
if (file % 2 == (rank % 2)) {
|
||||||
|
this->SetConsoleColor(BLACK, WHITE);
|
||||||
|
} else {
|
||||||
|
this->SetConsoleColor(WHITE, BLACK);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (height == 1) {
|
||||||
|
ChessPiecePosition* position = new ChessPiecePosition(file, rank);
|
||||||
|
|
||||||
|
if (chessboard->IsEmptyField(position)) {
|
||||||
|
return " ";
|
||||||
|
} else {
|
||||||
|
ChessPiece* piece = chessboard->GetChessPiece(position);
|
||||||
|
return " " + piece->GetUnicode() + " ";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return " ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,7 +243,50 @@ void ChessboardVisualizerGraphic::ClearTerminal() {
|
|||||||
std::cout << "\033[2J"; // clear the console
|
std::cout << "\033[2J"; // clear the console
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChessboardVisualizerGraphic::GeneratePlayers(Chessboard* chessboard) {
|
||||||
|
std::vector<std::string> temp;
|
||||||
|
temp.push_back(" ");
|
||||||
|
temp.push_back(chessboard->GetPlayer(ChessPieceColor::White)->GetName() + " vs. " + chessboard->GetPlayer(ChessPieceColor::Black)->GetName());
|
||||||
|
AddRowToBoard(temp);
|
||||||
|
}
|
||||||
|
|
||||||
void ChessboardVisualizerGraphic::DrawPlayers(Chessboard* chessboard) {
|
void ChessboardVisualizerGraphic::DrawPlayers(Chessboard* chessboard) {
|
||||||
std::cout << " " << chessboard->GetPlayer(ChessPieceColor::White)->GetName() << " vs. " << chessboard->GetPlayer(ChessPieceColor::Black)->GetName();
|
std::cout << " ";
|
||||||
|
std::cout << chessboard->GetPlayer(ChessPieceColor::White)->GetName() + " vs. " + chessboard->GetPlayer(ChessPieceColor::Black)->GetName();
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChessboardVisualizerGraphic::AddRowToBoard(const std::vector<std::string>& row) {
|
||||||
|
board.push_back(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
// board[2] bis board[25] Feld des Schachbretts
|
||||||
|
// in vectoren von 2 bis 25 index von 2 bis 9
|
||||||
|
void ChessboardVisualizerGraphic::DrawFromVector() {
|
||||||
|
for (int row = 0; row < board.size(); ++row) {
|
||||||
|
for (int column = 0; column < board[row].size(); ++column) {
|
||||||
|
if (row >= 2 && row <= 25 && column >= 2 && column <= 9) {
|
||||||
|
bool isSecondRowOfField = (row % 3 == 2);
|
||||||
|
bool isBlackWhite = (column % 2 == row % 2);
|
||||||
|
|
||||||
|
if ((row - 1) % 3 == 0) { // Change after 3 rows
|
||||||
|
if (isSecondRowOfField) {
|
||||||
|
this->SetConsoleColor(isBlackWhite ? WHITE : BLACK, isBlackWhite ? BLACK : WHITE);
|
||||||
|
} else {
|
||||||
|
this->SetConsoleColor(isBlackWhite ? BLACK : WHITE, isBlackWhite ? WHITE : BLACK);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (isSecondRowOfField) {
|
||||||
|
this->SetConsoleColor(isBlackWhite ? BLACK : WHITE, isBlackWhite ? WHITE : BLACK);
|
||||||
|
} else {
|
||||||
|
this->SetConsoleColor(isBlackWhite ? WHITE : BLACK, isBlackWhite ? BLACK : WHITE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::cout << board[row][column];
|
||||||
|
this->SetConsoleColor(DEFAULT, DEFAULT);
|
||||||
|
}
|
||||||
|
this->SetConsoleColor(DEFAULT, DEFAULT);
|
||||||
|
std::cout << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -21,15 +21,25 @@ class ChessboardVisualizerGraphic : public ChessboardVisualizer {
|
|||||||
inline static const std::string BOTTOM_RIGHT_CORNER = "\u255D";
|
inline static const std::string BOTTOM_RIGHT_CORNER = "\u255D";
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void SetConsoleColor(Colors foreground, Colors background);
|
std::vector<std::vector<std::string>> board;
|
||||||
void DrawTopOrBottomBorder(bool top);
|
|
||||||
void ClearTerminal();
|
void ClearTerminal();
|
||||||
|
void DrawTopOrBottomBorder(bool top);
|
||||||
|
void GenerateTopOrBottomBorder(bool top);
|
||||||
void DrawPlayers(Chessboard* chessboard);
|
void DrawPlayers(Chessboard* chessboard);
|
||||||
|
void GeneratePlayers(Chessboard* chessboard);
|
||||||
|
std::string GenerateBoardField(Chessboard* chessboard, char file, int rank, int height);
|
||||||
void DrawBoardField(Chessboard* chessboard, char file, int rank, int height);
|
void DrawBoardField(Chessboard* chessboard, char file, int rank, int height);
|
||||||
|
void DrawFiles();
|
||||||
|
void GenerateFiles();
|
||||||
|
void SetConsoleColor(Colors foreground, Colors background);
|
||||||
|
void SetColorsForField();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ChessboardVisualizerGraphic() = default;
|
ChessboardVisualizerGraphic() = default;
|
||||||
void Draw(Chessboard* chessboard);
|
void Draw(Chessboard* chessboard);
|
||||||
|
void GenerateChessboard(Chessboard* chessboard);
|
||||||
|
void DrawFromVector();
|
||||||
|
void AddRowToBoard(const std::vector<std::string>& row);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
1
Program/Display.cpp
Normal file
1
Program/Display.cpp
Normal file
@@ -0,0 +1 @@
|
|||||||
|
#include "Display.h"
|
||||||
41
Program/Display.hpp
Normal file
41
Program/Display.hpp
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
//
|
||||||
|
// Created by hamac on 10.01.2025.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef DISPLAY_H
|
||||||
|
#define DISPLAY_H
|
||||||
|
|
||||||
|
class Display {
|
||||||
|
public:
|
||||||
|
inline static std::vector<std::vector<std::string>> startMenu = {};
|
||||||
|
inline static std::vector<std::vector<std::string>> asciiArtTurboSchach = {
|
||||||
|
{"████████╗", "██╗░░░██╗", "██████╗░", "██████╗░", "░█████╗░", "░██████╗░", "█████╗░", "██╗░░██╗", "░█████╗░", "░█████╗░", "██╗░░██╗"},
|
||||||
|
{"╚══██╔══╝", "██║░░░██║", "██╔══██╗", "██╔══██╗", "██╔══██╗", "██╔════╝", "██╔══██╗", "██║░░██║", "██╔══██╗", "██╔══██╗", "██║░░██║"},
|
||||||
|
{"░░░██║░░░", "██║░░░██║", "██████╔╝", "██████╦╝", "██║░░██║", "╚█████╗░", "██║░░╚═╝", "███████║", "███████║", "██║░░╚═╝", "███████║"},
|
||||||
|
{"░░░██║░░░", "██║░░░██║", "██╔══██╗", "██╔══██╗", "██║░░██║", "░╚═══██╗", "██║░░██╗", "██╔══██║", "██╔══██║", "██║░░██╗", "██╔══██║"},
|
||||||
|
{"░░░██║░░░", "╚██████╔╝", "██║░░██║", "██████╦╝", "╚█████╔╝", "██████╔╝", "╚█████╔╝", "██║░░██║", "██║░░██║", "╚█████╔╝", "██║░░██║"},
|
||||||
|
{"░░░╚═╝░░░", "░╚═════╝░", "╚═╝░░╚═╝", "╚═════╝░", "░╚════╝░", "╚═════╝░", "░╚════╝░", "╚═╝░░╚═╝", "╚═╝░░╚═╝", "░╚════╝░", "╚═╝░░╚═╝"}
|
||||||
|
};
|
||||||
|
|
||||||
|
inline static std::vector<std::vector<std::string>> asciiArtMenu = {
|
||||||
|
{ "▒█▀▄▀█", "█▀▀", "█▀▀▄", "█░░█" },
|
||||||
|
{ "▒█▒█▒█", "█▀▀", "█░░█", "█░░█" },
|
||||||
|
{ "▒█░░▒█", "▀▀▀", "▀░░▀", "░▀▀▀" }
|
||||||
|
};
|
||||||
|
|
||||||
|
inline static const std::string TOP_LEFT_CORNER = "\u2554";
|
||||||
|
inline static const std::string TOP_RIGHT_CORNER = "\u2557";
|
||||||
|
inline static const std::string HORIZONTAL_LINE = "\u2550";
|
||||||
|
inline static const std::string VERTICAL_LINE = "\u2551";
|
||||||
|
inline static const std::string BOTTOM_LEFT_CORNER = "\u255A";
|
||||||
|
inline static const std::string BOTTOM_RIGHT_CORNER = "\u255D";
|
||||||
|
|
||||||
|
inline static const std::string TOP_LEFT_CORNER_SINGLE = "\u250C";
|
||||||
|
inline static const std::string TOP_RIGHT_CORNER_SINGLE = "\u2510";
|
||||||
|
inline static const std::string HORIZONTAL_LINE_SINGLE = "\u2500";
|
||||||
|
inline static const std::string VERTICAL_LINE_SINGLE = "\u2502";
|
||||||
|
inline static const std::string BOTTOM_LEFT_CORNER_SINGLE = "\u2514";
|
||||||
|
inline static const std::string BOTTOM_RIGHT_CORNER_SINGLE = "\u2518";
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //DISPLAY_H
|
||||||
230
main.cpp
230
main.cpp
@@ -5,11 +5,185 @@
|
|||||||
#include "Chessboard/Chessboard.hpp"
|
#include "Chessboard/Chessboard.hpp"
|
||||||
#include "Chessboard/ChessboardVisualizerText.hpp"
|
#include "Chessboard/ChessboardVisualizerText.hpp"
|
||||||
#include "Chessboard/ChessboardVisualizerGraphic.hpp"
|
#include "Chessboard/ChessboardVisualizerGraphic.hpp"
|
||||||
|
#include "Program/Display.hpp"
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#include <locale>
|
||||||
|
|
||||||
|
// Funktion zur Zählung von UTF-8-Zeichen
|
||||||
|
size_t countVisibleCharacters(const std::string& str) {
|
||||||
|
size_t count = 0;
|
||||||
|
for (size_t i = 0; i < str.size(); ++i) {
|
||||||
|
// UTF-8 Startbytes zählen (kein Fortsetzungsbyte)
|
||||||
|
if ((str[i] & 0b11000000) != 0b10000000) {
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
int GetSumAllCharsFromVector(const std::vector<std::string>& vec) {
|
||||||
|
int sum = 0;
|
||||||
|
for (const std::string& str : vec) {
|
||||||
|
sum += countVisibleCharacters(str);
|
||||||
|
}
|
||||||
|
return sum;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> GenerateEmptyLine(int lengthOfMenu) {
|
||||||
|
std::vector<std::string> result;
|
||||||
|
std::string string = "";
|
||||||
|
for (int i = 0; i < lengthOfMenu; ++i) {
|
||||||
|
if (i == 0) {
|
||||||
|
result.push_back(Display::VERTICAL_LINE);
|
||||||
|
} else if (i == lengthOfMenu-1) {
|
||||||
|
result.push_back(string + Display::VERTICAL_LINE);
|
||||||
|
} else {
|
||||||
|
string += " ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GenerateCenteredString(int lengthOfMenu, std::string str) {
|
||||||
|
std::string result = Display::VERTICAL_LINE;
|
||||||
|
|
||||||
|
float newLength = lengthOfMenu - countVisibleCharacters(str) - 2;
|
||||||
|
|
||||||
|
int firstHalfLength = std::floor(newLength / 2);
|
||||||
|
int secondHalfLength = std::ceil(newLength / 2);
|
||||||
|
|
||||||
|
for (int i = 0; i < firstHalfLength; ++i) {
|
||||||
|
result += " ";
|
||||||
|
}
|
||||||
|
|
||||||
|
result += str;
|
||||||
|
|
||||||
|
for (int i = 0; i < secondHalfLength; ++i) {
|
||||||
|
result += " ";
|
||||||
|
}
|
||||||
|
|
||||||
|
Display::startMenu.push_back(std::vector<std::string>{result + Display::VERTICAL_LINE});
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string GenerateBoxMenuLine(int size, std::string str) {
|
||||||
|
std::string result = Display::VERTICAL_LINE_SINGLE + " " + str;
|
||||||
|
while (countVisibleCharacters(result) < size) {
|
||||||
|
result += " ";
|
||||||
|
}
|
||||||
|
return result + Display::VERTICAL_LINE_SINGLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int main() {
|
||||||
SetConsoleOutputCP(CP_UTF8);
|
SetConsoleOutputCP(CP_UTF8);
|
||||||
|
std::cout << "\033[2J";
|
||||||
|
|
||||||
std::cout << "Spieler A: ";
|
|
||||||
|
int widthOfStartMenu = Display::asciiArtTurboSchach.size() + 4;
|
||||||
|
|
||||||
|
std::vector<std::string> temp;
|
||||||
|
|
||||||
|
std::vector<std::string> topBorderHorizontals;
|
||||||
|
std::string string;
|
||||||
|
|
||||||
|
topBorderHorizontals.push_back(Display::TOP_LEFT_CORNER + Display::HORIZONTAL_LINE + Display::HORIZONTAL_LINE + Display::HORIZONTAL_LINE + Display::HORIZONTAL_LINE);
|
||||||
|
for (const std::string& str : Display::asciiArtTurboSchach[0]) {
|
||||||
|
for (int i = 0; i < countVisibleCharacters(str); ++i) {
|
||||||
|
string += Display::HORIZONTAL_LINE;
|
||||||
|
}
|
||||||
|
topBorderHorizontals.push_back(string);
|
||||||
|
string = "";
|
||||||
|
}
|
||||||
|
topBorderHorizontals.push_back(Display::HORIZONTAL_LINE + Display::HORIZONTAL_LINE + Display::HORIZONTAL_LINE + Display::HORIZONTAL_LINE + Display::TOP_RIGHT_CORNER);
|
||||||
|
|
||||||
|
int lengthOfMenu = GetSumAllCharsFromVector(topBorderHorizontals);
|
||||||
|
|
||||||
|
Display::startMenu.push_back(topBorderHorizontals);
|
||||||
|
Display::startMenu.push_back(GenerateEmptyLine(lengthOfMenu));
|
||||||
|
Display::startMenu.push_back(GenerateEmptyLine(lengthOfMenu));
|
||||||
|
|
||||||
|
for (const auto& row : Display::asciiArtTurboSchach) {
|
||||||
|
temp.push_back(Display::VERTICAL_LINE + " ");
|
||||||
|
for (const auto& column : row) {
|
||||||
|
temp.push_back(column);
|
||||||
|
}
|
||||||
|
temp.push_back(" " + Display::VERTICAL_LINE);
|
||||||
|
Display::startMenu.push_back(temp);
|
||||||
|
temp.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
Display::startMenu.push_back(GenerateEmptyLine(lengthOfMenu));
|
||||||
|
Display::startMenu.push_back(GenerateEmptyLine(lengthOfMenu));
|
||||||
|
|
||||||
|
GenerateCenteredString(lengthOfMenu, "Welcome to TurboSchach!");
|
||||||
|
|
||||||
|
temp.clear();
|
||||||
|
|
||||||
|
Display::startMenu.push_back(GenerateEmptyLine(lengthOfMenu));
|
||||||
|
Display::startMenu.push_back(GenerateEmptyLine(lengthOfMenu));
|
||||||
|
|
||||||
|
GenerateCenteredString(lengthOfMenu, "Please select one of the menu options:");
|
||||||
|
GenerateCenteredString(lengthOfMenu, "std::cin >>");
|
||||||
|
|
||||||
|
Display::startMenu.push_back(GenerateEmptyLine(lengthOfMenu));
|
||||||
|
|
||||||
|
std::string tempString = Display::TOP_LEFT_CORNER_SINGLE;
|
||||||
|
for (int i = 0; i < 21; ++i) {
|
||||||
|
tempString += Display::HORIZONTAL_LINE_SINGLE;
|
||||||
|
}
|
||||||
|
tempString += Display::TOP_RIGHT_CORNER_SINGLE;
|
||||||
|
|
||||||
|
GenerateCenteredString(lengthOfMenu, tempString);
|
||||||
|
tempString = "";
|
||||||
|
|
||||||
|
GenerateCenteredString(lengthOfMenu, GenerateBoxMenuLine(22, "1 - New Game"));
|
||||||
|
GenerateCenteredString(lengthOfMenu, GenerateBoxMenuLine(22, "2 - Load Save"));
|
||||||
|
GenerateCenteredString(lengthOfMenu, GenerateBoxMenuLine(22, "3 - Instructions"));
|
||||||
|
GenerateCenteredString(lengthOfMenu, GenerateBoxMenuLine(22, ""));
|
||||||
|
GenerateCenteredString(lengthOfMenu, GenerateBoxMenuLine(22, "0 - Exit"));
|
||||||
|
|
||||||
|
tempString = Display::BOTTOM_LEFT_CORNER_SINGLE;
|
||||||
|
for (int i = 0; i < 21; ++i) {
|
||||||
|
tempString += Display::HORIZONTAL_LINE_SINGLE;
|
||||||
|
}
|
||||||
|
tempString += Display::BOTTOM_RIGHT_CORNER_SINGLE;
|
||||||
|
|
||||||
|
GenerateCenteredString(lengthOfMenu, tempString);
|
||||||
|
Display::startMenu.push_back(GenerateEmptyLine(lengthOfMenu));
|
||||||
|
Display::startMenu.push_back(GenerateEmptyLine(lengthOfMenu));
|
||||||
|
|
||||||
|
std::vector<std::string> bottomBorderHorizontals;
|
||||||
|
|
||||||
|
bottomBorderHorizontals.push_back(Display::BOTTOM_LEFT_CORNER + Display::HORIZONTAL_LINE + Display::HORIZONTAL_LINE + Display::HORIZONTAL_LINE + Display::HORIZONTAL_LINE);
|
||||||
|
for (const std::string& str : Display::asciiArtTurboSchach[0]) {
|
||||||
|
for (int i = 0; i < countVisibleCharacters(str); ++i) {
|
||||||
|
string += Display::HORIZONTAL_LINE;
|
||||||
|
}
|
||||||
|
bottomBorderHorizontals.push_back(string);
|
||||||
|
string = "";
|
||||||
|
}
|
||||||
|
bottomBorderHorizontals.push_back(Display::HORIZONTAL_LINE + Display::HORIZONTAL_LINE + Display::HORIZONTAL_LINE + Display::HORIZONTAL_LINE + Display::BOTTOM_RIGHT_CORNER);
|
||||||
|
|
||||||
|
Display::startMenu.push_back(bottomBorderHorizontals);
|
||||||
|
|
||||||
|
int option;
|
||||||
|
for (const auto& row : Display::startMenu) {
|
||||||
|
for (const auto& col : row) {
|
||||||
|
if (col.find("std::cin >>") != std::string::npos) {
|
||||||
|
//std::cin >> option;
|
||||||
|
}
|
||||||
|
std::cout << col;
|
||||||
|
}
|
||||||
|
std::cout << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*std::cout << "Spieler A: ";
|
||||||
std::string namePlayerA;
|
std::string namePlayerA;
|
||||||
getline(std::cin, namePlayerA);
|
getline(std::cin, namePlayerA);
|
||||||
std::cout << "Spieler B: ";
|
std::cout << "Spieler B: ";
|
||||||
@@ -31,14 +205,21 @@ int main(int argc, char* argv[]) {
|
|||||||
ChessboardVisualizerGraphic* visualizer = new ChessboardVisualizerGraphic();
|
ChessboardVisualizerGraphic* visualizer = new ChessboardVisualizerGraphic();
|
||||||
|
|
||||||
while (chessboard.IsCheckmate() == false) {
|
while (chessboard.IsCheckmate() == false) {
|
||||||
visualizer->Draw(&chessboard);
|
visualizer->GenerateChessboard(&chessboard);
|
||||||
std::string move;
|
std::string move;
|
||||||
std::cout << "Move [" << ((chessboard.GetCurrentPlayer()->GetColor() == ChessPieceColor::White) ? "White" : "Black") << "] : ";
|
std::cout << "Move [" << ((chessboard.GetCurrentPlayer()->GetColor() == ChessPieceColor::White) ? "White" : "Black") << "] : ";
|
||||||
std::cin >> move;
|
std::cin >> move;
|
||||||
chessboard.MoveChessPiece(move);
|
chessboard.MoveChessPiece(move);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "Game is over! - " << chessboard.GetOpponentPlayer()->GetName() << " has won the game!" << std::endl;
|
std::cout << "Game is over! - " << chessboard.GetOpponentPlayer()->GetName() << " has won the game!" << std::endl;*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
std::vector<std::vector<ChessPiece>> chessmatrix;
|
std::vector<std::vector<ChessPiece>> chessmatrix;
|
||||||
|
|
||||||
@@ -64,44 +245,3 @@ int main(int argc, char* argv[]) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// set black chess pieces
|
|
||||||
/*chessboard.SetChessPiece(new Rook{ChessPieceColor::Black, ChessPiecePosition{'A', 8}});
|
|
||||||
chessboard.SetChessPiece(new Knight{ChessPieceColor::Black, ChessPiecePosition{'B', 8}});
|
|
||||||
chessboard.SetChessPiece(new Bishop{ChessPieceColor::Black, ChessPiecePosition{'C', 8}});
|
|
||||||
chessboard.SetChessPiece(new Queen{ChessPieceColor::Black, ChessPiecePosition{'D', 8}});
|
|
||||||
chessboard.SetChessPiece(new King{ChessPieceColor::Black, ChessPiecePosition{'E', 8}});
|
|
||||||
chessboard.SetChessPiece(new Bishop{ChessPieceColor::Black, ChessPiecePosition{'F', 8}});
|
|
||||||
chessboard.SetChessPiece(new Knight{ChessPieceColor::Black, ChessPiecePosition{'G', 8}});
|
|
||||||
chessboard.SetChessPiece(new Rook{ChessPieceColor::Black, ChessPiecePosition{'H', 8}});
|
|
||||||
|
|
||||||
chessboard.SetChessPiece(new Pawn{ChessPieceColor::Black, ChessPiecePosition{'A', 7}});
|
|
||||||
chessboard.SetChessPiece(new Pawn{ChessPieceColor::Black, ChessPiecePosition{'B', 7}});
|
|
||||||
chessboard.SetChessPiece(new Pawn{ChessPieceColor::Black, ChessPiecePosition{'C', 7}});
|
|
||||||
chessboard.SetChessPiece(new Pawn{ChessPieceColor::Black, ChessPiecePosition{'D', 7}});
|
|
||||||
chessboard.SetChessPiece(new Pawn{ChessPieceColor::Black, ChessPiecePosition{'E', 7}});
|
|
||||||
chessboard.SetChessPiece(new Pawn{ChessPieceColor::Black, ChessPiecePosition{'F', 7}});
|
|
||||||
chessboard.SetChessPiece(new Pawn{ChessPieceColor::Black, ChessPiecePosition{'G', 7}});
|
|
||||||
chessboard.SetChessPiece(new Pawn{ChessPieceColor::Black, ChessPiecePosition{'H', 7}});
|
|
||||||
|
|
||||||
// set white chess pieces
|
|
||||||
chessboard.SetChessPiece(new Rook{ChessPieceColor::White, ChessPiecePosition{'A', 1}});
|
|
||||||
chessboard.SetChessPiece(new Knight{ChessPieceColor::White, ChessPiecePosition{'B', 1}});
|
|
||||||
chessboard.SetChessPiece(new Bishop{ChessPieceColor::White, ChessPiecePosition{'C', 1}});
|
|
||||||
chessboard.SetChessPiece(new Queen{ChessPieceColor::White, ChessPiecePosition{'D', 1}});
|
|
||||||
chessboard.SetChessPiece(new King{ChessPieceColor::White, ChessPiecePosition{'E', 1}});
|
|
||||||
chessboard.SetChessPiece(new Bishop{ChessPieceColor::White, ChessPiecePosition{'F', 1}});
|
|
||||||
chessboard.SetChessPiece(new Knight{ChessPieceColor::White, ChessPiecePosition{'G', 1}});
|
|
||||||
chessboard.SetChessPiece(new Rook{ChessPieceColor::White, ChessPiecePosition{'H', 1}});
|
|
||||||
|
|
||||||
chessboard.SetChessPiece(new Pawn{ChessPieceColor::White, ChessPiecePosition{'A', 2}});
|
|
||||||
chessboard.SetChessPiece(new Pawn{ChessPieceColor::White, ChessPiecePosition{'B', 2}});
|
|
||||||
chessboard.SetChessPiece(new Pawn{ChessPieceColor::White, ChessPiecePosition{'C', 2}});
|
|
||||||
chessboard.SetChessPiece(new Pawn{ChessPieceColor::White, ChessPiecePosition{'D', 2}});
|
|
||||||
chessboard.SetChessPiece(new Pawn{ChessPieceColor::White, ChessPiecePosition{'E', 2}});
|
|
||||||
chessboard.SetChessPiece(new Pawn{ChessPieceColor::White, ChessPiecePosition{'F', 2}});
|
|
||||||
chessboard.SetChessPiece(new Pawn{ChessPieceColor::White, ChessPiecePosition{'G', 2}});
|
|
||||||
chessboard.SetChessPiece(new Pawn{ChessPieceColor::White, ChessPiecePosition{'H', 2}});*/
|
|
||||||
|
|||||||
Reference in New Issue
Block a user