mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-16 20:45:33 -08:00
Add Snake and Light Trails music, dealt fresh each round
AI Assisted
This commit is contained in:
1 parent
6cd7a7ff80
commit
ff1c793633
14 files changed
+1377
-23
No files matched your search
@@ -11,7 +11,7 @@ import assert from "node:assert/strict";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath, pathToFileURL } from "node:url";
|
||||
import { ACTIVITIES, bestKey, bestKeys, memoKey, musicKey, musicLevel } from "../src/web-console/public/activities.js";
|
||||
import { BOSS_BITES, COMBO_MS, DISCOVERIES, FOOD_PER_LEVEL, FRUITS, GRID, ICE_STEPS, LEVELS, MAX_COMBO, MIN_CELL, MIN_STEP_MS, POWERS, STEP_MS, SURPRISES, age, applyPower, applySurprise, fruitFor, tallyBit, newRound, onFood, SPECIALS, pace, placeFood, step, stepMs, turn } from "../src/web-console/public/activities/snake.js";
|
||||
import { BOSS_BITES, COMBO_MS, MAX_LEVEL, MUSIC_TRACKS, dealMusic, heat, trackFor, DISCOVERIES, FOOD_PER_LEVEL, FRUITS, GRID, ICE_STEPS, LEVELS, MAX_COMBO, MIN_CELL, MIN_STEP_MS, POWERS, STEP_MS, SURPRISES, age, applyPower, applySurprise, fruitFor, tallyBit, newRound, onFood, SPECIALS, pace, placeFood, step, stepMs, turn } from "../src/web-console/public/activities/snake.js";
|
||||
import golf, * as golfRules from "../src/web-console/public/activities/golf.js";
|
||||
import { COURSE_W, COURSE_H, COURSES, FRONT_NINE, HOLE_COUNT, courseById } from "../src/web-console/public/activities/golf-holes.js";
|
||||
import { holeQuip, holeWord, knownGround, knownLiquid } from "../src/web-console/public/activities/golf-draw.js";
|
||||
@@ -308,13 +308,13 @@ test("memoKey builds a flat looks.json key from a list id", () => {
|
||||
|
||||
test("musicKey builds a flat looks.json key, and a game with music has a default volume a saved one replaces", () => {
|
||||
assert.equal(musicKey("ghoul"), "activityMusicGhoul");
|
||||
assert.deepEqual(ACTIVITIES.filter((a) => a.music !== undefined).map((a) => [a.id, a.music]), [["drive", 70], ["ghoul", 65]], "the games with music, at about the level they were picked at on the prototype pages");
|
||||
assert.deepEqual(ACTIVITIES.filter((a) => a.music !== undefined).map((a) => [a.id, a.music]), [["snake", 70], ["trails", 70], ["drive", 70], ["ghoul", 65]], "the games with music, at about the level they were picked at on the prototype pages");
|
||||
const ghoulEntry = ACTIVITIES.find((a) => a.id === "ghoul");
|
||||
assert.equal(musicLevel(ghoulEntry, undefined), 0.65, "nothing saved: the default");
|
||||
assert.equal(musicLevel(ghoulEntry, "loud"), 0.65, "not a number: the default");
|
||||
assert.equal(musicLevel(ghoulEntry, 0), 0, "turned all the way down");
|
||||
assert.equal(musicLevel(ghoulEntry, 140), 1, "never past full");
|
||||
assert.equal(musicLevel(ACTIVITIES[0], 80), 0, "a game with no music has none");
|
||||
assert.equal(musicLevel(ACTIVITIES.find((a) => a.id === "golf"), 80), 0, "a game with no music has none");
|
||||
});
|
||||
|
||||
test("every listed game, and a stub second game, answers the game contract", async () => {
|
||||
@@ -457,6 +457,58 @@ test("Snake: a wall hit ends the round and onScore fires once", async () => {
|
||||
assert.equal(scores.length, 1, "no second onScore after the round is over");
|
||||
});
|
||||
|
||||
test("Snake: a round deals every track once, never opens on the last opener, and gives each level its own", () => {
|
||||
let n = 7;
|
||||
const random = () => (n = (n * 1664525 + 1013904223) % 4294967296) / 4294967296;
|
||||
for (let i = 0; i < 20; i++) {
|
||||
const last = MUSIC_TRACKS[i % MUSIC_TRACKS.length];
|
||||
const deck = dealMusic(random, last);
|
||||
assert.deepEqual([...deck].sort(), [...MUSIC_TRACKS].sort(), "every track once");
|
||||
assert.notEqual(deck[0], last, "never opens on the last opener");
|
||||
}
|
||||
const deck = dealMusic(random, null);
|
||||
const heard = Array.from({ length: MAX_LEVEL }, (_, i) => trackFor(deck, i + 1));
|
||||
assert.equal(new Set(heard).size, MAX_LEVEL, "nine levels hear nine different tracks");
|
||||
assert.equal(trackFor(deck, 0), deck[0], "a level below one hears the first");
|
||||
assert.equal(trackFor(deck, MUSIC_TRACKS.length + 1), deck[0], "past the deck it comes round again");
|
||||
assert.notDeepEqual(dealMusic(random, null), dealMusic(random, null), "a new deal is a new order");
|
||||
});
|
||||
|
||||
test("Snake: the music's heat starts at 0.3, climbs with the snake's speed to 1 and thins out in Slow-mo", () => {
|
||||
const round = newRound(GRID, () => 0);
|
||||
assert.ok(Math.abs(heat(round) - 0.3) < 1e-9, "the opening pace is 0.3, so the lead and drums are in from the first step");
|
||||
round.snake = Array.from({ length: 30 }, (_, i) => ({ x: i % GRID, y: 0 }));
|
||||
assert.equal(heat(round), 1, "a long snake at its fastest pace is 1");
|
||||
round.effects = { slow: 7000 };
|
||||
assert.ok(heat(round) < 1 && heat(round) >= 0.3, "Slow-mo thins it out");
|
||||
round.snake = round.snake.slice(0, 3);
|
||||
assert.equal(heat(round), 0.3, "and never under 0.3");
|
||||
});
|
||||
|
||||
test("Snake: it asks for the deal's track while a round runs, and the next round opens on another", async () => {
|
||||
const { canvas } = stubCanvas();
|
||||
const asked = [];
|
||||
const game = (await import("../src/web-console/public/activities/snake.js")).default;
|
||||
const g = game.create({ canvas, music: (name, level) => asked.push([name, level]) });
|
||||
g.resize(GRID * MIN_CELL, GRID * MIN_CELL);
|
||||
g.tick(STEP_MS);
|
||||
assert.equal(asked.length, 0, "silent before a round");
|
||||
g.start();
|
||||
g.tick(16);
|
||||
assert.equal(asked.length, 1, "asked once a tick");
|
||||
const [first, opening] = asked[0];
|
||||
assert.ok(MUSIC_TRACKS.includes(first), "a track the game has");
|
||||
assert.ok(Math.abs(opening - 0.3) < 1e-9, "at the opening heat");
|
||||
for (let i = 0; i < GRID + 2 && g.state === "running"; i++) g.tick(STEP_MS);
|
||||
assert.equal(g.state, "over");
|
||||
const before = asked.length;
|
||||
g.tick(STEP_MS * 10);
|
||||
assert.equal(asked.length, before, "nothing asked for once the round is over");
|
||||
g.start();
|
||||
g.tick(16);
|
||||
assert.notEqual(asked.at(-1)[0], first, "the next round opens on another track");
|
||||
});
|
||||
|
||||
test("Snake: running into its own body ends the round", () => {
|
||||
const round = newRound(GRID, () => 0);
|
||||
// Head at (5,5) heading right into (6,5), which is body, not the tail.
|
||||
@@ -2307,6 +2359,62 @@ test("Light Trails: every pill's text reads at 4.5:1 on its backing and its time
|
||||
});
|
||||
});
|
||||
|
||||
test("Light Trails: a round deals every track once, never opens on the last opener, and gives each arena its own", () => {
|
||||
let n = 11;
|
||||
const random = () => (n = (n * 1664525 + 1013904223) % 4294967296) / 4294967296;
|
||||
for (let i = 0; i < 20; i++) {
|
||||
const last = trails.MUSIC_TRACKS[i % trails.MUSIC_TRACKS.length];
|
||||
const deck = trails.dealMusic(random, last);
|
||||
assert.deepEqual([...deck].sort(), [...trails.MUSIC_TRACKS].sort(), "every track once");
|
||||
assert.notEqual(deck[0], last, "never opens on the last opener");
|
||||
}
|
||||
const deck = trails.dealMusic(random, null);
|
||||
const heard = Array.from({ length: trails.MAX_LEVEL }, (_, i) => trails.trackFor(deck, i + 1));
|
||||
assert.equal(new Set(heard).size, trails.MAX_LEVEL, "nine arenas hear nine different tracks");
|
||||
assert.equal(trails.trackFor(deck, 0), deck[0], "a level below one hears the first");
|
||||
assert.notDeepEqual(trails.dealMusic(random, null), trails.dealMusic(random, null), "a new deal is a new order");
|
||||
});
|
||||
|
||||
test("Light Trails: the music's heat is low while a heat lines up, rises once the riders go, more so down to the last rival, and is full on a boost", () => {
|
||||
const round = trails.newRound(() => 0.5);
|
||||
assert.equal(round.phase, "ready");
|
||||
const waiting = trails.heat(round);
|
||||
assert.ok(waiting < 0.5, "lining up: no lead yet");
|
||||
round.level = 2;
|
||||
trails.newHeat(round, () => 0.5);
|
||||
round.phase = "race";
|
||||
assert.ok(round.riders.filter((r) => r.id !== 0).length >= 2, "two rivals at level 2");
|
||||
const racing = trails.heat(round);
|
||||
assert.ok(racing >= 0.5 && racing < 1, "racing with rivals left: the lead is in");
|
||||
for (const r of round.riders.filter((r) => r.id !== 0).slice(1)) r.alive = false;
|
||||
assert.ok(trails.heat(round) > racing && trails.heat(round) < 1, "down to the last rival it climbs");
|
||||
round.effects = { ...round.effects, boost: trails.BOOST_MS };
|
||||
assert.equal(trails.heat(round), 1, "a boost pushes it all the way");
|
||||
});
|
||||
|
||||
test("Light Trails: it asks for the deal's track while a round runs, silent before and after, and the next round opens on another", () => {
|
||||
const { canvas } = stubCanvas();
|
||||
const asked = [];
|
||||
const g = trails.default.create({ canvas, music: (name, level) => asked.push([name, level]) });
|
||||
g.resize(800, 600);
|
||||
g.tick(16);
|
||||
assert.equal(asked.length, 0, "silent before a round");
|
||||
g.start();
|
||||
g.tick(16);
|
||||
assert.equal(asked.length, 1, "asked once a tick");
|
||||
const [first] = asked[0];
|
||||
assert.ok(trails.MUSIC_TRACKS.includes(first), "a track the game has");
|
||||
g.round.lives = 1;
|
||||
for (let i = 0; i < 2000 && g.state === "running"; i++) g.tick(50);
|
||||
assert.equal(g.state, "over", "riding straight ends the round");
|
||||
const before = asked.length;
|
||||
g.tick(500);
|
||||
assert.equal(asked.length, before, "nothing asked for once the round is over");
|
||||
g.start();
|
||||
g.tick(16);
|
||||
assert.notEqual(asked.at(-1)[0], first, "the next round opens on another track");
|
||||
});
|
||||
|
||||
test("Light Trails game: the opening banner sits in the board from the start's first frame, held through the 3, 2, 1, and does not jump on the first tick", () => {
|
||||
const { canvas, shades } = bannerCanvas("rgba(0, 0, 0, 0.3)");
|
||||
const g = trails.default.create({ canvas });
|
||||
|
||||
@@ -1266,7 +1266,8 @@ test("a game with music has its own Music slider, at its default until moved, ke
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_WORKING });
|
||||
const slider = s.page.locator("#activities-music-level");
|
||||
await openActivities(s, "snake");
|
||||
assert.equal(await s.page.locator("#activities-music").isVisible(), false, "Snake has no music, so no slider");
|
||||
assert.equal(await s.page.locator("#activities-music").isVisible(), true, "Snake has a slider");
|
||||
assert.equal(await boxValue(slider), "70", "at its default");
|
||||
await s.page.keyboard.press("Escape");
|
||||
await s.page.waitForFunction(() => !document.getElementById("activities-modal").open);
|
||||
await openActivities(s, "ghoul");
|
||||
@@ -2515,7 +2516,7 @@ test("Ghoul Rush plays in the real window: its board's shape and Planny big enou
|
||||
test("the server serves the activities' scripts, golf's seventeen, Light Trails, Bug Hunt, Sunset Drive, Stack Deploy, Bumper Ring's two, Rapids Run's two, Hot Potato's two, Crossing Rush's two, Bounce Road's seven, Ghoul Rush's ninety-five, every game's sound effects and the shared pills included", () => {
|
||||
const server = fs.readFileSync(new URL("../src/web-console/static.mjs", import.meta.url), "utf8");
|
||||
const servable = server.slice(server.indexOf("const SERVABLE = new Set(["), server.indexOf("]);", server.indexOf("const SERVABLE = new Set([")));
|
||||
for (const file of ["activities.js", "tones.js", "music.js", "activities/snake.js", "screens/activities.js", "activities/golf.js", "activities/golf-holes.js", "activities/golf-draw.js", "activities/golf-decor.js", "activities/golf-kit.js", "activities/golf-paint.js", "activities/golf-looks.js", "activities/golf-course-pirate.js", "activities/golf-course-cave.js", "activities/golf-course-dino.js", "activities/golf-course-candy.js", "activities/golf-course-space.js", "activities/golf-course-frost.js", "activities/golf-look-dino.js", "activities/golf-look-candy.js", "activities/golf-look-space.js", "activities/golf-look-frost.js", "activities/trails.js", "activities/bugs.js", "activities/drive.js", "activities/stack.js", "activities/bumper.js", "activities/bumper-draw.js", "activities/rapids.js", "activities/rapids-draw.js", "activities/fuse.js", "activities/fuse-draw.js", "activities/hop.js", "activities/hop-draw.js", "activities/bounce.js", "activities/bounce-draw.js", "activities/bounce-roads.js", "activities/bounce-road.js", "activities/bounce-rivals.js", "activities/bounce-scenery.js", "activities/bounce-cars.js", "activities/ghoul-rush/ghoul.js", "activities/ghoul-rush/draw/ghoul-draw.js", "activities/ghoul-rush/core/ghoul-rooms.js", "activities/ghoul-rush/stages/wing/ghoul-bones.js", "activities/ghoul-rush/stages/wing/ghoul-bones-draw.js", "activities/ghoul-rush/stages/graveyard/ghoul-graveyard.js", "activities/ghoul-rush/stages/graveyard/ghoul-graveyard-draw.js", "activities/ghoul-rush/stages/grounds/ghoul-grounds.js", "activities/ghoul-rush/stages/grounds/ghoul-grounds-draw.js", "activities/ghoul-rush/stages/chapel/ghoul-chapel.js", "activities/ghoul-rush/stages/chapel/ghoul-chapel-draw.js", "activities/ghoul-rush/stages/sanatorium/ghoul-sanatorium.js", "activities/ghoul-rush/stages/sanatorium/ghoul-sanatorium-draw.js", "activities/ghoul-rush/stages/village/ghoul-village.js", "activities/ghoul-rush/stages/village/ghoul-village-draw.js", "activities/ghoul-rush/stages/village/ghoul-village-world.js", "activities/ghoul-rush/stages/village/ghoul-village-wolf.js", "activities/ghoul-rush/stages/mine/ghoul-mine.js", "activities/ghoul-rush/stages/mine/ghoul-mine-draw.js", "activities/ghoul-rush/stages/mine/ghoul-mine-world.js", "activities/ghoul-rush/stages/mine/ghoul-mine-tommy.js", "activities/ghoul-rush/rides/cart/ghoul-cart.js", "activities/ghoul-rush/rides/cart/ghoul-cart-draw.js", "activities/ghoul-rush/rides/sled/ghoul-sled.js", "activities/ghoul-rush/rides/sled/ghoul-sled-draw.js", "activities/ghoul-rush/rides/gurney/ghoul-gurney.js", "activities/ghoul-rush/rides/gurney/ghoul-gurney-draw.js", "activities/ghoul-rush/rides/banister/ghoul-banister.js", "activities/ghoul-rush/rides/banister/ghoul-banister-draw.js", "activities/ghoul-rush/rides/banister/ghoul-sfx-banister.js", "activities/ghoul-rush/rides/hearse/ghoul-hearse.js", "activities/ghoul-rush/rides/hearse/ghoul-hearse-draw.js", "activities/ghoul-rush/rides/wagon/ghoul-wagon.js", "activities/ghoul-rush/rides/wagon/ghoul-wagon-draw.js", "activities/ghoul-rush/rides/pew/ghoul-pew.js", "activities/ghoul-rush/rides/pew/ghoul-pew-draw.js", "activities/ghoul-rush/rides/pew/ghoul-pew-course.js", "activities/ghoul-rush/rides/pew/ghoul-pew-world.js", "activities/ghoul-rush/rides/mower/ghoul-mower.js", "activities/ghoul-rush/rides/mower/ghoul-mower-draw.js", "activities/ghoul-rush/rides/tray/ghoul-tray.js", "activities/ghoul-rush/rides/tray/ghoul-tray-draw.js", "activities/ghoul-rush/stages/carnival/ghoul-carnival.js", "activities/ghoul-rush/stages/carnival/ghoul-carnival-draw.js", "activities/ghoul-rush/stages/carnival/ghoul-carnival-world.js", "activities/ghoul-rush/stages/frozen/ghoul-frozen.js", "activities/ghoul-rush/stages/frozen/ghoul-frozen-draw.js", "activities/ghoul-rush/stages/frozen/ghoul-frozen-world.js", "activities/ghoul-rush/arms/ghoul-flare.js", "activities/ghoul-rush/stages/bog/ghoul-bog.js", "activities/ghoul-rush/stages/bog/ghoul-bog-draw.js", "activities/ghoul-rush/stages/marrow/ghoul-marrow.js", "activities/ghoul-rush/stages/marrow/ghoul-marrow-draw.js", "activities/ghoul-rush/rides/mat/ghoul-mat-room.js", "activities/ghoul-rush/rides/mat/ghoul-mat.js", "activities/ghoul-rush/rides/mat/ghoul-mat-draw.js", "activities/ghoul-rush/stages/marrow/ghoul-dollhouse-room.js", "activities/ghoul-rush/stages/marrow/ghoul-marrow-eye.js", "activities/ghoul-rush/stages/marrow/ghoul-marrow-eye-draw.js", "activities/ghoul-rush/rides/bonestair/ghoul-bonestair-room.js", "activities/ghoul-rush/rides/bonestair/ghoul-bonestair.js", "activities/ghoul-rush/rides/bonestair/ghoul-bonestair-draw.js", "activities/ghoul-rush/stages/marrow/ghoul-pit-room.js", "activities/ghoul-rush/stages/marrow/ghoul-marrow-heart.js", "activities/ghoul-rush/stages/marrow/ghoul-marrow-heart-draw.js", "activities/ghoul-rush/story/ghoul-ending.js", "activities/ghoul-rush/story/ghoul-ending-draw.js", "activities/ghoul-rush/draw/ghoul-picker-draw.js", "activities/ghoul-rush/core/ghoLine truncated
|
||||
for (const file of ["activities.js", "tones.js", "music.js", "activities/snake.js", "activities/snake-music.js", "activities/trails-music.js", "screens/activities.js", "activities/golf.js", "activities/golf-holes.js", "activities/golf-draw.js", "activities/golf-decor.js", "activities/golf-kit.js", "activities/golf-paint.js", "activities/golf-looks.js", "activities/golf-course-pirate.js", "activities/golf-course-cave.js", "activities/golf-course-dino.js", "activities/golf-course-candy.js", "activities/golf-course-space.js", "activities/golf-course-frost.js", "activities/golf-look-dino.js", "activities/golf-look-candy.js", "activities/golf-look-space.js", "activities/golf-look-frost.js", "activities/trails.js", "activities/bugs.js", "activities/drive.js", "activities/stack.js", "activities/bumper.js", "activities/bumper-draw.js", "activities/rapids.js", "activities/rapids-draw.js", "activities/fuse.js", "activities/fuse-draw.js", "activities/hop.js", "activities/hop-draw.js", "activities/bounce.js", "activities/bounce-draw.js", "activities/bounce-roads.js", "activities/bounce-road.js", "activities/bounce-rivals.js", "activities/bounce-scenery.js", "activities/bounce-cars.js", "activities/ghoul-rush/ghoul.js", "activities/ghoul-rush/draw/ghoul-draw.js", "activities/ghoul-rush/core/ghoul-rooms.js", "activities/ghoul-rush/stages/wing/ghoul-bones.js", "activities/ghoul-rush/stages/wing/ghoul-bones-draw.js", "activities/ghoul-rush/stages/graveyard/ghoul-graveyard.js", "activities/ghoul-rush/stages/graveyard/ghoul-graveyard-draw.js", "activities/ghoul-rush/stages/grounds/ghoul-grounds.js", "activities/ghoul-rush/stages/grounds/ghoul-grounds-draw.js", "activities/ghoul-rush/stages/chapel/ghoul-chapel.js", "activities/ghoul-rush/stages/chapel/ghoul-chapel-draw.js", "activities/ghoul-rush/stages/sanatorium/ghoul-sanatorium.js", "activities/ghoul-rush/stages/sanatorium/ghoul-sanatorium-draw.js", "activities/ghoul-rush/stages/village/ghoul-village.js", "activities/ghoul-rush/stages/village/ghoul-village-draw.js", "activities/ghoul-rush/stages/village/ghoul-village-world.js", "activities/ghoul-rush/stages/village/ghoul-village-wolf.js", "activities/ghoul-rush/stages/mine/ghoul-mine.js", "activities/ghoul-rush/stages/mine/ghoul-mine-draw.js", "activities/ghoul-rush/stages/mine/ghoul-mine-world.js", "activities/ghoul-rush/stages/mine/ghoul-mine-tommy.js", "activities/ghoul-rush/rides/cart/ghoul-cart.js", "activities/ghoul-rush/rides/cart/ghoul-cart-draw.js", "activities/ghoul-rush/rides/sled/ghoul-sled.js", "activities/ghoul-rush/rides/sled/ghoul-sled-draw.js", "activities/ghoul-rush/rides/gurney/ghoul-gurney.js", "activities/ghoul-rush/rides/gurney/ghoul-gurney-draw.js", "activities/ghoul-rush/rides/banister/ghoul-banister.js", "activities/ghoul-rush/rides/banister/ghoul-banister-draw.js", "activities/ghoul-rush/rides/banister/ghoul-sfx-banister.js", "activities/ghoul-rush/rides/hearse/ghoul-hearse.js", "activities/ghoul-rush/rides/hearse/ghoul-hearse-draw.js", "activities/ghoul-rush/rides/wagon/ghoul-wagon.js", "activities/ghoul-rush/rides/wagon/ghoul-wagon-draw.js", "activities/ghoul-rush/rides/pew/ghoul-pew.js", "activities/ghoul-rush/rides/pew/ghoul-pew-draw.js", "activities/ghoul-rush/rides/pew/ghoul-pew-course.js", "activities/ghoul-rush/rides/pew/ghoul-pew-world.js", "activities/ghoul-rush/rides/mower/ghoul-mower.js", "activities/ghoul-rush/rides/mower/ghoul-mower-draw.js", "activities/ghoul-rush/rides/tray/ghoul-tray.js", "activities/ghoul-rush/rides/tray/ghoul-tray-draw.js", "activities/ghoul-rush/stages/carnival/ghoul-carnival.js", "activities/ghoul-rush/stages/carnival/ghoul-carnival-draw.js", "activities/ghoul-rush/stages/carnival/ghoul-carnival-world.js", "activities/ghoul-rush/stages/frozen/ghoul-frozen.js", "activities/ghoul-rush/stages/frozen/ghoul-frozen-draw.js", "activities/ghoul-rush/stages/frozen/ghoul-frozen-world.js", "activities/ghoul-rush/arms/ghoul-flare.js", "activities/ghoul-rush/stages/bog/ghoul-bog.js", "activities/ghoul-rush/stages/bog/ghoul-bog-draw.js", "activities/ghoul-rush/stages/marrow/ghoul-marrow.js", "activities/ghoul-rush/stages/marrow/ghoul-marrow-draw.js", "activities/ghoul-rush/rides/mat/ghoul-mat-room.js", "activities/ghoul-rush/rides/mat/ghoul-mat.js", "activities/ghoul-rush/rides/mat/ghoul-mat-draw.js", "activities/ghoul-rush/stages/marrow/ghoul-dollhouse-room.js", "activities/ghoul-rush/stages/marrow/ghoul-marrow-eye.js", "activities/ghoul-rush/stages/marrow/ghoul-marrow-eye-draw.js", "activities/ghoul-rush/rides/bonestair/ghoul-bonestair-room.js", "activities/ghoul-rush/rides/bonestair/ghoul-bonestair.js", "activities/ghoul-rush/rides/bonestair/ghoul-bonestair-draw.js", "activities/ghoul-rush/stages/marrow/ghoul-pit-room.js", "activities/ghoul-rush/stages/marrow/ghoul-marrow-heart.js", "activities/ghoul-rush/stages/marrow/ghoul-marrow-heart-draw.js", "activities/ghoul-rush/story/ghoul-ending.js", "activities/ghoul-rush/story/ghoul-ending-draw.js", "activities/ghoul-rush/Line truncated
|
||||
assert.ok(servable.includes(`"${file}"`), `SERVABLE includes ${file}`);
|
||||
}
|
||||
});
|
||||
@@ -13,6 +13,10 @@ import { looks } from "../src/web-console/public/looks.js";
|
||||
import { compileTrack, hushMusic, music, musicNames, noteFreq } from "../src/web-console/public/music.js";
|
||||
import { MUSIC_TABLES } from "../src/web-console/public/tones.js";
|
||||
import { REGIONS, ROAD_MUSIC } from "../src/web-console/public/activities/drive.js";
|
||||
import { MUSIC_TRACKS } from "../src/web-console/public/activities/snake.js";
|
||||
import snakeSfx from "../src/web-console/public/activities/snake-sfx.js";
|
||||
import { MUSIC_TRACKS as TRAILS_TRACKS } from "../src/web-console/public/activities/trails.js";
|
||||
import trailsSfx from "../src/web-console/public/activities/trails-sfx.js";
|
||||
|
||||
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
||||
const GAMES = path.join(ROOT, "src/web-console/public/activities");
|
||||
@@ -213,6 +217,16 @@ test("music: a track that does not read is turned away", () => {
|
||||
assert.equal(arp.patterns.A.lines.a[0].len, 3, "held for three steps");
|
||||
});
|
||||
|
||||
test("music: a track in another meter sets its bar, and a pattern that is not whole bars is turned away", () => {
|
||||
const steps = (n) => Array(n).fill(".").join(" ");
|
||||
const ok = { bpm: 120, bar: 12, voices: { a: { wave: "pulse" } }, patterns: { A: { a: steps(24) } }, order: ["A"] };
|
||||
assert.equal(compileTrack(ok).length, 24, "two bars of 6/8");
|
||||
assert.throws(() => compileTrack({ ...ok, patterns: { A: { a: steps(16) } } }), /whole bars/);
|
||||
assert.throws(() => compileTrack({ ...ok, bar: 2 }), /bar/);
|
||||
assert.throws(() => compileTrack({ ...ok, bar: 100 }), /bar/);
|
||||
assert.equal(compileTrack({ ...ok, bar: undefined, patterns: { A: { a: steps(16) } } }).length, 16, "no bar: sixteen steps, as before");
|
||||
});
|
||||
|
||||
test("music: a track plays notes while asked for, quiets when hushed, and stays silent while Play sounds is off", () => {
|
||||
const saved = { sound: looks.sound, ctor: globalThis.AudioContext };
|
||||
const { Ctx, made } = AUDIO;
|
||||
@@ -335,6 +349,25 @@ test("music: the volume scales the track's level, a change glides there, and a v
|
||||
}
|
||||
});
|
||||
|
||||
test("music: Snake lists exactly the tracks it has, each a real track that no other game defines", () => {
|
||||
const tracks = new Set(musicNames());
|
||||
assert.deepEqual([...MUSIC_TRACKS].sort(), Object.keys(snakeSfx.music).sort(), "the game lists the tracks its sound file has");
|
||||
for (const name of MUSIC_TRACKS) {
|
||||
assert.ok(tracks.has(name), `track "${name}" exists`);
|
||||
assert.equal(MUSIC_TABLES.filter((t) => Object.hasOwn(t, name)).length, 1, `${name} is defined once`);
|
||||
}
|
||||
});
|
||||
|
||||
test("music: Light Trails lists exactly the tracks it has, each a real track that no other game defines, enough for every arena", () => {
|
||||
const tracks = new Set(musicNames());
|
||||
assert.deepEqual([...TRAILS_TRACKS].sort(), Object.keys(trailsSfx.music).sort(), "the game lists the tracks its sound file has");
|
||||
assert.ok(TRAILS_TRACKS.length >= 9, "nine arenas, none hearing a track twice");
|
||||
for (const name of TRAILS_TRACKS) {
|
||||
assert.ok(tracks.has(name), `track "${name}" exists`);
|
||||
assert.equal(MUSIC_TABLES.filter((t) => Object.hasOwn(t, name)).length, 1, `${name} is defined once`);
|
||||
}
|
||||
});
|
||||
|
||||
test("music: every Sunset Drive road has a song, and every song is a real track", () => {
|
||||
const tracks = new Set(musicNames());
|
||||
assert.deepEqual(Object.keys(ROAD_MUSIC).sort(), Object.keys(REGIONS).sort(), "a song for every road");
|
||||
|
||||
Reference in new issue
Block a user