diff options
Diffstat (limited to 'desktop/companion/test_mood.js')
| -rw-r--r-- | desktop/companion/test_mood.js | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/desktop/companion/test_mood.js b/desktop/companion/test_mood.js index 37af2ea..3439f7c 100644 --- a/desktop/companion/test_mood.js +++ b/desktop/companion/test_mood.js @@ -27,8 +27,9 @@ const L = new Function(lsrc + "\nreturn { parse, toggle, outputs };")(); const NOW = 10000000; // A snapshot with nothing going on, overridden per case. const calm = over => Object.assign({ - now: NOW, destructAt: 0, dodging: false, shoved: false, shovedAt: 0, recording: false, busy: false, - repliedAt: 0, clicks: { count: 0, at: 0 }, mockAt: 0, typingAt: 0, wakeAt: 0, admireAt: 0, + leaving: false, now: NOW, destructAt: 0, dodging: false, shoved: false, shovedAt: 0, recording: false, busy: false, + repliedAt: 0, clicks: { count: 0, at: 0 }, mockAt: 0, typingAt: 0, wakeAt: 0, admireAt: 0, singAt: 0, + djAt: 0, music: false, groove: "", monologue: false, idle: 0, }, over); const state = over => M.pick(calm(over)).state; @@ -40,6 +41,7 @@ assert.deepStrictEqual(M.pick(calm({})), { state: "base", frame: "base" }); // The priority table, top to bottom: with every trigger from a row down // active at once, that row wins. Merged so a higher row's values win. const ladder = [ + ["bye", { leaving: true }], ["destruct", { destructAt: NOW - 10 }], ["scorched", { destructAt: NOW - M.T.destruct - 10 }], ["dodge", { dodging: true }], @@ -47,6 +49,8 @@ const ladder = [ ["listen", { recording: true }], ["think", { busy: true }], ["wave", { repliedAt: NOW - 10 }], + ["sing", { singAt: NOW - 10 }], + ["dj", { djAt: NOW - 10 }], ["clicks", { clicks: { count: 2, at: NOW - 10 } }], ["admire", { admireAt: NOW - 10 }], ["mock", { mockAt: NOW - 10 }], @@ -60,6 +64,11 @@ for (let i = 0; i < ladder.length; i++) { assert.strictEqual(state(all), ladder[i][0], "everything from " + ladder[i][0] + " down"); } +// A hide: she waves goodbye, above everything else, whatever she was doing. +assert.deepStrictEqual( + M.pick(calm({ leaving: true, idle: 3, clicks: { count: 3, at: NOW - 10 } })), + { state: "bye", frame: "wave" }); + // Shoved: knocked off balance for a moment, then mad beside the balloon // for as long as it stays. assert.deepStrictEqual(M.pick(calm({ shoved: true, shovedAt: NOW - 10 })), { state: "shoved", frame: "shoved" }); @@ -71,8 +80,21 @@ assert.deepStrictEqual(M.pick(calm({ idle: 1 })), { state: "bored", frame: "slee assert.deepStrictEqual(M.pick(calm({ idle: 2 })), { state: "yawn", frame: "yawn" }); assert.deepStrictEqual(M.pick(calm({ idle: 3 })), { state: "lying", frame: "lying" }); +// Music while bored: she grooves with the picked frame instead, whistling +// when nothing was picked; yawning and lying down are unchanged. +assert.deepStrictEqual(M.pick(calm({ idle: 1, music: true, groove: "headbang" })), { state: "groove", frame: "headbang" }); +assert.deepStrictEqual(M.pick(calm({ idle: 1, music: true })), { state: "groove", frame: "whistle" }); +assert.deepStrictEqual(M.pick(calm({ idle: 1, groove: "headbang" })), { state: "bored", frame: "sleepy" }); +assert.strictEqual(state({ idle: 2, music: true }), "yawn"); +assert.strictEqual(state({ idle: 3, music: true }), "lying"); +// Music while awake is the rest pose; the DJ is only the burst. +assert.strictEqual(state({ music: true }), "base"); +assert.deepStrictEqual(M.pick(calm({ djAt: NOW - 10 })), { state: "dj", frame: "dj" }); + // Holds end on time. assert.strictEqual(state({ repliedAt: NOW - M.T.waveHold }), "base"); +assert.strictEqual(state({ singAt: NOW - M.T.singHold }), "base"); +assert.strictEqual(state({ djAt: NOW - M.T.djHold }), "base"); assert.strictEqual(state({ typingAt: NOW - M.T.typingHold }), "base"); assert.strictEqual(state({ wakeAt: NOW - M.T.wakeHold }), "base"); assert.strictEqual(state({ clicks: { count: 3, at: NOW - M.T.clickHold } }), "base"); |
