From 985e99cf772adcef31c6330287437ad3646e0a5b Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sat, 7 Dec 2024 20:44:10 +0100 Subject: [PATCH] bug: fix moveColumnCardToColumn for multi-card moves --- src/gamestate.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/gamestate.cpp b/src/gamestate.cpp index cfc51f6..a36c6b2 100644 --- a/src/gamestate.cpp +++ b/src/gamestate.cpp @@ -192,9 +192,18 @@ bool GameState::moveColumnCardToColumn(int fromColumnId, int toColumnId, int fro return false; } - // Success, move the card - toColumnStack.append(col); - fromColumnStack.removeLast(); + // Success, move the card, alongside all cards below it (if this is a multi-card move) + for (int i = fromCardIndex; i < fromColumnStack.size(); ++i) { + ColumnSlot* curCol = fromColumnStack[i]; + toColumnStack.append(curCol); + } + + // Remove the moved cards + while (fromColumnStack.size() > fromCardIndex) { + ColumnSlot* curSlot = fromColumnStack.takeLast(); + curSlot->deleteLater(); + } + ensureColumnRevealed(fromColumnId); qDebug() << "> Moving complete";