Kleine Änderung
This commit is contained in:
parent
dc31b31f4b
commit
8402e0f1b0
@ -17,7 +17,7 @@ std::vector<std::string> ChessUtils::split(const std::string &s, char delim) {
|
|||||||
}
|
}
|
||||||
return elems;
|
return elems;
|
||||||
}
|
}
|
||||||
|
//a4
|
||||||
std::pair<int, int> ChessUtils::convertPosition(const std::string &pos) {
|
std::pair<int, int> ChessUtils::convertPosition(const std::string &pos) {
|
||||||
int y = pos[pos.size()-2] - 'a';
|
int y = pos[pos.size()-2] - 'a';
|
||||||
int x = ChessUtils::fileConvertion.find((pos[pos.size()-1] - '0')-1)->second;
|
int x = ChessUtils::fileConvertion.find((pos[pos.size()-1] - '0')-1)->second;
|
||||||
|
@ -228,6 +228,8 @@ void Chessboard::move(std::string move) {
|
|||||||
board[oldCoords.first][oldCoords.second] = getEmptyBoard()[oldCoords.first][oldCoords.second];
|
board[oldCoords.first][oldCoords.second] = getEmptyBoard()[oldCoords.first][oldCoords.second];
|
||||||
board[newCoords.first][newCoords.second] = getCorrectPiece(splitMove[0][0]);
|
board[newCoords.first][newCoords.second] = getCorrectPiece(splitMove[0][0]);
|
||||||
|
|
||||||
|
//e4-e5
|
||||||
|
|
||||||
Chessboard::draw(board);
|
Chessboard::draw(board);
|
||||||
|
|
||||||
// Notation
|
// Notation
|
||||||
@ -244,12 +246,14 @@ void Chessboard::move(std::string move) {
|
|||||||
// Special:
|
// Special:
|
||||||
// 0-0 short castle
|
// 0-0 short castle
|
||||||
// 0-0-0 long 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
|
// capture: x
|
||||||
// check: +
|
// check: +
|
||||||
// checkmate: #
|
// checkmate: #
|
||||||
// draw/stalemate: 1/2-1/2
|
// draw/stalemate: 1/2-1/2
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method saves the current board state
|
// This method saves the current board state
|
||||||
|
@ -4,19 +4,19 @@
|
|||||||
|
|
||||||
#include "Chesspiece.h"
|
#include "Chesspiece.h"
|
||||||
|
|
||||||
Chesspiece::Chesspiece(char color, char identifier)
|
Chesspiece::Chesspiece(char color, std::pair<int, int> position)
|
||||||
: color(color), identifier(identifier) {}
|
: color(color), position(position) {}
|
||||||
|
|
||||||
std::pair<int, int> Chesspiece::getPosition() { return this->position; };
|
std::pair<int, int> Chesspiece::getPosition() { return this->position; };
|
||||||
void Chesspiece::setPosition(std::pair<int, int> position) {
|
void Chesspiece::setPosition(std::pair<int, int> position) {
|
||||||
this->position = position;
|
this->position = position;
|
||||||
calcAvaibleMoves();
|
Chesspiece::calcAvaibleMoves(); // Brett -> Auswahl Figuren -> Züge gewählte
|
||||||
}
|
}
|
||||||
|
|
||||||
char Chesspiece::getColor() { return color; }
|
char Chesspiece::getColor() { return color; }
|
||||||
void Chesspiece::setColor(char color) { color = color; }
|
void Chesspiece::setColor(char color) { color = color; }
|
||||||
|
|
||||||
std::vector<std::string> Chesspiece::getPositions() { return positions; }
|
std::vector<std::string> Chesspiece::getAvaibleMoves() { return avaibleMoves; }
|
||||||
|
|
||||||
bool Chesspiece::checkNotation(std::string notation) {
|
bool Chesspiece::checkNotation(std::string notation) {
|
||||||
std::regex pattern("R^([KQRNBP]?)([a-h][1-8])[-x]([a-h][1-8])([+#]?)$");
|
std::regex pattern("R^([KQRNBP]?)([a-h][1-8])[-x]([a-h][1-8])([+#]?)$");
|
||||||
|
@ -18,15 +18,16 @@ private:
|
|||||||
/* fields */
|
/* fields */
|
||||||
// ToDo: von char auf enum Color {W, B} umstellen
|
// ToDo: von char auf enum Color {W, B} umstellen
|
||||||
char color;
|
char color;
|
||||||
char identifier;
|
char identifier; // P,K,...
|
||||||
std::pair<int, int> position;
|
std::pair<int, int> position;
|
||||||
std::vector<std::string> positions;
|
// std::vector<std::pair<int, int>>
|
||||||
|
std::vector<std::string> avaibleMoves;
|
||||||
|
|
||||||
/* methods */
|
/* methods */
|
||||||
virtual std::vector<std::string> calcAvaibleMoves() = 0;
|
virtual std::vector<std::string> calcAvaibleMoves() = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Chesspiece(char color, char identifier);
|
Chesspiece(char color, std::pair<int, int> position);
|
||||||
|
|
||||||
virtual ~Chesspiece() = default;
|
virtual ~Chesspiece() = default;
|
||||||
|
|
||||||
@ -36,7 +37,7 @@ public:
|
|||||||
char getColor();
|
char getColor();
|
||||||
void setColor(char color);
|
void setColor(char color);
|
||||||
|
|
||||||
std::vector<std::string> getPositions();
|
std::vector<std::string> getAvaibleMoves();
|
||||||
|
|
||||||
bool checkNotation(std::string notation);
|
bool checkNotation(std::string notation);
|
||||||
};
|
};
|
||||||
|
9
Pawn.cpp
9
Pawn.cpp
@ -11,8 +11,10 @@ std::vector<std::string> Pawn::calcAvaibleMoves() {
|
|||||||
std::pair<int, int> pos = Chesspiece::getPosition();
|
std::pair<int, int> pos = Chesspiece::getPosition();
|
||||||
std::vector<std::string> moves;
|
std::vector<std::string> moves;
|
||||||
|
|
||||||
if (this->firstMove) {
|
//current
|
||||||
|
|
||||||
|
if (this->firstMove) {
|
||||||
|
//vector[8] => MoveList(1-1;2-2+)
|
||||||
//moves.
|
//moves.
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,7 +23,4 @@ std::vector<std::string> Pawn::calcAvaibleMoves() {
|
|||||||
return moves;
|
return moves;
|
||||||
}
|
}
|
||||||
|
|
||||||
Pawn::Pawn(char color, std::pair<int, int> position): Chesspiece(color, 'P') {
|
Pawn::Pawn(char color, std::pair<int, int> position): Chesspiece(color, position) {}
|
||||||
setPosition(position);
|
|
||||||
setColor(color);
|
|
||||||
}
|
|
10
README.md
10
README.md
@ -12,6 +12,8 @@
|
|||||||
6. Springer
|
6. Springer
|
||||||
3. Fancy User Interface
|
3. Fancy User Interface
|
||||||
4. Speicherung des Spielbretts
|
4. Speicherung des Spielbretts
|
||||||
|
5. Unentschieden anbieten
|
||||||
|
6. Aufgegeben
|
||||||
|
|
||||||
### Spielbrett
|
### Spielbrett
|
||||||
|
|
||||||
@ -49,12 +51,20 @@
|
|||||||
- 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
|
||||||
|
- Spezial Moves:
|
||||||
|
- Rochade -> Kurz/Lang
|
||||||
|
- En Passant
|
||||||
|
- Stalemate
|
||||||
|
- Bauer: 2 Felder
|
||||||
|
- Umwandeln
|
||||||
|
|
||||||
## 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
|
3. Historie der Spielzüge
|
||||||
|
4. Gravejard der geschlagenen Figuren
|
||||||
|
5. König platzieren -> Anzeigen wer gewinnt
|
||||||
|
|
||||||
# Gedankensammlung
|
# Gedankensammlung
|
||||||
- Initialisierung:
|
- Initialisierung:
|
||||||
|
6
main.cpp
6
main.cpp
@ -9,9 +9,9 @@ int main() {
|
|||||||
|
|
||||||
//Pawn pawn('w', {1,6});
|
//Pawn pawn('w', {1,6});
|
||||||
Chessboard chessboard;
|
Chessboard chessboard;
|
||||||
chessboard.init();
|
//chessboard.init();
|
||||||
/*chessboard.draw();
|
chessboard.draw();
|
||||||
chessboard.move("Pb2-b3");*/
|
/*chessboard.move("Pb2-b3");*/
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user