Const correctness for valid move checks

This commit is contained in:
ItsDrike 2024-12-06 03:49:25 +01:00
parent 4692ce356b
commit 03e74a6c67
Signed by: ItsDrike
GPG key ID: FA2745890B7048C0
2 changed files with 4 additions and 4 deletions

View file

@ -455,7 +455,7 @@ bool GameState::tryAutoMoveMultipleCards(const QList<PlayingCard*>& cards, int s
return false; return false;
} }
bool GameState::isFoundationMoveValid(const PlayingCard& cardToMove, int foundationId) { bool GameState::isFoundationMoveValid(const PlayingCard& cardToMove, int foundationId) const {
assert(foundationId >= 0 && foundationId < 4); assert(foundationId >= 0 && foundationId < 4);
const auto foundationSuit = static_cast<PlayingCard::Suit>(foundationId); const auto foundationSuit = static_cast<PlayingCard::Suit>(foundationId);
const auto& foundationStack = m_foundation[foundationId]; const auto& foundationStack = m_foundation[foundationId];
@ -484,7 +484,7 @@ bool GameState::isFoundationMoveValid(const PlayingCard& cardToMove, int foundat
return cardToMove.value() == requiredValue; return cardToMove.value() == requiredValue;
} }
bool GameState::isColumnMoveValid(const PlayingCard& cardToMove, int columnId) { bool GameState::isColumnMoveValid(const PlayingCard& cardToMove, int columnId) const {
assert(columnId >= 0 && columnId < 7); assert(columnId >= 0 && columnId < 7);
const auto& columnStack = m_columns[columnId]; const auto& columnStack = m_columns[columnId];

View file

@ -64,8 +64,8 @@ class GameState : public QObject {
bool tryAutoMoveSingleCard(PlayingCard& cardToMove, int skipColumnId = -1); bool tryAutoMoveSingleCard(PlayingCard& cardToMove, int skipColumnId = -1);
bool tryAutoMoveMultipleCards(const QList<PlayingCard*>& cards, int skipColumnId); bool tryAutoMoveMultipleCards(const QList<PlayingCard*>& cards, int skipColumnId);
bool isFoundationMoveValid(const PlayingCard& cardToMove, int foundationId); bool isFoundationMoveValid(const PlayingCard& cardToMove, int foundationId) const;
bool isColumnMoveValid(const PlayingCard& cardToMove, int columnId); bool isColumnMoveValid(const PlayingCard& cardToMove, int columnId) const;
void ensureColumnRevealed(int columnId); void ensureColumnRevealed(int columnId);
}; };