dev: refactoring things to be more OOP! whoop whoop

Still struggling to understand all these concepts, and I will admit
to using ChatGPT to try and explain where I was going wrong which
did help quite a bit. But if I get this right it will be much
more robust and less "fragile" as they say.
This commit is contained in:
A.M. Rowsell 2025-09-13 11:18:27 -04:00
commit a56fb4d60f
Signed by untrusted user who does not match committer: amr
GPG key ID: E0879EDBDB0CA7B1
4 changed files with 32 additions and 57 deletions

View file

@ -7,6 +7,7 @@
// defined by the Mozilla Public License, v. 2.0.
#include "inc/Board.hpp"
#include "inc/Piece.hpp"
#include "inc/strFuncs.hpp"
/*
@ -241,8 +242,8 @@ int Board::setupFromFEN(std::string strFEN) {
// ====== START OF FIELD 3 ======
std::string k = "k", K = "K", q = "q", Q = "Q";
// yeah this is hacky af but it works... blame SO
Piece *baseBKing = getPieceAt(blackKing).get();
Piece *baseWKing = getPieceAt(whiteKing).get();
Piece *baseBKing = getPieceAt(blackKing);
Piece *baseWKing = getPieceAt(whiteKing);
King *bKing = dynamic_cast<King *>(baseBKing);
King *wKing = dynamic_cast<King *>(baseWKing);
if(splitFEN[2] == "-") {
@ -310,8 +311,4 @@ void Board::deserializeBoard(uint64_t incomingBoard) {
serialBoard.boardRows[i] = static_cast<uint8_t>((incomingBoard >> (8 * i)) & 0xFF);
// how do we then figure out what has moved?
return;
}
std::unique_ptr<Piece> &Board::getPieceAt(Square square) {
return boardGrid[static_cast<int>(square.rank)][static_cast<int>(square.file)];
}