Maybe a way to really display the board
This commit is contained in:
parent
ba2c25710e
commit
705c505982
52
README.md
52
README.md
@ -1,51 +1,57 @@
|
|||||||
# c/c++ Abschlussprojekt - Schach
|
# c/c++ Abschlussprojekt - Schach
|
||||||
|
|
||||||
## Notwendige Umsetzungen
|
## Notwendige Umsetzungen
|
||||||
|
|
||||||
1. Klasse für Spielbrett
|
1. Klasse für Spielbrett
|
||||||
2. Oberklasse für Spielfiguren
|
2. Oberklasse für Spielfiguren
|
||||||
1. Bauer
|
1. Bauer
|
||||||
2. Dame
|
2. Dame
|
||||||
3. König
|
3. König
|
||||||
4. Läufer
|
4. Läufer
|
||||||
5. Turm
|
5. Turm
|
||||||
6. Springer
|
6. Springer
|
||||||
3. Fancy User Interface
|
3. Fancy User Interface
|
||||||
|
4. Speicherung des Spielbretts
|
||||||
|
|
||||||
### Spielbrett
|
### Spielbrett
|
||||||
|
|
||||||
- 8x8 Matrix
|
- 8x8 Matrix
|
||||||
- ANSI Linien checken
|
- ANSI Linien checken
|
||||||
- Unterscheidung von schwarzen und weißen Feldern
|
- Unterscheidung von schwarzen und weißen Feldern
|
||||||
- UTF-8 Spielfiguren
|
- UTF-8 Spielfiguren
|
||||||
- draw() Funktion
|
- draw() Funktion
|
||||||
- movement
|
- movement
|
||||||
- Schachnotation
|
- Schachnotation
|
||||||
- oder Klickbar?
|
- oder Klickbar?
|
||||||
- Beschriftung des Spielbretts
|
- Beschriftung des Spielbretts
|
||||||
|
|
||||||
### Spielfiguren
|
### Spielfiguren
|
||||||
|
|
||||||
- Interface für Implementierung?
|
- Interface für Implementierung?
|
||||||
- Default Felder:
|
- Default Felder:
|
||||||
- Art der Figure
|
- Art der Figure
|
||||||
- UTF-8 Code
|
- UTF-8 Code
|
||||||
- Schlagen: Ich sehe dich nach movement Regeln -> Du stirbst
|
- Schlagen: Ich sehe dich nach movement Regeln -> Du stirbst
|
||||||
- Bauer:
|
- Bauer:
|
||||||
- Movement: 1 Felder, außer bei Start 1-2 Felder
|
- Movement: 1 Felder, außer bei Start 1-2 Felder
|
||||||
- Schlagen: 1 Feld vor Diagonal
|
- Schlagen: 1 Feld vor Diagonal
|
||||||
- Spezialmove:
|
- Spezialmove:
|
||||||
- Beförderung
|
- Beförderung
|
||||||
- En Passent - Wie?
|
- En Passent - Wie?
|
||||||
- Dame:
|
- Dame:
|
||||||
- Movement: Fuck it, i do what i want
|
- Movement: Fuck it, i do what i want
|
||||||
- König:
|
- König:
|
||||||
- Movement: Körperklaus. Ich kann nur ein Feld nach überall
|
- Movement: Körperklaus. Ich kann nur ein Feld nach überall
|
||||||
- Spezialmove: Castlen
|
- Spezialmove: Castlen
|
||||||
- Läufer:
|
- Läufer:
|
||||||
- Movement: Die Diagnal ist mir
|
- Movement: Die Diagnal ist mir
|
||||||
- Turm:
|
- Turm:
|
||||||
- Movement: Vertikal und Horizontal
|
- Movement: Vertikal und Horizontal
|
||||||
- Springer:
|
- Springer:
|
||||||
- Movement: L-Bewegung (2 nach vorn + 1 nach links oder rechts); Krake
|
- Movement: L-Bewegung (2 nach vorn + 1 nach links oder rechts); Krake
|
||||||
|
|
||||||
## Optional wenn Lust und Zeit?
|
## Optional wenn Lust und Zeit?
|
||||||
|
|
||||||
1. Bedienung per Maus
|
1. Bedienung per Maus
|
||||||
2. Multiplayer
|
2. Multiplayer
|
||||||
|
3. Historie der Spielzüge
|
||||||
|
201
main.cpp
201
main.cpp
@ -4,12 +4,168 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <locale>
|
#include <locale>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <iomanip>
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
SetConsoleOutputCP(CP_UTF8);
|
||||||
|
|
||||||
|
// Zeichen für die Rahmen und das Schachbrett
|
||||||
|
const std::string topLeft = "┌", topRight = "┐", bottomLeft = "└", bottomRight = "┘";
|
||||||
|
const std::string horizontal = "─", vertical = "│";
|
||||||
|
const std::string topIntersection = "┬", bottomIntersection = "┴", middleIntersection = "┼";
|
||||||
|
|
||||||
|
const std::string whiteSquare = "□"; // Weißes Feld
|
||||||
|
const std::string blackSquare = "■"; // Schwarzes Feld
|
||||||
|
|
||||||
|
const int boardSize = 8; // Schachbrettgröße
|
||||||
|
|
||||||
|
// Obere Rahmenlinie
|
||||||
|
std::cout << topLeft;
|
||||||
|
for (int col = 0; col < boardSize; ++col) {
|
||||||
|
std::cout << horizontal << horizontal << horizontal;
|
||||||
|
if (col < boardSize - 1) std::cout << topIntersection;
|
||||||
|
}
|
||||||
|
std::cout << topRight << "\n";
|
||||||
|
|
||||||
|
// Schachbrett mit vertikalen Linien
|
||||||
|
for (int row = 0; row < boardSize; ++row) {
|
||||||
|
for (int subRow = 0; subRow < 1; ++subRow) {
|
||||||
|
std::cout << vertical;
|
||||||
|
for (int col = 0; col < boardSize; ++col) {
|
||||||
|
if ((row + col) % 2 == 0) {
|
||||||
|
std::cout << " " << whiteSquare << " ";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
std::cout << " " << blackSquare << " ";
|
||||||
|
}
|
||||||
|
std::cout << vertical;
|
||||||
|
}
|
||||||
|
std::cout << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Horizontale Trennlinie (außer nach der letzten Zeile)
|
||||||
|
if (row < boardSize - 1) {
|
||||||
|
std::cout << vertical;
|
||||||
|
for (int col = 0; col < boardSize; ++col) {
|
||||||
|
std::cout << horizontal << horizontal << horizontal;
|
||||||
|
if (col < boardSize - 1) std::cout << middleIntersection;
|
||||||
|
}
|
||||||
|
std::cout << vertical << "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Untere Rahmenlinie
|
||||||
|
std::cout << bottomLeft;
|
||||||
|
for (int col = 0; col < boardSize; ++col) {
|
||||||
|
std::cout << horizontal << horizontal << horizontal;
|
||||||
|
if (col < boardSize - 1) std::cout << bottomIntersection;
|
||||||
|
}
|
||||||
|
std::cout << bottomRight << "\n";
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*int main() {
|
||||||
//std::setlocale(LC_ALL, "");
|
//std::setlocale(LC_ALL, "");
|
||||||
|
|
||||||
SetConsoleOutputCP(CP_UTF8);
|
SetConsoleOutputCP(CP_UTF8);
|
||||||
|
|
||||||
|
const std::string white = "\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 black = "\u2B1B";
|
||||||
|
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";
|
||||||
|
|
||||||
|
int brett[8][8] = {
|
||||||
|
{201, 202, 203, 204, 205, 203, 202, 201},
|
||||||
|
{200, 200, 200, 200, 200, 200, 200, 200},
|
||||||
|
{1, 2, 1, 2, 1, 2, 1, 2},
|
||||||
|
{2, 1, 2, 1, 2, 1, 2, 1},
|
||||||
|
{1, 2, 1, 2, 1, 2, 1, 2},
|
||||||
|
{2, 1, 2, 1, 2, 1, 2, 1},
|
||||||
|
{100, 100, 100, 100, 100, 100, 100, 100},
|
||||||
|
{101, 102, 103, 104, 105, 103, 102, 101}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
std::string field;
|
||||||
|
for (auto& row : brett) {
|
||||||
|
for (int col : row) {
|
||||||
|
switch (col) {
|
||||||
|
case 1: field += white;
|
||||||
|
break;
|
||||||
|
case 101: field += whiteRook;
|
||||||
|
break;
|
||||||
|
case 102: field += whiteKnight;
|
||||||
|
break;
|
||||||
|
case 103: field += whiteBischop;
|
||||||
|
break;
|
||||||
|
case 104: field += whiteQueen;
|
||||||
|
break;
|
||||||
|
case 105: field += whiteKing;
|
||||||
|
break;
|
||||||
|
case 100: field += whitePawn;
|
||||||
|
break;
|
||||||
|
case 2: field += black;
|
||||||
|
break;
|
||||||
|
case 201: field += blackRook;
|
||||||
|
break;
|
||||||
|
case 202: field += blackKnight;
|
||||||
|
break;
|
||||||
|
case 203: field += blackBischop;
|
||||||
|
break;
|
||||||
|
case 204: field += blackQueen;
|
||||||
|
break;
|
||||||
|
case 205: field += blackKing;
|
||||||
|
break;
|
||||||
|
case 200: field += blackPawn;
|
||||||
|
break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
field += "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << field << std::endl;
|
||||||
|
|
||||||
|
//std::wcout << L"\u2500" << std::endl;
|
||||||
|
//std::cout << field << std::endl;
|
||||||
|
return 0;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
void firstVersion() {
|
||||||
|
const std::string white = "\u2B1C";
|
||||||
|
const std::string black = "\u2B1B";
|
||||||
|
|
||||||
|
std::string brett[8][8];
|
||||||
|
|
||||||
|
std::string field;
|
||||||
|
for (int y = 0; y < 8; y++) {
|
||||||
|
for (int x = 0; x < 8; x++) {
|
||||||
|
if (y % 2 == 0) {
|
||||||
|
field = (x % 2 == 0) ? "\u2B1C" : "\u2B1B";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
field = (x % 2 == 0) ? "⬛" : "⬜";
|
||||||
|
}
|
||||||
|
std::cout << field;
|
||||||
|
}
|
||||||
|
std::cout << "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void secondVersion() {
|
||||||
//wchar_t t = 0x25FF;
|
//wchar_t t = 0x25FF;
|
||||||
|
|
||||||
// Horizontale Linie u2500
|
// Horizontale Linie u2500
|
||||||
@ -21,9 +177,9 @@ int main() {
|
|||||||
|
|
||||||
std::string topRightCorner = "\u2554";
|
std::string topRightCorner = "\u2554";
|
||||||
std::string topLeftCorner = "\u2557";
|
std::string topLeftCorner = "\u2557";
|
||||||
std::string bottomRightCorner = "\u255A";
|
std::string bottomLeftCorner = "\u255A";
|
||||||
std::string bottomLeftCorner = "\u255D";
|
std::string bottomRightCorner = "\u255D";
|
||||||
std::string horizontalLine = "\u2550";
|
std::string horizontalLine = "\u2550\u2550";
|
||||||
std::string verticalLine = "\u2551";
|
std::string verticalLine = "\u2551";
|
||||||
std::string crossSuc = "\u256C";
|
std::string crossSuc = "\u256C";
|
||||||
std::string leftSide = "\u2560";
|
std::string leftSide = "\u2560";
|
||||||
@ -34,38 +190,19 @@ int main() {
|
|||||||
std::string firstLine = "\u2554\u2550\u2566";
|
std::string firstLine = "\u2554\u2550\u2566";
|
||||||
std::string line;
|
std::string line;
|
||||||
|
|
||||||
for (int row = 0; row < 8; ++row) {
|
for (int row = 0; row < 9; ++row) {
|
||||||
for (int col = 0; col < 8; ++col) {
|
for (int col = 0; col < 8; ++col) {
|
||||||
if (row == 0 && col > 0) line += horizontalLine + topSide;
|
if (row == 0 && col > 0) line += topSide + horizontalLine;
|
||||||
if (row == 7 && col > 0) line += horizontalLine + bottomSide;
|
if (row == 8 && col > 0) line += bottomSide + horizontalLine;
|
||||||
if (col == 0 && row < 7 && row > 0) line += leftSide;
|
if (col == 0 && row < 8 && row > 0) line += leftSide + horizontalLine;
|
||||||
if (col == 7 && row < 7 && row > 0) line += horizontalLine + rightSide;
|
if (row > 0 && row < 8 && col > 0) line += crossSuc + horizontalLine;
|
||||||
if ((row > 0 && row < 7) && (col > 0 && col < 7)) line += horizontalLine + crossSuc;
|
if (col == 7 && row < 8 && row > 0) line += rightSide;
|
||||||
if (row == 0 && col == 0) line += topRightCorner + horizontalLine + topSide;
|
if (row == 0 && col == 0) line += topRightCorner + horizontalLine;
|
||||||
if (row == 7 && col == 0) line += "\u255A\u2550\u2569";
|
if (row == 8 && col == 0) line += bottomLeftCorner + horizontalLine;
|
||||||
if (row == 0 && col == 7) line += "\u2550\u2557";
|
if (row == 0 && col == 7) line += topLeftCorner + "\n" + verticalLine;
|
||||||
if (row == 7 && col == 7) line += "\u2550\u255D";
|
if (row == 8 && col == 7) line += bottomRightCorner;
|
||||||
}
|
}
|
||||||
line += "\n";
|
line += "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
//std::wcout << L"\u2500" << std::endl;
|
|
||||||
std::cout << line << std::endl;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void firstVersion() {
|
|
||||||
std::string field;
|
|
||||||
for (int y = 0; y < 8; y++) {
|
|
||||||
for (int x = 0; x < 8; x++) {
|
|
||||||
if (y % 2 == 0) {
|
|
||||||
field = (x % 2 == 0) ? "⬜" : "⬛";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
field = (x % 2 == 0) ? "⬛" : "⬜";
|
|
||||||
}
|
|
||||||
std::cout << field;
|
|
||||||
}
|
|
||||||
std::cout << "\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user