solitare/qml/ThrowawayPile.qml
2024-12-06 05:08:58 +01:00

34 lines
1.1 KiB
QML

import QtQuick
import Solitare
// The throwaway pile (shows last 3 cards)
Row {
// This allows makes the cards overlap
spacing: -60
Repeater {
model: Math.min(GameState.throwawayPile.length, 3)
delegate: CardModel {
required property int index // passed from repeater
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) {
if (GameState.autoMoveThrownCard()) {
if (GameState.isWinnable()) {
console.log("Still winnable")
} else {
console.log("Game is lost")
}
}
}
}
}
}
}