42 lines
1.1 KiB
C++
42 lines
1.1 KiB
C++
//
|
|
// Created by hamac on 18.12.2024.
|
|
//
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
#include <regex>
|
|
|
|
|
|
class Chesspiece {
|
|
private:
|
|
/* fields */
|
|
// ToDo: von char auf enum Color {W, B} umstellen
|
|
char color;
|
|
char identifier;
|
|
std::pair<int, int> position;
|
|
std::vector<std::string> positions;
|
|
|
|
/* methods */
|
|
virtual std::vector<std::string> calcAvaibleMoves() = 0;
|
|
|
|
public:
|
|
virtual ~Chesspiece() = default;
|
|
|
|
std::pair<int, int> getPosition() { return this->position; };
|
|
void setPosition(std::pair<int, int> position) {
|
|
this->position = position;
|
|
calcAvaibleMoves();
|
|
}
|
|
|
|
char getColor() { return this->color; }
|
|
void setColor(char color) { this->color = color; }
|
|
|
|
std::vector<std::string> getPositions() { return this->positions; }
|
|
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);
|
|
}
|
|
};
|