2024-12-04 18:20:06 +00:00
|
|
|
import QtQuick
|
2024-12-05 00:22:18 +00:00
|
|
|
import Solitare
|
2024-12-04 18:20:06 +00:00
|
|
|
|
|
|
|
// The throwaway pile (shows last 3 cards)
|
|
|
|
Row {
|
2024-12-08 10:41:28 +00:00
|
|
|
id: throwawayRow
|
|
|
|
required property real cardWidth
|
|
|
|
required property real cardHeight
|
|
|
|
|
2024-12-04 18:20:06 +00:00
|
|
|
// This allows makes the cards overlap
|
2024-12-08 10:41:28 +00:00
|
|
|
spacing: -cardWidth * 0.75
|
2024-12-04 18:20:06 +00:00
|
|
|
|
|
|
|
Repeater {
|
|
|
|
model: Math.min(GameState.throwawayPile.length, 3)
|
2024-12-05 02:24:09 +00:00
|
|
|
|
2024-12-05 00:22:18 +00:00
|
|
|
delegate: CardModel {
|
2024-12-04 18:20:06 +00:00
|
|
|
required property int index // passed from repeater
|
2024-12-05 00:22:18 +00:00
|
|
|
property int reversedIndex: Math.min(GameState.throwawayPile.length, 3) - 1 - index
|
2024-12-05 02:24:09 +00:00
|
|
|
|
2024-12-08 10:41:28 +00:00
|
|
|
width: throwawayRow.cardWidth
|
|
|
|
height: throwawayRow.cardHeight
|
|
|
|
|
2024-12-04 18:20:06 +00:00
|
|
|
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
|
2024-12-06 03:55:48 +00:00
|
|
|
if (reversedIndex == 0) {
|
|
|
|
if (GameState.autoMoveThrownCard()) {
|
|
|
|
if (GameState.isWinnable()) {
|
2024-12-08 10:41:28 +00:00
|
|
|
console.log("Still winnable");
|
2024-12-06 03:55:48 +00:00
|
|
|
} else {
|
2024-12-08 10:41:28 +00:00
|
|
|
console.log("Game is lost");
|
2024-12-06 03:55:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-12-04 18:20:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|