diff --git a/assets/videos/slots/attract-abyssal-treasures.mp4 b/assets/videos/slots/attract-abyssal-treasures.mp4 new file mode 100644 index 0000000..f9ddab3 Binary files /dev/null and b/assets/videos/slots/attract-abyssal-treasures.mp4 differ diff --git a/assets/videos/slots/attract-dragons-hoard.mp4 b/assets/videos/slots/attract-dragons-hoard.mp4 new file mode 100644 index 0000000..daa5c39 Binary files /dev/null and b/assets/videos/slots/attract-dragons-hoard.mp4 differ diff --git a/assets/videos/slots/attract-fruit-frenzy.mp4 b/assets/videos/slots/attract-fruit-frenzy.mp4 new file mode 100644 index 0000000..f63997b Binary files /dev/null and b/assets/videos/slots/attract-fruit-frenzy.mp4 differ diff --git a/assets/videos/slots/attract-gold-rush-gulch.mp4 b/assets/videos/slots/attract-gold-rush-gulch.mp4 new file mode 100644 index 0000000..dab0ea9 Binary files /dev/null and b/assets/videos/slots/attract-gold-rush-gulch.mp4 differ diff --git a/assets/videos/slots/attract-liberty-belle.mp4 b/assets/videos/slots/attract-liberty-belle.mp4 new file mode 100644 index 0000000..99689fb Binary files /dev/null and b/assets/videos/slots/attract-liberty-belle.mp4 differ diff --git a/assets/videos/slots/attract-lucky-sevens.mp4 b/assets/videos/slots/attract-lucky-sevens.mp4 new file mode 100644 index 0000000..4631426 Binary files /dev/null and b/assets/videos/slots/attract-lucky-sevens.mp4 differ diff --git a/assets/videos/slots/attract-pharaohs-fortune.mp4 b/assets/videos/slots/attract-pharaohs-fortune.mp4 new file mode 100644 index 0000000..21b1581 Binary files /dev/null and b/assets/videos/slots/attract-pharaohs-fortune.mp4 differ diff --git a/assets/videos/slots/attract-sugar-spin.mp4 b/assets/videos/slots/attract-sugar-spin.mp4 new file mode 100644 index 0000000..6cb7da9 Binary files /dev/null and b/assets/videos/slots/attract-sugar-spin.mp4 differ diff --git a/assets/videos/slots/slots-floor.mp4 b/assets/videos/slots/slots-floor.mp4 new file mode 100644 index 0000000..c7e50f4 Binary files /dev/null and b/assets/videos/slots/slots-floor.mp4 differ diff --git a/src/games/slots/SlotsGame.js b/src/games/slots/SlotsGame.js index 09eb81c..bd12793 100644 --- a/src/games/slots/SlotsGame.js +++ b/src/games/slots/SlotsGame.js @@ -27,6 +27,12 @@ import { const D = { bg: 0, cab: 5, reel: 10, ui: 40 }; const JACKPOT_LS = 'slots-jackpot-grand'; +// Lobby-card attract videos: assets/videos/slots/attract-.mp4, +// except where the file name doesn't match the id. +const CARD_VIDEO_FILES = { + 'gold-rush': 'attract-gold-rush-gulch.mp4', +}; + const FEATURE_BLURBS = { 'liberty-belle': 'Pull the lever. Three bells ring in the big one.', 'fruit-frenzy': 'Losing spins can offer HOLDs or award up to 3 NUDGES.', @@ -99,7 +105,6 @@ export default class SlotsGame extends Phaser.Scene { } saveJackpot(v) { try { localStorage.setItem(JACKPOT_LS, String(v)); } catch { /* ignore */ } } - bestWin(id) { try { return Number(localStorage.getItem(`slots-best-${id}`)) || 0; } catch { return 0; } } // ── Background ─────────────────────────────────────────────────────────────── buildBackground(glowColor) { @@ -118,6 +123,7 @@ export default class SlotsGame extends Phaser.Scene { // ════════════════════════ LOBBY ═══════════════════════════════════════════════ buildLobby() { this.buildBackground(COLORS.gold); + this.buildLobbyVideo(); this.add.text(GAME_WIDTH / 2, 64, 'SLOT MACHINES', { fontFamily: 'Righteous', fontSize: '56px', color: COLORS.goldHex, }).setOrigin(0.5).setDepth(D.ui).setShadow(0, 0, 'rgba(212,160,23,0.85)', 22); @@ -125,26 +131,92 @@ export default class SlotsGame extends Phaser.Scene { fontFamily: '"Julius Sans One"', fontSize: '22px', color: COLORS.mutedHex, }).setOrigin(0.5).setDepth(D.ui); - this.creditText = this.add.text(GAME_WIDTH - 50, 64, `CHIPS ${this.credits.toLocaleString()}`, { + this.creditText = this.add.text(GAME_WIDTH - 50, 114, `CHIPS ${this.credits.toLocaleString()}`, { fontFamily: 'Righteous', fontSize: '30px', color: '#8cf28a', }).setOrigin(1, 0.5).setDepth(D.ui); - new Button(this, 150, 64, 'Leave', () => this.leave(), { width: 180, height: 54, variant: 'ghost' }) + new Button(this, 150, 114, 'Leave', () => this.leave(), { width: 180, height: 54, variant: 'ghost' }) .setDepth(D.ui); const lastPlayed = (() => { try { return localStorage.getItem('slots-last-machine'); } catch { return null; } })(); - const jackpot = this.loadJackpot(); const cw = 420; const chh = 380; const gap = 32; const x0 = GAME_WIDTH / 2 - (4 * cw + 3 * gap) / 2 + cw / 2; MACHINES.forEach((m, i) => { const x = x0 + (i % 4) * (cw + gap); const y = 380 + Math.floor(i / 4) * (chh + 50); - this.buildLobbyCard(m, x, y, cw, chh, { lastPlayed, jackpot, index: i }); + this.buildLobbyCard(m, x, y, cw, chh, { lastPlayed, index: i }); }); } - buildLobbyCard(m, x, y, w, h, { lastPlayed, jackpot, index }) { + // Looping casino-floor clip behind the lobby. Muted, no audio track, and the + // gradient from buildBackground stays underneath as the fallback if the + // fetch or playback fails. (Same pattern as SpellingBee's bg video.) + buildLobbyVideo() { + const KEY = 'slots-floor-video'; + const PATH = 'assets/videos/slots/slots-floor.mp4'; + if (!this.cache.video?.exists(KEY)) { + this.load.video(KEY, PATH, true); // noAudio — visual only + if (!this.load.isLoading()) this.load.start(); + } + const v = this.add.video(GAME_WIDTH / 2, GAME_HEIGHT / 2, KEY).setDepth(D.bg + 1); + v.setLoop(true); + v.setMute(true); + + // Cover, not contain: fill edge-to-edge once the real dimensions are known. + const fit = () => { + const w = v.videoTexture ? v.width : GAME_WIDTH; + const h = v.videoTexture ? v.height : GAME_HEIGHT; + v.setScale(Math.max(GAME_WIDTH / w, GAME_HEIGHT / h)); + }; + fit(); + v.on('created', fit); + v.on('playing', fit); + + // On failure, drop the video and let the gradient show through. + v.once('error', () => { if (v.scene) v.destroy(); }); + + v.setAlpha(0); + v.play(true); + this.tweens.add({ targets: v, alpha: 1, duration: 700, ease: 'Sine.easeOut' }); + + // Dim layer on top of the footage so the title and cards stay readable. + this.add.rectangle(GAME_WIDTH / 2, GAME_HEIGHT / 2, GAME_WIDTH, GAME_HEIGHT, + 0x000000, 0.45).setDepth(D.bg + 2); + } + + // Looping attract clip in the card's marquee area, on top of the static + // art. Starts muted (autoplay policy) and stays muted until the pointer + // hovers the card; pointerout mutes it again. On load/playback failure the + // video is destroyed and the fallback art beneath shows through. + addCardAttractVideo(card, file, w, h) { + const key = `slots-attract-${file.replace(/\.mp4$/, '')}`; + if (!this.cache.video?.exists(key)) { + this.load.video(key, `assets/videos/slots/${file}`); // audio kept — hover unmutes + if (!this.load.isLoading()) this.load.start(); + } + const v = this.add.video(0, -6, key).setOrigin(0.5); + card.add(v); + v.setLoop(true); + v.setMute(true); + + // Cover the marquee area (w-16 × h-90) once real dimensions are known; + // the texture is absent until the fetch lands, so scale on created/playing. + const fit = () => { + if (!v.videoTexture) return; + v.setScale(Math.max((w - 16) / v.width, (h - 90) / v.height)); + }; + v.on('created', fit); + v.on('playing', fit); + v.once('error', () => { if (v.scene) v.destroy(); }); + v.play(true); + + card.on('pointerover', () => { if (v.scene) v.setMute(false); }); + card.on('pointerout', () => { if (v.scene) v.setMute(true); }); + return v; + } + + buildLobbyCard(m, x, y, w, h, { lastPlayed, index }) { bakeMachineSymbols(this, m); const t = m.theme; const card = this.add.container(x, y).setDepth(D.ui); @@ -165,13 +237,16 @@ export default class SlotsGame extends Phaser.Scene { g.strokeRoundedRect(-w / 2 + 26, -42, w - 52, 130, 12); card.add(g); - // Marquee. + // Marquee: attract video (audio only while the pointer hovers the card). + // The static/generated art below stays as the fallback, revealed if the + // video fetch or playback fails. (Same video pattern as the lobby bg.) const cardArtKey = `slots-${m.id}-card`; - if (this.textures.exists(cardArtKey)) { + const hasCardArt = this.textures.exists(cardArtKey); + if (hasCardArt) { const art = this.add.image(0, -6, cardArtKey).setDisplaySize(w - 16, h - 90); card.add(art); } - if (!this.textures.exists(cardArtKey)) { + if (!hasCardArt) { const name = this.add.text(0, -h / 2 + 52, m.name.toUpperCase(), { fontFamily: 'Righteous', fontSize: '30px', color: t.accentHex, align: 'center', }).setOrigin(0.5).setShadow(0, 0, t.accentHex, 16); @@ -189,7 +264,7 @@ export default class SlotsGame extends Phaser.Scene { card.add(era); // Three sample symbols on the mini screen. - if (!this.textures.exists(cardArtKey)) { + if (!hasCardArt) { const sample = m.symbols.slice(0, 3); sample.forEach((sym, si) => { const img = this.add.image((si - 1) * 110, 22, textureKeyFor(this, m.id, sym)) @@ -198,6 +273,8 @@ export default class SlotsGame extends Phaser.Scene { }); } + this.addCardAttractVideo(card, CARD_VIDEO_FILES[m.id] ?? `attract-${m.id}.mp4`, w, h); + // Feature chip + stats. const chip = this.add.text(0, 118, m.featureLabel, { fontFamily: 'Righteous', fontSize: '20px', color: '#14100a', @@ -206,18 +283,6 @@ export default class SlotsGame extends Phaser.Scene { }).setOrigin(0.5); card.add(chip); - const best = this.bestWin(m.id); - const statStr = m.id === 'dragons-hoard' - ? `GRAND ${Math.floor(jackpot).toLocaleString()}` - : (best > 0 ? `BEST WIN ${best.toLocaleString()}` : 'UNPLAYED'); - const stat = this.add.text(0, 156, statStr, { - fontFamily: '"Julius Sans One"', fontSize: '18px', - color: m.id === 'dragons-hoard' ? '#ffd86b' : COLORS.mutedHex, - }).setOrigin(0.5); - card.add(stat); - if (m.id === 'dragons-hoard') { - this.tweens.add({ targets: stat, alpha: { from: 1, to: 0.55 }, duration: 700, yoyo: true, repeat: -1 }); - } if (lastPlayed === m.id) { const lp = this.add.text(-w / 2 + 16, -h / 2 + 18, '▸ LAST PLAYED', { fontFamily: '"Julius Sans One"', fontSize: '14px', color: '#8cf28a', @@ -225,7 +290,7 @@ export default class SlotsGame extends Phaser.Scene { card.add(lp); } - // Attract-mode marquee lights. + // Attract-mode marquee lights (row where the stats text used to be). const lights = this.add.graphics(); card.add(lights); const bulbs = 7; @@ -235,9 +300,8 @@ export default class SlotsGame extends Phaser.Scene { for (let b = 0; b < bulbs; b++) { const lx = -w / 2 + 40 + (b * (w - 80)) / (bulbs - 1); const on = Math.sin(bulbState.phase + b * 0.9) > 0; - const ly = this.textures.exists(cardArtKey) ? 100 : (-h / 2 + 110); lights.fillStyle(on ? t.glow : 0x1a140c, on ? 0.95 : 0.8); - lights.fillCircle(lx, ly, 5); + lights.fillCircle(lx, 156, 5); } }; drawBulbs();