2024-12-18 19:26:28 +00:00
|
|
|
//
|
|
|
|
// Created by hamac on 18.12.2024.
|
|
|
|
//
|
|
|
|
|
2024-12-18 23:05:13 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2024-12-19 13:21:45 +00:00
|
|
|
#include <regex>
|
|
|
|
|
2024-12-18 23:05:13 +00:00
|
|
|
|
2024-12-18 19:26:28 +00:00
|
|
|
class Chesspiece {
|
2024-12-18 23:05:13 +00:00
|
|
|
private:
|
|
|
|
/* fields */
|
2024-12-19 13:21:45 +00:00
|
|
|
// ToDo: von char auf enum Color {W, B} umstellen
|
2024-12-18 23:05:13 +00:00
|
|
|
char color;
|
|
|
|
char identifier;
|
2024-12-19 13:21:45 +00:00
|
|
|
std::pair<int, int> position;
|
2024-12-18 23:05:13 +00:00
|
|
|
std::vector<std::string> positions;
|
|
|
|
|
|
|
|
/* methods */
|
2024-12-19 13:21:45 +00:00
|
|
|
virtual std::vector<std::string> calcAvaibleMoves() = 0;
|
2024-12-18 23:05:13 +00:00
|
|
|
|
|
|
|
public:
|
2024-12-19 13:21:45 +00:00
|
|
|
virtual ~Chesspiece() = default;
|
|
|
|
|
|
|
|
std::pair<int, int> getPosition() { return this->position; };
|
|
|
|
void setPosition(std::pair<int, int> position) {
|
2024-12-18 23:05:13 +00:00
|
|
|
this->position = position;
|
|
|
|
calcAvaibleMoves();
|
|
|
|
}
|
2024-12-18 19:26:28 +00:00
|
|
|
|
2024-12-18 23:05:13 +00:00
|
|
|
char getColor() { return this->color; }
|
|
|
|
void setColor(char color) { this->color = color; }
|
2024-12-18 19:26:28 +00:00
|
|
|
|
2024-12-18 23:05:13 +00:00
|
|
|
std::vector<std::string> getPositions() { return this->positions; }
|
2024-12-19 13:21:45 +00:00
|
|
|
Ad
|
|
|
|
bool checkNotation(std::string notation) {
|
|
|
|
std::regex pattern(R"^([KQRNBP]?)([a-h][1-8])[-x]([a-h][1-8])([+#]?)$");
|
|
|
|
std::smatch match;
|
|
|
|
return (std::regex_search(notation, match, pattern) ? true : false);
|
|
|
|
}
|
2024-12-18 23:05:13 +00:00
|
|
|
};
|