From 986c2ce2becbe38cc3db4f9b746b26c68f0ed487 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Wed, 4 Dec 2024 00:05:29 +0100 Subject: [PATCH] Add support for making moves from QML --- Main.qml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Main.qml b/Main.qml index c97c59d..7a009d9 100644 --- a/Main.qml +++ b/Main.qml @@ -64,8 +64,16 @@ ApplicationWindow { model: Math.min(GameState.throwawayPile.length, 3) delegate: CardModel { required property int index // passed from repeater - card: GameState.throwawayPile[GameState.throwawayPile.length - 1 - index] + property int reversedIndex: Math.min(GameState.throwawayPile.length, 3) - 1 - index; + card: GameState.throwawayPile[GameState.throwawayPile.length - 1 - reversedIndex] isFaceDown: false + onClicked: { + // Only auto-move the last card in the throwaway pile + // cards below it are shown, but shouldn't have a click effect + if (reversedIndex == 0) { + GameState.autoMoveThrownCard() + } + } } } } @@ -74,6 +82,9 @@ ApplicationWindow { CardModel { card: GameState.drawPile.length > 0 ? GameState.drawPile[GameState.drawPile.length - 1] : null isFaceDown: true + onClicked: { + GameState.drawNextCard() + } } } } @@ -102,6 +113,11 @@ ApplicationWindow { card: col.card isFaceDown: !col.revealed + onClicked: { + if (col.revealed) { + GameState.autoMoveColumnCard(parent.index, index) + } + } } } }