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:
parent
c333e3da9e
commit
a56fb4d60f
4 changed files with 32 additions and 57 deletions
|
|
@ -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)];
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue