From 03e74a6c671b5cce32e3b5805019ad07dea73913 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Fri, 6 Dec 2024 03:49:25 +0100 Subject: [PATCH] Const correctness for valid move checks --- src/gamestate.cpp | 4 ++-- src/gamestate.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gamestate.cpp b/src/gamestate.cpp index ccb7084..a6229fa 100644 --- a/src/gamestate.cpp +++ b/src/gamestate.cpp @@ -455,7 +455,7 @@ bool GameState::tryAutoMoveMultipleCards(const QList& cards, int s return false; } -bool GameState::isFoundationMoveValid(const PlayingCard& cardToMove, int foundationId) { +bool GameState::isFoundationMoveValid(const PlayingCard& cardToMove, int foundationId) const { assert(foundationId >= 0 && foundationId < 4); const auto foundationSuit = static_cast(foundationId); const auto& foundationStack = m_foundation[foundationId]; @@ -484,7 +484,7 @@ bool GameState::isFoundationMoveValid(const PlayingCard& cardToMove, int foundat 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); const auto& columnStack = m_columns[columnId]; diff --git a/src/gamestate.h b/src/gamestate.h index cbeaae7..e44df58 100644 --- a/src/gamestate.h +++ b/src/gamestate.h @@ -64,8 +64,8 @@ class GameState : public QObject { bool tryAutoMoveSingleCard(PlayingCard& cardToMove, int skipColumnId = -1); bool tryAutoMoveMultipleCards(const QList& cards, int skipColumnId); - bool isFoundationMoveValid(const PlayingCard& cardToMove, int foundationId); - bool isColumnMoveValid(const PlayingCard& cardToMove, int columnId); + bool isFoundationMoveValid(const PlayingCard& cardToMove, int foundationId) const; + bool isColumnMoveValid(const PlayingCard& cardToMove, int columnId) const; void ensureColumnRevealed(int columnId); };