solitare/qml/ThrowawayPile.qml

35 lines
1 KiB
QML

import QtQuick
import Solitare
// The throwaway pile (shows last 3 cards)
Row {
id: throwawayRow
required property real cardWidth
required property real cardHeight
// This allows makes the cards overlap
spacing: -cardWidth * 0.75
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
width: throwawayRow.cardWidth
height: throwawayRow.cardHeight
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();
}
}
}
}
}