Move DrawPile to it's own file

This commit is contained in:
ItsDrike 2024-12-04 19:22:20 +01:00
parent 981d724ee4
commit 44318ac5ac
Signed by: ItsDrike
GPG key ID: FA2745890B7048C0
3 changed files with 14 additions and 9 deletions

View file

@ -24,6 +24,7 @@ qt_add_qml_module(appSolitare
QML_FILES CardModel.qml QML_FILES CardModel.qml
QML_FILES Tableau.qml QML_FILES Tableau.qml
QML_FILES ThrowawayPile.qml QML_FILES ThrowawayPile.qml
QML_FILES DrawPile.qml
SOURCES playingcard.h playingcard.cpp SOURCES playingcard.h playingcard.cpp
SOURCES gamestate.h gamestate.cpp SOURCES gamestate.h gamestate.cpp
SOURCES columnslot.h columnslot.cpp SOURCES columnslot.h columnslot.cpp

12
DrawPile.qml Normal file
View file

@ -0,0 +1,12 @@
import QtQuick
// Shows the top card facing down
// (or a blank card if the pile is empty)
CardModel {
card: GameState.drawPile.length > 0 ? GameState.drawPile[GameState.drawPile.length - 1] : null
isFaceDown: GameState.drawPile.length > 0 ? true : false
onClicked: {
GameState.drawNextCard()
}
}

View file

@ -55,15 +55,7 @@ ApplicationWindow {
anchors.right: parent.right anchors.right: parent.right
ThrowawayPile {} ThrowawayPile {}
DrawPile {}
// Draw pile (only the top card is shown)
CardModel {
card: GameState.drawPile.length > 0 ? GameState.drawPile[GameState.drawPile.length - 1] : null
isFaceDown: GameState.drawPile.length > 0 ? true : false
onClicked: {
GameState.drawNextCard()
}
}
} }
} }
} }