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;
|
||||
}
|
||||
|
||||
//a4
|
||||
std::pair<int, int> 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;
|
||||
|
@ -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
|
||||
|
@ -4,19 +4,19 @@
|
||||
|
||||
#include "Chesspiece.h"
|
||||
|
||||
Chesspiece::Chesspiece(char color, char identifier)
|
||||
: color(color), identifier(identifier) {}
|
||||
Chesspiece::Chesspiece(char color, std::pair<int, int> position)
|
||||
: color(color), position(position) {}
|
||||
|
||||
std::pair<int, int> Chesspiece::getPosition() { return this->position; };
|
||||
void Chesspiece::setPosition(std::pair<int, int> 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<std::string> Chesspiece::getPositions() { return positions; }
|
||||
std::vector<std::string> Chesspiece::getAvaibleMoves() { return avaibleMoves; }
|
||||
|
||||
bool Chesspiece::checkNotation(std::string notation) {
|
||||
std::regex pattern("R^([KQRNBP]?)([a-h][1-8])[-x]([a-h][1-8])([+#]?)$");
|
||||
|
@ -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<int, int> position;
|
||||
std::vector<std::string> positions;
|
||||
// std::vector<std::pair<int, int>>
|
||||
std::vector<std::string> avaibleMoves;
|
||||
|
||||
/* methods */
|
||||
virtual std::vector<std::string> calcAvaibleMoves() = 0;
|
||||
|
||||
public:
|
||||
Chesspiece(char color, char identifier);
|
||||
Chesspiece(char color, std::pair<int, int> position);
|
||||
|
||||
virtual ~Chesspiece() = default;
|
||||
|
||||
@ -36,7 +37,7 @@ public:
|
||||
char getColor();
|
||||
void setColor(char color);
|
||||
|
||||
std::vector<std::string> getPositions();
|
||||
std::vector<std::string> getAvaibleMoves();
|
||||
|
||||
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::vector<std::string> moves;
|
||||
|
||||
if (this->firstMove) {
|
||||
//current
|
||||
|
||||
if (this->firstMove) {
|
||||
//vector[8] => MoveList(1-1;2-2+)
|
||||
//moves.
|
||||
}
|
||||
|
||||
@ -21,7 +23,4 @@ std::vector<std::string> Pawn::calcAvaibleMoves() {
|
||||
return moves;
|
||||
}
|
||||
|
||||
Pawn::Pawn(char color, std::pair<int, int> position): Chesspiece(color, 'P') {
|
||||
setPosition(position);
|
||||
setColor(color);
|
||||
}
|
||||
Pawn::Pawn(char color, std::pair<int, int> position): Chesspiece(color, position) {}
|
10
README.md
10
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:
|
||||
|
6
main.cpp
6
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user