Add support for making moves from QML
This commit is contained in:
parent
4dbcd700c0
commit
986c2ce2be
18
Main.qml
18
Main.qml
|
@ -64,8 +64,16 @@ ApplicationWindow {
|
||||||
model: Math.min(GameState.throwawayPile.length, 3)
|
model: Math.min(GameState.throwawayPile.length, 3)
|
||||||
delegate: CardModel {
|
delegate: CardModel {
|
||||||
required property int index // passed from repeater
|
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
|
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 {
|
CardModel {
|
||||||
card: GameState.drawPile.length > 0 ? GameState.drawPile[GameState.drawPile.length - 1] : null
|
card: GameState.drawPile.length > 0 ? GameState.drawPile[GameState.drawPile.length - 1] : null
|
||||||
isFaceDown: true
|
isFaceDown: true
|
||||||
|
onClicked: {
|
||||||
|
GameState.drawNextCard()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,6 +113,11 @@ ApplicationWindow {
|
||||||
|
|
||||||
card: col.card
|
card: col.card
|
||||||
isFaceDown: !col.revealed
|
isFaceDown: !col.revealed
|
||||||
|
onClicked: {
|
||||||
|
if (col.revealed) {
|
||||||
|
GameState.autoMoveColumnCard(parent.index, index)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue