Add per-machine audio system with Gold Rush Gulch theme and speech cues

- Introduce an `audio` block on each machine definition to hold optional
  music, intro, bandit, and dynamite clip paths.
- SlotsGame now plays a per-machine theme track when the view opens and
  falls back to the shared soundtrack pool otherwise.
- Play one-shot intro cue and sequential spin cues (bandit discovery then
  tiered dynamite) after reels stop; cues queue so they never overlap.
- Suppress the stock sticky-wild sfx on Gold Rush Gulch since the bandit
  speech cue replaces it.
- Add music and speech assets for Gold Rush Gulch (theme, intro, bandit,
  one/two/triple dynamite).
This commit is contained in:
Brian Fertig 2026-11-24 18:19:42 -07:00
parent 523b946721
commit e0fd2e5573
No known key found for this signature in database
9 changed files with 71 additions and 2 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -98,8 +98,14 @@ export default class SlotsGame extends Phaser.Scene {
startMusic() {
if (this.musicPlayer) return;
try {
const m = this.view === 'machine' ? MACHINE_BY_ID[this.machineId] : null;
// Per-machine theme (m.audio.music, relative to assets/music/) replaces
// the shared soundtrack pool while that machine is open.
const music = this.cache.json.get('music');
if (music?.tracks) this.musicPlayer = new MusicPlayer(this, music.tracks);
const tracks = m?.audio?.music
? [{ file: m.audio.music, artist: m.name, title: 'Theme' }]
: (music?.tracks ?? []);
if (tracks.length) this.musicPlayer = new MusicPlayer(this, tracks);
} catch (_) { /* optional */ }
}
@ -367,6 +373,8 @@ export default class SlotsGame extends Phaser.Scene {
buildMachine() {
const m = MACHINE_BY_ID[this.machineId];
this.machine = m;
// One-shot intro cue (per-machine `audio.intro`) as the view opens.
if (m.audio?.intro) this.cueAudio(m.audio.intro);
bakeMachineSymbols(this, m);
this.session = createSession(m, Math.random);
this.bet = m.betLevels[this.betIdx] ?? m.betLevels[0];
@ -814,6 +822,10 @@ export default class SlotsGame extends Phaser.Scene {
});
this.stage?.reelsLanded(result.totalWin > 0);
// Machine audio cues — decided only once every reel has stopped, then
// played sequentially (bandit discovery first, then the dynamite tier).
await this.playSpinCues(result, m);
let spinTotal = result.totalWin;
// Animate the engine's step script in order.
@ -948,6 +960,36 @@ export default class SlotsGame extends Phaser.Scene {
this.setControlsEnabled(true);
}
// ── Per-machine audio cues (the `audio` block in machines.js) ──────────────
// Queues clip files so multiple cues play back-to-back, never overlapping.
cueAudio(file) {
if (!file) return Promise.resolve();
const run = () => new Promise((resolve) => {
const a = new Audio(file);
a.volume = 1;
a.onended = () => resolve();
a.onerror = () => resolve();
a.play().catch(() => resolve());
});
const p = (this._cueTail ?? Promise.resolve()).then(run);
this._cueTail = p.catch(() => { /* keep the chain alive */ });
return p;
}
// Called after all reels have stopped; collects this spin's cues in order
// and plays them sequentially. Bandit: at least one NEW sticky wild landed.
// Dynamite: tiered by sticks on the reels (1 / 2 / 3+ → highest tier).
async playSpinCues(result, m) {
const a = m.audio ?? {};
const cues = [];
const stickyStep = result.steps.find((st) => st.type === 'stickyWilds');
if (a.bandit && stickyStep?.placed?.length > 0) cues.push(a.bandit);
const scatter = m.scatter?.symbol;
const n = scatter ? result.grid.flat().filter((s) => s === scatter).length : 0;
if (a.dynamite?.length && n > 0) cues.push(a.dynamite[Math.min(n, a.dynamite.length) - 1]);
for (const file of cues) await this.cueAudio(file);
}
playStickySteps(step) {
for (const { c, r } of step.placed) {
const p = this.reelView.cellCenter(c, r);

View File

@ -606,7 +606,8 @@ export class GoldRushProps {
if (placed.size > 0) {
this.stampPoster();
this.stage.lights.flashAll(0xffe27a, 1);
this.stage.sound('sticky', () => playSound(this.scene, SFX.SCIFI_RISER));
// The scene plays the machine-specific bandit cue (m.audio.bandit) instead.
if (!this.scene.machine?.audio?.bandit) this.stage.sound('sticky', () => playSound(this.scene, SFX.SCIFI_RISER));
}
}

View File

@ -71,6 +71,7 @@ export const MACHINES = [
name: 'Liberty Belle',
tagline: '1899 Original',
era: 'vintage',
audio: { music: null, intro: null },
featureLabel: 'PULL THE LEVER',
layout: { reels: 3, rows: 1 },
evaluation: 'lines',
@ -147,6 +148,7 @@ export const MACHINES = [
name: 'Fruit Frenzy',
tagline: '1965 Electro-Mechanical',
era: 'vintage',
audio: { music: null, intro: null },
featureLabel: 'HOLD & NUDGE',
layout: { reels: 3, rows: 3 },
evaluation: 'lines',
@ -234,6 +236,7 @@ export const MACHINES = [
name: 'Lucky Sevens',
tagline: '1975 Vegas Strip',
era: 'vintage',
audio: { music: null, intro: null },
featureLabel: 'WILDS DOUBLE PAYS',
layout: { reels: 3, rows: 1 },
evaluation: 'lines',
@ -331,6 +334,7 @@ export const MACHINES = [
name: "Pharaoh's Fortune",
tagline: 'Free Spins of the Nile',
era: 'modern',
audio: { music: null, intro: null },
featureLabel: 'FREE SPINS',
layout: { reels: 5, rows: 3 },
evaluation: 'lines',
@ -425,6 +429,7 @@ export const MACHINES = [
name: 'Abyssal Treasures',
tagline: 'Cascades of the Deep',
era: 'modern',
audio: { music: null, intro: null },
featureLabel: 'CASCADING REELS',
layout: { reels: 5, rows: 3 },
evaluation: 'lines',
@ -504,6 +509,7 @@ export const MACHINES = [
name: "Dragon's Hoard",
tagline: 'Hold & Spin Jackpots',
era: 'modern',
audio: { music: null, intro: null },
featureLabel: 'JACKPOT COINS',
layout: { reels: 5, rows: 3 },
evaluation: 'lines',
@ -612,6 +618,25 @@ export const MACHINES = [
name: 'Gold Rush Gulch',
tagline: 'Sticky Bandits & Mine Carts',
era: 'modern',
// Per-machine audio overrides — the other machines reserve the same slots
// and can be filled in the same way later:
// music theme track (relative to assets/music/), replaces the shared
// soundtrack pool while this machine is open
// intro plays once when the machine view opens
// bandit plays when a spin lands at least one NEW sticky bandit
// (replaces the stock sticky-wild fx)
// dynamite tiered by sticks on the reels after the spin: index 0 = 1,
// 1 = 2, 2 = 3+; multiple cues play sequentially
audio: {
music: 'slots/gold-rush-gulch.mp3',
intro: 'assets/speech/slots/gold-rush-gulch-intro.mp3',
bandit: 'assets/speech/slots/gold-rush-gulch-bandit.mp3',
dynamite: [
'assets/speech/slots/gold-rush-one-dynomite.mp3',
'assets/speech/slots/gold-rush-two-dynomites.mp3',
'assets/speech/slots/gold-rush-triple-dynomite.mp3',
],
},
featureLabel: 'PICK BONUS',
layout: { reels: 5, rows: 3 },
evaluation: 'lines',
@ -699,6 +724,7 @@ export const MACHINES = [
name: 'Sugar Spin',
tagline: 'Tumbling Candy Mountain',
era: 'modern',
audio: { music: null, intro: null },
featureLabel: 'TUMBLE WINS',
layout: { reels: 6, rows: 5 },
evaluation: 'scatterPays',