diff --git a/README.md b/README.md index 95e6144..7b8cce5 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ A native 3D chess game for Omarchy, built with C++ and Qt Quick 3D. Play against The sets have individually sculpted pieces: swept metal panels, orbital rings and a crescent queen; carved wood and ivory horses; woodland foxes, owls, acorn sprites and antlered royalty; and glossy candy pieces with curled manes and gold crowns. -Pieces glide into place, knights hop, captures shrink away, and check gets a brief pulse. Reduced motion is available in Settings. The interface follows Omarchy's theme and language; the board's materials follow the selected set. +Every set moves in its own manner. Orbital craft hover over their squares with pulsing lights, bank into a glide and scan when chosen. Midnight Atelier's pieces are handled under flickering candlelight: tilted in unseen fingers, set down with a rock, and tipped over when taken. Moss & Myth's creatures breathe and stir, turn to watch a neighbour being picked, and leap. Candy Kingdom's sweets wobble like jelly and pop. Knights jump highest everywhere, and check gets a brief pulse. Reduced motion is available in Settings. The interface follows Omarchy's theme and language; the board's materials follow the selected set. ## Play diff --git a/src/BoardView.qml b/src/BoardView.qml index 3510dfb..ed5f2ec 100644 --- a/src/BoardView.qml +++ b/src/BoardView.qml @@ -21,6 +21,16 @@ Item { property var frames: ["#28343f", "#432b22", "#5b4934", "#f0dccb"] property var accents: ["#dcad62", "#cba265", "#9baa6b", "#dca6ab"] property bool sceneReady: false + // The board keeps time for its figures, which hover, breathe, stir and watch one another while the window has the player's attention. + property bool lively: motion + // Midnight Atelier is lit by a flame, which is never quite steady. + property real flicker: lively && design === 1 ? .04 * Math.sin(clock * 7.3) * Math.sin(clock * 2.1) + .018 * Math.sin(clock * 13.7) : 0 + property real clock: 0 + FrameAnimation { running: board.lively; onTriggered: board.clock += frameTime } + Timer { + interval: 1700; repeat: true; running: board.lively + onTriggered: if (Math.random() < .75) figures.objectAt(Math.floor(Math.random() * 32)).fidget() + } Component.onCompleted: Qt.callLater(function() { sceneReady = true }) clip: true focus: true @@ -107,7 +117,7 @@ Item { DirectionalLight { eulerRotation: Qt.vector3d(-45,-35,0) color: "#ffebd2" - brightness: 1.05 + brightness: 1.05 * (1 + board.flicker) castsShadow: true shadowMapQuality: Light.ShadowMapQualityHigh shadowFactor: 80 @@ -159,12 +169,15 @@ Item { source: "#Cylinder" visible: parent.target y: 56 - scale: Qt.vector3d(.23,1.1,.23) + // Markers swell and settle so the way forward is never static. + property real swell: board.lively && visible ? .23 * (1 + .09 * Math.sin(board.clock * 3.1 + tile.index)) : .23 + scale: Qt.vector3d(swell,1.1,swell) materials: PrincipledMaterial { baseColor: board.accents[board.design]; opacity: .8; lighting: PrincipledMaterial.NoLighting } } } } Repeater3D { + id: figures model: 32 ChessPiece { required property int index @@ -173,6 +186,8 @@ Item { design: board.design seat: board.seat motion: board.motion + clock: board.clock + attention: backend.selected selected: backend.selected === record.square && record.alive } } diff --git a/src/ChessPiece.qml b/src/ChessPiece.qml index 770376e..c15700a 100644 --- a/src/ChessPiece.qml +++ b/src/ChessPiece.qml @@ -12,7 +12,10 @@ Node { required property bool selected required property real seat property real lift: 0 - property real presence: record.alive ? 1 : 0 + // Followed by hand, like `place`, so a capture can be timed to its captor's arrival. + property bool alive: record.alive + property real presence: 0 + property int reprieve: 0 property bool ready: false // Moss & Myth is one carved figure per piece, painted in its mesh rather than by part. property bool woodland: design === 2 @@ -29,50 +32,234 @@ Node { property vector3d sugarGlow: !candy ? Qt.vector3d(0,0,0) : record.white ? Qt.vector3d(.24,.085,.095) : Qt.vector3d(.105,.05,.125) property vector3d secondGlow: design === 0 ? (record.white ? Qt.vector3d(.22,.95,1.05) : Qt.vector3d(1.25,.55,.08)) : !candy ? Qt.vector3d(0,0,0) : record.white ? Qt.vector3d(.15,.03,.06) : Qt.vector3d(.06,.025,.1) - x: record.square % 8 - 3.5 - z: 3.5 - Math.floor(record.square / 8) - y: .12 + lift + (selected ? .1 : 0) - scale: Qt.vector3d(presence, presence, presence) + // Each set moves in its own manner. Orbital craft hover, bank into a glide and scan with their lights up. Atelier's pieces + // are handled: tilted in unseen fingers, carried over, set down with a rock, and tipped over when taken. The woodland + // creatures breathe, look and leap. The sweets wobble like jelly and pop. + required property real clock + required property int attention + readonly property var manners: [ + { breath: 0, bulge: 0, sway: 0, hover: .035, drift: .02, raise: .2, raiseTime: 380, spring: false, bob: .06, pinch: 0, + windup: 0, crouch: 1, stretch: 1, squash: 1, lean: 11, counter: -6, dip: .03, settle: Easing.OutCubic, settleTime: 320, glide: Easing.InOutCubic, + arc: .04, arcPer: .01, arcMax: .1, knightArc: .45, pace: 340, pacePer: 60, start: 1, reach: 1, shake: 20, shakeTime: 170, + look: 9, glance: 14, skip: 0, fade: 320, pop: false, twirl: 0, topple: 0 }, + { breath: 0, bulge: 0, sway: 0, hover: 0, drift: 0, raise: .14, raiseTime: 220, spring: false, bob: 0, pinch: 3.5, + windup: 0, crouch: 1, stretch: 1, squash: 1, lean: 5, counter: -4, dip: 0, settle: Easing.OutElastic, settleTime: 650, glide: Easing.InOutCubic, + arc: .16, arcPer: .03, arcMax: .34, knightArc: .5, pace: 320, pacePer: 45, start: 1, reach: 1, shake: 0, shakeTime: 100, + look: 0, glance: 0, skip: 0, fade: 380, pop: false, twirl: 0, topple: 80 }, + { breath: .011, bulge: .6, sway: 1.2, hover: 0, drift: 0, raise: .17, raiseTime: 300, spring: true, bob: .1, pinch: 0, + windup: 70, crouch: .9, stretch: 1.07, squash: .88, lean: 9, counter: -5, dip: 0, settle: Easing.OutBack, settleTime: 320, glide: Easing.InOutSine, + arc: .12, arcPer: .04, arcMax: .36, knightArc: .55, pace: 300, pacePer: 50, start: .93, reach: 1.08, shake: 9, shakeTime: 110, + look: 20, glance: 15, skip: .07, fade: 300, pop: false, twirl: 160, topple: 0 }, + { breath: .014, bulge: .9, sway: .6, hover: 0, drift: 0, raise: .17, raiseTime: 320, spring: true, bob: .12, pinch: 0, + windup: 80, crouch: .84, stretch: 1.1, squash: .8, lean: 6, counter: -3, dip: 0, settle: Easing.OutElastic, settleTime: 560, glide: Easing.InOutSine, + arc: .16, arcPer: .04, arcMax: .4, knightArc: .6, pace: 320, pacePer: 50, start: .88, reach: 1.13, shake: 0, shakeTime: 100, + look: 12, glance: 0, skip: .05, fade: 280, pop: true, twirl: 0, topple: 0 } + ] + readonly property var manner: manners[design] + property int square: record.square + // Where the figure stands. It follows `square` by hand so a journey is measured before the slide starts. + property int place: 0 + property int travel: 360 + property real raise: selected ? manner.raise : 0 + property real held: raise / manner.raise + property real stretch: 1 + property real lean: 0 + property real leanX: 0 + property real leanZ: 0 + property real wiggle: 0 + // Idle life pauses with the clock when the window is left, and is gone altogether under reduced motion. + property real vigor: backend.reducedMotion ? 0 : 1 + // A tree stump stirs far less than the creatures around it. + property real liveliness: woodland && record.kind === 4 ? .3 : 1 + property real phase: pieceId * 2.399 + property real breath: vigor * liveliness * Math.sin(clock * (1.5 + pieceId % 5 * .11) + phase) + property real tall: stretch * (1 + manner.breath * breath * (1 + raise * 6)) + property real wide: 1 + (1 - tall) * manner.bulge + // A piece in the fingers tips toward the player and is never held quite still. + property real tilt: held * manner.pinch * (1 + vigor * .35 * Math.sin(clock * 1.7 + phase)) + // Orbital lights idle at a slow pulse, come up in the hand and when a neighbour is chosen, and go out with a capture. + property real pulse: design === 0 ? presence * (1 + vigor * .2 * Math.sin(clock * 1.3 + phase) + held * .9 + Math.abs(look) / 18) : 1 // Every figure faces whoever is seated at the board. Knights turn in toward its middle: the foxes // a little, the horses far enough to show their profile. property real knightTurn: woodland ? 32 : 58 - eulerRotation.y: 180 + seat + (record.kind === 2 ? (pieceId % 2 ? knightTurn : -knightTurn) * Math.cos(seat * Math.PI / 180) : 0) - Behavior on x { id: xBehavior; enabled: piece.ready && piece.motion; NumberAnimation { id: slideX; duration: 360; easing.type: Easing.InOutCubic } } - Behavior on z { id: zBehavior; enabled: piece.ready && piece.motion; NumberAnimation { id: slideZ; duration: 360; easing.type: Easing.InOutCubic } } - Behavior on y { id: yBehavior; enabled: piece.ready && piece.motion && !hop.running; NumberAnimation { id: selectionLift; duration: 180; easing.type: Easing.OutCubic } } - Behavior on presence { id: presenceBehavior; enabled: piece.ready && piece.motion; NumberAnimation { id: captureShrink; duration: 220; easing.type: Easing.InCubic } } + property real facing: 180 + seat + (record.kind === 2 ? (pieceId % 2 ? knightTurn : -knightTurn) * Math.cos(seat * Math.PI / 180) : 0) + // Neighbours turn part of the way toward the figure in hand; one standing behind them is left alone. + property real look: regard() + function regard() { + if (!motion || attention < 0 || selected || !record.alive) return 0 + let dx = attention % 8 - place % 8, dz = Math.floor(place / 8) - Math.floor(attention / 8) + let reach = Math.hypot(dx, dz) + if (reach < .5 || reach > 3.3) return 0 + return manner.look * liveliness * Math.sin(Math.atan2(-dx, -dz) - facing * Math.PI / 180) * Math.min(1, (3.3 - reach) / 2) + } + x: place % 8 - 3.5 + z: 3.5 - Math.floor(place / 8) + y: .12 + manner.hover + vigor * manner.drift * Math.sin(clock * .9 + phase) + lift + raise * (1 + vigor * manner.bob * Math.sin(clock * 3.1 + phase)) + scale: Qt.vector3d(presence * wide, presence * tall, presence * wide) + // A captured woodland figure twirls as it goes; a captured Atelier piece is tipped onto its side. + eulerRotation.y: facing + wiggle + look + vigor * liveliness * manner.sway * Math.sin(clock * .7 + phase * 1.7) + (1 - presence) * manner.twirl + eulerRotation.x: lean * leanZ + tilt + eulerRotation.z: -lean * leanX + Math.min(1, (1 - presence) * 2.2) * manner.topple * (pieceId % 2 ? 1 : -1) + Behavior on x { + id: xBehavior; enabled: piece.ready && piece.motion + SequentialAnimation { + PauseAnimation { duration: piece.manner.windup } + NumberAnimation { duration: piece.travel; easing.type: piece.manner.glide } + } + } + Behavior on z { + id: zBehavior; enabled: piece.ready && piece.motion + SequentialAnimation { + PauseAnimation { duration: piece.manner.windup } + NumberAnimation { duration: piece.travel; easing.type: piece.manner.glide } + } + } + Behavior on raise { + id: raiseBehavior; enabled: piece.ready && piece.motion + NumberAnimation { duration: piece.manner.raiseTime; easing.type: piece.manner.spring && piece.selected ? Easing.OutBack : Easing.OutCubic } + } + Behavior on look { + id: lookBehavior; enabled: piece.ready && piece.motion + SequentialAnimation { + PauseAnimation { duration: piece.pieceId * 53 % 140 } + NumberAnimation { duration: 380; easing.type: piece.manner.spring ? Easing.OutBack : Easing.InOutCubic } + } + } + // The captured figure waits for its captor to arrive. A sweet swells before it pops. + Behavior on presence { + id: presenceBehavior; enabled: piece.ready && piece.motion + SequentialAnimation { + PauseAnimation { duration: piece.reprieve } + NumberAnimation { duration: piece.manner.fade; easing.type: piece.manner.pop && !piece.record.alive ? Easing.InBack : Easing.InCubic } + } + } onMotionChanged: { if (!motion) { xBehavior.enabled = false; zBehavior.enabled = false - yBehavior.enabled = false; presenceBehavior.enabled = false - hop.stop(); lift = 0 + raiseBehavior.enabled = false; lookBehavior.enabled = false; presenceBehavior.enabled = false + compose() // Resolve moves queued before the first animation frame as well. - x = Qt.binding(function() { return piece.record.square % 8 - 3.5 }) - z = Qt.binding(function() { return 3.5 - Math.floor(piece.record.square / 8) }) - y = Qt.binding(function() { return .12 + piece.lift + (piece.selected ? .1 : 0) }) - presence = Qt.binding(function() { return piece.record.alive ? 1 : 0 }) + x = Qt.binding(function() { return piece.place % 8 - 3.5 }) + z = Qt.binding(function() { return 3.5 - Math.floor(piece.place / 8) }) + raise = Qt.binding(function() { return piece.selected ? piece.manner.raise : 0 }) + look = Qt.binding(function() { return piece.regard() }) + presence = alive ? 1 : 0 xBehavior.enabled = Qt.binding(function() { return piece.ready && piece.motion }) zBehavior.enabled = Qt.binding(function() { return piece.ready && piece.motion }) - yBehavior.enabled = Qt.binding(function() { return piece.ready && piece.motion && !hop.running }) + raiseBehavior.enabled = Qt.binding(function() { return piece.ready && piece.motion }) + lookBehavior.enabled = Qt.binding(function() { return piece.ready && piece.motion }) presenceBehavior.enabled = Qt.binding(function() { return piece.ready && piece.motion }) } } - Component.onCompleted: ready = true - Connections { - target: backend - function onMoved(id, knight, capture) { - if (id === piece.pieceId && piece.motion) { - hop.height = knight ? .48 : .14 - hop.restart() + onSquareChanged: { + if (ready && motion && record.alive) { + let dx = square % 8 - 3.5 - x, dz = 3.5 - Math.floor(square / 8) - z, reach = Math.hypot(dx, dz) + if (reach > .01) { + // Further is slower and higher; knights clear whatever stands between. + travel = Math.min(manner.pace + 320, manner.pace + manner.pacePer * reach) + leap.height = record.kind === 2 ? manner.knightArc : Math.min(manner.arcMax, manner.arc + manner.arcPer * reach) + // The figure leans along its path, which is turned into its own frame. + let turn = eulerRotation.y * Math.PI / 180 + leanX = (dx * Math.cos(turn) - dz * Math.sin(turn)) / reach + leanZ = (dx * Math.sin(turn) + dz * Math.cos(turn)) / reach + // The journey takes over whatever pose an interrupted stir left behind. + perk.stop(); skip.stop(); glance.stop() + leap.restart() + } + } + place = square + } + onAliveChanged: { + // The captor's journey is the last move's; the taken figure starts to go just before it lands. + let from = backend.lastFrom, to = backend.lastTo + let reach = from < 0 ? 0 : Math.hypot(to % 8 - from % 8, Math.floor(to / 8) - Math.floor(from / 8)) + reprieve = alive ? 0 : Math.max(0, manner.windup + Math.min(manner.pace + 320, manner.pace + manner.pacePer * reach) - manner.fade * .4) + presence = alive ? 1 : 0 + } + onSelectedChanged: if (selected && motion && ready) { skip.stop(); glance.stop(); perk.restart() } + // A new set starts from rest rather than finishing the last one's gesture. + onDesignChanged: compose() + Component.onCompleted: { place = square; presence = alive ? 1 : 0; ready = true } + function compose() { + leap.stop(); perk.stop(); glance.stop(); skip.stop() + lift = 0; stretch = 1; lean = 0; wiggle = 0 + } + // Now and then the board asks an idle figure to stir: a look to one side, or a small skip from the sweets, the young and the foxes. + function fidget() { + if (!motion || !record.alive || liveliness < 1 || selected || look !== 0) return + if (leap.running || perk.running || glance.running || skip.running) return + if (manner.skip > 0 && (manner.glance === 0 || (record.kind <= 2 && Math.random() < .4))) skip.restart() + else if (manner.glance > 0) { glance.side = Math.random() < .5 ? -1 : 1; glance.restart() } + } + // The journey: a crouch where the set has one, an arc leaning into the way ahead, and a landing that settles in character. + SequentialAnimation { + id: leap + objectName: "leap" + property real height: .2 + NumberAnimation { target: piece; property: "stretch"; to: piece.manner.crouch; duration: piece.manner.windup; easing.type: Easing.OutQuad } + ParallelAnimation { + SequentialAnimation { + NumberAnimation { target: piece; property: "lift"; to: leap.height; duration: piece.travel * .5; easing.type: Easing.OutQuad } + NumberAnimation { target: piece; property: "lift"; to: 0; duration: piece.travel * .5; easing.type: Easing.InQuad } + } + SequentialAnimation { + NumberAnimation { target: piece; property: "stretch"; to: piece.manner.stretch; duration: piece.travel * .3; easing.type: Easing.OutQuad } + NumberAnimation { target: piece; property: "stretch"; to: 1; duration: piece.travel * .7 } + } + SequentialAnimation { + NumberAnimation { target: piece; property: "lean"; to: piece.manner.lean; duration: piece.travel * .35; easing.type: Easing.OutQuad } + NumberAnimation { target: piece; property: "lean"; to: piece.manner.counter; duration: piece.travel * .65; easing.type: Easing.InOutQuad } + } + NumberAnimation { target: piece; property: "wiggle"; to: 0; duration: piece.travel * .5; easing.type: Easing.OutQuad } + } + ParallelAnimation { + SequentialAnimation { + NumberAnimation { target: piece; property: "stretch"; to: piece.manner.squash; duration: 70; easing.type: Easing.OutQuad } + NumberAnimation { target: piece; property: "stretch"; to: 1; duration: piece.manner.settleTime; easing.type: piece.manner.settle } } + NumberAnimation { target: piece; property: "lean"; to: 0; duration: piece.manner.settleTime; easing.type: piece.manner.settle } + // A hovering craft sinks a little under its own arrival. + SequentialAnimation { + NumberAnimation { target: piece; property: "lift"; to: -piece.manner.dip; duration: 130; easing.type: Easing.OutQuad } + NumberAnimation { target: piece; property: "lift"; to: 0; duration: 260; easing.type: Easing.InOutQuad } + } + } + } + // Picked up: a start and a stretch, then a shake of the head or a scan to either side. + ParallelAnimation { + id: perk + objectName: "perk" + NumberAnimation { target: piece; property: "lift"; to: 0; duration: 150; easing.type: Easing.OutQuad } + SequentialAnimation { + NumberAnimation { target: piece; property: "stretch"; to: piece.manner.start; duration: 70; easing.type: Easing.OutQuad } + NumberAnimation { target: piece; property: "stretch"; to: piece.manner.reach; duration: 150; easing.type: Easing.OutQuad } + NumberAnimation { target: piece; property: "stretch"; to: 1; duration: piece.manner.settleTime; easing.type: piece.manner.settle } + } + SequentialAnimation { + PauseAnimation { duration: 120 } + NumberAnimation { target: piece; property: "wiggle"; to: piece.manner.shake; duration: piece.manner.shakeTime; easing.type: Easing.InOutSine } + NumberAnimation { target: piece; property: "wiggle"; to: -piece.manner.shake * .8; duration: piece.manner.shakeTime * 1.4; easing.type: Easing.InOutSine } + NumberAnimation { target: piece; property: "wiggle"; to: 0; duration: piece.manner.shakeTime * 2; easing.type: piece.manner.spring ? Easing.OutBack : Easing.InOutCubic } } } SequentialAnimation { - id: hop - objectName: "moveHop" - property real height: .15 - NumberAnimation { target: piece; property: "lift"; to: hop.height; duration: 150; easing.type: Easing.OutQuad } - NumberAnimation { target: piece; property: "lift"; to: 0; duration: 210; easing.type: Easing.InOutQuad } + id: glance + property int side: 1 + NumberAnimation { target: piece; property: "wiggle"; to: glance.side * piece.manner.glance; duration: 380; easing.type: Easing.InOutSine } + PauseAnimation { duration: 500 } + NumberAnimation { target: piece; property: "wiggle"; to: 0; duration: 520; easing.type: Easing.InOutSine } + } + ParallelAnimation { + id: skip + SequentialAnimation { + NumberAnimation { target: piece; property: "lift"; to: piece.manner.skip; duration: 130; easing.type: Easing.OutQuad } + NumberAnimation { target: piece; property: "lift"; to: 0; duration: 170; easing.type: Easing.InQuad } + } + SequentialAnimation { + NumberAnimation { target: piece; property: "stretch"; to: 1.05; duration: 130 } + NumberAnimation { target: piece; property: "stretch"; to: .94; duration: 170 } + NumberAnimation { target: piece; property: "stretch"; to: 1; duration: piece.manner.settleTime; easing.type: piece.manner.settle } + } } Model { objectName: "piece-" + piece.pieceId @@ -93,7 +280,8 @@ Node { // A full lacquer mirrors the dark of the room at every grazing edge, so the sweets wear only a light glaze. clearcoatAmount: piece.woodland ? 0 : piece.design === 0 ? .2 : .35 clearcoatRoughnessAmount: piece.design === 1 ? .14 : piece.candy ? .08 : .2 - emissiveFactor: piece.sugarGlow + // A sweet warms a little in the hand. + emissiveFactor: piece.sugarGlow.times(1 + piece.held * .6) cullMode: Material.NoCulling } } @@ -138,7 +326,7 @@ Node { clearcoatAmount: piece.candy ? .35 : 0 clearcoatRoughnessAmount: piece.candy ? .08 : .2 // Orbital lights burn in their own colour whatever the room is doing. - emissiveFactor: piece.secondGlow + emissiveFactor: piece.secondGlow.times(piece.pulse) cullMode: Material.NoCulling } } diff --git a/tests/checkmate_tests.cpp b/tests/checkmate_tests.cpp index b38e9f8..a7f04ca 100644 --- a/tests/checkmate_tests.cpp +++ b/tests/checkmate_tests.cpp @@ -819,7 +819,7 @@ private slots: auto *pawn=window->findChild("figure-20"); QVERIFY(pawn); QVERIFY(backend.move(12,28)); - QTest::qWait(100); + QTest::qWait(160); QVERIFY(pawn->property("lift").toDouble()>0); QVERIFY(pawn->property("z").toDouble()>.5); QVERIFY(pawn->property("z").toDouble()<2.5); @@ -827,15 +827,99 @@ private slots: // Quick 3D coordinates use float precision, including the final animation setter. QTRY_VERIFY_WITH_TIMEOUT(qFuzzyCompare(pawn->property("z").toFloat(),2.5f),1500); QTRY_COMPARE_WITH_TIMEOUT(pawn->property("lift").toDouble(),0.0,1500); - auto *hop=pawn->findChild("moveHop"); - QVERIFY(hop); + auto *leap=pawn->findChild("leap"); + auto *perk=pawn->findChild("perk"); + QVERIFY(leap && perk); QVERIFY(backend.move(12,28)); - QVERIFY(hop->property("running").toBool()); + QVERIFY(leap->property("running").toBool()); backend.setReducedMotion(true); - QVERIFY(!hop->property("running").toBool()); + QVERIFY(!leap->property("running").toBool()); QCOMPARE(pawn->property("lift").toDouble(),0.0); QCOMPARE(pawn->property("z").toDouble(),.5); + // Every set picks a piece up to its own height, carries it in an arc that leans into the journey, and settles it squarely. + for (int set=0;set<4;++set) { + backend.newGame(false,0); + backend.setPieceSet(set); + backend.setReducedMotion(false); + QTRY_VERIFY(board->property("clock").toDouble()>0); + backend.selectSquare(12); + QVERIFY(perk->property("running").toBool()); + const double raised=std::vector{.2,.14,.17,.17}[set]; + QTRY_VERIFY(qAbs(pawn->property("raise").toDouble()-raised)<.001); + // A move made mid-shake, or a pick-up mid-skip, leaves nothing of the interrupted pose behind. + pawn->setProperty("wiggle",8.0); + pawn->setProperty("lift",.05); + backend.selectSquare(12); + backend.selectSquare(12); + QTRY_COMPARE(pawn->property("lift").toDouble(),0.0); + pawn->setProperty("wiggle",8.0); + QVERIFY(backend.move(12,28)); + QVERIFY(leap->property("running").toBool()); + QTRY_VERIFY(qAbs(pawn->property("lean").toDouble())>2); + QVERIFY(pawn->property("lift").toDouble()>0); + // A captured piece waits for its captor, then goes. + QVERIFY(backend.move(51,35)); + auto *taken=window->findChild("figure-"+QString::number(backend.position().board[35].id)); + QVERIFY(taken); + QVERIFY(backend.move(28,35)); + QCOMPARE(taken->property("presence").toDouble(),1.0); + QTRY_COMPARE_WITH_TIMEOUT(taken->property("presence").toDouble(),0.0,2500); + QTRY_VERIFY_WITH_TIMEOUT(!leap->property("running").toBool(),2500); + QCOMPARE(pawn->property("lean").toDouble(),0.0); + QCOMPARE(pawn->property("stretch").toDouble(),1.0); + QCOMPARE(pawn->property("lift").toDouble(),0.0); + QCOMPARE(pawn->property("wiggle").toDouble(),0.0); + // A long capture is waited out: the taken piece is still whole when a short one would already have gone. + QVERIFY(backend.move(59,35)); + auto *queen=window->findChild("figure-"+QString::number(backend.position().board[35].id)); + auto *far=window->findChild("figure-"+QString::number(backend.position().board[7].id)); + QVERIFY(queen && far); + QVERIFY(backend.move(14,22)); + QVERIFY(backend.move(35,7)); + QVERIFY(far->property("reprieve").toInt()>taken->property("reprieve").toInt()+150); + QCOMPARE(far->property("presence").toDouble(),1.0); + // Changing sets mid-journey starts the new one from rest. + backend.setPieceSet((set+1)%4); + QVERIFY(!queen->findChild("leap")->property("running").toBool()); + QCOMPARE(queen->property("lean").toDouble(),0.0); + backend.setReducedMotion(true); + QCOMPARE(far->property("presence").toDouble(),0.0); + } + // Moss & Myth is alive: it breathes, perks up in the hand, draws its neighbours' eyes, and leaps. + backend.newGame(false,0); + backend.setPieceSet(2); + backend.setReducedMotion(false); + QTRY_VERIFY(board->property("clock").toDouble()>0); + QTRY_VERIFY(qAbs(pawn->property("tall").toDouble()-1)>.002); + auto *neighbour=window->findChild("figure-"+QString::number(backend.position().board[11].id)); + QVERIFY(neighbour); + backend.selectSquare(12); + QVERIFY(perk->property("running").toBool()); + QTRY_VERIFY(qAbs(pawn->property("raise").toDouble()-.17)<.001); + QTRY_VERIFY(qAbs(neighbour->property("look").toDouble())>5); + QVERIFY(backend.move(12,28)); + QVERIFY(leap->property("running").toBool()); + QTRY_VERIFY(qAbs(pawn->property("lean").toDouble())>2); + QVERIFY(pawn->property("lift").toDouble()>0); + QTRY_VERIFY_WITH_TIMEOUT(!leap->property("running").toBool(),2000); + QVERIFY(qFuzzyCompare(pawn->property("z").toFloat(),.5f)); + QCOMPARE(pawn->property("lean").toDouble(),0.0); + QCOMPARE(pawn->property("stretch").toDouble(),1.0); + QTRY_COMPARE(neighbour->property("look").toDouble(),0.0); + // Reduced motion stills a leap in flight and every idle stir with it. + backend.undo(); + QVERIFY(leap->property("running").toBool()); + backend.selectSquare(11); + backend.setReducedMotion(true); + QVERIFY(!leap->property("running").toBool()); + QCOMPARE(pawn->property("tall").toDouble(),1.0); + QCOMPARE(pawn->property("look").toDouble(),0.0); + QCOMPARE(pawn->property("z").toDouble(),2.5); + QCOMPARE(pawn->property("y").toFloat(),.12f); + QCOMPARE(neighbour->property("y").toFloat(),.29f); + backend.setPieceSet(3); + backend.newGame(false,0); QTest::qWait(100); auto *scene=window->findChild("scene");