solitare/ThrowawayPile.qml

26 lines
835 B
QML

import QtQuick
// 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) {
GameState.autoMoveThrownCard()
}
}
}
}
}