One Card! - Multiplayer Card Game
import QtQuick 2.0
import Felgo 3.0
import QtGraphicalEffects 1.0
import "../scenes"
EntityBase {
id: card
entityType: "card"
width: 82
height: 134
transformOrigin: Item.Bottom
property int originalWidth: 82
property int originalHeight: 134
variationType: "wild4"
property int points: 50
property string cardColor: "black"
property int order
property bool hidden: !forceShowAllCards
property bool forceShowAllCards: system.debugBuild && !system.publishBuild
property alias cardImage: cardImage
property alias glowImage: glowImage
property alias cardButton: cardButton
property real hue: 60/360
property real lightness: 0
property real saturation: 0
property var newParent
Image {
id: glowImage
anchors.centerIn: parent
width: parent.width * 1.3
height: parent.height * 1.2
source: "../../assets/img/cards/glow.png"
visible: false
smooth: true
}
Image {
id: cardImage
anchors.fill: parent
source: "../../assets/img/cards/back.png"
smooth: true
layer.enabled: true
layer.effect: HueSaturation {
hue: parent.hue
lightness: parent.lightness
saturation: parent.saturation
Behavior on lightness {
NumberAnimation { easing.type: Easing.InOutQuad; duration: 400 }
}
Behavior on saturation {
NumberAnimation { easing.type: Easing.InOutQuad; duration: 400 }
}
}
}
MouseArea {
id: cardButton
anchors.fill: parent
onClicked: {
gameScene.cardSelected(entityId)
}
}
SequentialAnimation {
id: hiddenAnimation
running: false
NumberAnimation { target: scaleTransform; property: "xScale"; easing.type: Easing.InOutQuad; to: 0; duration: 80 }
PropertyAction { target: cardImage; property: "source"; value: updateCardImage() }
NumberAnimation { target: scaleTransform; property: "xScale"; easing.type: Easing.InOutQuad; to: 1.0; duration: 80 }
}
Behavior on x {
NumberAnimation { easing.type: Easing.InOutQuad; duration: 400 }
}
Behavior on y {
NumberAnimation { easing.type: Easing.InOutQuad; duration: 400 }
}
Behavior on rotation {
NumberAnimation { easing.type: Easing.InOutQuad; duration: 400 }
}
Behavior on width {
NumberAnimation { easing.type: Easing.InOutQuad; duration: 400 }
}
Behavior on height {
NumberAnimation { easing.type: Easing.InOutQuad; duration: 400 }
}
states: [
State {
name: "depot"
ParentChange { target: card; parent: newParent; x: 0; y: 0; rotation: 0}
},
State {
name: "player"
ParentChange { target: card; parent: newParent; x: 0; y: 0; rotation: 0}
},
State {
name: "stack"
ParentChange { target: card; parent: newParent; x: 0; y: 0; rotation: 0}
}
]
transform: Scale {
id: scaleTransform
origin.x: width/2
origin.y: height/2
}
onHiddenChanged: {
if(hidden && forceShowAllCards) {
hidden = false
}
hiddenAnimation.start()
}
function updateCardImage(){
if (hidden){
cardImage.layer.enabled = false
cardImage.source = "../../assets/img/cards/back.png"
} else if (variationType == "wild" || variationType == "wild4"){
card.hue = 0
card.saturation = 0
card.lightness = 0.0
cardImage.layer.enabled = true
cardImage.source = "../../assets/img/cards/" + variationType + "_" + cardColor + ".png"
} else {
cardImage.layer.enabled = true
card.lightness = 0.0
if (cardColor == "yellow") {
card.hue = 55/360
card.saturation = 0
} else if (cardColor == "red") {
card.hue = 0/360
card.saturation = 0
} else if (cardColor == "green") {
card.hue = 110/360
card.saturation = -0.1
} else if (cardColor == "blue") {
card.hue = 220/360
card.saturation = -0.1
}
cardImage.source = "../../assets/img/cards/" + variationType + "_red.png"