Add themed attract kits and props for all seven slot machines
- Introduce SlotsAttract.js: a reusable "attract kit" (MachineStage) that builds a lit cabinet, LED light-show state machine, marquee, idle/attract mode, tumble meter, optional background/marquee video, per-machine sound layer, and shared baked textures - Add per-theme props modules wired through the stage hook contract: - SlotsGoldRush.js — wanted poster, TNT plunger, lanterns, ore-cart bonus - SlotsDragon.js — sleeping dragon + sneaking knight, jackpot plaques, hold & spin visuals - SlotsAbyssal.js — procedural mermaid puppet, pearl ladder, sea life, bubble tumbles - SlotsPharaoh.js — winged sun disk, obelisks, tomb doors, expanding wild beam - SlotsLucky.js — candle light, rolling odometer, belly glass, coin tray, chrome lever - SlotsFruit.js — fruit-stand awning, payline lamps, neon cherries, HOLD/NUDGE push-buttons - SlotsLiberty.js — clockwork gear train, brass bell + striker, coin run, split-flap PAID - Extend SlotsReels with themed glass backplates, reel peek (vintage drums), idle wobble, dim/spotlight/squash helpers, cell halos, wind-up stop, and anticipation hooks - Upgrade SlotsFx with per-theme line styles (gold vein, fire, bubbles, sunbeam, lamp, slash), glow cells, confetti, bubble bursts, accelerated counter ticks, and themed coin textures - Update SlotsGame to route attract machines through MachineStage, add a bottom control bar, modal paytable overlay, and per-machine props registry; refactor video loading into loadLoopVideo - Add seven background loop videos under assets/videos/slots/
This commit is contained in:
parent
7e31a68794
commit
b2df177bf3
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,947 @@
|
||||||
|
// SlotsAbyssal — Abyssal Treasures props for the attract kit (SlotsAttract.js).
|
||||||
|
//
|
||||||
|
// Star of the show: Marina, a fully procedural mermaid puppet. Every part is
|
||||||
|
// baked on canvas at 2× ("baked units", BU) in the cartoon style of her
|
||||||
|
// symbol, then assembled in a Container scaled by 0.5 × rig scale:
|
||||||
|
// tail + hair strands → Phaser Ropes whose points are re-solved each frame
|
||||||
|
// (travelling waves, curl, buoyant drift)
|
||||||
|
// fin → rides the tail tip at the last segment's angle
|
||||||
|
// head / torso / arms → images; arms pivot at the shoulders, head tilts,
|
||||||
|
// eyes blink, mouth sings
|
||||||
|
// She sits on a giant clam in the right gutter, waves, points at pearl wilds,
|
||||||
|
// sings on every cascade, twirls on big wins, and in attract mode swims laps
|
||||||
|
// across the screen and blows heart bubbles.
|
||||||
|
//
|
||||||
|
// Also here: the pearl-ladder cascade multiplier (left gutter), fish schools,
|
||||||
|
// glowing jellyfish, and a manta ray silhouette. Hook contract matches
|
||||||
|
// SlotsGoldRush.js / SlotsDragon.js, plus onTumble(i) and onBigMoment().
|
||||||
|
|
||||||
|
import * as Phaser from 'phaser';
|
||||||
|
import { GAME_WIDTH, GAME_HEIGHT } from '../../config.js';
|
||||||
|
import { playSound, SFX } from '../../ui/Sounds.js';
|
||||||
|
import { canvasTex } from './SlotsAttract.js';
|
||||||
|
|
||||||
|
const ADD = Phaser.BlendModes.ADD;
|
||||||
|
const OL = '#2e1a3a'; // outline ink
|
||||||
|
const TAU = Math.PI * 2;
|
||||||
|
|
||||||
|
// ── Canvas helpers ────────────────────────────────────────────────────────────
|
||||||
|
function lin(ctx, x0, y0, x1, y1, stops) {
|
||||||
|
const g = ctx.createLinearGradient(x0, y0, x1, y1);
|
||||||
|
stops.forEach(([o, c]) => g.addColorStop(o, c));
|
||||||
|
return g;
|
||||||
|
}
|
||||||
|
|
||||||
|
// A stroke drawn as outline + fill (cartoon limbs).
|
||||||
|
function inkLine(ctx, pts, width, fill, ink = OL, inkW = 5) {
|
||||||
|
for (const [w, col] of [[width + inkW * 2, ink], [width, fill]]) {
|
||||||
|
ctx.strokeStyle = col; ctx.lineWidth = w; ctx.lineCap = 'round'; ctx.lineJoin = 'round';
|
||||||
|
ctx.beginPath();
|
||||||
|
pts.forEach(([x, y], i) => (i ? ctx.lineTo(x, y) : ctx.moveTo(x, y)));
|
||||||
|
ctx.stroke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawHead(ctx, { eyes = 'open', mouth = 'smile' }) {
|
||||||
|
const skin = lin(ctx, 0, 60, 0, 230, [[0, '#ffe6d4'], [1, '#f6bfa0']]);
|
||||||
|
// Neck.
|
||||||
|
ctx.fillStyle = '#f2b896';
|
||||||
|
ctx.fillRect(104, 196, 32, 60);
|
||||||
|
ctx.strokeStyle = OL; ctx.lineWidth = 5;
|
||||||
|
ctx.beginPath(); ctx.moveTo(104, 200); ctx.lineTo(104, 256); ctx.moveTo(136, 200); ctx.lineTo(136, 256); ctx.stroke();
|
||||||
|
// Face.
|
||||||
|
ctx.fillStyle = skin;
|
||||||
|
ctx.beginPath(); ctx.ellipse(120, 140, 78, 88, 0, 0, TAU); ctx.fill();
|
||||||
|
ctx.lineWidth = 5; ctx.stroke();
|
||||||
|
// Blush.
|
||||||
|
ctx.fillStyle = 'rgba(255,120,140,0.32)';
|
||||||
|
for (const x of [72, 168]) { ctx.beginPath(); ctx.ellipse(x, 176, 17, 10, 0, 0, TAU); ctx.fill(); }
|
||||||
|
// Eyes.
|
||||||
|
for (const [x, dir] of [[88, -1], [152, 1]]) {
|
||||||
|
if (eyes === 'open') {
|
||||||
|
ctx.fillStyle = '#ffffff';
|
||||||
|
ctx.beginPath(); ctx.ellipse(x, 142, 19, 23, 0, 0, TAU); ctx.fill();
|
||||||
|
ctx.strokeStyle = OL; ctx.lineWidth = 3; ctx.stroke();
|
||||||
|
const iris = ctx.createRadialGradient(x, 146, 2, x, 146, 16);
|
||||||
|
iris.addColorStop(0, '#7cc8ff'); iris.addColorStop(1, '#1f6fe0');
|
||||||
|
ctx.fillStyle = iris;
|
||||||
|
ctx.beginPath(); ctx.arc(x, 146, 15, 0, TAU); ctx.fill();
|
||||||
|
ctx.fillStyle = '#14204a';
|
||||||
|
ctx.beginPath(); ctx.arc(x, 147, 8, 0, TAU); ctx.fill();
|
||||||
|
ctx.fillStyle = '#ffffff';
|
||||||
|
ctx.beginPath(); ctx.arc(x - 5, 140, 5, 0, TAU); ctx.fill();
|
||||||
|
ctx.beginPath(); ctx.arc(x + 5, 152, 2.5, 0, TAU); ctx.fill();
|
||||||
|
// Upper lid + lashes.
|
||||||
|
ctx.strokeStyle = OL; ctx.lineWidth = 6; ctx.lineCap = 'round';
|
||||||
|
ctx.beginPath(); ctx.ellipse(x, 142, 20, 24, 0, Math.PI * 1.12, Math.PI * 1.88); ctx.stroke();
|
||||||
|
ctx.lineWidth = 4;
|
||||||
|
const ex = x + dir * 18;
|
||||||
|
ctx.beginPath(); ctx.moveTo(ex, 130); ctx.lineTo(ex + dir * 10, 122); ctx.stroke();
|
||||||
|
ctx.beginPath(); ctx.moveTo(ex - dir * 4, 124); ctx.lineTo(ex + dir * 2, 114); ctx.stroke();
|
||||||
|
} else {
|
||||||
|
ctx.strokeStyle = OL; ctx.lineWidth = 5; ctx.lineCap = 'round';
|
||||||
|
ctx.beginPath(); ctx.arc(x, 138, 17, Math.PI * 0.15, Math.PI * 0.85); ctx.stroke();
|
||||||
|
ctx.lineWidth = 3.5;
|
||||||
|
ctx.beginPath(); ctx.moveTo(x + dir * 16, 148); ctx.lineTo(x + dir * 25, 152); ctx.stroke();
|
||||||
|
}
|
||||||
|
// Brows.
|
||||||
|
ctx.strokeStyle = '#b07a30'; ctx.lineWidth = 4; ctx.lineCap = 'round';
|
||||||
|
ctx.beginPath(); ctx.arc(x, 128, 22, Math.PI * 1.25, Math.PI * 1.75); ctx.stroke();
|
||||||
|
}
|
||||||
|
// Nose.
|
||||||
|
ctx.strokeStyle = '#d08a70'; ctx.lineWidth = 3;
|
||||||
|
ctx.beginPath(); ctx.moveTo(118, 164); ctx.quadraticCurveTo(124, 172, 116, 174); ctx.stroke();
|
||||||
|
// Mouth.
|
||||||
|
if (mouth === 'o') {
|
||||||
|
ctx.fillStyle = '#c0304a';
|
||||||
|
ctx.beginPath(); ctx.ellipse(120, 196, 10, 13, 0, 0, TAU); ctx.fill();
|
||||||
|
ctx.strokeStyle = OL; ctx.lineWidth = 3; ctx.stroke();
|
||||||
|
ctx.fillStyle = '#ff8aa0';
|
||||||
|
ctx.beginPath(); ctx.ellipse(120, 202, 6, 4, 0, 0, TAU); ctx.fill();
|
||||||
|
} else {
|
||||||
|
ctx.strokeStyle = '#c0304a'; ctx.lineWidth = 5; ctx.lineCap = 'round';
|
||||||
|
ctx.beginPath(); ctx.arc(120, 180, 20, Math.PI * 0.2, Math.PI * 0.8); ctx.stroke();
|
||||||
|
}
|
||||||
|
// Bangs + side locks.
|
||||||
|
const hair = lin(ctx, 0, 30, 0, 230, [[0, '#fff0a8'], [0.4, '#ffd65a'], [1, '#e0a030']]);
|
||||||
|
ctx.fillStyle = hair;
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(34, 160);
|
||||||
|
ctx.bezierCurveTo(20, 70, 70, 34, 120, 34);
|
||||||
|
ctx.bezierCurveTo(176, 34, 222, 72, 206, 160);
|
||||||
|
ctx.quadraticCurveTo(196, 118, 176, 102);
|
||||||
|
ctx.quadraticCurveTo(158, 120, 140, 98);
|
||||||
|
ctx.quadraticCurveTo(118, 122, 98, 100);
|
||||||
|
ctx.quadraticCurveTo(78, 124, 62, 104);
|
||||||
|
ctx.quadraticCurveTo(44, 122, 34, 160);
|
||||||
|
ctx.closePath();
|
||||||
|
ctx.fill();
|
||||||
|
ctx.strokeStyle = OL; ctx.lineWidth = 5; ctx.stroke();
|
||||||
|
for (const side of [-1, 1]) {
|
||||||
|
const x = 120 + side * 80;
|
||||||
|
ctx.fillStyle = hair;
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(x - side * 4, 96);
|
||||||
|
ctx.quadraticCurveTo(x + side * 22, 170, x + side * 4, 238);
|
||||||
|
ctx.quadraticCurveTo(x - side * 16, 180, x - side * 18, 120);
|
||||||
|
ctx.closePath();
|
||||||
|
ctx.fill(); ctx.stroke();
|
||||||
|
}
|
||||||
|
ctx.strokeStyle = 'rgba(176,112,24,0.55)'; ctx.lineWidth = 2.5;
|
||||||
|
for (const [x0, y0, x1, y1] of [[70, 60, 60, 100], [100, 44, 96, 96], [140, 44, 142, 94], [170, 60, 178, 100]]) {
|
||||||
|
ctx.beginPath(); ctx.moveTo(x0, y0); ctx.quadraticCurveTo((x0 + x1) / 2 + 6, (y0 + y1) / 2, x1, y1); ctx.stroke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function bakeMermaidTextures(scene) {
|
||||||
|
canvasTex(scene, 'mm-head-open', 240, 260, (ctx) => drawHead(ctx, { eyes: 'open', mouth: 'smile' }));
|
||||||
|
canvasTex(scene, 'mm-head-blink', 240, 260, (ctx) => drawHead(ctx, { eyes: 'closed', mouth: 'smile' }));
|
||||||
|
canvasTex(scene, 'mm-head-sing', 240, 260, (ctx) => drawHead(ctx, { eyes: 'open', mouth: 'o' }));
|
||||||
|
|
||||||
|
// Torso (hips at bottom centre) with shell top and a fin frill at the waist.
|
||||||
|
canvasTex(scene, 'mm-torso', 240, 260, (ctx) => {
|
||||||
|
ctx.fillStyle = lin(ctx, 0, 0, 0, 260, [[0, '#ffe2d0'], [1, '#f2b896']]);
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(106, 0); ctx.lineTo(134, 0);
|
||||||
|
ctx.quadraticCurveTo(140, 30, 206, 40);
|
||||||
|
ctx.quadraticCurveTo(226, 48, 216, 74);
|
||||||
|
ctx.quadraticCurveTo(176, 140, 168, 200);
|
||||||
|
ctx.quadraticCurveTo(170, 236, 178, 260);
|
||||||
|
ctx.lineTo(62, 260);
|
||||||
|
ctx.quadraticCurveTo(70, 236, 72, 200);
|
||||||
|
ctx.quadraticCurveTo(64, 140, 24, 74);
|
||||||
|
ctx.quadraticCurveTo(14, 48, 34, 40);
|
||||||
|
ctx.quadraticCurveTo(100, 30, 106, 0);
|
||||||
|
ctx.closePath();
|
||||||
|
ctx.fill();
|
||||||
|
ctx.strokeStyle = OL; ctx.lineWidth = 5; ctx.stroke();
|
||||||
|
ctx.fillStyle = 'rgba(200,120,90,0.5)';
|
||||||
|
ctx.beginPath(); ctx.ellipse(120, 210, 3.5, 5, 0, 0, TAU); ctx.fill();
|
||||||
|
// Shell top.
|
||||||
|
ctx.strokeStyle = '#7a2aa8'; ctx.lineWidth = 3;
|
||||||
|
ctx.beginPath(); ctx.moveTo(86, 86); ctx.lineTo(108, 10); ctx.moveTo(154, 86); ctx.lineTo(132, 10); ctx.stroke();
|
||||||
|
for (const [cx, rot] of [[88, -0.2], [152, 0.2]]) {
|
||||||
|
ctx.save();
|
||||||
|
ctx.translate(cx, 112); ctx.rotate(rot);
|
||||||
|
ctx.fillStyle = lin(ctx, 0, -30, 0, 30, [[0, '#e0a8ff'], [0.5, '#a64ad8'], [1, '#6a1e9a']]);
|
||||||
|
ctx.beginPath(); ctx.moveTo(0, 26);
|
||||||
|
for (let k = 0; k <= 6; k++) {
|
||||||
|
const a = Math.PI * (1.08 + (k / 6) * 0.84);
|
||||||
|
ctx.quadraticCurveTo(Math.cos(a - 0.07) * 40, Math.sin(a - 0.07) * 40 + 4, Math.cos(a) * 34, Math.sin(a) * 34 + 2);
|
||||||
|
}
|
||||||
|
ctx.closePath(); ctx.fill();
|
||||||
|
ctx.strokeStyle = OL; ctx.lineWidth = 4; ctx.stroke();
|
||||||
|
ctx.strokeStyle = 'rgba(70,10,110,0.55)'; ctx.lineWidth = 2;
|
||||||
|
for (let k = 1; k < 6; k++) {
|
||||||
|
const a = Math.PI * (1.08 + (k / 6) * 0.84);
|
||||||
|
ctx.beginPath(); ctx.moveTo(0, 24); ctx.lineTo(Math.cos(a) * 32, Math.sin(a) * 32 + 2); ctx.stroke();
|
||||||
|
}
|
||||||
|
ctx.restore();
|
||||||
|
}
|
||||||
|
ctx.fillStyle = '#ff8ad2';
|
||||||
|
ctx.beginPath(); ctx.arc(120, 112, 8, 0, TAU); ctx.fill();
|
||||||
|
ctx.strokeStyle = OL; ctx.lineWidth = 3; ctx.stroke();
|
||||||
|
// Waist frill where the tail begins.
|
||||||
|
ctx.fillStyle = lin(ctx, 0, 226, 0, 260, [[0, '#7affd8'], [1, '#18b090']]);
|
||||||
|
ctx.beginPath(); ctx.moveTo(52, 260);
|
||||||
|
for (let k = 0; k <= 8; k++) {
|
||||||
|
const x = 52 + (k / 8) * 136;
|
||||||
|
ctx.quadraticCurveTo(x - 8, 222, x, 234);
|
||||||
|
}
|
||||||
|
ctx.lineTo(188, 260); ctx.closePath(); ctx.fill();
|
||||||
|
ctx.strokeStyle = OL; ctx.lineWidth = 4; ctx.stroke();
|
||||||
|
});
|
||||||
|
|
||||||
|
// One arm hanging down from the shoulder (origin near the top).
|
||||||
|
canvasTex(scene, 'mm-arm', 120, 250, (ctx) => {
|
||||||
|
inkLine(ctx, [[60, 24], [64, 122]], 34, '#f8cdb2');
|
||||||
|
inkLine(ctx, [[64, 122], [58, 200]], 26, '#f6c4a6');
|
||||||
|
ctx.fillStyle = '#f6c4a6';
|
||||||
|
ctx.beginPath(); ctx.ellipse(58, 214, 17, 22, 0, 0, TAU); ctx.fill();
|
||||||
|
ctx.strokeStyle = OL; ctx.lineWidth = 5; ctx.stroke();
|
||||||
|
ctx.fillStyle = '#f8cdb2';
|
||||||
|
ctx.beginPath(); ctx.arc(60, 26, 18, 0, TAU); ctx.fill();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Back hair volume.
|
||||||
|
canvasTex(scene, 'mm-hair-back', 320, 340, (ctx) => {
|
||||||
|
ctx.fillStyle = lin(ctx, 0, 0, 0, 340, [[0, '#ffe680'], [1, '#d89422']]);
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(160, 10);
|
||||||
|
ctx.bezierCurveTo(300, 10, 320, 150, 290, 330);
|
||||||
|
ctx.quadraticCurveTo(160, 290, 30, 330);
|
||||||
|
ctx.bezierCurveTo(0, 150, 20, 10, 160, 10);
|
||||||
|
ctx.closePath(); ctx.fill();
|
||||||
|
ctx.strokeStyle = OL; ctx.lineWidth = 5; ctx.stroke();
|
||||||
|
ctx.strokeStyle = 'rgba(160,96,16,0.45)'; ctx.lineWidth = 3;
|
||||||
|
for (let k = 0; k < 9; k++) {
|
||||||
|
const x = 50 + k * 28;
|
||||||
|
ctx.beginPath(); ctx.moveTo(x, 60); ctx.quadraticCurveTo(x + 12, 190, x - 6, 310); ctx.stroke();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// A floating lock of hair (rope texture: root wide on the left, tip right).
|
||||||
|
canvasTex(scene, 'mm-hair-strand', 512, 90, (ctx) => {
|
||||||
|
ctx.fillStyle = lin(ctx, 0, 0, 0, 90, [[0, '#fff0a0'], [0.5, '#ffd24a'], [1, '#d08a1c']]);
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(0, 4);
|
||||||
|
ctx.bezierCurveTo(180, 0, 380, 26, 508, 42);
|
||||||
|
ctx.lineTo(508, 48);
|
||||||
|
ctx.bezierCurveTo(380, 70, 180, 90, 0, 86);
|
||||||
|
ctx.closePath(); ctx.fill();
|
||||||
|
ctx.strokeStyle = OL; ctx.lineWidth = 4; ctx.stroke();
|
||||||
|
ctx.strokeStyle = 'rgba(160,96,16,0.5)'; ctx.lineWidth = 2.5;
|
||||||
|
for (const y of [26, 45, 64]) {
|
||||||
|
ctx.beginPath(); ctx.moveTo(10, y); ctx.bezierCurveTo(200, y, 380, 45, 480, 45); ctx.stroke();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Tail (rope texture: hips wide on the left, tapering to the fin joint).
|
||||||
|
canvasTex(scene, 'mm-tail', 1024, 200, (ctx) => {
|
||||||
|
const half = (x) => 68 - (x / 1024) * 42;
|
||||||
|
ctx.save();
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(0, 100 - half(0));
|
||||||
|
for (let x = 0; x <= 1024; x += 32) ctx.lineTo(x, 100 - half(x));
|
||||||
|
for (let x = 1024; x >= 0; x -= 32) ctx.lineTo(x, 100 + half(x));
|
||||||
|
ctx.closePath();
|
||||||
|
ctx.fillStyle = lin(ctx, 0, 0, 0, 200, [[0, '#5ef0c8'], [0.5, '#22c9a6'], [1, '#0d7a6c']]);
|
||||||
|
ctx.fill();
|
||||||
|
ctx.clip();
|
||||||
|
// Scales.
|
||||||
|
ctx.strokeStyle = 'rgba(190,255,235,0.55)'; ctx.lineWidth = 2.5;
|
||||||
|
for (let row = 0, y = 10; y < 200; row++, y += 22) {
|
||||||
|
for (let x = (row & 1) ? 18 : 0; x < 1024; x += 36) {
|
||||||
|
ctx.beginPath(); ctx.arc(x, y, 16, Math.PI * 0.15, Math.PI * 0.85); ctx.stroke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ctx.fillStyle = 'rgba(255,255,255,0.18)';
|
||||||
|
ctx.fillRect(0, 70, 1024, 22);
|
||||||
|
ctx.restore();
|
||||||
|
ctx.strokeStyle = OL; ctx.lineWidth = 5;
|
||||||
|
ctx.beginPath();
|
||||||
|
for (let x = 0; x <= 1024; x += 32) (x ? ctx.lineTo(x, 100 - half(x)) : ctx.moveTo(x, 100 - half(x)));
|
||||||
|
ctx.stroke();
|
||||||
|
ctx.beginPath();
|
||||||
|
for (let x = 0; x <= 1024; x += 32) (x ? ctx.lineTo(x, 100 + half(x)) : ctx.moveTo(x, 100 + half(x)));
|
||||||
|
ctx.stroke();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Fluke fin (joint on the left).
|
||||||
|
canvasTex(scene, 'mm-fin', 360, 280, (ctx) => {
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(20, 118);
|
||||||
|
ctx.quadraticCurveTo(150, 50, 344, 16);
|
||||||
|
ctx.quadraticCurveTo(300, 100, 246, 140);
|
||||||
|
ctx.quadraticCurveTo(300, 180, 344, 264);
|
||||||
|
ctx.quadraticCurveTo(150, 230, 20, 162);
|
||||||
|
ctx.closePath();
|
||||||
|
ctx.fillStyle = lin(ctx, 20, 0, 344, 0, [[0, '#22c9a6'], [0.6, '#5ef0c8'], [1, '#c8fff0']]);
|
||||||
|
ctx.fill();
|
||||||
|
ctx.strokeStyle = OL; ctx.lineWidth = 5; ctx.stroke();
|
||||||
|
ctx.strokeStyle = 'rgba(10,110,90,0.5)'; ctx.lineWidth = 2.5;
|
||||||
|
for (const [x, y] of [[300, 40], [260, 80], [230, 118], [230, 162], [260, 200], [300, 240]]) {
|
||||||
|
ctx.beginPath(); ctx.moveTo(28, 140); ctx.quadraticCurveTo((28 + x) / 2, (140 + y) / 2 + 6, x, y); ctx.stroke();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Giant clam: open lid (behind her) and the bowl (in front of her tail).
|
||||||
|
canvasTex(scene, 'mm-clam-back', 380, 250, (ctx) => {
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(30, 240);
|
||||||
|
for (let k = 0; k <= 10; k++) {
|
||||||
|
const a = Math.PI * (1 + k / 10);
|
||||||
|
const r = 170 + (k & 1 ? 10 : 0);
|
||||||
|
ctx.lineTo(190 + Math.cos(a) * r, 240 + Math.sin(a) * r * 1.25);
|
||||||
|
}
|
||||||
|
ctx.lineTo(350, 240); ctx.closePath();
|
||||||
|
ctx.fillStyle = lin(ctx, 0, 20, 0, 240, [[0, '#ffd2f0'], [0.6, '#d68ad8'], [1, '#8a4aa8']]);
|
||||||
|
ctx.fill();
|
||||||
|
ctx.strokeStyle = OL; ctx.lineWidth = 5; ctx.stroke();
|
||||||
|
ctx.strokeStyle = 'rgba(110,40,130,0.45)'; ctx.lineWidth = 3;
|
||||||
|
for (let k = 1; k < 10; k++) {
|
||||||
|
const a = Math.PI * (1 + k / 10);
|
||||||
|
ctx.beginPath(); ctx.moveTo(190, 236); ctx.lineTo(190 + Math.cos(a) * 165, 240 + Math.sin(a) * 205); ctx.stroke();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
canvasTex(scene, 'mm-clam-front', 400, 160, (ctx) => {
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(10, 24);
|
||||||
|
for (let k = 0; k <= 12; k++) ctx.quadraticCurveTo(10 + (k - 0.5) * 31.7, k & 1 ? 8 : 34, 10 + k * 31.7, 24);
|
||||||
|
ctx.bezierCurveTo(400, 120, 300, 156, 200, 156);
|
||||||
|
ctx.bezierCurveTo(100, 156, 0, 120, 10, 24);
|
||||||
|
ctx.closePath();
|
||||||
|
ctx.fillStyle = lin(ctx, 0, 10, 0, 156, [[0, '#f6b8f0'], [0.5, '#b866c8'], [1, '#6a2a88']]);
|
||||||
|
ctx.fill();
|
||||||
|
ctx.strokeStyle = OL; ctx.lineWidth = 5; ctx.stroke();
|
||||||
|
ctx.strokeStyle = 'rgba(90,20,110,0.45)'; ctx.lineWidth = 3;
|
||||||
|
for (let k = 1; k < 12; k++) {
|
||||||
|
const x = 10 + k * 31.7;
|
||||||
|
ctx.beginPath(); ctx.moveTo(x, 28); ctx.quadraticCurveTo(x + (200 - x) * 0.3, 100, 200 + (x - 200) * 0.4, 150); ctx.stroke();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function bakeSeaLife(scene) {
|
||||||
|
// Fish (white → tinted per school; the eye stays dark).
|
||||||
|
canvasTex(scene, 'mm-fish', 80, 44, (ctx) => {
|
||||||
|
ctx.fillStyle = 'rgba(255,255,255,0.95)';
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(6, 22); ctx.quadraticCurveTo(26, 2, 56, 14); ctx.lineTo(76, 4); ctx.lineTo(70, 22);
|
||||||
|
ctx.lineTo(76, 40); ctx.lineTo(56, 30); ctx.quadraticCurveTo(26, 42, 6, 22);
|
||||||
|
ctx.closePath(); ctx.fill();
|
||||||
|
ctx.fillStyle = 'rgba(0,0,0,0.18)';
|
||||||
|
ctx.beginPath(); ctx.ellipse(32, 15, 20, 5, 0, 0, TAU); ctx.fill();
|
||||||
|
ctx.fillStyle = '#10142a';
|
||||||
|
ctx.beginPath(); ctx.arc(18, 19, 3.5, 0, TAU); ctx.fill();
|
||||||
|
});
|
||||||
|
// Jellyfish bell.
|
||||||
|
canvasTex(scene, 'mm-jelly', 128, 96, (ctx) => {
|
||||||
|
const g = ctx.createRadialGradient(64, 60, 6, 64, 70, 70);
|
||||||
|
g.addColorStop(0, 'rgba(255,230,255,0.95)');
|
||||||
|
g.addColorStop(0.6, 'rgba(255,140,230,0.55)');
|
||||||
|
g.addColorStop(1, 'rgba(180,90,255,0.15)');
|
||||||
|
ctx.fillStyle = g;
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(6, 84); ctx.bezierCurveTo(6, 0, 122, 0, 122, 84);
|
||||||
|
for (let k = 6; k >= 0; k--) ctx.quadraticCurveTo(6 + (k + 0.5) * 16.6, 94, 6 + k * 16.6, 84);
|
||||||
|
ctx.closePath(); ctx.fill();
|
||||||
|
ctx.strokeStyle = 'rgba(255,220,255,0.9)'; ctx.lineWidth = 2; ctx.stroke();
|
||||||
|
});
|
||||||
|
canvasTex(scene, 'mm-tentacle', 256, 14, (ctx) => {
|
||||||
|
ctx.fillStyle = lin(ctx, 0, 0, 256, 0, [[0, 'rgba(255,190,245,0.9)'], [1, 'rgba(200,140,255,0)']]);
|
||||||
|
ctx.beginPath(); ctx.moveTo(0, 1); ctx.lineTo(256, 6); ctx.lineTo(256, 8); ctx.lineTo(0, 13); ctx.closePath(); ctx.fill();
|
||||||
|
});
|
||||||
|
// Manta ray silhouette.
|
||||||
|
canvasTex(scene, 'mm-manta', 520, 300, (ctx) => {
|
||||||
|
ctx.fillStyle = '#06102a';
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(260, 40);
|
||||||
|
ctx.quadraticCurveTo(300, 60, 516, 120);
|
||||||
|
ctx.quadraticCurveTo(330, 150, 290, 210);
|
||||||
|
ctx.quadraticCurveTo(270, 240, 262, 298);
|
||||||
|
ctx.lineTo(258, 298);
|
||||||
|
ctx.quadraticCurveTo(250, 240, 230, 210);
|
||||||
|
ctx.quadraticCurveTo(190, 150, 4, 120);
|
||||||
|
ctx.quadraticCurveTo(220, 60, 260, 40);
|
||||||
|
ctx.closePath(); ctx.fill();
|
||||||
|
});
|
||||||
|
// Heart (for bubble hearts).
|
||||||
|
canvasTex(scene, 'mm-heart', 48, 44, (ctx) => {
|
||||||
|
ctx.fillStyle = '#ff6fae';
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(24, 40);
|
||||||
|
ctx.bezierCurveTo(-6, 18, 8, -4, 24, 12);
|
||||||
|
ctx.bezierCurveTo(40, -4, 54, 18, 24, 40);
|
||||||
|
ctx.fill();
|
||||||
|
ctx.fillStyle = 'rgba(255,255,255,0.7)';
|
||||||
|
ctx.beginPath(); ctx.ellipse(15, 13, 5, 3, -0.6, 0, TAU); ctx.fill();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const vec = (n) => Array.from({ length: n }, () => new Phaser.Math.Vector2());
|
||||||
|
|
||||||
|
// ── Marina: the mermaid rig ───────────────────────────────────────────────────
|
||||||
|
class Mermaid {
|
||||||
|
constructor(scene, x, y, depth, scale = 0.9) {
|
||||||
|
this.scene = scene;
|
||||||
|
this.home = { x, y, depth, scale };
|
||||||
|
this.root = { x, y, rot: 0, scale, extraRot: 0 };
|
||||||
|
this.depth = depth;
|
||||||
|
this.t = 0;
|
||||||
|
this.blinkMs = 2500;
|
||||||
|
this.blinking = 0;
|
||||||
|
this.mouthMs = 0;
|
||||||
|
this.swimming = false;
|
||||||
|
// Animatable pose (rest values; actions tween these).
|
||||||
|
this.pose = {
|
||||||
|
armL: 0.3, armR: -0.3, head: 0, bob: 1,
|
||||||
|
tailCurl: -2.2, tailAmp: 0.16, tailFreq: 1.8, hairAmp: 0.28, hairFreq: 1.2, hairUp: 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
const c = scene.add.container(x, y).setDepth(depth);
|
||||||
|
this.c = c;
|
||||||
|
this.strandDefs = [
|
||||||
|
{ root: [-96, -150], ang: 0.5, curl: 0.5, len: 40 },
|
||||||
|
{ root: [-62, -205], ang: 0.25, curl: 0.35, len: 42 },
|
||||||
|
{ root: [0, -222], ang: 0, curl: 0, len: 44 },
|
||||||
|
{ root: [62, -205], ang: -0.25, curl: -0.35, len: 42 },
|
||||||
|
{ root: [96, -150], ang: -0.5, curl: -0.5, len: 40 },
|
||||||
|
];
|
||||||
|
this.strands = this.strandDefs.map(() => {
|
||||||
|
const r = scene.add.rope(0, 0, 'mm-hair-strand', null, vec(9), true);
|
||||||
|
c.add(r);
|
||||||
|
return r;
|
||||||
|
});
|
||||||
|
this.hairBack = scene.add.image(0, -360, 'mm-hair-back');
|
||||||
|
this.tail = scene.add.rope(0, 0, 'mm-tail', null, vec(17), true);
|
||||||
|
this.fin = scene.add.image(0, 0, 'mm-fin').setOrigin(0.06, 0.5);
|
||||||
|
this.torso = scene.add.image(0, 0, 'mm-torso').setOrigin(0.5, 1);
|
||||||
|
this.armL = scene.add.image(-90, -214, 'mm-arm').setOrigin(0.5, 0.1).setFlipX(true);
|
||||||
|
this.armR = scene.add.image(90, -214, 'mm-arm').setOrigin(0.5, 0.1);
|
||||||
|
this.head = scene.add.image(0, -244, 'mm-head-open').setOrigin(0.5, 0.94);
|
||||||
|
c.add([this.hairBack, this.tail, this.fin, this.torso, this.armL, this.armR, this.head]);
|
||||||
|
this.applyRoot();
|
||||||
|
this.solve(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
applyRoot() {
|
||||||
|
const r = this.root;
|
||||||
|
this.c.setPosition(r.x, r.y);
|
||||||
|
this.c.setRotation(r.rot + r.extraRot);
|
||||||
|
this.c.setScale(r.scale * 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Solve the ropes + part transforms for this frame.
|
||||||
|
solve(dt) {
|
||||||
|
this.t += dt / 1000;
|
||||||
|
const P = this.pose;
|
||||||
|
const t = this.t;
|
||||||
|
|
||||||
|
// Tail: a travelling wave on a curled spine.
|
||||||
|
const pts = this.tail.points;
|
||||||
|
const n = pts.length - 1;
|
||||||
|
const seg = 34;
|
||||||
|
let x = 0; let y = -12; let a = Math.PI / 2;
|
||||||
|
pts[0].set(x, y);
|
||||||
|
for (let i = 0; i < n; i++) {
|
||||||
|
const s = i / n;
|
||||||
|
a = Math.PI / 2 + P.tailCurl * s + P.tailAmp * (0.3 + s) * Math.sin(t * P.tailFreq * TAU / 2 - s * 5);
|
||||||
|
x += Math.cos(a) * seg; y += Math.sin(a) * seg;
|
||||||
|
pts[i + 1].set(x, y);
|
||||||
|
}
|
||||||
|
this.tail.setDirty();
|
||||||
|
this.fin.setPosition(x, y).setRotation(a);
|
||||||
|
|
||||||
|
// Head tilt + hair strands rooted on the head.
|
||||||
|
const ha = P.head + 0.05 * Math.sin(t * 0.7);
|
||||||
|
this.head.setRotation(ha);
|
||||||
|
const neckX = 0; const neckY = -244;
|
||||||
|
const cos = Math.cos(ha); const sin = Math.sin(ha);
|
||||||
|
const hb = { x: neckX + (0 * cos - -116 * sin), y: neckY + (0 * sin + -116 * cos) };
|
||||||
|
this.hairBack.setPosition(hb.x, hb.y).setRotation(ha);
|
||||||
|
this.strandDefs.forEach((d, k) => {
|
||||||
|
const rp = this.strands[k].points;
|
||||||
|
const rx = neckX + d.root[0] * cos - d.root[1] * sin;
|
||||||
|
const ry = neckY + d.root[0] * sin + d.root[1] * cos;
|
||||||
|
let sx = rx; let sy = ry;
|
||||||
|
rp[0].set(sx, sy);
|
||||||
|
for (let i = 0; i < rp.length - 1; i++) {
|
||||||
|
const s = i / (rp.length - 1);
|
||||||
|
const ang = Math.PI / 2 + ha + d.ang + d.curl * s * (1 + P.hairUp)
|
||||||
|
+ P.hairAmp * s * Math.sin(t * P.hairFreq * TAU / 2 - s * 3 + k);
|
||||||
|
sx += Math.cos(ang) * d.len; sy += Math.sin(ang) * d.len;
|
||||||
|
rp[i + 1].set(sx, sy);
|
||||||
|
}
|
||||||
|
this.strands[k].setDirty();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Arms sway a touch around their posed angle.
|
||||||
|
this.armL.setRotation(P.armL + 0.06 * Math.sin(t * 1.3));
|
||||||
|
this.armR.setRotation(P.armR + 0.06 * Math.sin(t * 1.3 + 1));
|
||||||
|
|
||||||
|
// Eyes + mouth.
|
||||||
|
this.blinkMs -= dt;
|
||||||
|
if (this.blinkMs <= 0) { this.blinking = 140; this.blinkMs = 2400 + Math.random() * 2800; }
|
||||||
|
if (this.blinking > 0) this.blinking -= dt;
|
||||||
|
if (this.mouthMs > 0) this.mouthMs -= dt;
|
||||||
|
const key = this.blinking > 0 ? 'mm-head-blink' : this.mouthMs > 0 ? 'mm-head-sing' : 'mm-head-open';
|
||||||
|
if (this.head.texture.key !== key) this.head.setTexture(key);
|
||||||
|
|
||||||
|
// Gentle float while seated.
|
||||||
|
if (!this.swimming) {
|
||||||
|
this.root.y = this.home.y + P.bob * 7 * Math.sin(t * 1.6);
|
||||||
|
this.root.rot = 0.035 * Math.sin(t * 0.9);
|
||||||
|
}
|
||||||
|
this.applyRoot();
|
||||||
|
}
|
||||||
|
|
||||||
|
// World position of a point in rig space (BU).
|
||||||
|
world(px, py) {
|
||||||
|
const r = this.root;
|
||||||
|
const rot = r.rot + r.extraRot;
|
||||||
|
const s = r.scale * 0.5;
|
||||||
|
return {
|
||||||
|
x: r.x + (px * Math.cos(rot) - py * Math.sin(rot)) * s,
|
||||||
|
y: r.y + (px * Math.sin(rot) + py * Math.cos(rot)) * s,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
say(ms = 700) { this.mouthMs = ms; }
|
||||||
|
|
||||||
|
tweenPose(props, duration, extra = {}) {
|
||||||
|
return this.scene.tweens.add({ targets: this.pose, ...props, duration, ease: 'Sine.inOut', ...extra });
|
||||||
|
}
|
||||||
|
|
||||||
|
wave() {
|
||||||
|
if (this.swimming || this.acting) return;
|
||||||
|
this.acting = true;
|
||||||
|
this.say(500);
|
||||||
|
this.scene.tweens.chain({
|
||||||
|
targets: this.pose,
|
||||||
|
tweens: [
|
||||||
|
{ armR: -2.5, head: 0.12, duration: 300, ease: 'Back.out' },
|
||||||
|
{ armR: -2.05, duration: 180, yoyo: true, repeat: 3, ease: 'Sine.inOut' },
|
||||||
|
{ armR: -0.3, head: 0, duration: 380, ease: 'Sine.inOut' },
|
||||||
|
],
|
||||||
|
onComplete: () => { this.acting = false; },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
cheer() {
|
||||||
|
if (this.swimming) return;
|
||||||
|
this.scene.tweens.killTweensOf(this.pose);
|
||||||
|
this.acting = true;
|
||||||
|
this.say(900);
|
||||||
|
this.scene.tweens.chain({
|
||||||
|
targets: this.pose,
|
||||||
|
tweens: [
|
||||||
|
{ armL: 2.7, armR: -2.7, bob: 3, hairUp: 0.6, duration: 240, ease: 'Back.out' },
|
||||||
|
{ armL: 2.4, armR: -2.4, duration: 160, yoyo: true, repeat: 2 },
|
||||||
|
{ armL: 0.3, armR: -0.3, bob: 1, hairUp: 0, duration: 400 },
|
||||||
|
],
|
||||||
|
onComplete: () => { this.acting = false; },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Point the left arm at a world position (the reels are to her left).
|
||||||
|
point(tx, ty) {
|
||||||
|
if (this.swimming) return;
|
||||||
|
const sh = this.world(-90, -214);
|
||||||
|
const ang = Math.atan2(ty - sh.y, tx - sh.x) - Math.PI / 2 - this.root.rot;
|
||||||
|
this.scene.tweens.killTweensOf(this.pose);
|
||||||
|
this.acting = true;
|
||||||
|
this.say(600);
|
||||||
|
this.scene.tweens.chain({
|
||||||
|
targets: this.pose,
|
||||||
|
tweens: [
|
||||||
|
{ armL: ang, head: -0.15, duration: 260, ease: 'Back.out' },
|
||||||
|
{ armL: 0.3, head: 0, duration: 420, delay: 900 },
|
||||||
|
],
|
||||||
|
onComplete: () => { this.acting = false; },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
twirl() {
|
||||||
|
if (this.swimming) return;
|
||||||
|
this.say(900);
|
||||||
|
this.scene.tweens.add({ targets: this.root, extraRot: TAU, duration: 900, ease: 'Cubic.inOut',
|
||||||
|
onComplete: () => { this.root.extraRot = 0; } });
|
||||||
|
this.tweenPose({ hairUp: 1 }, 450, { yoyo: true });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Props ─────────────────────────────────────────────────────────────────────
|
||||||
|
export class AbyssalProps {
|
||||||
|
constructor(stage) {
|
||||||
|
this.stage = stage;
|
||||||
|
this.scene = stage.scene;
|
||||||
|
this.m = stage.m;
|
||||||
|
this.A = stage.A;
|
||||||
|
this.D = stage.D;
|
||||||
|
this.g = stage.g;
|
||||||
|
this.view = null;
|
||||||
|
this.t = 0;
|
||||||
|
this.level = 0;
|
||||||
|
this.fish = [];
|
||||||
|
this.jellies = [];
|
||||||
|
this.waveMs = 6000;
|
||||||
|
this.schoolMs = 2000;
|
||||||
|
this.mantaMs = 20000;
|
||||||
|
this.lapMs = 0;
|
||||||
|
this.heartMs = 0;
|
||||||
|
this.pointedThisSpin = false;
|
||||||
|
bakeMermaidTextures(this.scene);
|
||||||
|
bakeSeaLife(this.scene);
|
||||||
|
this.buildClamAndMermaid();
|
||||||
|
this.buildLadder();
|
||||||
|
this.buildJellies();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Clam + Marina (right gutter) ───────────────────────────────────────────
|
||||||
|
buildClamAndMermaid() {
|
||||||
|
const { scene } = this;
|
||||||
|
const { cab } = this.g;
|
||||||
|
const x = Math.round((cab.x + cab.w + GAME_WIDTH) / 2);
|
||||||
|
const clamY = 760;
|
||||||
|
const depth = this.D.cab + 3;
|
||||||
|
this.clamBack = scene.add.image(x, clamY - 6, 'mm-clam-back').setOrigin(0.5, 1).setDisplaySize(300, 198)
|
||||||
|
.setDepth(depth);
|
||||||
|
this.pearlGlow = scene.add.image(x - 86, clamY - 52, 'slots-glow').setDisplaySize(130, 130)
|
||||||
|
.setTint(0xdff0ff).setBlendMode(ADD).setAlpha(0.45).setDepth(depth + 0.2);
|
||||||
|
this.pearl = scene.add.image(x - 86, clamY - 52, 'slots-pearl').setDisplaySize(46, 46).setDepth(depth + 0.25);
|
||||||
|
this.mermaid = new Mermaid(scene, x - 8, clamY - 70, depth + 0.1, 0.88);
|
||||||
|
this.clamFront = scene.add.image(x, clamY - 40, 'mm-clam-front').setOrigin(0.5, 0).setDisplaySize(316, 126)
|
||||||
|
.setDepth(depth + 0.3);
|
||||||
|
scene.tweens.add({ targets: this.pearlGlow, alpha: 0.75, duration: 1600, yoyo: true, repeat: -1, ease: 'Sine.inOut' });
|
||||||
|
}
|
||||||
|
|
||||||
|
clamFlash() {
|
||||||
|
const { scene } = this;
|
||||||
|
scene.tweens.add({ targets: this.pearlGlow, displayWidth: 260, displayHeight: 260, alpha: 1, duration: 200, yoyo: true });
|
||||||
|
scene.tweens.add({ targets: this.clamBack, scaleY: this.clamBack.scaleY * 0.9, duration: 120, yoyo: true, repeat: 1 });
|
||||||
|
this.stage.sound('pearl');
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Pearl ladder (left gutter): ×1 ×2 ×4 ×6 ────────────────────────────────
|
||||||
|
buildLadder() {
|
||||||
|
const { scene } = this;
|
||||||
|
const { cab } = this.g;
|
||||||
|
const mults = this.m.features.cascade?.multipliers ?? [1, 2, 4, 6];
|
||||||
|
const x = Math.round(cab.x / 2); const y = 530;
|
||||||
|
const depth = this.D.cab + 3;
|
||||||
|
const g = scene.add.graphics().setDepth(depth);
|
||||||
|
g.fillStyle(0x041a2e, 0.78);
|
||||||
|
g.fillRoundedRect(x - 92, y - 250, 184, 500, 60);
|
||||||
|
g.lineStyle(4, 0x59e7ff, 0.9);
|
||||||
|
g.strokeRoundedRect(x - 92, y - 250, 184, 500, 60);
|
||||||
|
g.lineStyle(2, 0xd9c27a, 0.7);
|
||||||
|
g.strokeRoundedRect(x - 84, y - 242, 168, 484, 54);
|
||||||
|
// Coral sprigs on the frame.
|
||||||
|
const sprig = (bx, by, dir, col) => {
|
||||||
|
g.lineStyle(7, col, 1);
|
||||||
|
g.lineBetween(bx, by, bx + dir * 26, by - 30);
|
||||||
|
g.lineBetween(bx + dir * 14, by - 16, bx + dir * 2, by - 40);
|
||||||
|
g.lineBetween(bx + dir * 26, by - 30, bx + dir * 40, by - 44);
|
||||||
|
g.fillStyle(col, 1);
|
||||||
|
g.fillCircle(bx + dir * 40, by - 44, 5); g.fillCircle(bx + dir * 2, by - 40, 5);
|
||||||
|
};
|
||||||
|
sprig(x - 88, y + 250, 1, 0xff5fa8);
|
||||||
|
sprig(x + 88, y + 250, -1, 0xb07aff);
|
||||||
|
sprig(x - 90, y - 160, 1, 0xff8c6a);
|
||||||
|
scene.add.text(x, y - 290, 'CASCADE', {
|
||||||
|
fontFamily: 'Righteous', fontSize: '34px', color: '#7af0ff', stroke: '#041a2e', strokeThickness: 7,
|
||||||
|
}).setOrigin(0.5).setDepth(depth).setShadow(0, 0, '#59e7ff', 14);
|
||||||
|
scene.add.text(x, y + 284, 'MULTIPLIER', {
|
||||||
|
fontFamily: '"Julius Sans One"', fontSize: '18px', color: '#cfefff', stroke: '#041a2e', strokeThickness: 5,
|
||||||
|
}).setOrigin(0.5).setDepth(depth);
|
||||||
|
this.ladder = mults.map((mult, i) => {
|
||||||
|
const py = y + 180 - i * 120;
|
||||||
|
const glow = scene.add.image(x, py, 'slots-glow').setDisplaySize(190, 190).setTint(0x59e7ff)
|
||||||
|
.setBlendMode(ADD).setAlpha(0).setDepth(depth + 0.1);
|
||||||
|
const pearl = scene.add.image(x, py, 'slots-pearl').setDisplaySize(96, 96).setAlpha(0.35).setDepth(depth + 0.2);
|
||||||
|
const label = scene.add.text(x, py + 2, `×${mult}`, {
|
||||||
|
fontFamily: 'Righteous', fontSize: '34px', color: '#1a3a5a',
|
||||||
|
}).setOrigin(0.5).setDepth(depth + 0.3).setAlpha(0.5);
|
||||||
|
return { glow, pearl, label, y: py, x };
|
||||||
|
});
|
||||||
|
this.setLevel(0, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
setLevel(i, silent = false) {
|
||||||
|
const { scene } = this;
|
||||||
|
const prev = this.level;
|
||||||
|
this.level = i;
|
||||||
|
this.ladder.forEach((rung, k) => {
|
||||||
|
const on = k === i;
|
||||||
|
const passed = k < i;
|
||||||
|
rung.pearl.setAlpha(on ? 1 : passed ? 0.7 : 0.35);
|
||||||
|
rung.label.setAlpha(on ? 1 : passed ? 0.7 : 0.5).setColor(on ? '#0a2a4a' : '#1a3a5a');
|
||||||
|
scene.tweens.add({ targets: rung.glow, alpha: on ? 0.9 : 0, duration: 260 });
|
||||||
|
});
|
||||||
|
if (silent || i <= prev) return;
|
||||||
|
// A light bubble rises from the old rung to the new one, then a sonar ping.
|
||||||
|
const from = this.ladder[prev]; const to = this.ladder[i];
|
||||||
|
const b = scene.add.image(from.x, from.y, 'slots-bubble').setScale(0.9).setDepth(this.D.cab + 3.5);
|
||||||
|
scene.tweens.add({
|
||||||
|
targets: b, y: to.y, duration: 380, ease: 'Sine.inOut',
|
||||||
|
onComplete: () => {
|
||||||
|
b.destroy();
|
||||||
|
const ring = scene.add.circle(to.x, to.y, 50).setStrokeStyle(4, 0x7af0ff).setDepth(this.D.cab + 3.5);
|
||||||
|
scene.tweens.add({ targets: ring, scale: 2.6, alpha: 0, duration: 650, onComplete: () => ring.destroy() });
|
||||||
|
scene.tweens.add({ targets: [to.pearl, to.label], scale: '*=1.25', duration: 150, yoyo: true });
|
||||||
|
this.stage.sound('sonar', () => playSound(scene, SFX.SCIFI_PLINK));
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Sea life ───────────────────────────────────────────────────────────────
|
||||||
|
buildJellies() {
|
||||||
|
const spots = [[150, 900, 0.9], [60, 600, 0.6], [1870, 380, 0.55]];
|
||||||
|
for (const [x, y, s] of spots) this.jellies.push(this.makeJelly(x, y, s));
|
||||||
|
}
|
||||||
|
|
||||||
|
makeJelly(x, y, s) {
|
||||||
|
const { scene } = this;
|
||||||
|
const depth = this.D.bg + 4.85;
|
||||||
|
const glow = scene.add.image(x, y, 'slots-glow').setDisplaySize(220 * s, 220 * s).setTint(0xff8ae8)
|
||||||
|
.setBlendMode(ADD).setAlpha(0.35).setDepth(depth);
|
||||||
|
const bell = scene.add.image(x, y, 'mm-jelly').setScale(s).setBlendMode(ADD).setDepth(depth + 0.02);
|
||||||
|
const tents = [-36, -12, 12, 36].map(() => scene.add.rope(0, 0, 'mm-tentacle', null, vec(8), true)
|
||||||
|
.setBlendMode(ADD).setDepth(depth + 0.01));
|
||||||
|
return { x, y, s, glow, bell, tents, ph: Math.random() * TAU, vx: (Math.random() - 0.5) * 6 };
|
||||||
|
}
|
||||||
|
|
||||||
|
updateJellies(dt) {
|
||||||
|
const sec = dt / 1000;
|
||||||
|
for (const j of this.jellies) {
|
||||||
|
j.ph += sec * TAU / 2.2;
|
||||||
|
const pulse = Math.sin(j.ph);
|
||||||
|
const thrust = Math.max(0, pulse);
|
||||||
|
j.y -= (8 + thrust * 34) * sec * j.s;
|
||||||
|
j.x += j.vx * sec;
|
||||||
|
if (j.y < -120) { j.y = GAME_HEIGHT + 120; }
|
||||||
|
j.bell.setPosition(j.x, j.y).setScale(j.s * (1 + 0.08 * pulse), j.s * (1 - 0.1 * pulse));
|
||||||
|
j.glow.setPosition(j.x, j.y + 8).setAlpha(0.25 + 0.15 * thrust);
|
||||||
|
[-36, -12, 12, 36].forEach((ox, k) => {
|
||||||
|
const rp = j.tents[k].points;
|
||||||
|
let px = j.x + ox * j.s * (1 - 0.1 * pulse); let py = j.y + 36 * j.s;
|
||||||
|
rp[0].set(px, py);
|
||||||
|
for (let i = 1; i < rp.length; i++) {
|
||||||
|
const a = Math.PI / 2 + 0.25 * Math.sin(j.ph - i * 0.6 + k);
|
||||||
|
px += Math.cos(a) * 16 * j.s; py += Math.sin(a) * 16 * j.s;
|
||||||
|
rp[i].set(px, py);
|
||||||
|
}
|
||||||
|
j.tents[k].setDirty();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
spawnSchool() {
|
||||||
|
const { scene } = this;
|
||||||
|
const colors = [0xffd23f, 0x3aa8ff, 0xff8c2a, 0xb07aff, 0x7affd8];
|
||||||
|
const tint = colors[Math.floor(Math.random() * colors.length)];
|
||||||
|
const dir = Math.random() < 0.5 ? 1 : -1;
|
||||||
|
const y0 = 120 + Math.random() * 760;
|
||||||
|
const n = 7 + Math.floor(Math.random() * 8);
|
||||||
|
const speed = 90 + Math.random() * 70;
|
||||||
|
const scale = 0.5 + Math.random() * 0.4;
|
||||||
|
const school = { dir, y0, x: dir > 0 ? -200 : GAME_WIDTH + 200, speed, members: [] };
|
||||||
|
for (let i = 0; i < n; i++) {
|
||||||
|
const img = scene.add.image(0, 0, 'mm-fish').setTint(tint).setScale(scale)
|
||||||
|
.setFlipX(dir > 0).setDepth(this.D.bg + 4.8);
|
||||||
|
school.members.push({ img, dx: -dir * (Math.random() * 160), dy: (Math.random() - 0.5) * 110,
|
||||||
|
ph: Math.random() * TAU, s: scale });
|
||||||
|
}
|
||||||
|
this.fish.push(school);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateFish(dt) {
|
||||||
|
const sec = dt / 1000;
|
||||||
|
for (let k = this.fish.length - 1; k >= 0; k--) {
|
||||||
|
const sc = this.fish[k];
|
||||||
|
sc.x += sc.dir * sc.speed * sec;
|
||||||
|
const yy = sc.y0 + Math.sin(sc.x / 260) * 50;
|
||||||
|
for (const f of sc.members) {
|
||||||
|
f.ph += sec * 9;
|
||||||
|
f.img.setPosition(sc.x + f.dx + Math.sin(f.ph * 0.2) * 12, yy + f.dy + Math.sin(f.ph * 0.15) * 8);
|
||||||
|
f.img.setScale(f.s * (1 + 0.05 * Math.sin(f.ph)), f.s);
|
||||||
|
}
|
||||||
|
if ((sc.dir > 0 && sc.x > GAME_WIDTH + 400) || (sc.dir < 0 && sc.x < -400)) {
|
||||||
|
for (const f of sc.members) f.img.destroy();
|
||||||
|
this.fish.splice(k, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mantaGlide() {
|
||||||
|
const { scene } = this;
|
||||||
|
const img = scene.add.image(-320, 220, 'mm-manta').setDisplaySize(560, 320).setAlpha(0.32)
|
||||||
|
.setDepth(this.D.bg + 4.55).setAngle(8);
|
||||||
|
const base = img.scaleY;
|
||||||
|
scene.tweens.add({ targets: img, scaleY: base * 0.7, duration: 1400, yoyo: true, repeat: -1, ease: 'Sine.inOut' });
|
||||||
|
const carrier = { x: -320 };
|
||||||
|
scene.tweens.add({
|
||||||
|
targets: carrier, x: GAME_WIDTH + 320, duration: 16000,
|
||||||
|
onUpdate: () => { img.x = carrier.x; img.y = 220 + Math.sin(carrier.x / 380) * 60; },
|
||||||
|
onComplete: () => { scene.tweens.killTweensOf(img); img.destroy(); },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bubble with a note or heart inside, floating up from Marina.
|
||||||
|
floatBubble(from, kind) {
|
||||||
|
const { scene } = this;
|
||||||
|
const b = scene.add.image(from.x, from.y, 'slots-bubble').setScale(0.75).setDepth(this.D.ui - 1.4);
|
||||||
|
const inner = kind === 'heart'
|
||||||
|
? scene.add.image(from.x, from.y, 'mm-heart').setScale(0.7).setDepth(this.D.ui - 1.39)
|
||||||
|
: scene.add.text(from.x, from.y, '♪', { fontFamily: 'Righteous', fontSize: '28px', color: '#ffffff' })
|
||||||
|
.setOrigin(0.5).setDepth(this.D.ui - 1.39);
|
||||||
|
const dx = (kind === 'heart' ? -160 : -40) - Math.random() * 60;
|
||||||
|
scene.tweens.add({
|
||||||
|
targets: [b, inner], x: from.x + dx, y: from.y - 180 - Math.random() * 60, duration: 2200,
|
||||||
|
ease: 'Sine.out', onComplete: () => { b.destroy(); inner.destroy(); },
|
||||||
|
});
|
||||||
|
scene.tweens.add({ targets: [b, inner], alpha: 0, delay: 1500, duration: 700 });
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Attract: Marina swims a lap across the screen and back to her clam ─────
|
||||||
|
swimLap() {
|
||||||
|
const mm = this.mermaid;
|
||||||
|
if (mm.swimming) return;
|
||||||
|
const { scene } = this;
|
||||||
|
mm.swimming = true;
|
||||||
|
this.stage.sound('splash');
|
||||||
|
scene.tweens.killTweensOf(mm.pose);
|
||||||
|
mm.tweenPose({ tailCurl: 0, tailAmp: 0.5, tailFreq: 3.4, armL: 0.08, armR: -0.08, hairUp: 0 }, 500);
|
||||||
|
mm.c.setDepth(this.D.ui - 1.5);
|
||||||
|
const h = mm.home;
|
||||||
|
const curve = new Phaser.Curves.Spline([
|
||||||
|
h.x, h.y, h.x - 60, h.y - 260, 1300, 520, 900, 420, 520, 560, 250, 380,
|
||||||
|
140, 560, 420, 720, 960, 680, 1400, 620, h.x - 40, h.y - 140, h.x, h.y,
|
||||||
|
]);
|
||||||
|
const carrier = { t: 0 };
|
||||||
|
let last = curve.getPoint(0);
|
||||||
|
this.lapTween = scene.tweens.add({
|
||||||
|
targets: carrier, t: 1, duration: 11000, ease: 'Sine.inOut',
|
||||||
|
onUpdate: () => {
|
||||||
|
const p = curve.getPoint(carrier.t);
|
||||||
|
const dx = p.x - last.x; const dy = p.y - last.y;
|
||||||
|
if (dx * dx + dy * dy > 0.5) {
|
||||||
|
const want = Math.atan2(dy, dx) + Math.PI / 2;
|
||||||
|
let diff = want - mm.root.rot;
|
||||||
|
diff = Math.atan2(Math.sin(diff), Math.cos(diff));
|
||||||
|
mm.root.rot += diff * 0.15;
|
||||||
|
}
|
||||||
|
mm.root.x = p.x; mm.root.y = p.y;
|
||||||
|
mm.root.scale = h.scale * (0.78 + 0.22 * Math.abs(carrier.t - 0.5) * 2);
|
||||||
|
last = p;
|
||||||
|
if (Math.random() < 0.08) this.floatTrailBubble(mm.world(0, 300));
|
||||||
|
},
|
||||||
|
onComplete: () => this.settleHome(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
floatTrailBubble(p) {
|
||||||
|
const b = this.scene.add.image(p.x, p.y, 'slots-bubble').setScale(0.2 + Math.random() * 0.2)
|
||||||
|
.setDepth(this.D.ui - 1.6);
|
||||||
|
this.scene.tweens.add({ targets: b, y: p.y - 120, alpha: 0, duration: 1400, onComplete: () => b.destroy() });
|
||||||
|
}
|
||||||
|
|
||||||
|
comeHome() {
|
||||||
|
const mm = this.mermaid;
|
||||||
|
if (!mm.swimming) return;
|
||||||
|
this.lapTween?.stop();
|
||||||
|
const h = mm.home;
|
||||||
|
this.scene.tweens.add({ targets: mm.root, x: h.x, y: h.y, scale: h.scale, duration: 700, ease: 'Sine.inOut',
|
||||||
|
onComplete: () => this.settleHome() });
|
||||||
|
}
|
||||||
|
|
||||||
|
settleHome() {
|
||||||
|
const mm = this.mermaid;
|
||||||
|
const h = mm.home;
|
||||||
|
mm.root.x = h.x; mm.root.y = h.y; mm.root.scale = h.scale;
|
||||||
|
this.scene.tweens.add({ targets: mm.root, rot: 0, duration: 300 });
|
||||||
|
mm.tweenPose({ tailCurl: -2.2, tailAmp: 0.16, tailFreq: 1.8, armL: 0.3, armR: -0.3 }, 600);
|
||||||
|
mm.c.setDepth(h.depth);
|
||||||
|
mm.swimming = false;
|
||||||
|
this.lapTween = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Hooks ──────────────────────────────────────────────────────────────────
|
||||||
|
onReels(view) { this.view = view; }
|
||||||
|
|
||||||
|
onAttract(on) {
|
||||||
|
if (on) { this.lapMs = 20000; this.heartMs = 5000; this.mantaMs = Math.max(this.mantaMs, 14000); }
|
||||||
|
else this.comeHome();
|
||||||
|
}
|
||||||
|
|
||||||
|
update(dt) {
|
||||||
|
this.t += dt / 1000;
|
||||||
|
this.mermaid.solve(dt);
|
||||||
|
this.updateFish(dt);
|
||||||
|
this.updateJellies(dt);
|
||||||
|
this.schoolMs += dt;
|
||||||
|
this.mantaMs += dt;
|
||||||
|
const att = this.stage.attracting;
|
||||||
|
if (this.schoolMs >= (att ? 6000 : 10000)) { this.schoolMs = 0; this.spawnSchool(); }
|
||||||
|
if (this.mantaMs >= (att ? 22000 : 45000)) { this.mantaMs = 0; this.mantaGlide(); }
|
||||||
|
if (this.stage.busy || !this.view) return;
|
||||||
|
this.waveMs += dt;
|
||||||
|
if (!att && this.waveMs >= 14000) { this.waveMs = 0; this.mermaid.wave(); this.stage.sound('giggle'); }
|
||||||
|
if (att) {
|
||||||
|
this.lapMs += dt;
|
||||||
|
this.heartMs += dt;
|
||||||
|
if (this.lapMs >= 24000) { this.lapMs = 0; this.swimLap(); }
|
||||||
|
if (this.heartMs >= 9000 && !this.mermaid.swimming) {
|
||||||
|
this.heartMs = 0;
|
||||||
|
this.mermaid.say(800);
|
||||||
|
for (let k = 0; k < 3; k++) {
|
||||||
|
this.scene.time.delayedCall(k * 260, () => this.floatBubble(this.mermaid.world(0, -300), 'heart'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onSpinStart() {
|
||||||
|
this.pointedThisSpin = false;
|
||||||
|
this.setLevel(0, true);
|
||||||
|
this.comeHome();
|
||||||
|
}
|
||||||
|
|
||||||
|
onReelStop(c) {
|
||||||
|
const view = this.view;
|
||||||
|
const grid = this.stage.pendingResult?.grid;
|
||||||
|
if (!view || !grid) return;
|
||||||
|
const wild = this.m.wild?.symbol;
|
||||||
|
grid[c].forEach((s, r) => {
|
||||||
|
if (s !== wild) return;
|
||||||
|
const p = view.cellCenter(c, r);
|
||||||
|
this.scene.fx?.bubbleBurst?.(p.x, p.y, 10);
|
||||||
|
if (!this.pointedThisSpin) {
|
||||||
|
this.pointedThisSpin = true;
|
||||||
|
this.clamFlash();
|
||||||
|
this.mermaid.point(p.x, p.y);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onLanded(result) {
|
||||||
|
if (result?.totalWin > 0 && !result.steps?.some((s) => s.type === 'tumble')) this.mermaid.cheer();
|
||||||
|
}
|
||||||
|
|
||||||
|
onTumble(i) {
|
||||||
|
this.setLevel(Math.min(i + 1, this.ladder.length - 1));
|
||||||
|
this.mermaid.say(600);
|
||||||
|
this.floatBubble(this.mermaid.world(0, -300), 'note');
|
||||||
|
this.stage.sound('sing');
|
||||||
|
if (i >= 1) this.mermaid.cheer();
|
||||||
|
}
|
||||||
|
|
||||||
|
onBigMoment() {
|
||||||
|
this.mermaid.twirl();
|
||||||
|
const p = this.mermaid.world(0, -200);
|
||||||
|
this.scene.fx?.bubbleBurst?.(p.x, p.y, 24);
|
||||||
|
}
|
||||||
|
|
||||||
|
shutdown() {}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,809 @@
|
||||||
|
// SlotsDragon — Dragon's Hoard props for the attract kit (SlotsAttract.js).
|
||||||
|
//
|
||||||
|
// "The sleeping dragon and the sneaking knight": the Hold & Spin story maps
|
||||||
|
// onto the real rules. The respin counter IS the dragon's slumber — a blank
|
||||||
|
// respin makes it stir (3 → 2 → 1), a new coin means the knight grabbed it
|
||||||
|
// quietly and the dragon settles (counter resets), and when the respins run
|
||||||
|
// out the dragon wakes and roars while the knight flees with the loot.
|
||||||
|
// Filling the board is the GRAND: the knight carries off the whole hoard.
|
||||||
|
//
|
||||||
|
// Layout ("standoff"): knight in the left gutter, dragon in the right, the gem
|
||||||
|
// jackpot plaques + hoard counter inside the cabinet between marquee and reels.
|
||||||
|
//
|
||||||
|
// Characters use drop-in art when supplied (attract.art.*, tuned via
|
||||||
|
// attract.characters.*), otherwise stand-ins built from the symbol art: the
|
||||||
|
// dragon symbol as the perched dragon (tinted by how deeply it sleeps, with a
|
||||||
|
// glowing eye, Zzz's and snore smoke) and the knight helmet peeking out.
|
||||||
|
//
|
||||||
|
// Hooks: same contract as SlotsGoldRush.js, plus makeJackpotStrip() and
|
||||||
|
// runHoldSpin(state, bet) → { award, cleanup } (SlotsGame routes to them).
|
||||||
|
// Every number shown comes from the engine; nothing here decides an outcome.
|
||||||
|
|
||||||
|
import * as Phaser from 'phaser';
|
||||||
|
import { GAME_WIDTH, GAME_HEIGHT } from '../../config.js';
|
||||||
|
import { playSound, SFX } from '../../ui/Sounds.js';
|
||||||
|
import { textureKeyFor } from './SlotsSymbols.js';
|
||||||
|
import { holdSpinRespin } from './SlotsLogic.js';
|
||||||
|
|
||||||
|
const ADD = Phaser.BlendModes.ADD;
|
||||||
|
const wait = (scene, ms) => new Promise((r) => scene.time.delayedCall(ms, r));
|
||||||
|
const TIER_ORDER = ['mini', 'minor', 'grand', 'major'];
|
||||||
|
const TIER_HEX = { mini: '#7dffb0', minor: '#8cc4ff', major: '#d9a3ff', grand: '#ffd86b' };
|
||||||
|
const FIRE_TINTS = [0xfff0a0, 0xff8c2a, 0xff3a1a];
|
||||||
|
|
||||||
|
// Stand-in anchors on the 200×200 dragon symbol (fractions of the image).
|
||||||
|
const STANDIN_DRAGON = { eye: [0.369, 0.229], nostril: [0.29, 0.28], mouth: [0.31, 0.32], head: [0.45, 0.12] };
|
||||||
|
|
||||||
|
export class DragonHoardProps {
|
||||||
|
constructor(stage) {
|
||||||
|
this.stage = stage;
|
||||||
|
this.scene = stage.scene;
|
||||||
|
this.m = stage.m;
|
||||||
|
this.A = stage.A;
|
||||||
|
this.D = stage.D;
|
||||||
|
this.g = stage.g;
|
||||||
|
this.view = null;
|
||||||
|
this.t = 0;
|
||||||
|
this.coinsLit = 0;
|
||||||
|
this.dragonStage = 0;
|
||||||
|
this.eyeHold = 0; // ms left on a temporary eye flash
|
||||||
|
this.zzzMs = 0;
|
||||||
|
this.snoreMs = 0;
|
||||||
|
this.peekMs = 0;
|
||||||
|
this.shadowMs = 0;
|
||||||
|
this.walkMs = 0;
|
||||||
|
this.freezeMs = 0;
|
||||||
|
this.tiers = this.A.tierColors ?? { mini: 0x2ecc71, minor: 0x3a8cff, major: 0xb04aff, grand: 0xff2a3a };
|
||||||
|
this.buildTorch();
|
||||||
|
this.buildDragon();
|
||||||
|
this.buildKnight();
|
||||||
|
this.buildJackpotRow();
|
||||||
|
this.buildSlumber();
|
||||||
|
}
|
||||||
|
|
||||||
|
sym(id) { return textureKeyFor(this.scene, this.m.id, id); }
|
||||||
|
coinKey(tier = null) {
|
||||||
|
if (tier) {
|
||||||
|
const k = this.stage.artKey(`coin${tier[0].toUpperCase()}${tier.slice(1)}`);
|
||||||
|
if (k) return k;
|
||||||
|
}
|
||||||
|
return this.sym(this.m.features.holdSpin.coinSymbol);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Torch (knight's side) ──────────────────────────────────────────────────
|
||||||
|
buildTorch() {
|
||||||
|
const { scene } = this;
|
||||||
|
const { cab } = this.g;
|
||||||
|
const x = cab.x - 40; const y = 150;
|
||||||
|
const g = scene.add.graphics().setDepth(this.D.cab + 2.5);
|
||||||
|
g.lineStyle(6, 0x2a2420, 1);
|
||||||
|
g.lineBetween(cab.x + 4, y + 40, x + 6, y + 40);
|
||||||
|
g.fillStyle(0x5a3412, 1);
|
||||||
|
g.fillRoundedRect(x - 8, y + 10, 16, 64, 5);
|
||||||
|
g.fillStyle(0x2a2420, 1);
|
||||||
|
g.fillRect(x - 11, y + 6, 22, 10);
|
||||||
|
this.torchGlow = scene.add.image(x, y, 'slots-glow').setDisplaySize(360, 360)
|
||||||
|
.setTint(0xff8c3a).setBlendMode(ADD).setDepth(this.D.cab + 2.4);
|
||||||
|
scene.add.particles(x, y + 4, 'slots-glow', {
|
||||||
|
speedY: { min: -90, max: -40 }, speedX: { min: -14, max: 14 }, lifespan: { min: 300, max: 600 },
|
||||||
|
scale: { start: 0.24, end: 0.03 }, alpha: { start: 0.95, end: 0 },
|
||||||
|
tint: FIRE_TINTS, blendMode: 'ADD', frequency: 26, quantity: 1,
|
||||||
|
}).setDepth(this.D.cab + 2.6);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── The dragon (right gutter) ──────────────────────────────────────────────
|
||||||
|
dragonCfg() {
|
||||||
|
const art = !!this.stage.artKey('dragonSleep');
|
||||||
|
const C = this.A.characters?.dragon ?? {};
|
||||||
|
const def = art
|
||||||
|
? { x: 1760, y: 600, height: 620, eye: [0.3, 0.3], nostril: [0.12, 0.42], mouth: [0.15, 0.48], head: [0.35, 0.12] }
|
||||||
|
: { x: 1745, y: 560, height: 460, ...STANDIN_DRAGON };
|
||||||
|
return { ...def, ...(art ? C.art : C.standin) };
|
||||||
|
}
|
||||||
|
|
||||||
|
buildDragon() {
|
||||||
|
const { scene } = this;
|
||||||
|
const cfg = this.dragonCfg();
|
||||||
|
this.dcfg = cfg;
|
||||||
|
this.dragonShadow = scene.add.image(cfg.x, cfg.y + cfg.height * 0.42, 'slots-glow')
|
||||||
|
.setDisplaySize(cfg.height * 0.9, 90).setTint(0x000000).setAlpha(0.45).setDepth(this.D.cab - 0.15);
|
||||||
|
const key = this.stage.artKey('dragonSleep') ?? this.sym('dragon');
|
||||||
|
this.dragon = scene.add.image(cfg.x, cfg.y, key).setDepth(this.D.cab - 0.1);
|
||||||
|
this.dragon.setDisplaySize(cfg.height * (this.dragon.width / this.dragon.height), cfg.height);
|
||||||
|
this.dragonBase = { sx: this.dragon.scaleX, sy: this.dragon.scaleY };
|
||||||
|
this.rimGlow = scene.add.image(cfg.x, cfg.y, 'slots-glow').setDisplaySize(cfg.height * 1.3, cfg.height * 1.3)
|
||||||
|
.setTint(0xff3a1a).setBlendMode(ADD).setAlpha(0).setDepth(this.D.cab - 0.12);
|
||||||
|
const e = this.anchor('eye');
|
||||||
|
this.eyeGlow = scene.add.image(e.x, e.y, 'slots-led').setDisplaySize(46, 46)
|
||||||
|
.setTint(0xffd23f).setBlendMode(ADD).setAlpha(0).setDepth(this.D.cab - 0.05);
|
||||||
|
|
||||||
|
const wingKey = this.stage.artKey('dragonWing');
|
||||||
|
if (wingKey) {
|
||||||
|
const W = { x: 1640, y: 420, height: 640, ...(this.A.characters?.wing ?? {}) };
|
||||||
|
this.wing = scene.add.image(W.x, W.y, wingKey).setOrigin(1, 1).setDepth(this.D.cab - 0.3);
|
||||||
|
this.wing.setDisplaySize(W.height * (this.wing.width / this.wing.height), W.height);
|
||||||
|
scene.tweens.add({ targets: this.wing, angle: -4, duration: 2600, yoyo: true, repeat: -1, ease: 'Sine.inOut' });
|
||||||
|
}
|
||||||
|
this.setDragonStage(0, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// World position of a named anchor on the dragon image (fractions).
|
||||||
|
anchor(name) {
|
||||||
|
const [fx, fy] = this.dcfg[name];
|
||||||
|
const d = this.dragon;
|
||||||
|
return { x: d.x + (fx - 0.5) * d.displayWidth, y: d.y + (fy - 0.5) * d.displayHeight };
|
||||||
|
}
|
||||||
|
|
||||||
|
// 0 asleep · 1 stirring · 2 one eye open · 3 awake.
|
||||||
|
setDragonStage(n, silent = false) {
|
||||||
|
const prev = this.dragonStage;
|
||||||
|
this.dragonStage = n;
|
||||||
|
const art = !!this.stage.artKey('dragonSleep');
|
||||||
|
if (art) {
|
||||||
|
const key = n >= 3 ? this.stage.artKey('dragonRoar') : n >= 2 ? this.stage.artKey('dragonWake') : this.stage.artKey('dragonSleep');
|
||||||
|
if (key && this.dragon.texture.key !== key) this.dragon.setTexture(key);
|
||||||
|
this.dragon.clearTint();
|
||||||
|
} else {
|
||||||
|
this.dragon.setTint([0x9098c0, 0xbcc0d8, 0xe4e4f0, 0xffffff][n]);
|
||||||
|
}
|
||||||
|
this.eyeGlow.setTint(n >= 3 ? 0xff5a1a : 0xffd23f);
|
||||||
|
this.scene.tweens.add({ targets: this.eyeGlow, alpha: n >= 2 ? 1 : 0, duration: 200 });
|
||||||
|
this.scene.tweens.add({ targets: this.rimGlow, alpha: [0, 0.12, 0.25, 0.5][n], duration: 300 });
|
||||||
|
if (silent || n <= prev) return;
|
||||||
|
if (n === 1 || n === 2) {
|
||||||
|
this.stage.sound('stir');
|
||||||
|
this.scene.cameras.main.shake(260, 0.003 * n);
|
||||||
|
this.scene.tweens.add({ targets: this.dragon, angle: { from: -2.5, to: 2.5 }, duration: 90, yoyo: true, repeat: 3,
|
||||||
|
onComplete: () => this.dragon.setAngle(0) });
|
||||||
|
this.emberBurst(this.anchor('head'), 8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Briefly crack an eye open (wild landed, tease, attract) without waking.
|
||||||
|
flashEye(ms = 900) {
|
||||||
|
if (this.dragonStage >= 2) return;
|
||||||
|
this.eyeHold = ms;
|
||||||
|
this.eyeGlow.setAlpha(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
emberBurst(p, n = 10) {
|
||||||
|
const em = this.scene.add.particles(p.x, p.y, 'slots-led', {
|
||||||
|
speed: { min: 60, max: 220 }, angle: { min: 200, max: 340 }, gravityY: 120,
|
||||||
|
lifespan: { min: 500, max: 1000 }, scale: { start: 0.18, end: 0.02 },
|
||||||
|
tint: FIRE_TINTS, blendMode: 'ADD', emitting: false,
|
||||||
|
}).setDepth(this.D.ui - 3);
|
||||||
|
em.explode(n);
|
||||||
|
this.scene.time.delayedCall(1100, () => em.destroy());
|
||||||
|
}
|
||||||
|
|
||||||
|
smokePuff(p, n = 2) {
|
||||||
|
for (let k = 0; k < n; k++) {
|
||||||
|
const s = this.scene.add.image(p.x, p.y, 'slots-glow').setTint(0x8a8a9a)
|
||||||
|
.setDisplaySize(30, 30).setAlpha(0.55).setDepth(this.D.cab - 0.04);
|
||||||
|
this.scene.tweens.add({
|
||||||
|
targets: s, x: p.x - 50 - k * 25, y: p.y - 40 - k * 20, displayWidth: 130, displayHeight: 130, alpha: 0,
|
||||||
|
duration: 1500 + k * 300, delay: k * 140, ease: 'Sine.out', onComplete: () => s.destroy(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
zzz() {
|
||||||
|
const h = this.anchor('head');
|
||||||
|
const t = this.scene.add.text(h.x + 20, h.y, 'z', {
|
||||||
|
fontFamily: 'Righteous', fontSize: '26px', color: '#cfe0ff', stroke: '#1a2050', strokeThickness: 5,
|
||||||
|
}).setOrigin(0.5).setDepth(this.D.ui - 3);
|
||||||
|
this.scene.tweens.add({
|
||||||
|
targets: t, x: h.x + 70, y: h.y - 90, scale: 1.8, alpha: { from: 1, to: 0 }, duration: 2200,
|
||||||
|
ease: 'Sine.out', onComplete: () => t.destroy(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Awake: roar, shake, and breathe fire across the reels.
|
||||||
|
async roar() {
|
||||||
|
const { scene } = this;
|
||||||
|
this.setDragonStage(3);
|
||||||
|
this.stage.lights.setMood('bigWin');
|
||||||
|
this.stage.sound('roar', () => playSound(scene, SFX.SCIFI_EXPLODE));
|
||||||
|
scene.cameras.main.shake(800, 0.014);
|
||||||
|
scene.tweens.add({ targets: this.dragon, scaleX: this.dragonBase.sx * 1.08, scaleY: this.dragonBase.sy * 1.08,
|
||||||
|
duration: 160, yoyo: true, hold: 500 });
|
||||||
|
await wait(scene, 220);
|
||||||
|
this.stage.sound('fire');
|
||||||
|
const m = this.anchor('mouth');
|
||||||
|
const fire = scene.add.particles(m.x, m.y, 'slots-glow', {
|
||||||
|
angle: { min: 172, max: 192 }, speed: { min: 700, max: 1150 }, lifespan: { min: 650, max: 950 },
|
||||||
|
scale: { start: 0.22, end: 1.25 }, alpha: { start: 1, end: 0 }, tint: FIRE_TINTS,
|
||||||
|
blendMode: 'ADD', frequency: 10, quantity: 4,
|
||||||
|
}).setDepth(this.D.reel + 25);
|
||||||
|
const tint = scene.add.rectangle(GAME_WIDTH / 2, GAME_HEIGHT / 2, GAME_WIDTH, GAME_HEIGHT, 0xff4a1a, 0)
|
||||||
|
.setBlendMode(ADD).setDepth(this.D.reel + 24);
|
||||||
|
scene.tweens.add({ targets: tint, fillAlpha: 0.22, duration: 300, yoyo: true, hold: 700, onComplete: () => tint.destroy() });
|
||||||
|
await wait(scene, 1300);
|
||||||
|
fire.stop();
|
||||||
|
scene.time.delayedCall(1100, () => fire.destroy());
|
||||||
|
}
|
||||||
|
|
||||||
|
// A huge shadow dragon sweeps across the cave (attract).
|
||||||
|
shadowFlyover() {
|
||||||
|
const { scene } = this;
|
||||||
|
const img = scene.add.image(GAME_WIDTH + 500, 230, this.sym('dragon')).setDisplaySize(900, 900)
|
||||||
|
.setTint(0x000000).setAlpha(0.28).setDepth(this.D.bg + 4.55);
|
||||||
|
const base = img.scaleY;
|
||||||
|
scene.tweens.add({ targets: img, scaleY: base * 0.82, duration: 260, yoyo: true, repeat: -1 });
|
||||||
|
const carrier = { x: GAME_WIDTH + 500 };
|
||||||
|
scene.tweens.add({
|
||||||
|
targets: carrier, x: -600, duration: 5200, ease: 'Sine.inOut',
|
||||||
|
onUpdate: () => { img.x = carrier.x; img.y = 230 + Math.sin(carrier.x / 260) * 40; },
|
||||||
|
onComplete: () => { scene.tweens.killTweensOf(img); img.destroy(); },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── The knight (left gutter) ───────────────────────────────────────────────
|
||||||
|
buildKnight() {
|
||||||
|
const { scene } = this;
|
||||||
|
const { cab } = this.g;
|
||||||
|
const sneak = this.stage.artKey('knightSneak');
|
||||||
|
const K = { x: cab.x / 2, y: 860, height: 380, ...(this.A.characters?.knight ?? {}) };
|
||||||
|
this.kcfg = K;
|
||||||
|
if (sneak) {
|
||||||
|
this.knight = scene.add.image(K.x, K.y, sneak).setOrigin(0.5, 1).setDepth(this.D.cab + 3);
|
||||||
|
this.knight.setDisplaySize(K.height * (this.knight.width / this.knight.height), K.height);
|
||||||
|
this.knightArt = true;
|
||||||
|
this.knightHome = { x: K.x, y: K.y };
|
||||||
|
scene.tweens.add({ targets: this.knight, y: K.y - 6, duration: 700, yoyo: true, repeat: -1, ease: 'Sine.inOut' });
|
||||||
|
} else {
|
||||||
|
// Helmet stand-in hides behind the cabinet's left edge and peeks out.
|
||||||
|
this.knight = scene.add.image(cab.x + 80, 600, this.sym('knight')).setDisplaySize(180, 180)
|
||||||
|
.setFlipX(true).setDepth(this.D.cab - 0.1);
|
||||||
|
this.knightArt = false;
|
||||||
|
this.knightHome = { x: cab.x + 80, y: 600 };
|
||||||
|
this.knightOut = { x: cab.x - 66, y: 600 };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
knightTexture(name) {
|
||||||
|
const k = this.stage.artKey(name);
|
||||||
|
if (k && this.knightArt) {
|
||||||
|
const h = this.knight.displayHeight;
|
||||||
|
this.knight.setTexture(k);
|
||||||
|
this.knight.setDisplaySize(h * (this.knight.width / this.knight.height), h);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
knightPeek() {
|
||||||
|
if (this.knightBusy) return;
|
||||||
|
this.knightBusy = true;
|
||||||
|
const { scene } = this;
|
||||||
|
const k = this.knight;
|
||||||
|
if (this.knightArt) {
|
||||||
|
scene.tweens.chain({ targets: k, tweens: [
|
||||||
|
{ x: this.knightHome.x + 40, duration: 900, ease: 'Sine.inOut' },
|
||||||
|
{ x: this.knightHome.x, duration: 900, delay: 900, ease: 'Sine.inOut' },
|
||||||
|
], onComplete: () => { this.knightBusy = false; } });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
scene.tweens.chain({ targets: k, tweens: [
|
||||||
|
{ x: this.knightOut.x, angle: 8, duration: 380, ease: 'Back.out' },
|
||||||
|
{ angle: -4, duration: 500, yoyo: true, ease: 'Sine.inOut' },
|
||||||
|
{ x: this.knightHome.x, angle: 0, duration: 300, delay: 300, ease: 'Quad.in' },
|
||||||
|
], onComplete: () => { this.knightBusy = false; } });
|
||||||
|
}
|
||||||
|
|
||||||
|
knightEnterRaid() {
|
||||||
|
const { scene } = this;
|
||||||
|
scene.tweens.killTweensOf(this.knight);
|
||||||
|
this.knightBusy = true;
|
||||||
|
this.knight.setAngle(0).setAlpha(1);
|
||||||
|
this.knightTexture('knightSneak');
|
||||||
|
if (this.knightArt) {
|
||||||
|
scene.tweens.add({ targets: this.knight, x: this.knightHome.x + 60, duration: 600, ease: 'Sine.out' });
|
||||||
|
} else {
|
||||||
|
scene.tweens.add({ targets: this.knight, x: this.knightOut.x, duration: 420, ease: 'Back.out' });
|
||||||
|
}
|
||||||
|
this.stage.sound('sneak');
|
||||||
|
}
|
||||||
|
|
||||||
|
knightGrab() {
|
||||||
|
const k = this.knight;
|
||||||
|
const y = k.y;
|
||||||
|
this.scene.tweens.add({ targets: k, y: y - 16, duration: 120, yoyo: true, ease: 'Quad.out', onComplete: () => k.setY(y) });
|
||||||
|
}
|
||||||
|
|
||||||
|
knightFlee() {
|
||||||
|
const { scene } = this;
|
||||||
|
this.knightTexture('knightRun');
|
||||||
|
if (this.knightArt) this.knight.setFlipX(true);
|
||||||
|
scene.tweens.add({ targets: this.knight, x: -260, angle: this.knightArt ? 0 : -18, duration: 520, ease: 'Quad.in' });
|
||||||
|
}
|
||||||
|
|
||||||
|
knightVictory() {
|
||||||
|
const { scene } = this;
|
||||||
|
this.knightTexture('knightVictory');
|
||||||
|
const y = this.knight.y;
|
||||||
|
scene.tweens.add({ targets: this.knight, y: y - 46, duration: 220, yoyo: true, repeat: 3, ease: 'Quad.out',
|
||||||
|
onComplete: () => this.knight.setY(y) });
|
||||||
|
const fx = scene.fx;
|
||||||
|
for (let k = 0; k < 4; k++) scene.time.delayedCall(k * 220, () => fx?.burst(this.knight.x, y - 60, 10, 0xffe27a));
|
||||||
|
}
|
||||||
|
|
||||||
|
knightReset() {
|
||||||
|
const { scene } = this;
|
||||||
|
scene.tweens.killTweensOf(this.knight);
|
||||||
|
this.knight.setFlipX(!this.knightArt).setAngle(0).setAlpha(1);
|
||||||
|
this.knightTexture('knightSneak');
|
||||||
|
this.knight.setPosition(this.knightHome.x, this.knightHome.y);
|
||||||
|
if (this.knightArt) {
|
||||||
|
scene.tweens.add({ targets: this.knight, y: this.knightHome.y - 6, duration: 700, yoyo: true, repeat: -1, ease: 'Sine.inOut' });
|
||||||
|
}
|
||||||
|
this.knightBusy = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Art-only: the knight tiptoes along the control bar, freezing when the dragon snorts.
|
||||||
|
knightWalk() {
|
||||||
|
const key = this.stage.artKey('knightSneak');
|
||||||
|
if (!key || this.walker) return;
|
||||||
|
const img = this.scene.add.image(-80, 930, key).setOrigin(0.5, 1).setDepth(this.D.ui - 0.5);
|
||||||
|
img.setDisplaySize(120 * (img.width / img.height), 120);
|
||||||
|
this.walker = img;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Jackpot plaques + hoard counter (inside the cabinet) ───────────────────
|
||||||
|
buildJackpotRow() {
|
||||||
|
const { scene } = this;
|
||||||
|
const y = Math.round((this.g.marquee.y + this.g.marquee.h + 12 + this.g.win.y - 26) / 2);
|
||||||
|
const widths = [180, 180, 320, 180, 180];
|
||||||
|
const gap = 12;
|
||||||
|
let x = GAME_WIDTH / 2 - (widths.reduce((a, b) => a + b, 0) + gap * 4) / 2;
|
||||||
|
const depth = this.D.cab + 3;
|
||||||
|
this.plaques = {};
|
||||||
|
const g = scene.add.graphics().setDepth(depth);
|
||||||
|
const gem = (cx, w, h, color) => {
|
||||||
|
const pts = [
|
||||||
|
[cx - w / 2 + 16, y - h / 2], [cx + w / 2 - 16, y - h / 2], [cx + w / 2, y],
|
||||||
|
[cx + w / 2 - 16, y + h / 2], [cx - w / 2 + 16, y + h / 2], [cx - w / 2, y],
|
||||||
|
].map(([px, py]) => ({ x: px, y: py }));
|
||||||
|
g.fillStyle(0x0e0408, 0.95);
|
||||||
|
g.fillPoints(pts, true);
|
||||||
|
g.lineStyle(3, color, 1);
|
||||||
|
g.strokePoints(pts, true, true);
|
||||||
|
g.lineStyle(1, 0xffd86b, 0.6);
|
||||||
|
g.strokePoints(pts.map((p) => ({ x: cx + (p.x - cx) * 0.94, y: y + (p.y - y) * 0.84 })), true, true);
|
||||||
|
};
|
||||||
|
const slots = [...TIER_ORDER, 'hoard'];
|
||||||
|
slots.forEach((tier, i) => {
|
||||||
|
const w = widths[i];
|
||||||
|
const cx = x + w / 2;
|
||||||
|
x += w + gap;
|
||||||
|
const big = tier === 'grand';
|
||||||
|
const h = big ? 78 : 66;
|
||||||
|
const color = tier === 'hoard' ? 0xffd23f : this.tiers[tier];
|
||||||
|
const glow = scene.add.image(cx, y, 'slots-glow').setDisplaySize(w * 1.3, h * 2.2)
|
||||||
|
.setTint(color).setBlendMode(ADD).setAlpha(0.22).setDepth(depth - 0.1);
|
||||||
|
scene.tweens.add({ targets: glow, alpha: 0.38, duration: 1400 + i * 170, yoyo: true, repeat: -1, ease: 'Sine.inOut' });
|
||||||
|
gem(cx, w, h, color);
|
||||||
|
const label = scene.add.text(cx, y - h / 2 + 16, tier === 'hoard' ? 'HOARD · 6 = RAID' : tier.toUpperCase(), {
|
||||||
|
fontFamily: '"Julius Sans One"', fontSize: big ? '17px' : '14px', color: tier === 'hoard' ? '#ffd86b' : TIER_HEX[tier],
|
||||||
|
}).setOrigin(0.5).setDepth(depth + 0.1);
|
||||||
|
const plaque = { cx, y, w, h, glow, label };
|
||||||
|
if (tier === 'hoard') {
|
||||||
|
plaque.pips = Array.from({ length: 6 }, (_, k) => scene.add.image(cx - 65 + k * 26, y + 12, this.coinKey())
|
||||||
|
.setDisplaySize(24, 24).setTint(0x3a2a10).setAlpha(0.6).setDepth(depth + 0.1));
|
||||||
|
} else {
|
||||||
|
plaque.value = scene.add.text(cx, y + 11, '', {
|
||||||
|
fontFamily: 'Righteous', fontSize: big ? '36px' : '26px', color: big ? '#ffd86b' : '#fff6d8',
|
||||||
|
}).setOrigin(0.5).setDepth(depth + 0.1).setShadow(0, 0, TIER_HEX[tier], big ? 14 : 8);
|
||||||
|
}
|
||||||
|
this.plaques[tier] = plaque;
|
||||||
|
});
|
||||||
|
this.grandShown = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// JackpotStrip-compatible object for SlotsGame.
|
||||||
|
makeJackpotStrip() {
|
||||||
|
return {
|
||||||
|
refresh: (bet, grand) => this.refreshJackpots(bet, grand),
|
||||||
|
flash: (tier) => this.flashPlaque(tier),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
refreshJackpots(bet, grand) {
|
||||||
|
const jp = this.m.features.holdSpin.jackpots;
|
||||||
|
for (const tier of ['mini', 'minor', 'major']) this.plaques[tier].value.setText((jp[tier] * bet).toLocaleString());
|
||||||
|
const target = Math.floor(grand);
|
||||||
|
const txt = this.plaques.grand.value;
|
||||||
|
if (this.grandShown === null || target <= this.grandShown) {
|
||||||
|
this.grandShown = target;
|
||||||
|
txt.setText(target.toLocaleString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Count the progressive up so it visibly grows with every bet.
|
||||||
|
const carrier = { v: this.grandShown };
|
||||||
|
this.grandShown = target;
|
||||||
|
this.scene.tweens.killTweensOf(this.grandCarrier ?? {});
|
||||||
|
this.grandCarrier = carrier;
|
||||||
|
this.scene.tweens.add({
|
||||||
|
targets: carrier, v: target, duration: 1400, ease: 'Sine.out',
|
||||||
|
onUpdate: () => txt.setText(Math.floor(carrier.v).toLocaleString()),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
flashPlaque(tier) {
|
||||||
|
const p = this.plaques[tier];
|
||||||
|
if (!p) return;
|
||||||
|
this.scene.tweens.add({ targets: p.glow, alpha: { from: 1, to: 0.3 }, duration: 180, yoyo: true, repeat: 4 });
|
||||||
|
const t = p.value ?? p.label;
|
||||||
|
this.scene.tweens.add({ targets: t, scale: 1.25, duration: 140, yoyo: true, repeat: 2 });
|
||||||
|
}
|
||||||
|
|
||||||
|
setHoardCount(n) {
|
||||||
|
const pips = this.plaques.hoard.pips;
|
||||||
|
pips.forEach((pip, k) => {
|
||||||
|
const lit = k < n;
|
||||||
|
if (lit === !!pip.lit) return;
|
||||||
|
pip.lit = lit;
|
||||||
|
if (lit) {
|
||||||
|
pip.clearTint().setAlpha(1);
|
||||||
|
this.scene.tweens.add({ targets: pip, scale: pip.scale * 1.6, duration: 120, yoyo: true });
|
||||||
|
} else {
|
||||||
|
pip.setTint(0x3a2a10).setAlpha(0.6);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Slumber meter (above the dragon; visible during the raid) ───────────────
|
||||||
|
buildSlumber() {
|
||||||
|
const { scene } = this;
|
||||||
|
const x = this.dcfg.x; const y = 236;
|
||||||
|
const c = scene.add.container(x, y).setDepth(this.D.ui).setAlpha(0);
|
||||||
|
const bg = scene.add.graphics();
|
||||||
|
bg.fillStyle(0x0e0610, 0.9); bg.fillRoundedRect(-140, -52, 280, 104, 20);
|
||||||
|
bg.lineStyle(3, 0x6a8cff, 0.9); bg.strokeRoundedRect(-140, -52, 280, 104, 20);
|
||||||
|
const title = scene.add.text(0, -28, 'DRAGON SLUMBER', {
|
||||||
|
fontFamily: 'Righteous', fontSize: '22px', color: '#cfe0ff',
|
||||||
|
}).setOrigin(0.5);
|
||||||
|
this.slumberPips = [-60, 0, 60].map((px) => {
|
||||||
|
const ring = scene.add.circle(px, 16, 22, 0x1a2050, 1).setStrokeStyle(3, 0x6a8cff);
|
||||||
|
const z = scene.add.text(px, 15, 'Z', { fontFamily: 'Righteous', fontSize: '26px', color: '#cfe0ff' }).setOrigin(0.5);
|
||||||
|
c.add([ring, z]);
|
||||||
|
return { ring, z };
|
||||||
|
});
|
||||||
|
c.addAt([bg, title], 0);
|
||||||
|
this.slumber = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
setSlumber(n) {
|
||||||
|
this.slumberPips.forEach((p, k) => {
|
||||||
|
const on = k < n;
|
||||||
|
p.ring.setFillStyle(on ? 0x2a3a90 : 0x3a0a0a, 1).setStrokeStyle(3, on ? 0x6a8cff : 0xff3a1a);
|
||||||
|
p.z.setText(on ? 'Z' : '!').setColor(on ? '#cfe0ff' : '#ff8c6a');
|
||||||
|
});
|
||||||
|
this.scene.tweens.add({ targets: this.slumber, scale: 1.08, duration: 110, yoyo: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Hooks ──────────────────────────────────────────────────────────────────
|
||||||
|
onReels(view) { this.view = view; }
|
||||||
|
|
||||||
|
onArtLoaded() {
|
||||||
|
// Rebuild characters if their art arrived after construction.
|
||||||
|
if (this.stage.artKey('dragonSleep') && this.dragon.texture.key !== this.stage.artKey('dragonSleep')) {
|
||||||
|
for (const o of [this.dragon, this.dragonShadow, this.rimGlow, this.eyeGlow, this.wing]) o?.destroy();
|
||||||
|
this.buildDragon();
|
||||||
|
}
|
||||||
|
if (this.stage.artKey('knightSneak') && !this.knightArt) {
|
||||||
|
this.knight.destroy();
|
||||||
|
this.buildKnight();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onAttract(on) {
|
||||||
|
if (on) { this.peekMs = 3000; this.shadowMs = 9000; this.walkMs = 6000; }
|
||||||
|
}
|
||||||
|
|
||||||
|
update(dt) {
|
||||||
|
this.t += dt / 1000;
|
||||||
|
// Breathing: slow while asleep, quick once awake.
|
||||||
|
const period = this.dragonStage >= 2 ? 1.4 : 3.4;
|
||||||
|
const br = Math.sin((this.t * Math.PI * 2) / period);
|
||||||
|
if (!this.scene.tweens.isTweening(this.dragon)) {
|
||||||
|
this.dragon.scaleX = this.dragonBase.sx * (1 + 0.008 * br);
|
||||||
|
this.dragon.scaleY = this.dragonBase.sy * (1 + 0.022 * br);
|
||||||
|
}
|
||||||
|
const f = 0.8 + 0.12 * Math.sin(this.t * 11) + 0.08 * Math.sin(this.t * 6.7 + 1);
|
||||||
|
this.torchGlow.setAlpha(0.5 * f);
|
||||||
|
if (this.dragonStage >= 2) this.eyeGlow.setAlpha(0.8 + 0.2 * Math.sin(this.t * 9));
|
||||||
|
if (this.eyeHold > 0) {
|
||||||
|
this.eyeHold -= dt;
|
||||||
|
if (this.eyeHold <= 0 && this.dragonStage < 2) this.scene.tweens.add({ targets: this.eyeGlow, alpha: 0, duration: 300 });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.dragonStage === 0) {
|
||||||
|
this.zzzMs += dt;
|
||||||
|
this.snoreMs += dt;
|
||||||
|
if (this.zzzMs > 1500) { this.zzzMs = 0; this.zzz(); }
|
||||||
|
if (this.snoreMs > 4200) {
|
||||||
|
this.snoreMs = 0;
|
||||||
|
this.smokePuff(this.anchor('nostril'), 2);
|
||||||
|
this.freezeMs = 1100;
|
||||||
|
if (this.stage.attracting) this.stage.sound('snore');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Art-only knight walk along the bar; he freezes while the dragon snorts.
|
||||||
|
if (this.walker) {
|
||||||
|
this.freezeMs = Math.max(0, this.freezeMs - dt);
|
||||||
|
if (this.freezeMs <= 0) this.walker.x += dt * 0.11;
|
||||||
|
this.walker.y = 930 - (this.freezeMs > 0 ? 0 : Math.abs(Math.sin(this.walker.x / 22)) * 5);
|
||||||
|
if (this.walker.x > GAME_WIDTH + 80) { this.walker.destroy(); this.walker = null; }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.stage.busy || !this.view) return;
|
||||||
|
this.peekMs += dt;
|
||||||
|
this.shadowMs += dt;
|
||||||
|
this.walkMs += dt;
|
||||||
|
if (this.peekMs >= (this.stage.attracting ? 9000 : 30000)) { this.peekMs = 0; this.knightPeek(); }
|
||||||
|
if (this.stage.attracting) {
|
||||||
|
if (this.shadowMs >= 24000) { this.shadowMs = 0; this.shadowFlyover(); }
|
||||||
|
if (this.walkMs >= 20000) { this.walkMs = 0; this.knightWalk(); }
|
||||||
|
if (Math.random() < dt / 13000) this.flashEye(1400);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onSpinStart() {
|
||||||
|
this.coinsLit = 0;
|
||||||
|
this.setHoardCount(0);
|
||||||
|
if (this.dragonStage !== 0) this.setDragonStage(0, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
countThrough(c, sym) {
|
||||||
|
const grid = this.stage.pendingResult?.grid;
|
||||||
|
if (!grid) return 0;
|
||||||
|
let n = 0;
|
||||||
|
for (let k = 0; k <= c && k < grid.length; k++) n += grid[k].filter((s) => s === sym).length;
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
onReelStop(c) {
|
||||||
|
const view = this.view;
|
||||||
|
const grid = this.stage.pendingResult?.grid;
|
||||||
|
if (!view || !grid) return;
|
||||||
|
const coin = this.m.features.holdSpin.coinSymbol;
|
||||||
|
const n = this.countThrough(c, coin);
|
||||||
|
if (n > this.coinsLit) {
|
||||||
|
this.coinsLit = n;
|
||||||
|
this.setHoardCount(Math.min(6, n));
|
||||||
|
}
|
||||||
|
// A dragon wild landing makes the dragon crack an eye and the cell smoulder.
|
||||||
|
const wild = this.m.wild?.symbol;
|
||||||
|
grid[c].forEach((s, r) => {
|
||||||
|
if (s !== wild) return;
|
||||||
|
const p = view.cellCenter(c, r);
|
||||||
|
this.emberBurst(p, 12);
|
||||||
|
this.flashEye(1000);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onAnticipate() {
|
||||||
|
this.flashEye(2400);
|
||||||
|
}
|
||||||
|
|
||||||
|
onLanded(result) {
|
||||||
|
if (!result?.holdSpinTriggered) return;
|
||||||
|
const p = this.plaques.hoard;
|
||||||
|
this.flashPlaque('hoard');
|
||||||
|
const burst = this.scene.add.image(p.cx, p.y, 'slots-glow').setDisplaySize(80, 80)
|
||||||
|
.setTint(0xffd23f).setBlendMode(ADD).setDepth(this.D.ui - 2);
|
||||||
|
this.scene.tweens.add({ targets: burst, displayWidth: 900, displayHeight: 500, alpha: 0, duration: 700,
|
||||||
|
onComplete: () => burst.destroy() });
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Hold & Spin: "Raid the Hoard" ──────────────────────────────────────────
|
||||||
|
async runHoldSpin(state, bet) {
|
||||||
|
const { scene, stage } = this;
|
||||||
|
const view = this.view;
|
||||||
|
const cfg = this.m.features.holdSpin;
|
||||||
|
const depth = view.depth + 6;
|
||||||
|
const objs = [];
|
||||||
|
const add = (o) => { objs.push(o); return o; };
|
||||||
|
scene.setStatus?.('');
|
||||||
|
stage.lights.setMood('feature');
|
||||||
|
stage.sound('raid', () => playSound(scene, SFX.SCIFI_RISER));
|
||||||
|
|
||||||
|
// Intro.
|
||||||
|
const cx = view.x + view.width() / 2; const cy = view.y + view.height() / 2;
|
||||||
|
const banner = add(scene.add.text(cx, cy, 'RAID THE HOARD!', {
|
||||||
|
fontFamily: 'Righteous', fontSize: '84px', color: '#ffd86b', stroke: '#14060a', strokeThickness: 12,
|
||||||
|
}).setOrigin(0.5).setDepth(depth + 6).setScale(0.3).setShadow(0, 0, 'rgba(255,180,60,0.9)', 26));
|
||||||
|
scene.tweens.add({ targets: banner, scale: 1, duration: 420, ease: 'Back.out' });
|
||||||
|
this.knightEnterRaid();
|
||||||
|
this.setDragonStage(0, true);
|
||||||
|
scene.tweens.add({ targets: this.slumber, alpha: 1, duration: 300 });
|
||||||
|
this.setSlumber(cfg.respins);
|
||||||
|
|
||||||
|
// Board: dark slots over the reels.
|
||||||
|
const board = add(scene.add.graphics().setDepth(depth));
|
||||||
|
board.fillStyle(0x07030a, 0.88);
|
||||||
|
board.fillRect(view.x - 6, view.y - 6, view.width() + 12, view.height() + 12);
|
||||||
|
for (let c = 0; c < view.nReels; c++) {
|
||||||
|
for (let r = 0; r < view.rows; r++) {
|
||||||
|
const p = view.cellCenter(c, r);
|
||||||
|
board.fillStyle(0x1a0c14, 1);
|
||||||
|
board.fillRoundedRect(p.x - view.cellW / 2 + 5, p.y - view.cellH / 2 + 5, view.cellW - 10, view.cellH - 10, 12);
|
||||||
|
board.lineStyle(2, 0xffd86b, 0.35);
|
||||||
|
board.strokeRoundedRect(p.x - view.cellW / 2 + 5, p.y - view.cellH / 2 + 5, view.cellW - 10, view.cellH - 10, 12);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const coins = new Map();
|
||||||
|
const keyOf = (c, r) => `${c},${r}`;
|
||||||
|
const addCoin = (coin, slam) => {
|
||||||
|
const p = view.cellCenter(coin.c, coin.r);
|
||||||
|
const size = Math.min(view.cellW, view.cellH) * 0.86;
|
||||||
|
const ring = coin.tier
|
||||||
|
? add(scene.add.image(p.x, p.y, 'slots-glow').setDisplaySize(size * 1.6, size * 1.6)
|
||||||
|
.setTint(this.tiers[coin.tier]).setBlendMode(ADD).setAlpha(0.8).setDepth(depth + 1))
|
||||||
|
: null;
|
||||||
|
const img = add(scene.add.image(p.x, p.y, this.coinKey(coin.tier)).setDisplaySize(size, size).setDepth(depth + 2));
|
||||||
|
const label = coin.tier ? coin.tier.toUpperCase() : (coin.value * bet).toLocaleString();
|
||||||
|
const txt = add(scene.add.text(p.x, p.y, label, {
|
||||||
|
fontFamily: 'Righteous', fontSize: coin.tier ? '26px' : '30px',
|
||||||
|
color: coin.tier ? TIER_HEX[coin.tier] : '#fff6d8', stroke: '#2a1400', strokeThickness: 6,
|
||||||
|
}).setOrigin(0.5).setDepth(depth + 3));
|
||||||
|
coins.set(keyOf(coin.c, coin.r), { coin, img, txt, ring });
|
||||||
|
if (!slam) return;
|
||||||
|
const sx = img.scaleX; const sy = img.scaleY;
|
||||||
|
img.setScale(sx * 1.9, sy * 1.9).setAlpha(0);
|
||||||
|
txt.setAlpha(0);
|
||||||
|
scene.tweens.add({ targets: img, scaleX: sx, scaleY: sy, alpha: 1, duration: 230, ease: 'Quad.in',
|
||||||
|
onComplete: () => {
|
||||||
|
scene.tweens.add({ targets: txt, alpha: 1, duration: 150 });
|
||||||
|
const shock = scene.add.circle(p.x, p.y, size * 0.45).setStrokeStyle(5, coin.tier ? this.tiers[coin.tier] : 0xffd86b)
|
||||||
|
.setDepth(depth + 4);
|
||||||
|
scene.tweens.add({ targets: shock, scale: 2.2, alpha: 0, duration: 420, onComplete: () => shock.destroy() });
|
||||||
|
scene.fx?.burst(p.x, p.y, 8, coin.tier ? this.tiers[coin.tier] : 0xf0c441);
|
||||||
|
scene.cameras.main.shake(90, 0.002);
|
||||||
|
if (coin.tier) {
|
||||||
|
this.flashPlaque(coin.tier);
|
||||||
|
stage.lights.flashAll(this.tiers[coin.tier], 1);
|
||||||
|
stage.sound('jackpotLand', () => playSound(scene, SFX.UI_CHIME));
|
||||||
|
} else {
|
||||||
|
stage.sound('coinLand', () => playSound(scene, SFX.COINS));
|
||||||
|
}
|
||||||
|
} });
|
||||||
|
};
|
||||||
|
for (const coin of state.holdSpin.locked) addCoin(coin, false);
|
||||||
|
await wait(scene, 1300);
|
||||||
|
scene.tweens.add({ targets: banner, alpha: 0, y: banner.y - 40, duration: 350 });
|
||||||
|
|
||||||
|
// Respins: every empty cell runs its own little reel, then they stop in turn.
|
||||||
|
let res = null;
|
||||||
|
let guard = 0;
|
||||||
|
while (++guard < 1000) {
|
||||||
|
const empty = [];
|
||||||
|
for (let c = 0; c < view.nReels; c++) {
|
||||||
|
for (let r = 0; r < view.rows; r++) if (!coins.has(keyOf(c, r))) empty.push({ c, r });
|
||||||
|
}
|
||||||
|
const spinners = new Map(empty.map((e) => [keyOf(e.c, e.r), this.startSpinner(e.c, e.r, depth + 1)]));
|
||||||
|
stage.sound('spin', () => playSound(scene, SFX.DICE_ROLL));
|
||||||
|
res = holdSpinRespin(state, bet);
|
||||||
|
const landed = new Map(res.newCoins.map((cn) => [keyOf(cn.c, cn.r), cn]));
|
||||||
|
await wait(scene, 560);
|
||||||
|
for (const e of empty) {
|
||||||
|
await wait(scene, 70);
|
||||||
|
this.stopSpinner(spinners.get(keyOf(e.c, e.r)));
|
||||||
|
const cn = landed.get(keyOf(e.c, e.r));
|
||||||
|
if (cn) addCoin(cn, true);
|
||||||
|
}
|
||||||
|
await wait(scene, 300);
|
||||||
|
|
||||||
|
if (res.newCoins.length > 0) {
|
||||||
|
// The knight grabbed loot without a sound; the dragon settles back down.
|
||||||
|
this.knightGrab();
|
||||||
|
if (this.dragonStage > 0) this.smokePuff(this.anchor('nostril'), 2);
|
||||||
|
this.setDragonStage(0, true);
|
||||||
|
stage.lights.setMood('feature');
|
||||||
|
if (!res.finished) this.setSlumber(cfg.respins);
|
||||||
|
} else if (!res.finished) {
|
||||||
|
this.setSlumber(res.respinsLeft);
|
||||||
|
this.setDragonStage(Math.min(2, cfg.respins - res.respinsLeft));
|
||||||
|
stage.lights.setMood(this.dragonStage >= 2 ? 'anticipation' : 'feature');
|
||||||
|
}
|
||||||
|
if (res.finished) break;
|
||||||
|
await wait(scene, 450);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Finale.
|
||||||
|
const award = res.award;
|
||||||
|
if (award.grandHit) {
|
||||||
|
this.setSlumber(0);
|
||||||
|
this.knightVictory();
|
||||||
|
const g = add(scene.add.text(cx, cy, 'GRAND JACKPOT!', {
|
||||||
|
fontFamily: 'Righteous', fontSize: '96px', color: '#ffd86b', stroke: '#5a0a10', strokeThickness: 14,
|
||||||
|
}).setOrigin(0.5).setDepth(depth + 8).setScale(0.2).setShadow(0, 0, 'rgba(255,60,60,0.9)', 30));
|
||||||
|
scene.tweens.add({ targets: g, scale: 1, duration: 500, ease: 'Back.out' });
|
||||||
|
this.flashPlaque('grand');
|
||||||
|
for (let k = 0; k < 5; k++) scene.time.delayedCall(k * 260, () => scene.fx?.coinShower(cx - 480 + k * 240, cy + 80, 22));
|
||||||
|
scene.fx?.nuggetRain?.(2600);
|
||||||
|
await this.roar();
|
||||||
|
await wait(scene, 600);
|
||||||
|
scene.tweens.add({ targets: g, alpha: 0, duration: 300 });
|
||||||
|
} else {
|
||||||
|
this.setSlumber(0);
|
||||||
|
this.knightFlee();
|
||||||
|
await this.roar();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Collect: every coin flies into the raid total.
|
||||||
|
const total = add(scene.add.text(GAME_WIDTH / 2, Math.round((this.g.cab.y + this.g.cab.h + 934) / 2), 'RAIDED 0', {
|
||||||
|
fontFamily: 'Righteous', fontSize: '40px', color: '#ffd86b', stroke: '#14060a', strokeThickness: 7,
|
||||||
|
}).setOrigin(0.5).setDepth(this.D.ui + 2));
|
||||||
|
let sum = 0;
|
||||||
|
const ordered = [...coins.values()].sort((a, b) => a.coin.c - b.coin.c || a.coin.r - b.coin.r);
|
||||||
|
for (const { coin, img, txt } of ordered) {
|
||||||
|
const amount = coin.tier ? cfg.jackpots[coin.tier] * bet : coin.value * bet;
|
||||||
|
scene.tweens.add({ targets: img, scaleX: img.scaleX * 1.2, scaleY: img.scaleY * 1.2, duration: 110, yoyo: true });
|
||||||
|
if (coin.tier) {
|
||||||
|
const b = add(scene.add.text(cx, cy, `${coin.tier.toUpperCase()} JACKPOT!`, {
|
||||||
|
fontFamily: 'Righteous', fontSize: '72px', color: TIER_HEX[coin.tier], stroke: '#14060a', strokeThickness: 10,
|
||||||
|
}).setOrigin(0.5).setDepth(depth + 8).setScale(0.3));
|
||||||
|
scene.tweens.add({ targets: b, scale: 1, duration: 300, ease: 'Back.out' });
|
||||||
|
this.flashPlaque(coin.tier);
|
||||||
|
stage.sound('jackpotLand', () => playSound(scene, SFX.CASINO_WIN));
|
||||||
|
await wait(scene, 900);
|
||||||
|
scene.tweens.add({ targets: b, alpha: 0, duration: 200 });
|
||||||
|
}
|
||||||
|
const fly = scene.add.text(txt.x, txt.y, `+${amount.toLocaleString()}`, {
|
||||||
|
fontFamily: 'Righteous', fontSize: '30px', color: '#fff6d8', stroke: '#2a1400', strokeThickness: 6,
|
||||||
|
}).setOrigin(0.5).setDepth(this.D.ui + 3);
|
||||||
|
await new Promise((r) => scene.tweens.add({
|
||||||
|
targets: fly, x: total.x, y: total.y, scale: 0.7, duration: 260, ease: 'Quad.in',
|
||||||
|
onComplete: () => { fly.destroy(); r(); },
|
||||||
|
}));
|
||||||
|
sum += amount;
|
||||||
|
total.setText(`RAIDED ${sum.toLocaleString()}`);
|
||||||
|
scene.tweens.add({ targets: total, scale: 1.12, duration: 70, yoyo: true });
|
||||||
|
img.setAlpha(0.45); txt.setAlpha(0.45);
|
||||||
|
stage.sound('collectTick', () => playSound(scene, SFX.COINS));
|
||||||
|
}
|
||||||
|
if (award.grandHit) {
|
||||||
|
sum += Math.floor(scene.jackpot ?? 0);
|
||||||
|
total.setText(`RAIDED ${sum.toLocaleString()}`);
|
||||||
|
}
|
||||||
|
await wait(scene, 900);
|
||||||
|
|
||||||
|
const cleanup = () => {
|
||||||
|
for (const o of objs) o.destroy();
|
||||||
|
scene.tweens.add({ targets: this.slumber, alpha: 0, duration: 300 });
|
||||||
|
this.knightReset();
|
||||||
|
this.setDragonStage(0, true);
|
||||||
|
};
|
||||||
|
return { award, cleanup };
|
||||||
|
}
|
||||||
|
|
||||||
|
// A tiny reel for one empty cell: blurred coins streaming down, masked to the cell.
|
||||||
|
startSpinner(c, r, depth) {
|
||||||
|
const { scene } = this;
|
||||||
|
const view = this.view;
|
||||||
|
const p = view.cellCenter(c, r);
|
||||||
|
const w = view.cellW; const h = view.cellH;
|
||||||
|
const mg = scene.make.graphics({ add: false });
|
||||||
|
mg.fillStyle(0xffffff);
|
||||||
|
mg.fillRect(p.x - w / 2 + 6, p.y - h / 2 + 6, w - 12, h - 12);
|
||||||
|
const mask = mg.createGeometryMask();
|
||||||
|
const size = Math.min(w, h) * 0.62;
|
||||||
|
const imgs = [0, 1].map((k) => {
|
||||||
|
const im = scene.add.image(p.x, p.y - h, this.coinKey()).setDisplaySize(size, size * 1.5)
|
||||||
|
.setTint(0x9a7a3a).setAlpha(0.5).setDepth(depth).setMask(mask);
|
||||||
|
scene.tweens.add({ targets: im, y: p.y + h, duration: 210, repeat: -1, delay: k * 105 });
|
||||||
|
return im;
|
||||||
|
});
|
||||||
|
return { imgs, mg };
|
||||||
|
}
|
||||||
|
|
||||||
|
stopSpinner(sp) {
|
||||||
|
if (!sp) return;
|
||||||
|
for (const im of sp.imgs) { this.scene.tweens.killTweensOf(im); im.destroy(); }
|
||||||
|
sp.mg.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
shutdown() {}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,589 @@
|
||||||
|
// SlotsFruit — Fruit Frenzy props for the attract kit (SlotsAttract.js).
|
||||||
|
//
|
||||||
|
// "The 1965 fruit stand on Fremont Street": an electromechanical upright under
|
||||||
|
// a striped fruit-stand awning with coloured glass bulbs, payline number lamps
|
||||||
|
// on the chrome bezel, and the classic pub-fruit-machine HOLD & NUDGE done with
|
||||||
|
// chunky illuminated push-buttons (VintageHoldNudge, a drop-in for
|
||||||
|
// HoldNudgeUI). The gutters hold a lit "fruit ladder" pay board (left), a
|
||||||
|
// relay-animated neon cherries sign and a FRESH FRUIT crate that the winning
|
||||||
|
// fruit arcs into (right). Lamps, chrome, neon and moving things only.
|
||||||
|
//
|
||||||
|
// Hooks: onReels, onSpinStart, onLanded, onBigMoment, onBet, onAttract,
|
||||||
|
// update, makeHoldNudgeUI(). Nothing here decides an outcome.
|
||||||
|
|
||||||
|
import * as Phaser from 'phaser';
|
||||||
|
import { playSound, SFX } from '../../ui/Sounds.js';
|
||||||
|
import { canvasTex } from './SlotsAttract.js';
|
||||||
|
import { textureKeyFor } from './SlotsSymbols.js';
|
||||||
|
import { chromeFill, ChromeLever } from './SlotsVintage.js';
|
||||||
|
|
||||||
|
const ADD = Phaser.BlendModes.ADD;
|
||||||
|
const wait = (scene, ms) => new Promise((r) => scene.time.delayedCall(ms, r));
|
||||||
|
const AMBER = 0xffb030;
|
||||||
|
const NEON_RED = 0xff3a5a;
|
||||||
|
const NEON_GREEN = 0x5aff6a;
|
||||||
|
|
||||||
|
function bakeAwning(scene, w) {
|
||||||
|
return canvasTex(scene, `ff-awning-${w}`, w, 84, (ctx) => {
|
||||||
|
const sw = 36;
|
||||||
|
const n = Math.ceil(w / sw);
|
||||||
|
for (let k = 0; k < n; k++) {
|
||||||
|
ctx.fillStyle = k % 2 ? '#f4ead2' : '#c81e32';
|
||||||
|
ctx.fillRect(k * sw, 12, sw, 50);
|
||||||
|
ctx.beginPath(); ctx.arc(k * sw + sw / 2, 62, sw / 2, 0, Math.PI); ctx.fill();
|
||||||
|
}
|
||||||
|
const shade = ctx.createLinearGradient(0, 12, 0, 80);
|
||||||
|
shade.addColorStop(0, 'rgba(255,255,255,0.18)');
|
||||||
|
shade.addColorStop(1, 'rgba(0,0,0,0.25)');
|
||||||
|
ctx.fillStyle = shade;
|
||||||
|
ctx.fillRect(0, 12, w, 70);
|
||||||
|
const bar = ctx.createLinearGradient(0, 0, 0, 14);
|
||||||
|
bar.addColorStop(0, '#e8ecf2'); bar.addColorStop(1, '#6a6e76');
|
||||||
|
ctx.fillStyle = bar;
|
||||||
|
ctx.fillRect(0, 0, w, 14);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function bakeCrate(scene) {
|
||||||
|
canvasTex(scene, 'ff-crate-back', 330, 80, (ctx) => {
|
||||||
|
ctx.fillStyle = '#5a3418'; ctx.fillRect(0, 0, 330, 80);
|
||||||
|
ctx.fillStyle = 'rgba(0,0,0,0.35)'; ctx.fillRect(0, 0, 330, 80);
|
||||||
|
});
|
||||||
|
canvasTex(scene, 'ff-crate-front', 340, 110, (ctx) => {
|
||||||
|
for (let k = 0; k < 3; k++) {
|
||||||
|
const g = ctx.createLinearGradient(0, k * 36, 0, k * 36 + 32);
|
||||||
|
g.addColorStop(0, '#c8904a'); g.addColorStop(1, '#8a5a28');
|
||||||
|
ctx.fillStyle = g; ctx.fillRect(0, k * 37, 340, 33);
|
||||||
|
ctx.strokeStyle = 'rgba(70,40,10,0.4)'; ctx.lineWidth = 1.5;
|
||||||
|
for (let x = 20; x < 340; x += 47) { ctx.beginPath(); ctx.moveTo(x, k * 37 + 4); ctx.lineTo(x + 30, k * 37 + 6); ctx.stroke(); }
|
||||||
|
}
|
||||||
|
ctx.fillStyle = '#6a4220'; ctx.fillRect(0, 0, 14, 110); ctx.fillRect(326, 0, 14, 110);
|
||||||
|
ctx.fillStyle = '#3a2008';
|
||||||
|
ctx.font = 'bold 30px Righteous, sans-serif';
|
||||||
|
ctx.textAlign = 'center';
|
||||||
|
ctx.fillText('FRESH FRUIT', 170, 64);
|
||||||
|
ctx.font = '14px Righteous, sans-serif';
|
||||||
|
ctx.fillText('FREMONT ST. · 1965', 170, 92);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── VintageHoldNudge: illuminated push-buttons (HoldNudgeUI-compatible) ──────
|
||||||
|
class VintageHoldNudge {
|
||||||
|
constructor(props) {
|
||||||
|
this.props = props;
|
||||||
|
this.scene = props.scene;
|
||||||
|
this.stage = props.stage;
|
||||||
|
this.view = props.view;
|
||||||
|
this.active = false;
|
||||||
|
const view = this.view;
|
||||||
|
const depth = props.D.cab + 3;
|
||||||
|
const y = view.y + view.height() + 26 + 40;
|
||||||
|
this.buttons = Array.from({ length: view.nReels }, (_, c) => {
|
||||||
|
const x = view.cellCenter(c, 0).x;
|
||||||
|
const ct = this.scene.add.container(x, y).setDepth(depth);
|
||||||
|
const housing = this.scene.add.graphics();
|
||||||
|
chromeFill(housing, -70, -29, 140, 58, 10);
|
||||||
|
const lens = this.scene.add.graphics();
|
||||||
|
const glow = this.scene.add.image(0, 0, 'slots-glow').setDisplaySize(220, 120).setBlendMode(ADD).setAlpha(0);
|
||||||
|
const label = this.scene.add.text(0, 1, 'HOLD', {
|
||||||
|
fontFamily: 'Righteous', fontSize: '24px', color: '#5a4a3a',
|
||||||
|
}).setOrigin(0.5);
|
||||||
|
ct.add([glow, housing, lens, label]);
|
||||||
|
ct.setSize(140, 58);
|
||||||
|
const b = { c, ct, lens, glow, label, state: null };
|
||||||
|
ct.on('pointerdown', () => this.press(b));
|
||||||
|
this.setButton(b, 'off');
|
||||||
|
return b;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Lamp strip: HOLD ● NUDGE ● ● ● [TAKE]
|
||||||
|
const ly = y + 56;
|
||||||
|
const lamp = (x) => {
|
||||||
|
const dot = this.scene.add.circle(x, ly, 9, 0x3a2a1a).setStrokeStyle(1.5, 0x1a1008).setDepth(depth);
|
||||||
|
const g = this.scene.add.image(x, ly, 'slots-glow').setDisplaySize(46, 46).setBlendMode(ADD).setAlpha(0).setDepth(depth + 0.1);
|
||||||
|
return { dot, g };
|
||||||
|
};
|
||||||
|
const cx = view.x + view.width() / 2;
|
||||||
|
const txt = (x, s) => this.scene.add.text(x, ly, s, {
|
||||||
|
fontFamily: 'Righteous', fontSize: '16px', color: '#f4ead2',
|
||||||
|
}).setOrigin(0, 0.5).setDepth(depth);
|
||||||
|
this.holdLamp = lamp(cx - 210); txt(cx - 194, 'HOLD');
|
||||||
|
txt(cx - 40, 'NUDGE');
|
||||||
|
this.nudgeLamps = [cx + 40, cx + 68, cx + 96].map(lamp);
|
||||||
|
this.take = this.scene.add.container(view.x + view.width() - 50, ly).setDepth(depth).setVisible(false);
|
||||||
|
const tg = this.scene.add.graphics();
|
||||||
|
chromeFill(tg, -62, -17, 124, 34, 8);
|
||||||
|
tg.fillStyle(0x2a6a2a, 1); tg.fillRoundedRect(-56, -13, 112, 26, 6);
|
||||||
|
this.takeLabel = this.scene.add.text(0, 0, 'DONE', { fontFamily: 'Righteous', fontSize: '16px', color: '#eaffea' }).setOrigin(0.5);
|
||||||
|
this.take.add([tg, this.takeLabel]);
|
||||||
|
this.take.setSize(124, 34);
|
||||||
|
this.take.on('pointerdown', () => this.finishNudges?.());
|
||||||
|
this.heldFrames = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
setLamp(l, on, color = AMBER) {
|
||||||
|
l.dot.setFillStyle(on ? color : 0x3a2a1a);
|
||||||
|
l.g.setTint(color).setAlpha(on ? 0.8 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// off · blink (holds offered) · held · nudge · attract (lens lit, not pressable)
|
||||||
|
setButton(b, state) {
|
||||||
|
b.state = state;
|
||||||
|
this.scene.tweens.killTweensOf(b.glow);
|
||||||
|
const col = { off: 0x3a3028, blink: AMBER, held: AMBER, nudge: NEON_GREEN, attract: AMBER }[state];
|
||||||
|
b.lens.clear();
|
||||||
|
b.lens.fillStyle(col, 1);
|
||||||
|
b.lens.fillRoundedRect(-62, -21, 124, 42, 8);
|
||||||
|
if (state !== 'off') {
|
||||||
|
b.lens.fillStyle(0xffffff, 0.3);
|
||||||
|
b.lens.fillRoundedRect(-58, -18, 116, 12, 6);
|
||||||
|
}
|
||||||
|
b.label.setText(state === 'held' ? 'HELD' : state === 'nudge' ? '▼' : 'HOLD')
|
||||||
|
.setColor(state === 'off' ? '#5a4a3a' : '#2a1404');
|
||||||
|
b.glow.setTint(col).setAlpha(state === 'off' ? 0 : 0.55);
|
||||||
|
if (state === 'blink') {
|
||||||
|
this.scene.tweens.add({ targets: b.glow, alpha: { from: 0.7, to: 0.1 }, duration: 320, yoyo: true, repeat: -1 });
|
||||||
|
}
|
||||||
|
if (state === 'blink' || state === 'held' || state === 'nudge') b.ct.setInteractive({ useHandCursor: true });
|
||||||
|
else b.ct.disableInteractive();
|
||||||
|
}
|
||||||
|
|
||||||
|
press(b) {
|
||||||
|
if (this.onHold && (b.state === 'blink' || b.state === 'held')) {
|
||||||
|
const held = this.onHold(b.c);
|
||||||
|
this.setButton(b, held ? 'held' : 'blink');
|
||||||
|
this.setHeldFrame(b.c, held);
|
||||||
|
this.stage.sound('hold', () => playSound(this.scene, SFX.CHIP_BET));
|
||||||
|
} else if (this.onNudgePress && b.state === 'nudge') {
|
||||||
|
this.onNudgePress(b.c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setHeldFrame(c, on) {
|
||||||
|
const old = this.heldFrames[c];
|
||||||
|
if (old) { old.forEach((o) => o.destroy()); this.heldFrames[c] = null; }
|
||||||
|
if (!on) return;
|
||||||
|
const v = this.view;
|
||||||
|
const x = v.reelX(c);
|
||||||
|
const g = this.scene.add.graphics().setDepth(v.depth + 3);
|
||||||
|
g.lineStyle(10, AMBER, 0.35); g.strokeRoundedRect(x - 4, v.y - 4, v.cellW + 8, v.height() + 8, 10);
|
||||||
|
g.lineStyle(3, 0xffe08a, 1); g.strokeRoundedRect(x - 2, v.y - 2, v.cellW + 4, v.height() + 4, 8);
|
||||||
|
const t = this.scene.add.text(x + v.cellW / 2, v.y + 16, 'HELD', {
|
||||||
|
fontFamily: 'Righteous', fontSize: '18px', color: '#2a1404', backgroundColor: '#ffb030', padding: { x: 10, y: 2 },
|
||||||
|
}).setOrigin(0.5).setDepth(v.depth + 3.1);
|
||||||
|
this.heldFrames[c] = [g, t];
|
||||||
|
}
|
||||||
|
|
||||||
|
// HoldNudgeUI API ────────────────────────────────────────────────────────────
|
||||||
|
showBanner(str) { this.scene.setStatus?.(str); }
|
||||||
|
hideBanner() {}
|
||||||
|
|
||||||
|
offerHolds(onToggle) {
|
||||||
|
this.clear(true);
|
||||||
|
this.active = true;
|
||||||
|
this.onHold = onToggle;
|
||||||
|
this.setLamp(this.holdLamp, true);
|
||||||
|
this.scene.tweens.add({ targets: this.holdLamp.g, alpha: { from: 0.9, to: 0.2 }, duration: 320, yoyo: true, repeat: -1 });
|
||||||
|
for (const b of this.buttons) this.setButton(b, 'blink');
|
||||||
|
playSound(this.scene, 'sfx-card-show-8bit');
|
||||||
|
}
|
||||||
|
|
||||||
|
runNudges(count, onNudge) {
|
||||||
|
this.clear(true);
|
||||||
|
this.active = true;
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
let left = count;
|
||||||
|
let lastWin = 0;
|
||||||
|
const lamps = () => this.nudgeLamps.forEach((l, k) => this.setLamp(l, k < left, NEON_GREEN));
|
||||||
|
lamps();
|
||||||
|
this.showBanner(`NUDGES: ${left}`);
|
||||||
|
this.take.setVisible(true).setInteractive({ useHandCursor: true });
|
||||||
|
this.takeLabel.setText('DONE');
|
||||||
|
for (const b of this.buttons) this.setButton(b, 'nudge');
|
||||||
|
playSound(this.scene, SFX.SCIFI_RISER);
|
||||||
|
this.finishNudges = () => { this.clear(); resolve(lastWin); };
|
||||||
|
this.onNudgePress = async (c) => {
|
||||||
|
if (left <= 0 || this.nudgeBusy) return;
|
||||||
|
this.nudgeBusy = true;
|
||||||
|
left--;
|
||||||
|
lamps();
|
||||||
|
this.stage.sound('nudge', () => playSound(this.scene, SFX.PIECE_CLICK));
|
||||||
|
this.scene.cameras.main.shake(90, 0.002);
|
||||||
|
const res = await onNudge(c);
|
||||||
|
lastWin = res.totalWin;
|
||||||
|
this.nudgeBusy = false;
|
||||||
|
this.showBanner(left > 0 ? `NUDGES: ${left}${lastWin > 0 ? ` WIN ${lastWin}` : ''}` : 'LAST NUDGE!');
|
||||||
|
if (left <= 0) { this.finishNudges(); return; }
|
||||||
|
this.takeLabel.setText(lastWin > 0 ? `TAKE ${lastWin}` : 'DONE');
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
clear(keepFrames = false) {
|
||||||
|
this.active = false;
|
||||||
|
this.onHold = null;
|
||||||
|
this.onNudgePress = null;
|
||||||
|
this.finishNudges = null;
|
||||||
|
for (const b of this.buttons) this.setButton(b, 'off');
|
||||||
|
this.scene.tweens.killTweensOf(this.holdLamp.g);
|
||||||
|
this.setLamp(this.holdLamp, false);
|
||||||
|
for (const l of this.nudgeLamps) this.setLamp(l, false);
|
||||||
|
this.take.setVisible(false).disableInteractive();
|
||||||
|
if (!keepFrames) {
|
||||||
|
// Held frames linger while the held reels sit still, then fade.
|
||||||
|
const frames = this.heldFrames.filter(Boolean);
|
||||||
|
this.heldFrames = [];
|
||||||
|
for (const pair of frames) {
|
||||||
|
this.scene.tweens.add({ targets: pair, alpha: 0, duration: 400, delay: 900, onComplete: () => pair.forEach((o) => o.destroy()) });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Attract: lenses blink in a rolling sequence (pub fruit machine "come play").
|
||||||
|
attractTick(k) {
|
||||||
|
if (this.active) return;
|
||||||
|
this.buttons.forEach((b, i) => this.setButton(b, i === k % this.buttons.length ? 'attract' : 'off'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class FruitFrenzyProps {
|
||||||
|
constructor(stage) {
|
||||||
|
this.stage = stage;
|
||||||
|
this.scene = stage.scene;
|
||||||
|
this.m = stage.m;
|
||||||
|
this.A = stage.A;
|
||||||
|
this.D = stage.D;
|
||||||
|
this.g = stage.g;
|
||||||
|
this.view = null;
|
||||||
|
this.t = 0;
|
||||||
|
this.crateItems = [];
|
||||||
|
this.rollMs = 0;
|
||||||
|
this.rollK = 0;
|
||||||
|
this.ladderMs = 0;
|
||||||
|
this.ladderK = 0;
|
||||||
|
this.leverMs = 0;
|
||||||
|
this.neonStep = 0;
|
||||||
|
this.neonMs = 0;
|
||||||
|
bakeCrate(this.scene);
|
||||||
|
this.buildAwning();
|
||||||
|
this.buildPaylineLamps();
|
||||||
|
this.buildGlass();
|
||||||
|
this.lever = new ChromeLever(this);
|
||||||
|
this.buildLadder();
|
||||||
|
this.buildNeon();
|
||||||
|
this.buildCrate();
|
||||||
|
}
|
||||||
|
|
||||||
|
sym(id) { return textureKeyFor(this.scene, this.m.id, id); }
|
||||||
|
|
||||||
|
// ── Fruit-stand awning with coloured bulbs at the scallop tips ─────────────
|
||||||
|
buildAwning() {
|
||||||
|
const { cab } = this.g;
|
||||||
|
const w = cab.w + 48;
|
||||||
|
const x0 = cab.x - 24; const y0 = cab.y - 58;
|
||||||
|
const key = bakeAwning(this.scene, w);
|
||||||
|
this.scene.add.image(x0, y0, key).setOrigin(0).setDepth(this.D.cab + 2.05);
|
||||||
|
const pts = [];
|
||||||
|
for (let x = 18; x < w; x += 36) pts.push({ x: x0 + x, y: y0 + 80, u: x / w });
|
||||||
|
this.stage.lights.addStrip('awning', [pts], {
|
||||||
|
size: 26, depth: this.D.cab + 2.1, channel: 0x000000, channelWidth: 0.01, texture: 'slots-bulb',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Payline number lamps on the bezel (1–5) ────────────────────────────────
|
||||||
|
buildPaylineLamps() {
|
||||||
|
const { win, cellH } = this.g;
|
||||||
|
const lines = this.m.paylines;
|
||||||
|
const rowY = (r) => win.y + r * cellH + cellH / 2;
|
||||||
|
const left = {}; const right = {};
|
||||||
|
lines.forEach((ln, i) => {
|
||||||
|
(left[ln[0]] ??= []).push(i);
|
||||||
|
(right[ln[ln.length - 1]] ??= []).push(i);
|
||||||
|
});
|
||||||
|
this.lineLamps = lines.map(() => []);
|
||||||
|
const depth = this.D.cab + 3;
|
||||||
|
const place = (side, x) => {
|
||||||
|
for (const [r, ids] of Object.entries(side)) {
|
||||||
|
ids.forEach((id, k) => {
|
||||||
|
const y = rowY(Number(r)) + (ids.length > 1 ? (k - (ids.length - 1) / 2) * 36 : 0);
|
||||||
|
const dot = this.scene.add.circle(x, y, 11, 0x5a3a20).setStrokeStyle(1.5, 0x1a1008).setDepth(depth);
|
||||||
|
const glow = this.scene.add.image(x, y, 'slots-glow').setDisplaySize(52, 52).setTint(AMBER)
|
||||||
|
.setBlendMode(ADD).setAlpha(0.25).setDepth(depth + 0.1);
|
||||||
|
this.scene.add.text(x, y, String(id + 1), {
|
||||||
|
fontFamily: 'Righteous', fontSize: '13px', color: '#fff4d8',
|
||||||
|
}).setOrigin(0.5).setDepth(depth + 0.2);
|
||||||
|
this.lineLamps[id].push({ dot, glow });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
place(left, win.x - 13);
|
||||||
|
place(right, win.x + win.w + 13);
|
||||||
|
}
|
||||||
|
|
||||||
|
blinkLine(id) {
|
||||||
|
for (const l of this.lineLamps[id] ?? []) {
|
||||||
|
l.dot.setFillStyle(AMBER);
|
||||||
|
this.scene.tweens.add({ targets: l.glow, alpha: { from: 1, to: 0.2 }, duration: 160, yoyo: true, repeat: 5,
|
||||||
|
onComplete: () => { l.glow.setAlpha(0.25); l.dot.setFillStyle(0x5a3a20); } });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
buildGlass() {
|
||||||
|
const { win } = this.g;
|
||||||
|
const maskG = this.scene.make.graphics({ add: false });
|
||||||
|
maskG.fillStyle(0xffffff); maskG.fillRect(win.x, win.y, win.w, win.h);
|
||||||
|
this.scene.add.image(win.x + win.w * 0.3, win.y + win.h / 2, 'slots-gloss')
|
||||||
|
.setDisplaySize(150, win.h * 1.8).setAngle(24).setBlendMode(ADD).setAlpha(0.09)
|
||||||
|
.setDepth(this.D.reel + 2.6).setMask(maskG.createGeometryMask());
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Fruit ladder pay board (left gutter) ───────────────────────────────────
|
||||||
|
buildLadder() {
|
||||||
|
const { scene } = this;
|
||||||
|
const { cab } = this.g;
|
||||||
|
const cx = Math.round(cab.x / 2);
|
||||||
|
const depth = this.D.cab + 1;
|
||||||
|
const g = scene.add.graphics().setDepth(depth);
|
||||||
|
chromeFill(g, cx - 196, 140, 392, 670, 22);
|
||||||
|
g.fillStyle(0xf4ead2, 1); g.fillRoundedRect(cx - 186, 150, 372, 650, 18);
|
||||||
|
g.fillStyle(0xc81e32, 1); g.fillRoundedRect(cx - 186, 150, 372, 86, { tl: 18, tr: 18, bl: 0, br: 0 });
|
||||||
|
scene.add.text(cx, 193, 'FRUIT PAYS', {
|
||||||
|
fontFamily: 'Righteous', fontSize: '44px', color: '#f4ead2', stroke: '#5a0a14', strokeThickness: 5,
|
||||||
|
}).setOrigin(0.5).setDepth(depth + 0.1);
|
||||||
|
const pt = this.m.paytable;
|
||||||
|
const entries = [
|
||||||
|
['bar', 3], ['bell', 3], ['melon', 3], ['plum', 3], ['orange', 3], ['lemon', 3], ['cherry', 3], ['cherry', 2],
|
||||||
|
].filter(([s, n]) => pt[s]?.[n] !== undefined);
|
||||||
|
const top = 262; const rowH = (790 - top) / entries.length;
|
||||||
|
this.ladder = entries.map(([sym, n], i) => {
|
||||||
|
const y = top + i * rowH + rowH / 2;
|
||||||
|
const glow = scene.add.image(cx, y, 'slots-glow').setDisplaySize(420, rowH * 1.8).setTint(AMBER)
|
||||||
|
.setBlendMode(ADD).setAlpha(0).setDepth(depth + 0.05);
|
||||||
|
const panel = scene.add.rectangle(cx, y, 350, rowH - 8, 0xffffff, 0).setStrokeStyle(2, 0xc8a878, 0.6)
|
||||||
|
.setDepth(depth + 0.06);
|
||||||
|
const lamp = scene.add.circle(cx - 160, y, 8, 0x8a6a4a).setDepth(depth + 0.1);
|
||||||
|
for (let k = 0; k < n; k++) {
|
||||||
|
scene.add.image(cx - 118 + k * 40, y, this.sym(sym)).setDisplaySize(rowH * 0.62, rowH * 0.62).setDepth(depth + 0.1);
|
||||||
|
}
|
||||||
|
const val = scene.add.text(cx + 166, y, '', {
|
||||||
|
fontFamily: 'Righteous', fontSize: '28px', color: '#7a1018',
|
||||||
|
}).setOrigin(1, 0.5).setDepth(depth + 0.1);
|
||||||
|
return { sym, n, pay: pt[sym][n], glow, panel, lamp, val };
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
lightRow(row, on) {
|
||||||
|
row.glow.setAlpha(on ? 0.6 : 0);
|
||||||
|
row.lamp.setFillStyle(on ? AMBER : 0x8a6a4a);
|
||||||
|
row.panel.setFillStyle(0xffe8a8, on ? 0.6 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
blinkRow(sym, n) {
|
||||||
|
const row = this.ladder.find((r) => r.sym === sym && r.n === n);
|
||||||
|
if (!row) return;
|
||||||
|
let k = 0;
|
||||||
|
this.scene.time.addEvent({ delay: 170, repeat: 9, callback: () => this.lightRow(row, (k++ & 1) === 0) });
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Neon cherries sign (right gutter, top) ─────────────────────────────────
|
||||||
|
buildNeon() {
|
||||||
|
const { scene } = this;
|
||||||
|
const { cab } = this.g;
|
||||||
|
const cx = Math.round((cab.x + cab.w + 120 + 1900) / 2);
|
||||||
|
const depth = this.D.cab + 1;
|
||||||
|
const box = scene.add.graphics().setDepth(depth);
|
||||||
|
chromeFill(box, cx - 210, 150, 420, 420, 22);
|
||||||
|
box.fillStyle(0x0a0810, 1); box.fillRoundedRect(cx - 200, 160, 400, 400, 18);
|
||||||
|
const arc = (x, y, r, a0, a1, n = 40) => Array.from({ length: n + 1 }, (_, i) => {
|
||||||
|
const a = a0 + (a1 - a0) * (i / n);
|
||||||
|
return { x: x + Math.cos(a) * r, y: y + Math.sin(a) * r };
|
||||||
|
});
|
||||||
|
const quad = (p0, p1, p2, n = 24) => Array.from({ length: n + 1 }, (_, i) => {
|
||||||
|
const t = i / n;
|
||||||
|
return { x: (1 - t) ** 2 * p0.x + 2 * (1 - t) * t * p1.x + t * t * p2.x, y: (1 - t) ** 2 * p0.y + 2 * (1 - t) * t * p1.y + t * t * p2.y };
|
||||||
|
});
|
||||||
|
const joint = { x: cx + 20, y: 220 };
|
||||||
|
const lC = { x: cx - 70, y: 400 }; const rC = { x: cx + 60, y: 418 };
|
||||||
|
const tube = (pts, color) => {
|
||||||
|
const glow = scene.add.graphics().setDepth(depth + 0.1).setBlendMode(ADD);
|
||||||
|
glow.lineStyle(20, color, 0.22); glow.strokePoints(pts, false);
|
||||||
|
const core = scene.add.graphics().setDepth(depth + 0.2);
|
||||||
|
core.lineStyle(7, color, 1); core.strokePoints(pts, false);
|
||||||
|
core.lineStyle(2.5, 0xffffff, 0.75); core.strokePoints(pts, false);
|
||||||
|
return { parts: [glow, core], on: true };
|
||||||
|
};
|
||||||
|
this.neon = [
|
||||||
|
tube(quad({ x: lC.x, y: lC.y - 60 }, { x: lC.x + 10, y: 280 }, joint), NEON_GREEN),
|
||||||
|
tube(quad({ x: rC.x, y: rC.y - 60 }, { x: rC.x + 4, y: 300 }, joint), NEON_GREEN),
|
||||||
|
tube(arc(lC.x, lC.y, 62, 0, Math.PI * 2), NEON_RED),
|
||||||
|
tube(arc(rC.x, rC.y, 62, 0, Math.PI * 2), NEON_RED),
|
||||||
|
tube([...quad(joint, { x: cx + 70, y: 160 }, { x: cx + 140, y: 200 }), ...quad({ x: cx + 140, y: 200 }, { x: cx + 90, y: 250 }, joint)], NEON_GREEN),
|
||||||
|
];
|
||||||
|
const word = scene.add.text(cx, 515, 'Fruit', {
|
||||||
|
fontFamily: 'Righteous', fontSize: '68px', color: '#ffd0e8',
|
||||||
|
}).setOrigin(0.5).setDepth(depth + 0.2).setShadow(0, 0, '#ff3a8a', 18, false, true);
|
||||||
|
this.neon.push({ parts: [word], on: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
setNeon(i, on) {
|
||||||
|
const seg = this.neon[i];
|
||||||
|
seg.on = on;
|
||||||
|
for (const p of seg.parts) p.setAlpha(on ? 1 : 0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
neonFlash(times = 3) {
|
||||||
|
let k = 0;
|
||||||
|
this.scene.time.addEvent({ delay: 180, repeat: times * 2 - 1, callback: () => {
|
||||||
|
const on = (k++ & 1) === 1;
|
||||||
|
this.neon.forEach((_, i) => this.setNeon(i, on));
|
||||||
|
} });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Relay sequence (attract): light segment by segment, double flash, hold.
|
||||||
|
neonTick(dt) {
|
||||||
|
this.neonMs += dt;
|
||||||
|
const n = this.neon.length;
|
||||||
|
const step = this.neonStep;
|
||||||
|
const dur = step === 0 ? 500 : step <= n ? 240 : step <= n + 4 ? 230 : 3600;
|
||||||
|
if (this.neonMs < dur) return;
|
||||||
|
this.neonMs = 0;
|
||||||
|
if (step === 0) { this.neon.forEach((_, i) => this.setNeon(i, false)); this.stage.sound('neon'); }
|
||||||
|
else if (step <= n) this.setNeon(step - 1, true);
|
||||||
|
else if (step <= n + 4) this.neon.forEach((_, i) => this.setNeon(i, (step - n) % 2 === 0));
|
||||||
|
this.neonStep = step >= n + 5 ? 0 : step + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Fresh fruit crate (right gutter, bottom) ───────────────────────────────
|
||||||
|
buildCrate() {
|
||||||
|
const { cab } = this.g;
|
||||||
|
const cx = Math.round((cab.x + cab.w + 120 + 1900) / 2);
|
||||||
|
const y = 700;
|
||||||
|
this.crate = { cx, top: y, depth: this.D.cab + 2 };
|
||||||
|
this.scene.add.image(cx, y + 10, 'ff-crate-back').setOrigin(0.5, 0).setDepth(this.D.cab + 1.9);
|
||||||
|
this.scene.add.image(cx, y + 50, 'ff-crate-front').setOrigin(0.5, 0).setDepth(this.D.cab + 2.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
// A fruit (or coin, for BAR) arcs out of the reel cell and drops in the crate.
|
||||||
|
fruitToCrate(sym, from, delay) {
|
||||||
|
const { scene } = this;
|
||||||
|
const C = this.crate;
|
||||||
|
scene.time.delayedCall(delay, () => {
|
||||||
|
const coin = sym === 'bar';
|
||||||
|
const img = scene.add.image(from.x, from.y, coin ? 'slots-coin-p' : this.sym(sym))
|
||||||
|
.setDepth(this.D.ui - 1.5);
|
||||||
|
if (coin) img.setScale(1.3); else img.setDisplaySize(64, 64);
|
||||||
|
const layer = Math.min(3, Math.floor(this.crateItems.length / 9));
|
||||||
|
const tx = C.cx + (Math.random() - 0.5) * 260;
|
||||||
|
const ty = C.top + 62 - layer * 14 - Math.random() * 6;
|
||||||
|
const ctrl = { x: (from.x + tx) / 2, y: Math.min(from.y, ty) - 220 };
|
||||||
|
const carrier = { t: 0 };
|
||||||
|
scene.tweens.add({
|
||||||
|
targets: carrier, t: 1, duration: 620, ease: 'Sine.in',
|
||||||
|
onUpdate: () => {
|
||||||
|
const t = carrier.t;
|
||||||
|
img.x = (1 - t) ** 2 * from.x + 2 * (1 - t) * t * ctrl.x + t * t * tx;
|
||||||
|
img.y = (1 - t) ** 2 * from.y + 2 * (1 - t) * t * ctrl.y + t * t * ty;
|
||||||
|
img.angle = t * 240;
|
||||||
|
},
|
||||||
|
onComplete: () => {
|
||||||
|
img.setDepth(C.depth + this.crateItems.length * 0.0001);
|
||||||
|
scene.tweens.add({ targets: img, y: ty - 10, duration: 110, yoyo: true, ease: 'Quad.out' });
|
||||||
|
this.crateItems.push(img);
|
||||||
|
if (this.crateItems.length > 30) {
|
||||||
|
const old = this.crateItems.shift();
|
||||||
|
scene.tweens.add({ targets: old, alpha: 0, duration: 300, onComplete: () => old.destroy() });
|
||||||
|
}
|
||||||
|
if (coin) this.stage.sound('coins', () => playSound(scene, SFX.COINS));
|
||||||
|
else this.stage.sound('fruit', () => playSound(scene, SFX.SQUISH));
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Hooks ──────────────────────────────────────────────────────────────────
|
||||||
|
onReels(view) { this.view = view; }
|
||||||
|
|
||||||
|
makeHoldNudgeUI() {
|
||||||
|
this.holdBank = new VintageHoldNudge(this);
|
||||||
|
return this.holdBank;
|
||||||
|
}
|
||||||
|
|
||||||
|
onBet(idx, bet) {
|
||||||
|
const lines = this.m.paylines.length;
|
||||||
|
for (const r of this.ladder) r.val.setText(Math.round((r.pay * bet) / lines).toLocaleString());
|
||||||
|
}
|
||||||
|
|
||||||
|
onSpinStart() {
|
||||||
|
if (!this.lever.pulling) this.lever.pull();
|
||||||
|
this.ladder.forEach((r) => this.lightRow(r, false));
|
||||||
|
this.neon.forEach((_, i) => this.setNeon(i, true));
|
||||||
|
this.neonStep = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
onLanded(result) {
|
||||||
|
if (!result?.totalWin) return;
|
||||||
|
this.neonFlash(3);
|
||||||
|
const view = this.view;
|
||||||
|
let delay = 0; let flown = 0;
|
||||||
|
for (const st of result.steps) {
|
||||||
|
if (st.type !== 'lineWins') continue;
|
||||||
|
for (const w of st.wins) {
|
||||||
|
this.blinkLine(w.line);
|
||||||
|
this.blinkRow(w.symbol, w.count);
|
||||||
|
for (const { c, r } of w.cells) {
|
||||||
|
if (flown++ >= 15) break;
|
||||||
|
this.fruitToCrate(w.symbol, view.cellCenter(c, r), delay);
|
||||||
|
delay += 90;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async onBigMoment() {
|
||||||
|
this.neonFlash(6);
|
||||||
|
for (let k = 0; k < 5; k++) {
|
||||||
|
this.stage.sound('bell', () => playSound(this.scene, SFX.UI_CHIME));
|
||||||
|
await wait(this.scene, 380);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onAttract(on) {
|
||||||
|
if (on) { this.neonStep = 0; this.leverMs = 6000; }
|
||||||
|
else {
|
||||||
|
this.neon.forEach((_, i) => this.setNeon(i, true));
|
||||||
|
this.ladder.forEach((r) => this.lightRow(r, false));
|
||||||
|
if (this.holdBank && !this.holdBank.active) this.holdBank.attractTick(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
update(dt) {
|
||||||
|
this.t += dt / 1000;
|
||||||
|
if (!this.stage.attracting) {
|
||||||
|
// Steady neon with the odd flicker.
|
||||||
|
if (Math.random() < dt / 2500) {
|
||||||
|
const i = Math.floor(Math.random() * this.neon.length);
|
||||||
|
if (this.neon[i].on) { this.setNeon(i, false); this.scene.time.delayedCall(60, () => this.setNeon(i, true)); }
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.neonTick(dt);
|
||||||
|
if (this.stage.busy) return;
|
||||||
|
// Hold lenses roll; the ladder chases up and down.
|
||||||
|
this.rollMs += dt;
|
||||||
|
if (this.rollMs >= 320) { this.rollMs = 0; this.holdBank?.attractTick(this.rollK++); }
|
||||||
|
this.ladderMs += dt;
|
||||||
|
if (this.ladderMs >= 140) {
|
||||||
|
this.ladderMs = 0;
|
||||||
|
const n = this.ladder.length;
|
||||||
|
const pos = this.ladderK % (n * 2 - 2);
|
||||||
|
const i = pos < n ? pos : n * 2 - 2 - pos;
|
||||||
|
this.ladder.forEach((r, k) => this.lightRow(r, k === i));
|
||||||
|
this.ladderK++;
|
||||||
|
}
|
||||||
|
this.leverMs += dt;
|
||||||
|
if (this.leverMs >= 12000) { this.leverMs = 0; this.lever.wiggle(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
shutdown() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -3,13 +3,23 @@
|
||||||
// Everything animates engine-decided results; nothing here invents a payout.
|
// Everything animates engine-decided results; nothing here invents a payout.
|
||||||
|
|
||||||
import { GAME_WIDTH, GAME_HEIGHT } from '../../config.js';
|
import { GAME_WIDTH, GAME_HEIGHT } from '../../config.js';
|
||||||
import { playSound, SFX } from '../../ui/Sounds.js';
|
import { playSound, playSoundEx, SFX } from '../../ui/Sounds.js';
|
||||||
import { textureKeyFor } from './SlotsSymbols.js';
|
import { textureKeyFor, allSymbolIds } from './SlotsSymbols.js';
|
||||||
|
import { hsv } from './SlotsAttract.js';
|
||||||
|
|
||||||
const LINE_COLORS = [0xffd86b, 0x59e7ff, 0xff7da0, 0x8cf28a, 0xc89bff, 0xffa45e];
|
const LINE_COLORS = [0xffd86b, 0x59e7ff, 0xff7da0, 0x8cf28a, 0xc89bff, 0xffa45e];
|
||||||
|
|
||||||
const oneShot = (file, volume = 0.7) => {
|
const oneShot = (file, volume = 0.7, rate = 1) => {
|
||||||
try { const a = new Audio(`assets/fx/${file}`); a.volume = volume; a.play(); } catch { /* ignore */ }
|
try {
|
||||||
|
const a = new Audio(`assets/fx/${file}`);
|
||||||
|
a.volume = volume;
|
||||||
|
if (rate !== 1) {
|
||||||
|
a.preservesPitch = false;
|
||||||
|
a.mozPreservesPitch = false;
|
||||||
|
a.playbackRate = rate;
|
||||||
|
}
|
||||||
|
a.play();
|
||||||
|
} catch { /* ignore */ }
|
||||||
};
|
};
|
||||||
|
|
||||||
const wait = (scene, ms) => new Promise((r) => scene.time.delayedCall(ms, r));
|
const wait = (scene, ms) => new Promise((r) => scene.time.delayedCall(ms, r));
|
||||||
|
|
@ -21,6 +31,40 @@ export class SlotsFx {
|
||||||
this.machine = machine;
|
this.machine = machine;
|
||||||
this.depth = depth;
|
this.depth = depth;
|
||||||
this.lineG = scene.add.graphics().setDepth(depth);
|
this.lineG = scene.add.graphics().setDepth(depth);
|
||||||
|
// Attract machines get the richer presentation (dimming, glows, confetti,
|
||||||
|
// rainbow beams). `sfx` is swapped for the MachineStage sound layer and
|
||||||
|
// `winTarget` is the WIN meter position.
|
||||||
|
this.fancy = !!machine.attract;
|
||||||
|
this.sfx = (name, fallback) => fallback?.();
|
||||||
|
this.winTarget = null;
|
||||||
|
this.keyToSym = {};
|
||||||
|
for (const sym of allSymbolIds(machine)) this.keyToSym[textureKeyFor(scene, machine.id, sym)] = sym;
|
||||||
|
}
|
||||||
|
|
||||||
|
symColor(sym) { return this.machine.attract?.symbolColors?.[sym] ?? 0xffffff; }
|
||||||
|
|
||||||
|
// Soft additive glow behind winning symbols.
|
||||||
|
glowCells(cells, tint = 0xffffff) {
|
||||||
|
for (const { c, r } of cells) {
|
||||||
|
const p = this.view.cellCenter(c, r);
|
||||||
|
const img = this.scene.add.image(p.x, p.y, 'slots-glow').setBlendMode('ADD')
|
||||||
|
.setDepth(this.view.depth - 1).setTint(tint).setAlpha(0);
|
||||||
|
img.setDisplaySize(this.view.cellW * 1.4, this.view.cellH * 1.4);
|
||||||
|
this.scene.tweens.add({
|
||||||
|
targets: img, alpha: 0.95, duration: 160, yoyo: true, hold: 460,
|
||||||
|
onComplete: () => img.destroy(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
confetti(x, y, tint, count = 10) {
|
||||||
|
const em = this.scene.add.particles(x, y, 'slots-sprinkle', {
|
||||||
|
speed: { min: 140, max: 420 }, angle: { min: 0, max: 360 }, gravityY: 700,
|
||||||
|
lifespan: 750, rotate: { min: 0, max: 360 }, scale: { start: 1.1, end: 0.4 },
|
||||||
|
alpha: { start: 1, end: 0 }, tint: [tint, tint, 0xffffff], emitting: false,
|
||||||
|
}).setDepth(this.depth + 2);
|
||||||
|
em.explode(count);
|
||||||
|
this.scene.time.delayedCall(900, () => em.destroy());
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Particles ────────────────────────────────────────────────────────────────
|
// ── Particles ────────────────────────────────────────────────────────────────
|
||||||
|
|
@ -34,7 +78,7 @@ export class SlotsFx {
|
||||||
}
|
}
|
||||||
|
|
||||||
coinShower(x, y, count = 24) {
|
coinShower(x, y, count = 24) {
|
||||||
const em = this.scene.add.particles(x, y, 'slots-coin-p', {
|
const em = this.scene.add.particles(x, y, this.machine.attract?.coinTexture ?? 'slots-coin-p', {
|
||||||
speedX: { min: -260, max: 260 }, speedY: { min: -520, max: -220 },
|
speedX: { min: -260, max: 260 }, speedY: { min: -520, max: -220 },
|
||||||
gravityY: 900, lifespan: 1400, rotate: { min: 0, max: 360 },
|
gravityY: 900, lifespan: 1400, rotate: { min: 0, max: 360 },
|
||||||
scale: { min: 0.7, max: 1.2 }, quantity: count, emitting: false,
|
scale: { min: 0.7, max: 1.2 }, quantity: count, emitting: false,
|
||||||
|
|
@ -55,7 +99,8 @@ export class SlotsFx {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Counters ─────────────────────────────────────────────────────────────────
|
// ── Counters ─────────────────────────────────────────────────────────────────
|
||||||
rollCounter(textObj, from, to, ms = 700) {
|
// accelerate: ticks come faster and climb in pitch toward the end.
|
||||||
|
rollCounter(textObj, from, to, ms = 700, { accelerate = false } = {}) {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
const carrier = { v: from };
|
const carrier = { v: from };
|
||||||
let lastTick = 0;
|
let lastTick = 0;
|
||||||
|
|
@ -64,7 +109,12 @@ export class SlotsFx {
|
||||||
onUpdate: (tw) => {
|
onUpdate: (tw) => {
|
||||||
textObj.setText(Math.floor(carrier.v).toLocaleString());
|
textObj.setText(Math.floor(carrier.v).toLocaleString());
|
||||||
const now = tw.elapsed;
|
const now = tw.elapsed;
|
||||||
if (now - lastTick > 160) { lastTick = now; playSound(this.scene, SFX.COINS); }
|
const p = accelerate ? Math.min(1, now / ms) : 0;
|
||||||
|
if (now - lastTick > 160 - 100 * p) {
|
||||||
|
lastTick = now;
|
||||||
|
if (accelerate) playSoundEx(this.scene, SFX.COINS, { rate: 1 + 0.5 * p });
|
||||||
|
else playSound(this.scene, SFX.COINS);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onComplete: () => { textObj.setText(Math.floor(to).toLocaleString()); resolve(); },
|
onComplete: () => { textObj.setText(Math.floor(to).toLocaleString()); resolve(); },
|
||||||
});
|
});
|
||||||
|
|
@ -74,45 +124,202 @@ export class SlotsFx {
|
||||||
// ── Payline wins ─────────────────────────────────────────────────────────────
|
// ── Payline wins ─────────────────────────────────────────────────────────────
|
||||||
async playLineWins(step, machine) {
|
async playLineWins(step, machine) {
|
||||||
const wins = step.wins.slice(0, 6);
|
const wins = step.wins.slice(0, 6);
|
||||||
|
if (this.fancy) this.view.dimExcept(wins.flatMap((w) => w.cells));
|
||||||
for (let i = 0; i < wins.length; i++) {
|
for (let i = 0; i < wins.length; i++) {
|
||||||
const win = wins[i];
|
const win = wins[i];
|
||||||
const color = LINE_COLORS[win.line % LINE_COLORS.length];
|
const color = LINE_COLORS[win.line % LINE_COLORS.length];
|
||||||
await this.traceLine(win.cells, color);
|
await this.traceLine(win.cells, color, this.lineStyleFor(win));
|
||||||
this.pulseCells(win.cells);
|
this.pulseCells(win.cells);
|
||||||
const last = this.view.cellCenter(win.cells[win.cells.length - 1].c, win.cells[win.cells.length - 1].r);
|
const last = this.view.cellCenter(win.cells[win.cells.length - 1].c, win.cells[win.cells.length - 1].r);
|
||||||
const mult = win.wildMult > 1 ? ` ×${win.wildMult}` : '';
|
const mult = win.wildMult > 1 ? ` ×${win.wildMult}` : '';
|
||||||
this.floatText(last.x, last.y - 30, `+${(win.credits * (step.multiplier ?? 1)).toLocaleString()}${mult}`);
|
this.floatText(last.x, last.y - 30, `+${(win.credits * (step.multiplier ?? 1)).toLocaleString()}${mult}`);
|
||||||
playSound(this.scene, 'sfx-casino-win-8bit');
|
playSound(this.scene, 'sfx-casino-win-8bit');
|
||||||
|
if (this.fancy) this.glowCells(win.cells, color);
|
||||||
await wait(this.scene, 360);
|
await wait(this.scene, 360);
|
||||||
this.lineG.clear();
|
this.lineG.clear();
|
||||||
}
|
}
|
||||||
|
if (this.fancy) this.view.undim();
|
||||||
if (step.multiplier > 1) this.flashMultiplier(step.multiplier);
|
if (step.multiplier > 1) this.flashMultiplier(step.multiplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
traceLine(cells, color) {
|
// attract.lineStyle: a style name, or { wild, <symbol>, default } picked per
|
||||||
|
// win ('wild' applies when a wild is part of the line).
|
||||||
|
lineStyleFor(win) {
|
||||||
|
const ls = this.machine.attract?.lineStyle;
|
||||||
|
if (!ls || typeof ls === 'string') return ls ?? null;
|
||||||
|
const wild = this.machine.wild?.symbol;
|
||||||
|
const hasWild = wild && win.cells.some(({ c, r }) => this.keyToSym[this.view.image(c, r).texture.key] === wild);
|
||||||
|
return (hasWild && ls.wild) || ls[win.symbol] || ls.default || null;
|
||||||
|
}
|
||||||
|
|
||||||
|
traceLine(cells, color, style = null) {
|
||||||
|
if (style === 'slash') return this.slashLine(cells);
|
||||||
|
if (style === 'lamp') return this.lampLine(cells);
|
||||||
|
const vein = style === 'goldVein';
|
||||||
|
const fire = style === 'fire';
|
||||||
|
const bubbly = style === 'bubbles';
|
||||||
|
const sun = style === 'sunbeam';
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
const pts = cells.map(({ c, r }) => this.view.cellCenter(c, r));
|
const pts = cells.map(({ c, r }) => this.view.cellCenter(c, r));
|
||||||
const carrier = { t: 0 };
|
const carrier = { t: 0 };
|
||||||
|
// Gold vein: a sparkle rides the tip as the line is traced.
|
||||||
|
const head = vein
|
||||||
|
? this.scene.add.image(pts[0].x, pts[0].y, 'slots-glint').setBlendMode('ADD')
|
||||||
|
.setScale(0.5).setDepth(this.depth + 1)
|
||||||
|
: null;
|
||||||
|
// Fire: flames shed from the burning tip as it travels.
|
||||||
|
const flame = fire ? { x: pts[0].x, y: pts[0].y } : null;
|
||||||
|
const flames = fire
|
||||||
|
? this.scene.add.particles(0, 0, 'slots-glow', {
|
||||||
|
speedY: { min: -90, max: -30 }, speedX: { min: -25, max: 25 }, lifespan: { min: 350, max: 650 },
|
||||||
|
scale: { start: 0.22, end: 0.04 }, alpha: { start: 0.9, end: 0 },
|
||||||
|
tint: [0xfff0a0, 0xff8c2a, 0xff3a1a], blendMode: 'ADD', frequency: 8, quantity: 2,
|
||||||
|
}).setDepth(this.depth + 1)
|
||||||
|
: null;
|
||||||
|
flames?.startFollow(flame);
|
||||||
|
// Bubbles: a stream of bubbles shed from the tip of the current.
|
||||||
|
const bub = bubbly ? { x: pts[0].x, y: pts[0].y } : null;
|
||||||
|
const bubs = bubbly
|
||||||
|
? this.scene.add.particles(0, 0, 'slots-bubble', {
|
||||||
|
speedY: { min: -120, max: -40 }, speedX: { min: -30, max: 30 }, lifespan: { min: 500, max: 900 },
|
||||||
|
scale: { start: 0.3, end: 0.1 }, alpha: { start: 0.95, end: 0 }, frequency: 18, quantity: 1,
|
||||||
|
}).setDepth(this.depth + 1)
|
||||||
|
: null;
|
||||||
|
bubs?.startFollow(bub);
|
||||||
|
// Sunbeam: hot white-gold light with sand sparkling off the tip.
|
||||||
|
const sand = sun ? { x: pts[0].x, y: pts[0].y } : null;
|
||||||
|
const sands = sun
|
||||||
|
? this.scene.add.particles(0, 0, 'slots-led', {
|
||||||
|
speed: { min: 30, max: 140 }, gravityY: 260, lifespan: { min: 400, max: 800 },
|
||||||
|
scale: { start: 0.12, end: 0.02 }, tint: [0xffd86b, 0xfff3c0, 0xe8b860],
|
||||||
|
blendMode: 'ADD', frequency: 10, quantity: 2,
|
||||||
|
}).setDepth(this.depth + 1)
|
||||||
|
: null;
|
||||||
|
sands?.startFollow(sand);
|
||||||
|
const stroke = (width, col, alpha, upto) => {
|
||||||
|
this.lineG.lineStyle(width, col, alpha);
|
||||||
|
this.lineG.beginPath();
|
||||||
|
this.lineG.moveTo(pts[0].x, pts[0].y);
|
||||||
|
for (const p of upto) this.lineG.lineTo(p.x, p.y);
|
||||||
|
this.lineG.strokePath();
|
||||||
|
};
|
||||||
this.scene.tweens.add({
|
this.scene.tweens.add({
|
||||||
targets: carrier, t: 1, duration: 240, ease: 'Quad.out',
|
targets: carrier, t: 1, duration: vein ? 360 : 240, ease: 'Quad.out',
|
||||||
onUpdate: () => {
|
onUpdate: () => {
|
||||||
this.lineG.clear();
|
this.lineG.clear();
|
||||||
this.lineG.lineStyle(7, color, 0.9);
|
|
||||||
this.lineG.beginPath();
|
|
||||||
this.lineG.moveTo(pts[0].x, pts[0].y);
|
|
||||||
const total = (pts.length - 1) * carrier.t;
|
const total = (pts.length - 1) * carrier.t;
|
||||||
for (let s = 1; s <= Math.floor(total); s++) this.lineG.lineTo(pts[s].x, pts[s].y);
|
const upto = [];
|
||||||
|
for (let s = 1; s <= Math.floor(total); s++) upto.push(pts[s]);
|
||||||
const f = total - Math.floor(total);
|
const f = total - Math.floor(total);
|
||||||
const s = Math.floor(total);
|
const s = Math.floor(total);
|
||||||
if (s < pts.length - 1 && f > 0) {
|
if (s < pts.length - 1 && f > 0) {
|
||||||
this.lineG.lineTo(
|
upto.push({
|
||||||
pts[s].x + (pts[s + 1].x - pts[s].x) * f,
|
x: pts[s].x + (pts[s + 1].x - pts[s].x) * f,
|
||||||
pts[s].y + (pts[s + 1].y - pts[s].y) * f,
|
y: pts[s].y + (pts[s + 1].y - pts[s].y) * f,
|
||||||
);
|
});
|
||||||
|
}
|
||||||
|
if (sun) {
|
||||||
|
stroke(30, 0xffd86b, 0.25, upto);
|
||||||
|
stroke(12, 0xfff3c0, 0.95, upto);
|
||||||
|
stroke(4, 0xffffff, 1, upto);
|
||||||
|
const tip = upto[upto.length - 1] ?? pts[0];
|
||||||
|
sand.x = tip.x; sand.y = tip.y;
|
||||||
|
} else if (bubbly) {
|
||||||
|
stroke(22, 0x39e6ff, 0.25, upto);
|
||||||
|
stroke(8, 0x7af0ff, 0.9, upto);
|
||||||
|
stroke(3, 0xffffff, 1, upto);
|
||||||
|
const tip = upto[upto.length - 1] ?? pts[0];
|
||||||
|
bub.x = tip.x; bub.y = tip.y;
|
||||||
|
} else if (fire) {
|
||||||
|
stroke(24, 0xff3a1a, 0.3, upto);
|
||||||
|
stroke(10, 0xff8c2a, 0.95, upto);
|
||||||
|
stroke(3, 0xfff0a0, 1, upto);
|
||||||
|
const tip = upto[upto.length - 1] ?? pts[0];
|
||||||
|
flame.x = tip.x; flame.y = tip.y;
|
||||||
|
} else if (vein) {
|
||||||
|
stroke(22, 0xffb52e, 0.28, upto);
|
||||||
|
stroke(9, 0xffd23f, 0.95, upto);
|
||||||
|
stroke(3, 0xfff6cf, 1, upto);
|
||||||
|
const tip = upto[upto.length - 1] ?? pts[0];
|
||||||
|
head.setPosition(tip.x, tip.y).setAngle(carrier.t * 180);
|
||||||
|
} else {
|
||||||
|
stroke(7, color, 0.9, upto);
|
||||||
}
|
}
|
||||||
this.lineG.strokePath();
|
|
||||||
},
|
},
|
||||||
onComplete: resolve,
|
onComplete: () => {
|
||||||
|
if (head) this.scene.tweens.add({ targets: head, alpha: 0, scale: 0.9, duration: 260, onComplete: () => head.destroy() });
|
||||||
|
if (sands) {
|
||||||
|
sands.stop();
|
||||||
|
this.scene.time.delayedCall(850, () => sands.destroy());
|
||||||
|
}
|
||||||
|
if (bubs) {
|
||||||
|
bubs.stop();
|
||||||
|
this.scene.time.delayedCall(950, () => bubs.destroy());
|
||||||
|
}
|
||||||
|
if (flames) {
|
||||||
|
flames.stop();
|
||||||
|
this.scene.time.delayedCall(700, () => flames.destroy());
|
||||||
|
this.sfx('fire');
|
||||||
|
}
|
||||||
|
resolve();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Vintage: the payline is a lit lamp wire — it blinks on, not traced.
|
||||||
|
async lampLine(cells) {
|
||||||
|
const pts = cells.map(({ c, r }) => this.view.cellCenter(c, r));
|
||||||
|
const a = { x: this.view.x - 12, y: pts[0].y };
|
||||||
|
const b = { x: this.view.x + this.view.width() + 12, y: pts[pts.length - 1].y };
|
||||||
|
const line = pts.length > 1 && pts.some((p) => p.y !== pts[0].y) ? [a, ...pts, b] : [a, b];
|
||||||
|
for (let k = 0; k < 3; k++) {
|
||||||
|
this.lineG.clear();
|
||||||
|
const [c0, c1, c2] = this.machine.attract?.lampColors ?? [0xff3a2a, 0xff6a4a, 0xfff0d0];
|
||||||
|
for (const [w, col, al] of [[18, c0, 0.3], [6, c1, 0.95], [2, c2, 1]]) {
|
||||||
|
this.lineG.lineStyle(w, col, al);
|
||||||
|
this.lineG.strokePoints(line, false);
|
||||||
|
}
|
||||||
|
await wait(this.scene, 110);
|
||||||
|
this.lineG.clear();
|
||||||
|
await wait(this.scene, 70);
|
||||||
|
}
|
||||||
|
this.lineG.lineStyle(6, (this.machine.attract?.lampColors ?? [0, 0xff6a4a])[1], 0.9);
|
||||||
|
this.lineG.strokePoints(line, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Knight wins: a fast, bright sword-slash streak along the line.
|
||||||
|
slashLine(cells) {
|
||||||
|
const { scene } = this;
|
||||||
|
const pts = cells.map(({ c, r }) => this.view.cellCenter(c, r));
|
||||||
|
const a = pts[0]; const b = pts[pts.length - 1];
|
||||||
|
const carrier = { t: 0 };
|
||||||
|
const glint = scene.add.image(a.x, a.y, 'slots-glint').setBlendMode('ADD').setScale(0.8).setDepth(this.depth + 1);
|
||||||
|
this.sfx('slash', () => playSound(scene, SFX.SWORD_SLICE));
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
scene.tweens.add({
|
||||||
|
targets: carrier, t: 1, duration: 170, ease: 'Quad.in',
|
||||||
|
onUpdate: () => {
|
||||||
|
this.lineG.clear();
|
||||||
|
const total = (pts.length - 1) * carrier.t;
|
||||||
|
const upto = [pts[0]];
|
||||||
|
for (let s = 1; s <= Math.floor(total); s++) upto.push(pts[s]);
|
||||||
|
const s = Math.floor(total); const f = total - s;
|
||||||
|
if (s < pts.length - 1 && f > 0) {
|
||||||
|
upto.push({ x: pts[s].x + (pts[s + 1].x - pts[s].x) * f, y: pts[s].y + (pts[s + 1].y - pts[s].y) * f });
|
||||||
|
}
|
||||||
|
for (const [w, col, al] of [[26, 0x7ab8ff, 0.25], [9, 0xcfe6ff, 0.9], [3, 0xffffff, 1]]) {
|
||||||
|
this.lineG.lineStyle(w, col, al);
|
||||||
|
this.lineG.strokePoints(upto, false);
|
||||||
|
}
|
||||||
|
const tip = upto[upto.length - 1];
|
||||||
|
glint.setPosition(tip.x, tip.y).setAngle(carrier.t * 360);
|
||||||
|
},
|
||||||
|
onComplete: () => {
|
||||||
|
glint.setPosition(b.x, b.y);
|
||||||
|
scene.tweens.add({ targets: glint, scale: 1.6, alpha: 0, duration: 300, onComplete: () => glint.destroy() });
|
||||||
|
resolve();
|
||||||
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -132,8 +339,10 @@ export class SlotsFx {
|
||||||
|
|
||||||
// ── Scatter-pays wins (Sugar Spin) ───────────────────────────────────────────
|
// ── Scatter-pays wins (Sugar Spin) ───────────────────────────────────────────
|
||||||
async playScatterPay(step) {
|
async playScatterPay(step) {
|
||||||
|
if (this.fancy) this.view.dimExcept(step.wins.flatMap((w) => w.cells));
|
||||||
for (const win of step.wins) {
|
for (const win of step.wins) {
|
||||||
this.pulseCells(win.cells);
|
this.pulseCells(win.cells);
|
||||||
|
if (this.fancy) this.glowCells(win.cells, this.symColor(win.symbol));
|
||||||
oneShot('gem-01.mp3', 0.5);
|
oneShot('gem-01.mp3', 0.5);
|
||||||
const mid = win.cells[Math.floor(win.cells.length / 2)];
|
const mid = win.cells[Math.floor(win.cells.length / 2)];
|
||||||
const p = this.view.cellCenter(mid.c, mid.r);
|
const p = this.view.cellCenter(mid.c, mid.r);
|
||||||
|
|
@ -158,20 +367,41 @@ export class SlotsFx {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Tumbles ──────────────────────────────────────────────────────────────────
|
// ── Tumbles ──────────────────────────────────────────────────────────────────
|
||||||
|
// Winning symbols burst into a cloud of rising bubbles (underwater tumble).
|
||||||
|
bubbleBurst(x, y, count = 12) {
|
||||||
|
const em = this.scene.add.particles(x, y, 'slots-bubble', {
|
||||||
|
speed: { min: 40, max: 200 }, angle: { min: 0, max: 360 }, gravityY: -260,
|
||||||
|
lifespan: { min: 600, max: 1100 }, scale: { start: 0.35, end: 0.12 },
|
||||||
|
alpha: { start: 0.95, end: 0 }, emitting: false,
|
||||||
|
}).setDepth(this.depth + 2);
|
||||||
|
em.explode(count);
|
||||||
|
this.scene.time.delayedCall(1200, () => em.destroy());
|
||||||
|
}
|
||||||
|
|
||||||
async playTumble(step) {
|
async playTumble(step) {
|
||||||
const { view, scene } = this;
|
const { view, scene } = this;
|
||||||
|
// Underwater style: pops become bubbles, things sink instead of bouncing.
|
||||||
|
const water = this.machine.attract?.tumbleStyle === 'bubbles';
|
||||||
// Pop the removed symbols.
|
// Pop the removed symbols.
|
||||||
for (const { c, r } of step.removed) {
|
for (const { c, r } of step.removed) {
|
||||||
const img = view.image(c, r);
|
const img = view.image(c, r);
|
||||||
const p = view.cellCenter(c, r);
|
const p = view.cellCenter(c, r);
|
||||||
this.burst(p.x, p.y, 5, 0xfff1bd);
|
if (water) this.bubbleBurst(p.x, p.y, 12);
|
||||||
|
else if (this.fancy) this.confetti(p.x, p.y, this.symColor(this.keyToSym[img.texture.key]), 9);
|
||||||
|
else this.burst(p.x, p.y, 5, 0xfff1bd);
|
||||||
scene.tweens.add({
|
scene.tweens.add({
|
||||||
targets: img,
|
targets: img,
|
||||||
scaleX: img.scaleX * 1.3, scaleY: img.scaleY * 1.3, alpha: 0,
|
scaleX: img.scaleX * 1.3, scaleY: img.scaleY * 1.3, alpha: 0,
|
||||||
duration: 190, ease: 'Quad.in',
|
duration: 190, ease: 'Quad.in',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
oneShot(step.cascadeIndex % 2 === 0 ? 'gem-01.mp3' : 'gem-02.mp3', 0.55);
|
if (this.fancy) {
|
||||||
|
// Each cascade in the chain pops a little higher.
|
||||||
|
const rate = Math.min(2, 1 + 0.12 * step.cascadeIndex);
|
||||||
|
this.sfx('pop', () => oneShot(step.cascadeIndex % 2 === 0 ? 'gem-01.mp3' : 'gem-02.mp3', 0.55, rate), { rate });
|
||||||
|
} else {
|
||||||
|
oneShot(step.cascadeIndex % 2 === 0 ? 'gem-01.mp3' : 'gem-02.mp3', 0.55);
|
||||||
|
}
|
||||||
await wait(scene, 210);
|
await wait(scene, 210);
|
||||||
|
|
||||||
// Survivors fall into place.
|
// Survivors fall into place.
|
||||||
|
|
@ -179,7 +409,8 @@ export class SlotsFx {
|
||||||
const img = view.image(c, fromR);
|
const img = view.image(c, fromR);
|
||||||
scene.tweens.add({
|
scene.tweens.add({
|
||||||
targets: img, y: view.cellCenter(c, toR).y,
|
targets: img, y: view.cellCenter(c, toR).y,
|
||||||
duration: 240 + (toR - fromR) * 40, ease: 'Bounce.easeOut',
|
duration: water ? 420 + (toR - fromR) * 70 : 240 + (toR - fromR) * 40,
|
||||||
|
ease: water ? 'Sine.inOut' : 'Bounce.easeOut',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -194,31 +425,108 @@ export class SlotsFx {
|
||||||
temps.push(img);
|
temps.push(img);
|
||||||
scene.tweens.add({
|
scene.tweens.add({
|
||||||
targets: img, y: target.y,
|
targets: img, y: target.y,
|
||||||
duration: 300 + r * 40, ease: 'Bounce.easeOut',
|
duration: water ? 560 + r * 60 : 300 + r * 40, ease: water ? 'Sine.out' : 'Bounce.easeOut',
|
||||||
});
|
});
|
||||||
|
// Sinking things sway a little on the way down.
|
||||||
|
if (water) scene.tweens.add({ targets: img, angle: { from: -9, to: 9 }, duration: 260, yoyo: true, repeat: 1 });
|
||||||
}
|
}
|
||||||
await wait(scene, 480);
|
await wait(scene, water ? 700 : 480);
|
||||||
for (const t of temps) t.destroy();
|
for (const t of temps) t.destroy();
|
||||||
view.showGrid(step.grid);
|
view.showGrid(step.grid);
|
||||||
|
if (this.fancy && !water) {
|
||||||
|
view.squash([
|
||||||
|
...step.refills.map(({ c, r }) => ({ c, r })),
|
||||||
|
...step.falls.map(({ c, toR }) => ({ c, r: toR })),
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Rainbow multiplier (Sugar Spin finale) ───────────────────────────────────
|
// ── Rainbow multiplier (Sugar Spin finale) ───────────────────────────────────
|
||||||
async playRainbow(step) {
|
async playRainbow(step) {
|
||||||
playSound(this.scene, SFX.SCIFI_RISER);
|
this.sfx('rainbow', () => playSound(this.scene, SFX.SCIFI_RISER));
|
||||||
|
if (this.fancy) this.view.dimExcept(step.cells);
|
||||||
for (const { c, r, value } of step.cells) {
|
for (const { c, r, value } of step.cells) {
|
||||||
const p = this.view.cellCenter(c, r);
|
const p = this.view.cellCenter(c, r);
|
||||||
this.pulseCells([{ c, r }]);
|
this.pulseCells([{ c, r }]);
|
||||||
|
if (this.fancy) this.glowCells([{ c, r }], 0xffa3e0);
|
||||||
this.floatText(p.x, p.y - 20, `×${value}`, '#ffa3e0', 44);
|
this.floatText(p.x, p.y - 20, `×${value}`, '#ffa3e0', 44);
|
||||||
await wait(this.scene, 250);
|
await wait(this.scene, 250);
|
||||||
}
|
}
|
||||||
const x = this.view.x + this.view.width() / 2;
|
const x = this.view.x + this.view.width() / 2;
|
||||||
this.floatText(x, this.view.y + this.view.height() / 2, `TOTAL ×${step.factor}!`, '#ffa3e0', 60);
|
this.floatText(x, this.view.y + this.view.height() / 2, `TOTAL ×${step.factor}!`, '#ffa3e0', 60);
|
||||||
oneShot('firework.mp3', 0.7);
|
oneShot('firework.mp3', 0.7);
|
||||||
|
if (this.fancy) {
|
||||||
|
this.rainbowSweep();
|
||||||
|
await this.rainbowBeams(step.cells);
|
||||||
|
this.view.undim();
|
||||||
|
}
|
||||||
await wait(this.scene, 700);
|
await wait(this.scene, 700);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A full-screen rainbow light band sweeping left → right.
|
||||||
|
rainbowSweep() {
|
||||||
|
const img = this.scene.add.image(-500, GAME_HEIGHT / 2, 'slots-rainbow-band')
|
||||||
|
.setDisplaySize(760, GAME_HEIGHT * 1.5).setAngle(14).setBlendMode('ADD').setAlpha(0.45)
|
||||||
|
.setDepth(this.depth + 4);
|
||||||
|
this.scene.tweens.add({
|
||||||
|
targets: img, x: GAME_WIDTH + 500, duration: 950, ease: 'Sine.inOut',
|
||||||
|
onComplete: () => img.destroy(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rainbow arcs from each multiplier cell into the WIN meter.
|
||||||
|
rainbowBeams(cells) {
|
||||||
|
const tgt = this.winTarget;
|
||||||
|
if (!tgt || cells.length === 0) return Promise.resolve();
|
||||||
|
const { scene } = this;
|
||||||
|
const g = scene.add.graphics().setDepth(this.depth + 5).setBlendMode('ADD');
|
||||||
|
const paths = cells.map(({ c, r }) => {
|
||||||
|
const a = this.view.cellCenter(c, r);
|
||||||
|
return {
|
||||||
|
a,
|
||||||
|
k: { x: (a.x + tgt.x) / 2 + (a.x < tgt.x ? -140 : 140), y: Math.min(a.y, tgt.y) - 260 },
|
||||||
|
};
|
||||||
|
});
|
||||||
|
const at = ({ a, k }, s) => ({
|
||||||
|
x: (1 - s) * (1 - s) * a.x + 2 * (1 - s) * s * k.x + s * s * tgt.x,
|
||||||
|
y: (1 - s) * (1 - s) * a.y + 2 * (1 - s) * s * k.y + s * s * tgt.y,
|
||||||
|
});
|
||||||
|
const heads = paths.map(() => scene.add.image(0, 0, 'slots-led').setBlendMode('ADD')
|
||||||
|
.setDisplaySize(70, 70).setDepth(this.depth + 6));
|
||||||
|
const N = 40;
|
||||||
|
const carrier = { t: 0 };
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
scene.tweens.add({
|
||||||
|
targets: carrier, t: 1, duration: 560, ease: 'Sine.in',
|
||||||
|
onUpdate: () => {
|
||||||
|
g.clear();
|
||||||
|
paths.forEach((path, pi) => {
|
||||||
|
const upto = Math.floor(N * carrier.t);
|
||||||
|
for (let i = 0; i < upto; i++) {
|
||||||
|
const p0 = at(path, i / N);
|
||||||
|
const p1 = at(path, (i + 1) / N);
|
||||||
|
g.lineStyle(12, hsv(i / N, 0.65, 1), 0.9);
|
||||||
|
g.lineBetween(p0.x, p0.y, p1.x, p1.y);
|
||||||
|
}
|
||||||
|
const h = at(path, carrier.t);
|
||||||
|
heads[pi].setPosition(h.x, h.y);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onComplete: () => {
|
||||||
|
playSound(scene, SFX.COINS);
|
||||||
|
scene.tweens.add({
|
||||||
|
targets: [g, ...heads], alpha: 0, duration: 320,
|
||||||
|
onComplete: () => { g.destroy(); heads.forEach((hd) => hd.destroy()); },
|
||||||
|
});
|
||||||
|
resolve();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// ── Expanding wild (Pharaoh free spins) ──────────────────────────────────────
|
// ── Expanding wild (Pharaoh free spins) ──────────────────────────────────────
|
||||||
async playExpandWild(step) {
|
async playExpandWild(step) {
|
||||||
|
if (this.expandOverride) return this.expandOverride(step);
|
||||||
playSound(this.scene, SFX.SCIFI_RISER);
|
playSound(this.scene, SFX.SCIFI_RISER);
|
||||||
const wildKey = textureKeyFor(this.scene, this.machine.id, this.machine.wild.symbol);
|
const wildKey = textureKeyFor(this.scene, this.machine.id, this.machine.wild.symbol);
|
||||||
for (const { c, r } of step.cells) {
|
for (const { c, r } of step.cells) {
|
||||||
|
|
@ -260,7 +568,8 @@ export class SlotsFx {
|
||||||
async bigWin(amount, bet) {
|
async bigWin(amount, bet) {
|
||||||
const ratio = amount / Math.max(1, bet);
|
const ratio = amount / Math.max(1, bet);
|
||||||
if (ratio < 10) return;
|
if (ratio < 10) return;
|
||||||
const label = ratio >= 50 ? 'EPIC WIN' : ratio >= 25 ? 'MEGA WIN' : 'BIG WIN';
|
const labels = this.machine.attract?.bigWinLabels ?? ['BIG WIN', 'MEGA WIN', 'EPIC WIN'];
|
||||||
|
const label = ratio >= 50 ? labels[2] : ratio >= 25 ? labels[1] : labels[0];
|
||||||
const scene = this.scene;
|
const scene = this.scene;
|
||||||
const cx = GAME_WIDTH / 2; const cy = GAME_HEIGHT / 2;
|
const cx = GAME_WIDTH / 2; const cy = GAME_HEIGHT / 2;
|
||||||
|
|
||||||
|
|
@ -282,6 +591,7 @@ export class SlotsFx {
|
||||||
scene.tweens.add({ targets: title, scale: 1, duration: 380, ease: 'Back.out' });
|
scene.tweens.add({ targets: title, scale: 1, duration: 380, ease: 'Back.out' });
|
||||||
this.coinShower(cx - 320, cy + 180, 26);
|
this.coinShower(cx - 320, cy + 180, 26);
|
||||||
this.coinShower(cx + 320, cy + 180, 26);
|
this.coinShower(cx + 320, cy + 180, 26);
|
||||||
|
if (this.machine.attract?.coinTexture) this.nuggetRain(ratio >= 25 ? 2600 : 1600);
|
||||||
await this.rollCounter(amountText, 0, amount, ratio >= 50 ? 1700 : 1100);
|
await this.rollCounter(amountText, 0, amount, ratio >= 50 ? 1700 : 1100);
|
||||||
if (ratio >= 25) this.coinShower(cx, cy + 220, 34);
|
if (ratio >= 25) this.coinShower(cx, cy + 220, 34);
|
||||||
await wait(scene, 900);
|
await wait(scene, 900);
|
||||||
|
|
@ -291,5 +601,16 @@ export class SlotsFx {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Treasure falling from the top of the screen (attract machines with a coin texture).
|
||||||
|
nuggetRain(ms) {
|
||||||
|
const em = this.scene.add.particles(0, -30, this.machine.attract.coinTexture, {
|
||||||
|
x: { min: 0, max: GAME_WIDTH }, speedY: { min: 300, max: 620 }, speedX: { min: -40, max: 40 },
|
||||||
|
gravityY: 500, lifespan: 2600, rotate: { min: 0, max: 360 }, scale: { min: 0.9, max: 1.6 },
|
||||||
|
frequency: 22, quantity: 2,
|
||||||
|
}).setDepth(this.depth + 11);
|
||||||
|
this.scene.time.delayedCall(ms, () => em.stop());
|
||||||
|
this.scene.time.delayedCall(ms + 2800, () => em.destroy());
|
||||||
|
}
|
||||||
|
|
||||||
destroy() { this.lineG.destroy(); }
|
destroy() { this.lineG.destroy(); }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,20 @@ import { SlotsFx } from './SlotsFx.js';
|
||||||
import {
|
import {
|
||||||
buildLever, HoldNudgeUI, FreeSpinBanner, runHoldSpin, runPickBonus, JackpotStrip,
|
buildLever, HoldNudgeUI, FreeSpinBanner, runHoldSpin, runPickBonus, JackpotStrip,
|
||||||
} from './SlotsFeatures.js';
|
} from './SlotsFeatures.js';
|
||||||
|
import { MachineStage, loadLoopVideo } from './SlotsAttract.js';
|
||||||
|
import { GoldRushProps } from './SlotsGoldRush.js';
|
||||||
|
import { DragonHoardProps } from './SlotsDragon.js';
|
||||||
|
import { AbyssalProps } from './SlotsAbyssal.js';
|
||||||
|
import { PharaohProps } from './SlotsPharaoh.js';
|
||||||
|
import { LuckySevensProps } from './SlotsLucky.js';
|
||||||
|
import { FruitFrenzyProps } from './SlotsFruit.js';
|
||||||
|
import { LibertyBelleProps } from './SlotsLiberty.js';
|
||||||
|
|
||||||
|
// Machine-specific attract props, named by a machine's `attract.props`.
|
||||||
|
const ATTRACT_PROPS = {
|
||||||
|
goldRush: GoldRushProps, dragonHoard: DragonHoardProps, abyssal: AbyssalProps, pharaoh: PharaohProps,
|
||||||
|
lucky: LuckySevensProps, fruit: FruitFrenzyProps, liberty: LibertyBelleProps,
|
||||||
|
};
|
||||||
|
|
||||||
const D = { bg: 0, cab: 5, reel: 10, ui: 40 };
|
const D = { bg: 0, cab: 5, reel: 10, ui: 40 };
|
||||||
const JACKPOT_LS = 'slots-jackpot-grand';
|
const JACKPOT_LS = 'slots-jackpot-grand';
|
||||||
|
|
@ -56,20 +70,39 @@ export default class SlotsGame extends Phaser.Scene {
|
||||||
this.busy = false;
|
this.busy = false;
|
||||||
this.betIdx = 1;
|
this.betIdx = 1;
|
||||||
this.freeSpinWin = 0;
|
this.freeSpinWin = 0;
|
||||||
|
// scene.restart reuses this instance — drop per-view objects from the last run.
|
||||||
|
this.musicPlayer = null;
|
||||||
|
this.stage = null;
|
||||||
|
this.paytableBox = null;
|
||||||
|
this.paytableVeil = null;
|
||||||
|
this.paytableOpen = false;
|
||||||
|
this.payBtn = null;
|
||||||
|
this.lever = null;
|
||||||
|
this.jackpotStrip = null;
|
||||||
|
this.holdNudge = null;
|
||||||
|
this.freeSpinBanner = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
async create() {
|
async create() {
|
||||||
bakeParticleTextures(this);
|
bakeParticleTextures(this);
|
||||||
try {
|
// An attract machine with its own ambient bed replaces the music; its
|
||||||
const music = this.cache.json.get('music');
|
// MachineStage calls startMusic() itself if that bed fails to load.
|
||||||
if (music?.tracks) new MusicPlayer(this, music.tracks);
|
const m = this.view === 'machine' ? MACHINE_BY_ID[this.machineId] : null;
|
||||||
} catch (_) { /* optional */ }
|
if (!m?.attract?.sounds?.ambient) this.startMusic();
|
||||||
|
|
||||||
if (this.credits === null) await this.loadPlayerChips();
|
if (this.credits === null) await this.loadPlayerChips();
|
||||||
if (this.view === 'machine' && MACHINE_BY_ID[this.machineId]) this.buildMachine();
|
if (this.view === 'machine' && MACHINE_BY_ID[this.machineId]) this.buildMachine();
|
||||||
else this.buildLobby();
|
else this.buildLobby();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
startMusic() {
|
||||||
|
if (this.musicPlayer) return;
|
||||||
|
try {
|
||||||
|
const music = this.cache.json.get('music');
|
||||||
|
if (music?.tracks) this.musicPlayer = new MusicPlayer(this, music.tracks);
|
||||||
|
} catch (_) { /* optional */ }
|
||||||
|
}
|
||||||
|
|
||||||
// ── Bankroll (Video Poker pattern: shared casino chips) ─────────────────────
|
// ── Bankroll (Video Poker pattern: shared casino chips) ─────────────────────
|
||||||
async loadPlayerChips() {
|
async loadPlayerChips() {
|
||||||
try {
|
try {
|
||||||
|
|
@ -153,15 +186,8 @@ export default class SlotsGame extends Phaser.Scene {
|
||||||
// gradient from buildBackground stays underneath as the fallback if the
|
// gradient from buildBackground stays underneath as the fallback if the
|
||||||
// fetch or playback fails. (Same pattern as SpellingBee's bg video.)
|
// fetch or playback fails. (Same pattern as SpellingBee's bg video.)
|
||||||
buildLobbyVideo() {
|
buildLobbyVideo() {
|
||||||
const KEY = 'slots-floor-video';
|
const v = loadLoopVideo(this, 'slots-floor-video', 'assets/videos/slots/slots-floor.mp4', { noAudio: true })
|
||||||
const PATH = 'assets/videos/slots/slots-floor.mp4';
|
.setPosition(GAME_WIDTH / 2, GAME_HEIGHT / 2).setDepth(D.bg + 1);
|
||||||
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.
|
// Cover, not contain: fill edge-to-edge once the real dimensions are known.
|
||||||
const fit = () => {
|
const fit = () => {
|
||||||
|
|
@ -173,9 +199,6 @@ export default class SlotsGame extends Phaser.Scene {
|
||||||
v.on('created', fit);
|
v.on('created', fit);
|
||||||
v.on('playing', 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.setAlpha(0);
|
||||||
v.play(true);
|
v.play(true);
|
||||||
this.tweens.add({ targets: v, alpha: 1, duration: 700, ease: 'Sine.easeOut' });
|
this.tweens.add({ targets: v, alpha: 1, duration: 700, ease: 'Sine.easeOut' });
|
||||||
|
|
@ -191,14 +214,9 @@ export default class SlotsGame extends Phaser.Scene {
|
||||||
// video is destroyed and the fallback art beneath shows through.
|
// video is destroyed and the fallback art beneath shows through.
|
||||||
addCardAttractVideo(card, file, w, h) {
|
addCardAttractVideo(card, file, w, h) {
|
||||||
const key = `slots-attract-${file.replace(/\.mp4$/, '')}`;
|
const key = `slots-attract-${file.replace(/\.mp4$/, '')}`;
|
||||||
if (!this.cache.video?.exists(key)) {
|
// Audio kept — hover unmutes.
|
||||||
this.load.video(key, `assets/videos/slots/${file}`); // audio kept — hover unmutes
|
const v = loadLoopVideo(this, key, `assets/videos/slots/${file}`).setPosition(0, -6).setOrigin(0.5);
|
||||||
if (!this.load.isLoading()) this.load.start();
|
|
||||||
}
|
|
||||||
const v = this.add.video(0, -6, key).setOrigin(0.5);
|
|
||||||
card.add(v);
|
card.add(v);
|
||||||
v.setLoop(true);
|
|
||||||
v.setMute(true);
|
|
||||||
|
|
||||||
// Cover the marquee area (w-16 × h-90) once real dimensions are known;
|
// 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.
|
// the texture is absent until the fetch lands, so scale on created/playing.
|
||||||
|
|
@ -208,7 +226,6 @@ export default class SlotsGame extends Phaser.Scene {
|
||||||
};
|
};
|
||||||
v.on('created', fit);
|
v.on('created', fit);
|
||||||
v.on('playing', fit);
|
v.on('playing', fit);
|
||||||
v.once('error', () => { if (v.scene) v.destroy(); });
|
|
||||||
v.play(true);
|
v.play(true);
|
||||||
|
|
||||||
card.on('pointerover', () => { if (v.scene) v.setMute(false); });
|
card.on('pointerover', () => { if (v.scene) v.setMute(false); });
|
||||||
|
|
@ -354,6 +371,7 @@ export default class SlotsGame extends Phaser.Scene {
|
||||||
this.session = createSession(m, Math.random);
|
this.session = createSession(m, Math.random);
|
||||||
this.bet = m.betLevels[this.betIdx] ?? m.betLevels[0];
|
this.bet = m.betLevels[this.betIdx] ?? m.betLevels[0];
|
||||||
this.jackpot = this.loadJackpot();
|
this.jackpot = this.loadJackpot();
|
||||||
|
if (m.attract) { this.buildAttractMachine(m); return; }
|
||||||
this.buildBackground(m.theme.glow);
|
this.buildBackground(m.theme.glow);
|
||||||
|
|
||||||
// Geometry.
|
// Geometry.
|
||||||
|
|
@ -430,22 +448,173 @@ export default class SlotsGame extends Phaser.Scene {
|
||||||
this.setStatus(m.features.lever ? 'PULL THE LEVER TO SPIN' : 'PLACE YOUR BET • PRESS SPIN');
|
this.setStatus(m.features.lever ? 'PULL THE LEVER TO SPIN' : 'PLACE YOUR BET • PRESS SPIN');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── Attract-kit machine: centred cabinet, LED lighting, bottom control bar,
|
||||||
|
// paytable behind a button. See SlotsAttract.js.
|
||||||
|
buildAttractMachine(m) {
|
||||||
|
const A = m.attract;
|
||||||
|
const { cellW, cellH, gap } = A.layout;
|
||||||
|
const winW = m.layout.reels * cellW + (m.layout.reels - 1) * gap;
|
||||||
|
const winH = m.layout.rows * cellH;
|
||||||
|
const wx = Math.round(GAME_WIDTH / 2 - winW / 2);
|
||||||
|
const wy = A.layout.windowY ?? 248;
|
||||||
|
// Tall uprights (vintage): a lower cabinet top, strip peeking above/below
|
||||||
|
// the paylines, and extra cabinet below the reels (belly glass, tray…).
|
||||||
|
const peekPx = Math.round((A.layout.peek ?? 0) * cellH);
|
||||||
|
const cabTop = A.layout.cabTop ?? 24;
|
||||||
|
const cab = {
|
||||||
|
x: wx - 60, y: cabTop, w: winW + 120,
|
||||||
|
h: wy + winH + peekPx + 44 + (A.layout.belly ?? 0) - cabTop,
|
||||||
|
};
|
||||||
|
let mh = A.layout.marqueeH ?? 132;
|
||||||
|
let mw = Math.round(mh * (800 / 120));
|
||||||
|
if (mw > cab.w - 90) { mw = cab.w - 90; mh = Math.round(mw * (120 / 800)); }
|
||||||
|
const marquee = { x: Math.round(GAME_WIDTH / 2 - mw / 2), y: cab.y + 26, w: mw, h: mh };
|
||||||
|
// `win` is the visible reel window (including any peek).
|
||||||
|
const win = { x: wx, y: wy - peekPx, w: winW, h: winH + peekPx * 2 };
|
||||||
|
|
||||||
|
this.buildBackground(m.theme.glow);
|
||||||
|
this.stage = new MachineStage(this, m, {
|
||||||
|
cab, win, marquee, cellW, cellH, gap, nReels: m.layout.reels, rows: m.layout.rows,
|
||||||
|
}, D, ATTRACT_PROPS[A.props] ?? null);
|
||||||
|
|
||||||
|
this.reelView = new ReelView(this, m, {
|
||||||
|
x: wx, y: wy, cellW, cellH, gap, depth: D.reel, glass: A.glass, peek: peekPx,
|
||||||
|
});
|
||||||
|
this.reelView.showGrid(this.session.grid ?? this.idleGrid(m));
|
||||||
|
this.reelView.onReelStop = (c) => this.stage.reelStop(c);
|
||||||
|
this.reelView.onAnticipationStart = (c) => this.stage.anticipate(c);
|
||||||
|
if (A.sounds?.stop) {
|
||||||
|
this.reelView.stopSound = () => this.stage.sound('stop', () => playSound(this, SFX.PIECE_CLICK));
|
||||||
|
}
|
||||||
|
this.stage.attachReels(this.reelView);
|
||||||
|
|
||||||
|
this.fx = new SlotsFx(this, this.reelView, m, D.reel + 20);
|
||||||
|
this.fx.sfx = (name, fallback, cfg) => this.stage.sound(name, fallback, cfg);
|
||||||
|
if (this.stage.props?.playExpandWild) this.fx.expandOverride = (step) => this.stage.props.playExpandWild(step);
|
||||||
|
this.holdNudge = m.features.holdNudge
|
||||||
|
? (this.stage.props?.makeHoldNudgeUI?.() ?? new HoldNudgeUI(this, this.reelView, D.ui - 2))
|
||||||
|
: null;
|
||||||
|
if (m.features.holdSpin) {
|
||||||
|
this.jackpotStrip = this.stage.props?.makeJackpotStrip?.()
|
||||||
|
?? new JackpotStrip(this, m, GAME_WIDTH / 2, wy - 40, D.cab + 3);
|
||||||
|
this.jackpotStrip.refresh(this.bet, this.jackpot);
|
||||||
|
}
|
||||||
|
if (m.features.lever && !this.stage.props?.ownsLever) {
|
||||||
|
this.lever = buildLever(this, cab.x + cab.w + 46, wy - 20, winH + 60, m.theme, () => this.onSpin());
|
||||||
|
}
|
||||||
|
|
||||||
|
this.buildPaytableOverlay(m);
|
||||||
|
this.buildAttractControls(m, cab.y + cab.h);
|
||||||
|
this.fx.winTarget = { x: this.winText.x, y: this.winText.y };
|
||||||
|
this.stage.spinButton = this.spinBtn;
|
||||||
|
this.stage.canAttract = () => !this.busy && !this.freeSpinBanner && !this.paytableOpen;
|
||||||
|
this.input.on('pointerdown', () => this.stage?.poke());
|
||||||
|
this.input.keyboard?.on('keydown', () => this.stage?.poke());
|
||||||
|
this.refreshMeters();
|
||||||
|
this.stage.hook('onBet', this.betIdx, this.bet);
|
||||||
|
this.setStatus(m.features.lever ? 'PULL THE LEVER • OR PRESS SPIN' : 'PLACE YOUR BET • PRESS SPIN');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bottom control bar: Machines / Paytable | CHIPS | BET − n + | WIN | MAX BET | SPIN.
|
||||||
|
buildAttractControls(m, cabBottom) {
|
||||||
|
const bar = m.attract.bar ?? {};
|
||||||
|
const barY = 1000; const barH = 132;
|
||||||
|
const g = this.add.graphics().setDepth(D.ui - 1);
|
||||||
|
g.fillStyle(0x000000, 0.3);
|
||||||
|
g.fillRoundedRect(46, barY - barH / 2 + 8, GAME_WIDTH - 80, barH, 26);
|
||||||
|
g.fillStyle(bar.fill ?? 0x1a1020, 0.9);
|
||||||
|
g.fillRoundedRect(40, barY - barH / 2, GAME_WIDTH - 80, barH, 26);
|
||||||
|
g.lineStyle(4, bar.trim ?? m.theme.trim, 1);
|
||||||
|
g.strokeRoundedRect(40, barY - barH / 2, GAME_WIDTH - 80, barH, 26);
|
||||||
|
|
||||||
|
const mkMeter = (x, label, color) => {
|
||||||
|
this.add.text(x, barY - 30, label, {
|
||||||
|
fontFamily: '"Julius Sans One"', fontSize: '18px', color: bar.labelHex ?? '#f2e6f0',
|
||||||
|
}).setOrigin(0.5).setDepth(D.ui);
|
||||||
|
return this.add.text(x, barY + 14, '0', {
|
||||||
|
fontFamily: 'Righteous', fontSize: '40px', color,
|
||||||
|
}).setOrigin(0.5).setDepth(D.ui).setShadow(0, 0, color, 12);
|
||||||
|
};
|
||||||
|
this.creditText = mkMeter(570, 'CHIPS', '#8cf28a');
|
||||||
|
this.betText = mkMeter(840, 'BET', m.theme.accentHex);
|
||||||
|
this.winText = mkMeter(1140, 'WIN', '#ffd86b');
|
||||||
|
|
||||||
|
this.statusText = this.add.text(GAME_WIDTH / 2, Math.round((cabBottom + barY - barH / 2) / 2), '', {
|
||||||
|
fontFamily: '"Julius Sans One"', fontSize: '24px', color: bar.statusHex ?? '#ffffff',
|
||||||
|
}).setOrigin(0.5).setDepth(D.ui).setShadow(0, 2, 'rgba(0,0,0,0.75)', 6);
|
||||||
|
|
||||||
|
const btn = { bg: bar.button ?? COLORS.gold, bgHover: bar.buttonHover ?? COLORS.gold };
|
||||||
|
this.lobbyBtn = new Button(this, 150, barY, 'Machines', () => this.backToLobby(),
|
||||||
|
{ width: 180, height: 60, variant: 'ghost', fontSize: 22 });
|
||||||
|
this.payBtn = new Button(this, 350, barY, 'Paytable', () => this.togglePaytable(),
|
||||||
|
{ width: 180, height: 60, variant: 'ghost', fontSize: 22 });
|
||||||
|
this.betDownBtn = new Button(this, 740, barY + 4, '−', () => this.adjustBet(-1), { width: 64, height: 56, fontSize: 32 });
|
||||||
|
this.betUpBtn = new Button(this, 940, barY + 4, '+', () => this.adjustBet(1), { width: 64, height: 56, fontSize: 32 });
|
||||||
|
this.maxBetBtn = new Button(this, 1400, barY, 'MAX BET', () => {
|
||||||
|
this.betIdx = this.machine.betLevels.length - 1;
|
||||||
|
this.bet = this.machine.betLevels[this.betIdx];
|
||||||
|
playSound(this, SFX.CHIP_BET);
|
||||||
|
this.refreshMeters(); this.refreshPaytable();
|
||||||
|
this.jackpotStrip?.refresh(this.bet, this.jackpot);
|
||||||
|
this.stage?.hook('onBet', this.betIdx, this.bet);
|
||||||
|
this.onSpin();
|
||||||
|
}, { width: 190, height: 60, fontSize: 24 });
|
||||||
|
this.spinBtn = new Button(this, 1690, barY, 'SPIN', () => this.onSpin(), {
|
||||||
|
width: 290, height: 92, fontSize: 40, variant: 'solid',
|
||||||
|
bg: btn.bg, bgHover: btn.bgHover, textColor: bar.spinTextHex ?? '#14100a', textHoverColor: '#14100a',
|
||||||
|
});
|
||||||
|
[this.lobbyBtn, this.payBtn, this.betDownBtn, this.betUpBtn, this.maxBetBtn, this.spinBtn]
|
||||||
|
.forEach((b) => b.setDepth(D.ui));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Paytable as a modal overlay (attract machines): same content as the side
|
||||||
|
// panel, built into a hidden container. Click anywhere or Esc closes it.
|
||||||
|
buildPaytableOverlay(m) {
|
||||||
|
const pw = 620; const ph = 760;
|
||||||
|
const px = Math.round((GAME_WIDTH - pw) / 2); const py = Math.round((GAME_HEIGHT - ph) / 2) - 20;
|
||||||
|
const box = this.add.container(0, 0).setDepth(D.ui + 30).setVisible(false);
|
||||||
|
const veil = this.add.rectangle(GAME_WIDTH / 2, GAME_HEIGHT / 2, GAME_WIDTH, GAME_HEIGHT, 0x000000, 0.6);
|
||||||
|
veil.on('pointerup', () => this.togglePaytable(false));
|
||||||
|
box.add(veil);
|
||||||
|
this.buildPaytablePanel(m, { px, py, pw, ph }, box);
|
||||||
|
box.add(this.add.text(px + pw / 2, py + ph - 26, 'CLICK ANYWHERE TO CLOSE', {
|
||||||
|
fontFamily: '"Julius Sans One"', fontSize: '16px', color: COLORS.mutedHex,
|
||||||
|
}).setOrigin(0.5));
|
||||||
|
this.paytableBox = box;
|
||||||
|
this.paytableVeil = veil;
|
||||||
|
this.paytableOpen = false;
|
||||||
|
this.input.keyboard?.on('keydown-ESC', () => this.togglePaytable(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
togglePaytable(open = !this.paytableOpen) {
|
||||||
|
if (!this.paytableBox || open === this.paytableOpen) return;
|
||||||
|
this.paytableOpen = open;
|
||||||
|
this.paytableBox.setVisible(open);
|
||||||
|
if (open) this.paytableVeil.setInteractive();
|
||||||
|
else this.paytableVeil.disableInteractive();
|
||||||
|
playSound(this, SFX.CLICK);
|
||||||
|
}
|
||||||
|
|
||||||
idleGrid(m) {
|
idleGrid(m) {
|
||||||
// Show each reel's strip top as the idle window.
|
// Show each reel's strip top as the idle window.
|
||||||
return m.strips.map((strip) => Array.from({ length: m.layout.rows }, (_, r) => strip[r % strip.length]));
|
return m.strips.map((strip) => Array.from({ length: m.layout.rows }, (_, r) => strip[r % strip.length]));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Right-hand paytable panel ────────────────────────────────────────────────
|
// ── Right-hand paytable panel ────────────────────────────────────────────────
|
||||||
buildPaytablePanel(m) {
|
// rect: where to draw (defaults to the classic right-hand panel).
|
||||||
const px = 1336; const py = 96; const pw = GAME_WIDTH - px - 28; const ph = 700;
|
// sink: optional container to build into (the attract paytable overlay).
|
||||||
const g = this.add.graphics().setDepth(D.ui - 1);
|
buildPaytablePanel(m, rect = null, sink = null) {
|
||||||
|
const px = rect?.px ?? 1336; const py = rect?.py ?? 96;
|
||||||
|
const pw = rect?.pw ?? GAME_WIDTH - px - 28; const ph = rect?.ph ?? 700;
|
||||||
|
const put = (obj, depth = D.ui) => (sink ? sink.add(obj) : obj.setDepth(depth), obj);
|
||||||
|
const g = put(this.add.graphics(), D.ui - 1);
|
||||||
g.fillStyle(0x0a0810, 0.92);
|
g.fillStyle(0x0a0810, 0.92);
|
||||||
g.fillRoundedRect(px, py, pw, ph, 18);
|
g.fillRoundedRect(px, py, pw, ph, 18);
|
||||||
g.lineStyle(3, m.theme.trim, 0.7);
|
g.lineStyle(3, m.theme.trim, 0.7);
|
||||||
g.strokeRoundedRect(px, py, pw, ph, 18);
|
g.strokeRoundedRect(px, py, pw, ph, 18);
|
||||||
this.add.text(px + pw / 2, py + 30, 'PAYTABLE', {
|
put(this.add.text(px + pw / 2, py + 30, 'PAYTABLE', {
|
||||||
fontFamily: 'Righteous', fontSize: '28px', color: m.theme.accentHex,
|
fontFamily: 'Righteous', fontSize: '28px', color: m.theme.accentHex,
|
||||||
}).setOrigin(0.5).setDepth(D.ui).setShadow(0, 0, m.theme.accentHex, 12);
|
}).setOrigin(0.5).setShadow(0, 0, m.theme.accentHex, 12));
|
||||||
|
|
||||||
this.payCells = [];
|
this.payCells = [];
|
||||||
const isScatterPays = m.evaluation === 'scatterPays';
|
const isScatterPays = m.evaluation === 'scatterPays';
|
||||||
|
|
@ -457,21 +626,21 @@ export default class SlotsGame extends Phaser.Scene {
|
||||||
|
|
||||||
// Column headers.
|
// Column headers.
|
||||||
counts.forEach((cnt, ci) => {
|
counts.forEach((cnt, ci) => {
|
||||||
this.add.text(px + 92 + ci * colW + colW / 2, py + 66, isScatterPays ? `${cnt}+` : `×${cnt}`, {
|
put(this.add.text(px + 92 + ci * colW + colW / 2, py + 66, isScatterPays ? `${cnt}+` : `×${cnt}`, {
|
||||||
fontFamily: '"Julius Sans One"', fontSize: '18px', color: COLORS.mutedHex,
|
fontFamily: '"Julius Sans One"', fontSize: '18px', color: COLORS.mutedHex,
|
||||||
}).setOrigin(0.5).setDepth(D.ui);
|
}).setOrigin(0.5));
|
||||||
});
|
});
|
||||||
|
|
||||||
entries.forEach(([sym, table], ri) => {
|
entries.forEach(([sym, table], ri) => {
|
||||||
const ry = py + 96 + ri * rowH;
|
const ry = py + 96 + ri * rowH;
|
||||||
const isGroup = !!m.symbolGroups?.[sym];
|
const isGroup = !!m.symbolGroups?.[sym];
|
||||||
if (isGroup) {
|
if (isGroup) {
|
||||||
this.add.text(iconX, ry, sym === 'any-seven' ? 'ANY 7' : 'ANY BAR', {
|
put(this.add.text(iconX, ry, sym === 'any-seven' ? 'ANY 7' : 'ANY BAR', {
|
||||||
fontFamily: 'Righteous', fontSize: '16px', color: COLORS.textHex,
|
fontFamily: 'Righteous', fontSize: '16px', color: COLORS.textHex,
|
||||||
}).setOrigin(0.5).setDepth(D.ui);
|
}).setOrigin(0.5));
|
||||||
} else {
|
} else {
|
||||||
this.add.image(iconX, ry, textureKeyFor(this, m.id, sym))
|
put(this.add.image(iconX, ry, textureKeyFor(this, m.id, sym))
|
||||||
.setDisplaySize(rowH - 8, rowH - 8).setDepth(D.ui);
|
.setDisplaySize(rowH - 8, rowH - 8));
|
||||||
}
|
}
|
||||||
counts.forEach((cnt, ci) => {
|
counts.forEach((cnt, ci) => {
|
||||||
let calc;
|
let calc;
|
||||||
|
|
@ -483,9 +652,9 @@ export default class SlotsGame extends Phaser.Scene {
|
||||||
calc = pay !== undefined ? (bet) => Math.round(pay * bet / m.paylines.length) : null;
|
calc = pay !== undefined ? (bet) => Math.round(pay * bet / m.paylines.length) : null;
|
||||||
}
|
}
|
||||||
if (!calc) return;
|
if (!calc) return;
|
||||||
const txt = this.add.text(px + 92 + ci * colW + colW / 2, ry, '', {
|
const txt = put(this.add.text(px + 92 + ci * colW + colW / 2, ry, '', {
|
||||||
fontFamily: '"Julius Sans One"', fontSize: '19px', color: COLORS.textHex,
|
fontFamily: '"Julius Sans One"', fontSize: '19px', color: COLORS.textHex,
|
||||||
}).setOrigin(0.5).setDepth(D.ui);
|
}).setOrigin(0.5));
|
||||||
this.payCells.push({ txt, calc });
|
this.payCells.push({ txt, calc });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -493,10 +662,10 @@ export default class SlotsGame extends Phaser.Scene {
|
||||||
// Feature / scatter footnotes.
|
// Feature / scatter footnotes.
|
||||||
let fy = py + 96 + entries.length * rowH + 14;
|
let fy = py + 96 + entries.length * rowH + 14;
|
||||||
const note = (str, color = COLORS.mutedHex) => {
|
const note = (str, color = COLORS.mutedHex) => {
|
||||||
this.add.text(px + 24, fy, str, {
|
put(this.add.text(px + 24, fy, str, {
|
||||||
fontFamily: '"Julius Sans One"', fontSize: '17px', color,
|
fontFamily: '"Julius Sans One"', fontSize: '17px', color,
|
||||||
wordWrap: { width: pw - 48 },
|
wordWrap: { width: pw - 48 },
|
||||||
}).setOrigin(0, 0).setDepth(D.ui);
|
}).setOrigin(0, 0));
|
||||||
fy += 44;
|
fy += 44;
|
||||||
};
|
};
|
||||||
if (m.wild?.multipliers) note('Wild substitutes: 1 wild ×2 pay, 2 wilds ×4 pay.', m.theme.accentHex);
|
if (m.wild?.multipliers) note('Wild substitutes: 1 wild ×2 pay, 2 wilds ×4 pay.', m.theme.accentHex);
|
||||||
|
|
@ -545,6 +714,7 @@ export default class SlotsGame extends Phaser.Scene {
|
||||||
playSound(this, SFX.CHIP_BET);
|
playSound(this, SFX.CHIP_BET);
|
||||||
this.refreshMeters(); this.refreshPaytable();
|
this.refreshMeters(); this.refreshPaytable();
|
||||||
this.jackpotStrip?.refresh(this.bet, this.jackpot);
|
this.jackpotStrip?.refresh(this.bet, this.jackpot);
|
||||||
|
this.stage?.hook('onBet', this.betIdx, this.bet);
|
||||||
this.onSpin();
|
this.onSpin();
|
||||||
}, { width: 190, height: 60, fontSize: 24 });
|
}, { width: 190, height: 60, fontSize: 24 });
|
||||||
this.lobbyBtn = new Button(this, GAME_WIDTH - 150, btnY, 'Machines', () => this.backToLobby(),
|
this.lobbyBtn = new Button(this, GAME_WIDTH - 150, btnY, 'Machines', () => this.backToLobby(),
|
||||||
|
|
@ -562,6 +732,7 @@ export default class SlotsGame extends Phaser.Scene {
|
||||||
this.refreshMeters();
|
this.refreshMeters();
|
||||||
this.refreshPaytable();
|
this.refreshPaytable();
|
||||||
this.jackpotStrip?.refresh(this.bet, this.jackpot);
|
this.jackpotStrip?.refresh(this.bet, this.jackpot);
|
||||||
|
this.stage?.hook('onBet', this.betIdx, this.bet);
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshMeters(win = null) {
|
refreshMeters(win = null) {
|
||||||
|
|
@ -573,7 +744,7 @@ export default class SlotsGame extends Phaser.Scene {
|
||||||
setStatus(str) { this.statusText?.setText(str); }
|
setStatus(str) { this.statusText?.setText(str); }
|
||||||
|
|
||||||
setControlsEnabled(v) {
|
setControlsEnabled(v) {
|
||||||
[this.betDownBtn, this.betUpBtn, this.spinBtn, this.maxBetBtn, this.lobbyBtn]
|
[this.betDownBtn, this.betUpBtn, this.spinBtn, this.maxBetBtn, this.lobbyBtn, this.payBtn]
|
||||||
.forEach((b) => b?.setEnabled(v));
|
.forEach((b) => b?.setEnabled(v));
|
||||||
this.lever?.setEnabled(v);
|
this.lever?.setEnabled(v);
|
||||||
}
|
}
|
||||||
|
|
@ -591,6 +762,8 @@ export default class SlotsGame extends Phaser.Scene {
|
||||||
this.busy = true;
|
this.busy = true;
|
||||||
this.setControlsEnabled(false);
|
this.setControlsEnabled(false);
|
||||||
this.holdNudge?.hideBanner();
|
this.holdNudge?.hideBanner();
|
||||||
|
this.togglePaytable(false);
|
||||||
|
this.stage?.beginSpin();
|
||||||
|
|
||||||
if (!free) {
|
if (!free) {
|
||||||
this.credits -= this.bet;
|
this.credits -= this.bet;
|
||||||
|
|
@ -612,12 +785,34 @@ export default class SlotsGame extends Phaser.Scene {
|
||||||
// Anticipation when the engine says something big landed.
|
// Anticipation when the engine says something big landed.
|
||||||
const big = result.holdSpinTriggered || result.scatterCount >= (m.scatter ? 3 : Infinity)
|
const big = result.holdSpinTriggered || result.scatterCount >= (m.scatter ? 3 : Infinity)
|
||||||
|| result.freeSpinsAwarded > 0;
|
|| result.freeSpinsAwarded > 0;
|
||||||
playSound(this, m.era === 'vintage' ? SFX.DICE_ROLL : SFX.ROULETTE);
|
let anticipationFrom = big ? m.layout.reels - 1 : null;
|
||||||
|
// Attract tease (real-slot style): once `after` copies of the symbol have
|
||||||
|
// landed, every later reel slow-stops — whether or not the feature hits.
|
||||||
|
// Purely presentational: the grid is already decided.
|
||||||
|
const tease = m.attract?.tease;
|
||||||
|
if (tease) {
|
||||||
|
anticipationFrom = null;
|
||||||
|
let n = 0;
|
||||||
|
for (let c = 0; c < result.grid.length; c++) {
|
||||||
|
n += result.grid[c].filter((sym) => sym === tease.symbol).length;
|
||||||
|
if (n >= tease.after) {
|
||||||
|
if (c + 1 < m.layout.reels) anticipationFrom = c + 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this.stage) this.stage.pendingResult = result;
|
||||||
|
const spinSfx = () => playSound(this, m.era === 'vintage' ? SFX.DICE_ROLL : SFX.ROULETTE);
|
||||||
|
if (this.stage) this.stage.sound('spin', spinSfx);
|
||||||
|
else spinSfx();
|
||||||
await this.reelView.spin(result.stops, {
|
await this.reelView.spin(result.stops, {
|
||||||
anticipationFrom: big ? m.layout.reels - 1 : null,
|
anticipationFrom,
|
||||||
|
anticipationMs: tease?.ms,
|
||||||
stepped: !!m.features.steppedStops,
|
stepped: !!m.features.steppedStops,
|
||||||
held: heldBefore,
|
held: heldBefore,
|
||||||
|
windup: !!this.stage,
|
||||||
});
|
});
|
||||||
|
this.stage?.reelsLanded(result.totalWin > 0);
|
||||||
|
|
||||||
let spinTotal = result.totalWin;
|
let spinTotal = result.totalWin;
|
||||||
|
|
||||||
|
|
@ -625,11 +820,19 @@ export default class SlotsGame extends Phaser.Scene {
|
||||||
for (const step of result.steps) {
|
for (const step of result.steps) {
|
||||||
if (step.type === 'lineWins') await this.fx.playLineWins(step, m);
|
if (step.type === 'lineWins') await this.fx.playLineWins(step, m);
|
||||||
else if (step.type === 'scatterPay') await this.fx.playScatterPay(step);
|
else if (step.type === 'scatterPay') await this.fx.playScatterPay(step);
|
||||||
else if (step.type === 'tumble') await this.fx.playTumble(step);
|
else if (step.type === 'tumble') {
|
||||||
else if (step.type === 'rainbow') await this.fx.playRainbow(step);
|
this.stage?.tumble(step.cascadeIndex);
|
||||||
|
await this.fx.playTumble(step);
|
||||||
|
} else if (step.type === 'rainbow') {
|
||||||
|
this.stage?.bigMoment();
|
||||||
|
await this.fx.playRainbow(step);
|
||||||
|
}
|
||||||
else if (step.type === 'expandWild') await this.fx.playExpandWild(step);
|
else if (step.type === 'expandWild') await this.fx.playExpandWild(step);
|
||||||
else if (step.type === 'scatterAward') await this.fx.playScatterAward(step);
|
else if (step.type === 'scatterAward') {
|
||||||
else if (step.type === 'stickyWilds') this.playStickySteps(step);
|
this.stage?.hook('onScatterAward', step);
|
||||||
|
await this.fx.playScatterAward(step);
|
||||||
|
}
|
||||||
|
else if (step.type === 'stickyWilds' && !this.stage?.props?.onStickies) this.playStickySteps(step);
|
||||||
}
|
}
|
||||||
this.reelView.showGrid(result.grid);
|
this.reelView.showGrid(result.grid);
|
||||||
this.decorateCells(result);
|
this.decorateCells(result);
|
||||||
|
|
@ -638,11 +841,15 @@ export default class SlotsGame extends Phaser.Scene {
|
||||||
this.session.stickyWilds.map(({ c, r }) => ({ c, r })),
|
this.session.stickyWilds.map(({ c, r }) => ({ c, r })),
|
||||||
m.features.stickyWilds.symbol,
|
m.features.stickyWilds.symbol,
|
||||||
);
|
);
|
||||||
|
this.stage?.hook('onStickies', this.session.stickyWilds,
|
||||||
|
result.steps.find((st) => st.type === 'stickyWilds') ?? null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Interactive features.
|
// Interactive features.
|
||||||
if (result.holdSpinTriggered) {
|
if (result.holdSpinTriggered) {
|
||||||
const { award, cleanup } = await runHoldSpin(this, this.reelView, this.fx, this.session, this.bet, m);
|
const { award, cleanup } = this.stage?.props?.runHoldSpin
|
||||||
|
? await this.stage.props.runHoldSpin(this.session, this.bet)
|
||||||
|
: await runHoldSpin(this, this.reelView, this.fx, this.session, this.bet, m);
|
||||||
let bonusWin = award.credits;
|
let bonusWin = award.credits;
|
||||||
for (const j of award.jackpots) this.jackpotStrip.flash(j.tier);
|
for (const j of award.jackpots) this.jackpotStrip.flash(j.tier);
|
||||||
if (award.grandHit) {
|
if (award.grandHit) {
|
||||||
|
|
@ -656,8 +863,12 @@ export default class SlotsGame extends Phaser.Scene {
|
||||||
spinTotal += bonusWin;
|
spinTotal += bonusWin;
|
||||||
}
|
}
|
||||||
if (result.pickBonusTriggered) {
|
if (result.pickBonusTriggered) {
|
||||||
|
const props = this.stage?.props;
|
||||||
|
if (props?.beforePickBonus) await props.beforePickBonus(result);
|
||||||
const bonus = createPickBonus(m, this.bet, Math.random);
|
const bonus = createPickBonus(m, this.bet, Math.random);
|
||||||
spinTotal += await runPickBonus(this, this.fx, m, bonus);
|
spinTotal += props?.runPickBonus
|
||||||
|
? await props.runPickBonus(bonus)
|
||||||
|
: await runPickBonus(this, this.fx, m, bonus);
|
||||||
}
|
}
|
||||||
if (result.nudgesAwarded > 0) {
|
if (result.nudgesAwarded > 0) {
|
||||||
this.setStatus('');
|
this.setStatus('');
|
||||||
|
|
@ -676,8 +887,11 @@ export default class SlotsGame extends Phaser.Scene {
|
||||||
if (spinTotal > 0) {
|
if (spinTotal > 0) {
|
||||||
this.credits += spinTotal;
|
this.credits += spinTotal;
|
||||||
this.sessionNet += spinTotal;
|
this.sessionNet += spinTotal;
|
||||||
await this.fx.rollCounter(this.winText, 0, spinTotal, Math.min(900, 250 + spinTotal));
|
this.stage?.settle(spinTotal, this.bet);
|
||||||
|
await this.fx.rollCounter(this.winText, 0, spinTotal, Math.min(900, 250 + spinTotal),
|
||||||
|
{ accelerate: !!this.stage });
|
||||||
this.refreshMeters(spinTotal);
|
this.refreshMeters(spinTotal);
|
||||||
|
if (spinTotal / Math.max(1, this.bet) >= 10) this.stage?.bigMoment();
|
||||||
await this.fx.bigWin(spinTotal, this.bet);
|
await this.fx.bigWin(spinTotal, this.bet);
|
||||||
this.setStatus(`WIN ${spinTotal.toLocaleString()}`);
|
this.setStatus(`WIN ${spinTotal.toLocaleString()}`);
|
||||||
this.saveBest(spinTotal);
|
this.saveBest(spinTotal);
|
||||||
|
|
@ -703,18 +917,23 @@ export default class SlotsGame extends Phaser.Scene {
|
||||||
|
|
||||||
// Free spins play themselves out.
|
// Free spins play themselves out.
|
||||||
if (result.freeSpinsAwarded > 0 && !this.freeSpinBanner) {
|
if (result.freeSpinsAwarded > 0 && !this.freeSpinBanner) {
|
||||||
this.freeSpinBanner = new FreeSpinBanner(this, this.reelView, this.machine.theme, D.ui - 2);
|
// Props can stage the feature intro (e.g. tomb doors) and own the counter display.
|
||||||
|
await this.stage?.props?.onFreeSpins?.('start', result.freeSpinsAwarded);
|
||||||
|
this.freeSpinBanner = this.stage?.props?.makeFreeSpinBanner?.()
|
||||||
|
?? new FreeSpinBanner(this, this.reelView, this.machine.theme, D.ui - 2);
|
||||||
this.freeSpinWin = 0;
|
this.freeSpinWin = 0;
|
||||||
}
|
}
|
||||||
if (this.freeSpinBanner) {
|
if (this.freeSpinBanner) {
|
||||||
this.freeSpinWin += free ? spinTotal : 0;
|
this.freeSpinWin += free ? spinTotal : 0;
|
||||||
if (spinIsFree(this.session)) {
|
if (spinIsFree(this.session)) {
|
||||||
this.freeSpinBanner.update(this.session.freeSpins.remaining, this.session.freeSpins.total, this.freeSpinWin);
|
this.freeSpinBanner.update(this.session.freeSpins.remaining, this.session.freeSpins.total, this.freeSpinWin);
|
||||||
|
this.stage?.endSpin();
|
||||||
this.busy = false;
|
this.busy = false;
|
||||||
this.time.delayedCall(650, () => this.onSpin());
|
this.time.delayedCall(650, () => this.onSpin());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Free spins over.
|
// Free spins over.
|
||||||
|
await this.stage?.props?.onFreeSpins?.('end', this.freeSpinWin);
|
||||||
this.freeSpinBanner.destroy();
|
this.freeSpinBanner.destroy();
|
||||||
this.freeSpinBanner = null;
|
this.freeSpinBanner = null;
|
||||||
if (this.freeSpinWin > 0) {
|
if (this.freeSpinWin > 0) {
|
||||||
|
|
@ -724,6 +943,7 @@ export default class SlotsGame extends Phaser.Scene {
|
||||||
this.flushChips();
|
this.flushChips();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.stage?.endSpin();
|
||||||
this.busy = false;
|
this.busy = false;
|
||||||
this.setControlsEnabled(true);
|
this.setControlsEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
@ -743,6 +963,12 @@ export default class SlotsGame extends Phaser.Scene {
|
||||||
const m = this.machine;
|
const m = this.machine;
|
||||||
if (m.features.holdSpin) {
|
if (m.features.holdSpin) {
|
||||||
for (const { c, r, value, tier } of result.coinCells) {
|
for (const { c, r, value, tier } of result.coinCells) {
|
||||||
|
if (this.stage) {
|
||||||
|
this.reelView.addCellHalo(c, r, 'slots-glow', {
|
||||||
|
size: 1.15, alpha: 0.55, add: true,
|
||||||
|
tint: (tier && m.attract.tierColors?.[tier]) || 0xffd23f,
|
||||||
|
});
|
||||||
|
}
|
||||||
this.reelView.setOverlayText(c, r, tier ? tier.toUpperCase() : `${value * this.bet}`,
|
this.reelView.setOverlayText(c, r, tier ? tier.toUpperCase() : `${value * this.bet}`,
|
||||||
{ color: tier ? '#ff8c8c' : '#fff6d8', size: tier ? 20 : 24 });
|
{ color: tier ? '#ff8c8c' : '#fff6d8', size: tier ? 20 : 24 });
|
||||||
}
|
}
|
||||||
|
|
@ -750,6 +976,7 @@ export default class SlotsGame extends Phaser.Scene {
|
||||||
if (m.features.rainbow) {
|
if (m.features.rainbow) {
|
||||||
for (const [k, v] of Object.entries(this.session.rainbowValues)) {
|
for (const [k, v] of Object.entries(this.session.rainbowValues)) {
|
||||||
const [c, r] = k.split(',').map(Number);
|
const [c, r] = k.split(',').map(Number);
|
||||||
|
if (this.stage) this.reelView.addCellHalo(c, r, 'slots-rainbow-ring', { size: 1.02, spinMs: 3200 });
|
||||||
this.reelView.setOverlayText(c, r, `×${v}`, { color: '#ffa3e0', size: 26 });
|
this.reelView.setOverlayText(c, r, `×${v}`, { color: '#ffa3e0', size: 26 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,899 @@
|
||||||
|
// SlotsGoldRush — Gold Rush Gulch props for the attract kit (SlotsAttract.js).
|
||||||
|
//
|
||||||
|
// MachineStage constructs this once the cabinet is built and forwards hooks:
|
||||||
|
// onReels(view) reels exist
|
||||||
|
// onSpinStart() a spin begins (stage.pendingResult is set)
|
||||||
|
// onReelStop(c) reel c landed
|
||||||
|
// onAnticipate(c) reel c is now being teased
|
||||||
|
// onLanded(result) all reels landed
|
||||||
|
// onAttract(on) entered / left attract mode
|
||||||
|
// update(dt) every frame
|
||||||
|
// SlotsGame additionally calls:
|
||||||
|
// onStickies(list, step) after the sticky overlays are rebuilt
|
||||||
|
// beforePickBonus(result) → Promise (the dynamite BOOM)
|
||||||
|
// runPickBonus(bonus) → Promise<total> (the mine-cart bonus)
|
||||||
|
//
|
||||||
|
// Gutter props: a WANTED poster (left) and a TNT plunger box wired into the
|
||||||
|
// cabinet (right), lanterns hanging off the cabinet, a rail track on the
|
||||||
|
// control bar for ore-cart drive-bys, and a bandit who peeks out in attract
|
||||||
|
// mode. Everything animates outcomes the engine already decided.
|
||||||
|
|
||||||
|
import * as Phaser from 'phaser';
|
||||||
|
import { GAME_WIDTH, GAME_HEIGHT } from '../../config.js';
|
||||||
|
import { Button } from '../../ui/Button.js';
|
||||||
|
import { playSound, SFX } from '../../ui/Sounds.js';
|
||||||
|
import { textureKeyFor } from './SlotsSymbols.js';
|
||||||
|
import { pick } from './SlotsLogic.js';
|
||||||
|
import { canvasTex, roundRectPath } from './SlotsAttract.js';
|
||||||
|
|
||||||
|
const ADD = Phaser.BlendModes.ADD;
|
||||||
|
const wait = (scene, ms) => new Promise((r) => scene.time.delayedCall(ms, r));
|
||||||
|
const INK = '#4a2a0e';
|
||||||
|
|
||||||
|
function seeded(seed) {
|
||||||
|
let a = seed >>> 0;
|
||||||
|
return () => {
|
||||||
|
a = (a + 0x6D2B79F5) | 0;
|
||||||
|
let t = Math.imul(a ^ (a >>> 15), 1 | a);
|
||||||
|
t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
|
||||||
|
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Textures ──────────────────────────────────────────────────────────────────
|
||||||
|
function bakeGoldRushTextures(scene) {
|
||||||
|
// Aged parchment with a torn edge.
|
||||||
|
canvasTex(scene, 'slots-gr-poster', 280, 400, (ctx, w, h) => {
|
||||||
|
const rnd = seeded(11);
|
||||||
|
const edge = [];
|
||||||
|
const jag = () => 3 + rnd() * 7;
|
||||||
|
for (let x = 0; x <= w; x += 14) edge.push([x, jag()]);
|
||||||
|
for (let y = 0; y <= h; y += 14) edge.push([w - jag(), y]);
|
||||||
|
for (let x = w; x >= 0; x -= 14) edge.push([x, h - jag()]);
|
||||||
|
for (let y = h; y >= 0; y -= 14) edge.push([jag(), y]);
|
||||||
|
ctx.beginPath();
|
||||||
|
edge.forEach(([x, y], i) => (i ? ctx.lineTo(x, y) : ctx.moveTo(x, y)));
|
||||||
|
ctx.closePath();
|
||||||
|
const g = ctx.createLinearGradient(0, 0, 0, h);
|
||||||
|
g.addColorStop(0, '#efdcae');
|
||||||
|
g.addColorStop(1, '#d9bd84');
|
||||||
|
ctx.fillStyle = g;
|
||||||
|
ctx.fill();
|
||||||
|
ctx.save();
|
||||||
|
ctx.clip();
|
||||||
|
for (let i = 0; i < 40; i++) {
|
||||||
|
const x = rnd() * w; const y = rnd() * h; const r = 8 + rnd() * 30;
|
||||||
|
const s = ctx.createRadialGradient(x, y, 0, x, y, r);
|
||||||
|
s.addColorStop(0, 'rgba(120,80,30,0.09)');
|
||||||
|
s.addColorStop(1, 'rgba(120,80,30,0)');
|
||||||
|
ctx.fillStyle = s;
|
||||||
|
ctx.fillRect(x - r, y - r, r * 2, r * 2);
|
||||||
|
}
|
||||||
|
const burn = ctx.createRadialGradient(w / 2, h / 2, Math.min(w, h) * 0.35, w / 2, h / 2, h * 0.62);
|
||||||
|
burn.addColorStop(0, 'rgba(90,50,10,0)');
|
||||||
|
burn.addColorStop(1, 'rgba(90,50,10,0.55)');
|
||||||
|
ctx.fillStyle = burn;
|
||||||
|
ctx.fillRect(0, 0, w, h);
|
||||||
|
ctx.restore();
|
||||||
|
ctx.lineWidth = 3;
|
||||||
|
ctx.strokeStyle = 'rgba(80,45,10,0.6)';
|
||||||
|
ctx.stroke();
|
||||||
|
// Nail.
|
||||||
|
const n = ctx.createRadialGradient(w / 2 - 2, 16, 0, w / 2, 18, 7);
|
||||||
|
n.addColorStop(0, '#e8e8e8'); n.addColorStop(1, '#3a3a3a');
|
||||||
|
ctx.fillStyle = n;
|
||||||
|
ctx.beginPath(); ctx.arc(w / 2, 18, 6, 0, Math.PI * 2); ctx.fill();
|
||||||
|
});
|
||||||
|
|
||||||
|
// WANTED frame for a sticky bandit cell: wood border with rope corners.
|
||||||
|
canvasTex(scene, 'slots-gr-frame', 220, 184, (ctx, w, h) => {
|
||||||
|
ctx.save();
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.rect(0, 0, w, h);
|
||||||
|
ctx.rect(12, 12, w - 24, h - 24);
|
||||||
|
ctx.clip('evenodd');
|
||||||
|
const g = ctx.createLinearGradient(0, 0, 0, h);
|
||||||
|
g.addColorStop(0, '#9a6630'); g.addColorStop(0.5, '#6e4318'); g.addColorStop(1, '#4a2d12');
|
||||||
|
ctx.fillStyle = g;
|
||||||
|
ctx.fillRect(0, 0, w, h);
|
||||||
|
ctx.strokeStyle = 'rgba(0,0,0,0.25)';
|
||||||
|
for (let y = 3; y < h; y += 5) { ctx.beginPath(); ctx.moveTo(0, y); ctx.lineTo(w, y + 2); ctx.stroke(); }
|
||||||
|
ctx.restore();
|
||||||
|
ctx.lineWidth = 2;
|
||||||
|
ctx.strokeStyle = '#ffd23f';
|
||||||
|
ctx.strokeRect(13, 13, w - 26, h - 26);
|
||||||
|
ctx.strokeStyle = '#2a1606';
|
||||||
|
ctx.strokeRect(1, 1, w - 2, h - 2);
|
||||||
|
// Rope lashings at the corners.
|
||||||
|
for (const [x, y] of [[12, 12], [w - 12, 12], [12, h - 12], [w - 12, h - 12]]) {
|
||||||
|
for (let k = -1; k <= 1; k++) {
|
||||||
|
ctx.fillStyle = '#d8b878';
|
||||||
|
ctx.strokeStyle = '#6a4a20';
|
||||||
|
ctx.lineWidth = 1.5;
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.ellipse(x + k * 4, y - k * 4, 9, 4, Math.PI / 4, 0, Math.PI * 2);
|
||||||
|
ctx.fill(); ctx.stroke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Six-point sheriff star with ball tips.
|
||||||
|
canvasTex(scene, 'slots-gr-star', 96, 96, (ctx) => {
|
||||||
|
const cx = 48; const cy = 48;
|
||||||
|
const g = ctx.createLinearGradient(10, 10, 86, 86);
|
||||||
|
g.addColorStop(0, '#fff3b0'); g.addColorStop(0.45, '#f0c441'); g.addColorStop(1, '#9a6a12');
|
||||||
|
ctx.fillStyle = g;
|
||||||
|
ctx.strokeStyle = '#5a3a08';
|
||||||
|
ctx.lineWidth = 2;
|
||||||
|
ctx.beginPath();
|
||||||
|
for (let i = 0; i < 12; i++) {
|
||||||
|
const a = -Math.PI / 2 + (i / 12) * Math.PI * 2;
|
||||||
|
const r = i % 2 === 0 ? 38 : 21;
|
||||||
|
const x = cx + Math.cos(a) * r; const y = cy + Math.sin(a) * r;
|
||||||
|
if (i === 0) ctx.moveTo(x, y); else ctx.lineTo(x, y);
|
||||||
|
}
|
||||||
|
ctx.closePath();
|
||||||
|
ctx.fill(); ctx.stroke();
|
||||||
|
for (let i = 0; i < 6; i++) {
|
||||||
|
const a = -Math.PI / 2 + (i / 6) * Math.PI * 2;
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.arc(cx + Math.cos(a) * 40, cy + Math.sin(a) * 40, 5.5, 0, Math.PI * 2);
|
||||||
|
ctx.fill(); ctx.stroke();
|
||||||
|
}
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.arc(cx, cy, 16, 0, Math.PI * 2);
|
||||||
|
ctx.fillStyle = '#fff6d0';
|
||||||
|
ctx.fill(); ctx.stroke();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Hanging oil lantern.
|
||||||
|
canvasTex(scene, 'slots-gr-lantern', 80, 124, (ctx) => {
|
||||||
|
ctx.strokeStyle = '#2a2420';
|
||||||
|
ctx.lineWidth = 3;
|
||||||
|
ctx.beginPath(); ctx.arc(40, 8, 6, 0, Math.PI * 2); ctx.stroke();
|
||||||
|
ctx.fillStyle = '#3a302a';
|
||||||
|
ctx.beginPath(); ctx.moveTo(26, 16); ctx.lineTo(54, 16); ctx.lineTo(62, 32); ctx.lineTo(18, 32); ctx.closePath(); ctx.fill();
|
||||||
|
const glass = ctx.createRadialGradient(40, 66, 4, 40, 66, 34);
|
||||||
|
glass.addColorStop(0, '#fffbe0'); glass.addColorStop(0.35, '#ffd27a'); glass.addColorStop(1, '#a85a10');
|
||||||
|
ctx.fillStyle = glass;
|
||||||
|
roundRectPath(ctx, 20, 32, 40, 66, 10);
|
||||||
|
ctx.fill();
|
||||||
|
ctx.fillStyle = '#ffffff';
|
||||||
|
ctx.beginPath(); ctx.ellipse(40, 68, 5, 11, 0, 0, Math.PI * 2); ctx.fill();
|
||||||
|
ctx.strokeStyle = '#2a2420';
|
||||||
|
ctx.lineWidth = 2.5;
|
||||||
|
for (const x of [22, 40, 58]) { ctx.beginPath(); ctx.moveTo(x, 32); ctx.lineTo(x, 98); ctx.stroke(); }
|
||||||
|
ctx.beginPath(); ctx.moveTo(20, 64); ctx.lineTo(60, 64); ctx.stroke();
|
||||||
|
ctx.fillStyle = '#3a302a';
|
||||||
|
roundRectPath(ctx, 16, 96, 48, 14, 4);
|
||||||
|
ctx.fill();
|
||||||
|
});
|
||||||
|
|
||||||
|
canvasTex(scene, 'slots-gr-rock', 24, 20, (ctx) => {
|
||||||
|
const rnd = seeded(5);
|
||||||
|
ctx.beginPath();
|
||||||
|
for (let i = 0; i < 7; i++) {
|
||||||
|
const a = (i / 7) * Math.PI * 2; const r = 7 + rnd() * 4;
|
||||||
|
const x = 12 + Math.cos(a) * r; const y = 10 + Math.sin(a) * r * 0.8;
|
||||||
|
if (i === 0) ctx.moveTo(x, y); else ctx.lineTo(x, y);
|
||||||
|
}
|
||||||
|
ctx.closePath();
|
||||||
|
const g = ctx.createLinearGradient(0, 0, 24, 20);
|
||||||
|
g.addColorStop(0, '#9a8468'); g.addColorStop(1, '#3e3226');
|
||||||
|
ctx.fillStyle = g;
|
||||||
|
ctx.fill();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Point along a polyline at fraction t (by length).
|
||||||
|
function along(pts, t) {
|
||||||
|
let L = 0;
|
||||||
|
const seg = [];
|
||||||
|
for (let i = 1; i < pts.length; i++) {
|
||||||
|
const d = Math.hypot(pts[i].x - pts[i - 1].x, pts[i].y - pts[i - 1].y);
|
||||||
|
seg.push(d); L += d;
|
||||||
|
}
|
||||||
|
let s = t * L;
|
||||||
|
for (let i = 0; i < seg.length; i++) {
|
||||||
|
if (s <= seg[i] || i === seg.length - 1) {
|
||||||
|
const f = seg[i] > 0 ? Math.min(1, s / seg[i]) : 0;
|
||||||
|
return { x: pts[i].x + (pts[i + 1].x - pts[i].x) * f, y: pts[i].y + (pts[i + 1].y - pts[i].y) * f };
|
||||||
|
}
|
||||||
|
s -= seg[i];
|
||||||
|
}
|
||||||
|
return pts[pts.length - 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
function bezierPts(a, k, b, n = 24) {
|
||||||
|
const out = [];
|
||||||
|
for (let i = 0; i <= n; i++) {
|
||||||
|
const s = i / n;
|
||||||
|
out.push({
|
||||||
|
x: (1 - s) * (1 - s) * a.x + 2 * (1 - s) * s * k.x + s * s * b.x,
|
||||||
|
y: (1 - s) * (1 - s) * a.y + 2 * (1 - s) * s * k.y + s * s * b.y,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class GoldRushProps {
|
||||||
|
constructor(stage) {
|
||||||
|
this.stage = stage;
|
||||||
|
this.scene = stage.scene;
|
||||||
|
this.m = stage.m;
|
||||||
|
this.D = stage.D;
|
||||||
|
this.g = stage.g;
|
||||||
|
this.view = null;
|
||||||
|
this.t = 0;
|
||||||
|
this.lit = 0;
|
||||||
|
this.badges = new Map();
|
||||||
|
this.cartMs = 0;
|
||||||
|
this.peekMs = 0;
|
||||||
|
this.peekSide = 0;
|
||||||
|
this.cartBusy = false;
|
||||||
|
this.scatter = this.m.features.pickBonus?.scatter ?? 'dynamite';
|
||||||
|
bakeGoldRushTextures(this.scene);
|
||||||
|
this.buildLanterns();
|
||||||
|
this.buildPoster();
|
||||||
|
this.buildTnt();
|
||||||
|
this.buildRails();
|
||||||
|
}
|
||||||
|
|
||||||
|
sym(id) { return textureKeyFor(this.scene, this.m.id, id); }
|
||||||
|
|
||||||
|
sparkEmitter(x, y, opts = {}) {
|
||||||
|
return this.scene.add.particles(x, y, 'slots-spark', {
|
||||||
|
speed: { min: 40, max: 170 }, lifespan: { min: 180, max: 420 },
|
||||||
|
scale: { start: 0.9, end: 0 }, tint: [0xffd23f, 0xff7a2a, 0xffffff],
|
||||||
|
frequency: 14, quantity: 2, blendMode: 'ADD', ...opts,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Props ──────────────────────────────────────────────────────────────────
|
||||||
|
buildLanterns() {
|
||||||
|
const { scene } = this;
|
||||||
|
const { cab } = this.g;
|
||||||
|
this.lanterns = [];
|
||||||
|
const g = scene.add.graphics().setDepth(this.D.cab + 2.5);
|
||||||
|
for (const side of [-1, 1]) {
|
||||||
|
const edge = side < 0 ? cab.x : cab.x + cab.w;
|
||||||
|
const x = edge + side * 38;
|
||||||
|
// Iron bracket arm + chain.
|
||||||
|
g.lineStyle(6, 0x2a2420, 1);
|
||||||
|
g.lineBetween(edge - side * 6, 72, x + side * 4, 72);
|
||||||
|
g.lineBetween(edge, 88, edge + side * 22, 72);
|
||||||
|
g.lineStyle(2, 0x2a2420, 1);
|
||||||
|
g.lineBetween(x, 72, x, 88);
|
||||||
|
const glow = scene.add.image(x, 150, 'slots-glow').setDisplaySize(340, 340)
|
||||||
|
.setTint(0xffa040).setBlendMode(ADD).setDepth(this.D.cab + 2.4);
|
||||||
|
const hot = scene.add.image(x, 150, 'slots-glow').setDisplaySize(120, 120)
|
||||||
|
.setTint(0xffe0a0).setBlendMode(ADD).setDepth(this.D.cab + 2.7);
|
||||||
|
const img = scene.add.image(x, 86, 'slots-gr-lantern').setOrigin(0.5, 0)
|
||||||
|
.setDisplaySize(64, 99).setDepth(this.D.cab + 2.6);
|
||||||
|
this.lanterns.push({ img, glow, hot, ph: Math.random() * 10 });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
buildPoster() {
|
||||||
|
const { scene } = this;
|
||||||
|
const { cab } = this.g;
|
||||||
|
const c = scene.add.container(cab.x / 2, 470).setDepth(this.D.cab + 3);
|
||||||
|
const paper = scene.add.image(0, 0, 'slots-gr-poster').setDisplaySize(270, 386);
|
||||||
|
const title = scene.add.text(0, -140, 'WANTED', {
|
||||||
|
fontFamily: 'Righteous', fontSize: '58px', color: INK,
|
||||||
|
}).setOrigin(0.5);
|
||||||
|
const face = scene.add.image(0, -36, this.sym('bandit')).setDisplaySize(170, 170);
|
||||||
|
face.setCrop(0, 0, face.frame.width, face.frame.height * 0.62);
|
||||||
|
const l1 = scene.add.text(0, 24, 'BANDIT WILDS', {
|
||||||
|
fontFamily: 'Righteous', fontSize: '26px', color: INK,
|
||||||
|
}).setOrigin(0.5);
|
||||||
|
const l2 = scene.add.text(0, 54, 'STICK FOR 3 SPINS', {
|
||||||
|
fontFamily: '"Julius Sans One"', fontSize: '16px', color: INK,
|
||||||
|
}).setOrigin(0.5);
|
||||||
|
const rule = scene.add.rectangle(0, 78, 200, 2, 0x4a2a0e, 0.7);
|
||||||
|
this.posterStatus = scene.add.text(0, 108, 'NONE AT LARGE', {
|
||||||
|
fontFamily: 'Righteous', fontSize: '26px', color: '#8a1a0a',
|
||||||
|
}).setOrigin(0.5);
|
||||||
|
this.posterCounts = scene.add.text(0, 140, '', {
|
||||||
|
fontFamily: '"Julius Sans One"', fontSize: '16px', color: INK,
|
||||||
|
}).setOrigin(0.5);
|
||||||
|
c.add([paper, title, face, l1, l2, rule, this.posterStatus, this.posterCounts]);
|
||||||
|
this.poster = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
updatePoster(list) {
|
||||||
|
const n = list.length;
|
||||||
|
this.posterStatus.setText(n ? `${n} AT LARGE` : 'NONE AT LARGE');
|
||||||
|
this.posterCounts.setText(n ? `SPINS LEFT: ${list.map((s) => s.spinsLeft).join(' · ')}` : '');
|
||||||
|
}
|
||||||
|
|
||||||
|
stampPoster() {
|
||||||
|
const { scene } = this;
|
||||||
|
const s = scene.add.text(0, 30, 'STUCK!', {
|
||||||
|
fontFamily: 'Righteous', fontSize: '66px', color: '#c0201a',
|
||||||
|
stroke: '#f3e2bf', strokeThickness: 4,
|
||||||
|
}).setOrigin(0.5).setAngle(-14).setScale(2.4).setAlpha(0);
|
||||||
|
this.poster.add(s);
|
||||||
|
scene.tweens.add({
|
||||||
|
targets: s, scale: 1, alpha: 0.92, duration: 200, ease: 'Quad.in',
|
||||||
|
onComplete: () => {
|
||||||
|
scene.tweens.add({ targets: this.poster, scale: 1.05, duration: 80, yoyo: true });
|
||||||
|
scene.tweens.add({ targets: s, alpha: 0, delay: 1400, duration: 400, onComplete: () => s.destroy() });
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTnt() {
|
||||||
|
const { scene } = this;
|
||||||
|
const { cab, win } = this.g;
|
||||||
|
const x = Math.round((cab.x + cab.w + GAME_WIDTH) / 2);
|
||||||
|
const y = win.y + 230;
|
||||||
|
const c = scene.add.container(x, y).setDepth(this.D.cab + 3);
|
||||||
|
|
||||||
|
const title = scene.add.text(0, -186, 'DYNAMITE', {
|
||||||
|
fontFamily: 'Righteous', fontSize: '34px', color: '#ffe27a', stroke: '#14100a', strokeThickness: 6,
|
||||||
|
}).setOrigin(0.5);
|
||||||
|
const sub = scene.add.text(0, -150, '3 OPENS THE MINE', {
|
||||||
|
fontFamily: '"Julius Sans One"', fontSize: '16px', color: '#f3e2bf', stroke: '#14100a', strokeThickness: 4,
|
||||||
|
}).setOrigin(0.5);
|
||||||
|
|
||||||
|
// Plunger (moves as a unit).
|
||||||
|
const plunger = scene.add.container(0, 0);
|
||||||
|
const pg = scene.add.graphics();
|
||||||
|
pg.fillStyle(0x8a8a8a, 1); pg.fillRect(-6, -110, 12, 112);
|
||||||
|
pg.fillStyle(0x3a2a1a, 1); pg.fillRoundedRect(-70, -124, 140, 22, 8);
|
||||||
|
pg.fillStyle(0xffffff, 0.18); pg.fillRoundedRect(-66, -122, 132, 6, 3);
|
||||||
|
plunger.add(pg);
|
||||||
|
|
||||||
|
// Crate.
|
||||||
|
const box = scene.add.graphics();
|
||||||
|
box.fillStyle(0x000000, 0.35); box.fillRoundedRect(-122, 8, 250, 168, 10);
|
||||||
|
box.fillStyle(0x7a4a1e, 1); box.fillRoundedRect(-125, 0, 250, 168, 10);
|
||||||
|
box.fillStyle(0x5a3412, 1);
|
||||||
|
for (let k = 0; k < 4; k++) box.fillRect(-125, 40 * k + 2, 250, 3);
|
||||||
|
box.lineStyle(5, 0x3a2008, 1); box.strokeRoundedRect(-125, 0, 250, 168, 10);
|
||||||
|
box.fillStyle(0x2a1606, 1); box.fillRect(-28, -6, 56, 10);
|
||||||
|
const tnt = scene.add.text(0, 140, 'T N T', {
|
||||||
|
fontFamily: 'Righteous', fontSize: '34px', color: '#c0201a', stroke: '#f3e2bf', strokeThickness: 3,
|
||||||
|
}).setOrigin(0.5);
|
||||||
|
|
||||||
|
// Three dynamite slots.
|
||||||
|
this.sticks = [-78, 0, 78].map((sx) => {
|
||||||
|
const glow = scene.add.image(sx, 62, 'slots-glow').setDisplaySize(130, 130)
|
||||||
|
.setTint(0xff7a2a).setBlendMode(ADD).setAlpha(0);
|
||||||
|
const img = scene.add.image(sx, 62, this.sym(this.scatter)).setDisplaySize(84, 84)
|
||||||
|
.setTint(0x4a4a4a).setAlpha(0.55);
|
||||||
|
return { img, glow, x: sx, lit: false };
|
||||||
|
});
|
||||||
|
|
||||||
|
c.add([title, sub, plunger, box, ...this.sticks.map((s) => s.glow), ...this.sticks.map((s) => s.img), tnt]);
|
||||||
|
this.tnt = { c, plunger, x, y };
|
||||||
|
|
||||||
|
// Detonator wire from the crate into the cabinet.
|
||||||
|
const a = { x: x - 125, y: y + 120 };
|
||||||
|
const b = { x: cab.x + cab.w - 4, y: win.y + win.h * 0.78 };
|
||||||
|
this.wirePts = bezierPts(a, { x: (a.x + b.x) / 2, y: Math.max(a.y, b.y) + 110 }, b);
|
||||||
|
const wire = scene.add.graphics().setDepth(this.D.cab + 2.9);
|
||||||
|
wire.lineStyle(6, 0x1a1008, 1);
|
||||||
|
wire.strokePoints(this.wirePts);
|
||||||
|
wire.lineStyle(2, 0x8a2a1a, 0.9);
|
||||||
|
wire.strokePoints(this.wirePts);
|
||||||
|
}
|
||||||
|
|
||||||
|
setLit(n) {
|
||||||
|
const { scene } = this;
|
||||||
|
this.sticks.forEach((s, i) => {
|
||||||
|
const want = i < n;
|
||||||
|
if (want === s.lit) return;
|
||||||
|
s.lit = want;
|
||||||
|
if (want) {
|
||||||
|
s.img.clearTint().setAlpha(1);
|
||||||
|
scene.tweens.add({ targets: s.img, scale: s.img.scale * 1.35, duration: 140, yoyo: true, ease: 'Quad.out' });
|
||||||
|
scene.tweens.add({ targets: s.glow, alpha: 0.9, duration: 160 });
|
||||||
|
playSound(scene, SFX.PIECE_CLICK);
|
||||||
|
} else {
|
||||||
|
s.img.setTint(0x4a4a4a).setAlpha(0.55);
|
||||||
|
s.glow.setAlpha(0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (n >= 2 && !this.boxSparks) {
|
||||||
|
const { c } = this.tnt;
|
||||||
|
this.boxSparks = this.sparkEmitter(c.x, c.y - 4).setDepth(this.D.cab + 3.5);
|
||||||
|
this.stage.sound('fuse');
|
||||||
|
}
|
||||||
|
if (n < 2 && this.boxSparks) { this.boxSparks.destroy(); this.boxSparks = null; }
|
||||||
|
}
|
||||||
|
|
||||||
|
plunge() {
|
||||||
|
const { scene } = this;
|
||||||
|
scene.tweens.add({ targets: this.tnt.plunger, y: 46, duration: 130, ease: 'Quad.in' });
|
||||||
|
scene.tweens.add({ targets: this.tnt.c, scaleY: 0.96, duration: 70, yoyo: true, delay: 120 });
|
||||||
|
}
|
||||||
|
|
||||||
|
buildRails() {
|
||||||
|
const g = this.scene.add.graphics().setDepth(this.D.ui - 0.9);
|
||||||
|
const y = 930;
|
||||||
|
g.fillStyle(0x3a2210, 1);
|
||||||
|
for (let x = 64; x < GAME_WIDTH - 64; x += 26) g.fillRect(x, y, 14, 7);
|
||||||
|
g.fillStyle(0x6e675e, 1);
|
||||||
|
g.fillRect(56, y - 4, GAME_WIDTH - 112, 4);
|
||||||
|
g.fillStyle(0xd8d0c0, 0.8);
|
||||||
|
g.fillRect(56, y - 4, GAME_WIDTH - 112, 1.5);
|
||||||
|
this.railY = y - 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Little attract shows ────────────────────────────────────────────────────
|
||||||
|
driveBy() {
|
||||||
|
if (this.cartBusy) return;
|
||||||
|
this.cartBusy = true;
|
||||||
|
const { scene } = this;
|
||||||
|
const y = this.railY;
|
||||||
|
const cart = scene.add.image(-90, y, this.sym('wagon')).setOrigin(0.5, 1)
|
||||||
|
.setDisplaySize(130, 130).setDepth(this.D.ui - 0.5);
|
||||||
|
this.stage.sound('cartRoll');
|
||||||
|
const carrier = { x: -90 };
|
||||||
|
let lastSpill = 0;
|
||||||
|
scene.tweens.add({
|
||||||
|
targets: carrier, x: GAME_WIDTH + 90, duration: 7000,
|
||||||
|
onUpdate: (tw) => {
|
||||||
|
cart.x = carrier.x;
|
||||||
|
cart.y = y - Math.abs(Math.sin(carrier.x * 0.06)) * 2.5;
|
||||||
|
if (tw.elapsed - lastSpill > 1100) {
|
||||||
|
lastSpill = tw.elapsed;
|
||||||
|
const n = scene.add.image(cart.x - 20, cart.y - 112, 'slots-nugget').setDepth(this.D.ui - 0.4);
|
||||||
|
scene.tweens.add({
|
||||||
|
targets: n, x: n.x - 40, y: y - 6, angle: 200, duration: 520, ease: 'Bounce.out',
|
||||||
|
onComplete: () => scene.tweens.add({ targets: n, alpha: 0, delay: 900, duration: 400, onComplete: () => n.destroy() }),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onComplete: () => { cart.destroy(); this.cartBusy = false; },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
peek() {
|
||||||
|
const { scene } = this;
|
||||||
|
const { cab } = this.g;
|
||||||
|
const left = (this.peekSide++ % 2) === 0;
|
||||||
|
const hidden = left ? cab.x + 90 : cab.x + cab.w - 90;
|
||||||
|
const shown = left ? cab.x - 50 : cab.x + cab.w + 50;
|
||||||
|
const img = scene.add.image(hidden, 760, this.sym('bandit')).setDisplaySize(160, 160)
|
||||||
|
.setFlipX(!left).setDepth(this.D.cab - 0.1);
|
||||||
|
img.setCrop(0, 0, img.frame.width, img.frame.height * 0.62);
|
||||||
|
scene.tweens.chain({
|
||||||
|
targets: img,
|
||||||
|
tweens: [
|
||||||
|
{ x: shown, angle: left ? -10 : 10, duration: 380, ease: 'Back.out' },
|
||||||
|
{ angle: left ? -4 : 4, duration: 600, yoyo: true, ease: 'Sine.inOut' },
|
||||||
|
{ x: hidden, angle: 0, duration: 300, ease: 'Quad.in', delay: 200 },
|
||||||
|
],
|
||||||
|
onComplete: () => img.destroy(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
dustPuff(x, y, count = 7) {
|
||||||
|
const em = this.scene.add.particles(x, y, 'slots-glow', {
|
||||||
|
speedX: { min: -80, max: 80 }, speedY: { min: -80, max: -15 },
|
||||||
|
scale: { start: 0.08, end: 0.2 }, alpha: { start: 0.5, end: 0 },
|
||||||
|
tint: [0xc8a070, 0xa88a60], lifespan: 700, emitting: false,
|
||||||
|
}).setDepth((this.view?.depth ?? this.D.reel) + 4);
|
||||||
|
em.explode(count);
|
||||||
|
this.scene.time.delayedCall(800, () => em.destroy());
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Hooks ──────────────────────────────────────────────────────────────────
|
||||||
|
onReels(view) { this.view = view; }
|
||||||
|
|
||||||
|
onAttract(on) {
|
||||||
|
if (on) { this.cartMs = 13000; this.peekMs = 5000; }
|
||||||
|
}
|
||||||
|
|
||||||
|
update(dt) {
|
||||||
|
this.t += dt / 1000;
|
||||||
|
for (const L of this.lanterns) {
|
||||||
|
const t = this.t + L.ph;
|
||||||
|
const f = 0.78 + 0.1 * Math.sin(t * 13) + 0.07 * Math.sin(t * 7.3 + 1) + 0.05 * Math.sin(t * 23.7);
|
||||||
|
L.glow.setAlpha(0.5 * f);
|
||||||
|
L.hot.setAlpha(0.7 * f);
|
||||||
|
L.img.setAngle(3 * Math.sin(t * 1.1));
|
||||||
|
}
|
||||||
|
this.poster.setAngle(1.1 * Math.sin(this.t * 0.6));
|
||||||
|
if (this.stage.busy || !this.view) return;
|
||||||
|
this.cartMs += dt;
|
||||||
|
this.peekMs += dt;
|
||||||
|
if (this.cartMs >= (this.stage.attracting ? 15000 : 45000)) { this.cartMs = 0; this.driveBy(); }
|
||||||
|
if (this.stage.attracting && this.peekMs >= 11000) { this.peekMs = 0; this.peek(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
onSpinStart() {
|
||||||
|
this.lit = 0;
|
||||||
|
this.setLit(0);
|
||||||
|
this.stopFuseRun();
|
||||||
|
this.scene.tweens.killTweensOf(this.tnt.plunger);
|
||||||
|
this.tnt.plunger.y = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
countThrough(c) {
|
||||||
|
const grid = this.stage.pendingResult?.grid;
|
||||||
|
if (!grid) return 0;
|
||||||
|
let n = 0;
|
||||||
|
for (let k = 0; k <= c && k < grid.length; k++) n += grid[k].filter((s) => s === this.scatter).length;
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
onReelStop(c) {
|
||||||
|
const view = this.view;
|
||||||
|
if (!view) return;
|
||||||
|
const p = view.cellCenter(c, view.rows - 1);
|
||||||
|
this.dustPuff(p.x, view.y + view.height() - 4, 6);
|
||||||
|
const n = this.countThrough(c);
|
||||||
|
if (n > this.lit) {
|
||||||
|
this.lit = n;
|
||||||
|
this.setLit(Math.min(3, n));
|
||||||
|
const col = this.stage.pendingResult.grid[c];
|
||||||
|
col.forEach((s, r) => {
|
||||||
|
if (s !== this.scatter) return;
|
||||||
|
const q = view.cellCenter(c, r);
|
||||||
|
this.scene.fx?.burst(q.x, q.y - view.cellH * 0.3, 10, 0xff9a3c);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// A spitting fuse spark runs back and forth along the teased reel's top.
|
||||||
|
onAnticipate(c) {
|
||||||
|
const view = this.view;
|
||||||
|
if (!view) return;
|
||||||
|
this.stopFuseRun();
|
||||||
|
const x0 = view.reelX(c) + 10; const x1 = view.reelX(c) + view.cellW - 10;
|
||||||
|
const y = view.y - 2;
|
||||||
|
const head = { x: x0, y };
|
||||||
|
const em = this.sparkEmitter(0, 0).setDepth(view.depth + 5);
|
||||||
|
em.startFollow(head);
|
||||||
|
const tw = this.scene.tweens.add({ targets: head, x: x1, duration: 420, yoyo: true, repeat: -1, ease: 'Sine.inOut' });
|
||||||
|
this.fuseRun = { em, tw };
|
||||||
|
this.stage.sound('fuse');
|
||||||
|
}
|
||||||
|
|
||||||
|
stopFuseRun() {
|
||||||
|
if (!this.fuseRun) return;
|
||||||
|
this.fuseRun.tw.stop();
|
||||||
|
this.fuseRun.em.destroy();
|
||||||
|
this.fuseRun = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
onLanded() {
|
||||||
|
const teased = !!this.fuseRun;
|
||||||
|
this.stopFuseRun();
|
||||||
|
if (teased && this.lit < 3) {
|
||||||
|
// Fizzled: the crate's fuse sputters out in a puff of smoke.
|
||||||
|
const { c } = this.tnt;
|
||||||
|
this.dustPuff(c.x, c.y - 10, 10);
|
||||||
|
this.setLit(this.lit);
|
||||||
|
if (this.boxSparks) { this.boxSparks.destroy(); this.boxSparks = null; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Sticky bandits ─────────────────────────────────────────────────────────
|
||||||
|
onStickies(list, step) {
|
||||||
|
const view = this.view;
|
||||||
|
if (!view) return;
|
||||||
|
const key = (c, r) => `${c},${r}`;
|
||||||
|
const live = new Set(list.map((s) => key(s.c, s.r)));
|
||||||
|
const placed = new Set((step?.placed ?? []).map((p) => key(p.c, p.r)));
|
||||||
|
|
||||||
|
for (const [k, b] of this.badges) {
|
||||||
|
if (live.has(k)) continue;
|
||||||
|
b.frame.destroy(); b.star.destroy();
|
||||||
|
this.badges.delete(k);
|
||||||
|
}
|
||||||
|
for (const e of step?.expiring ?? []) {
|
||||||
|
if (!live.has(key(e.c, e.r))) this.escape(e.c, e.r);
|
||||||
|
}
|
||||||
|
for (const s of list) {
|
||||||
|
const k = key(s.c, s.r);
|
||||||
|
let b = this.badges.get(k);
|
||||||
|
if (!b) { b = this.makeBadge(s.c, s.r); this.badges.set(k, b); }
|
||||||
|
const changed = b.left !== null && b.left !== s.spinsLeft;
|
||||||
|
b.left = s.spinsLeft;
|
||||||
|
b.txt.setText(String(s.spinsLeft));
|
||||||
|
if (placed.has(k)) this.arrive(s.c, s.r, b);
|
||||||
|
else if (changed) {
|
||||||
|
this.scene.tweens.add({ targets: b.star, angle: { from: 0, to: 360 }, duration: 520, ease: 'Cubic.out' });
|
||||||
|
this.scene.tweens.add({ targets: b.star, scale: 1.3, duration: 140, yoyo: true });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.updatePoster(list);
|
||||||
|
if (placed.size > 0) {
|
||||||
|
this.stampPoster();
|
||||||
|
this.stage.lights.flashAll(0xffe27a, 1);
|
||||||
|
this.stage.sound('sticky', () => playSound(this.scene, SFX.SCIFI_RISER));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
makeBadge(c, r) {
|
||||||
|
const { scene } = this;
|
||||||
|
const view = this.view;
|
||||||
|
const p = view.cellCenter(c, r);
|
||||||
|
const frame = scene.add.image(p.x, p.y, 'slots-gr-frame')
|
||||||
|
.setDisplaySize(view.cellW * 0.98, view.cellH * 0.98).setDepth(view.depth + 2.5);
|
||||||
|
const star = scene.add.container(p.x + view.cellW * 0.36, p.y - view.cellH * 0.3).setDepth(view.depth + 3);
|
||||||
|
const img = scene.add.image(0, 0, 'slots-gr-star').setDisplaySize(58, 58);
|
||||||
|
const txt = scene.add.text(0, 1, '', {
|
||||||
|
fontFamily: 'Righteous', fontSize: '24px', color: INK,
|
||||||
|
}).setOrigin(0.5);
|
||||||
|
star.add([img, txt]);
|
||||||
|
return { frame, star, txt, left: null };
|
||||||
|
}
|
||||||
|
|
||||||
|
arrive(c, r, badge) {
|
||||||
|
const { scene } = this;
|
||||||
|
const view = this.view;
|
||||||
|
const p = view.cellCenter(c, r);
|
||||||
|
const img = view.stickyImgs.find((i) => i.cell && i.cell.c === c && i.cell.r === r);
|
||||||
|
if (img) {
|
||||||
|
const y = img.y;
|
||||||
|
img.setY(y - 90).setAlpha(0);
|
||||||
|
scene.tweens.add({ targets: img, y, alpha: 1, duration: 480, ease: 'Bounce.out' });
|
||||||
|
}
|
||||||
|
badge.frame.setScale(badge.frame.scaleX * 1.35, badge.frame.scaleY * 1.35).setAlpha(0);
|
||||||
|
scene.tweens.add({
|
||||||
|
targets: badge.frame, scaleX: badge.frame.scaleX / 1.35, scaleY: badge.frame.scaleY / 1.35,
|
||||||
|
alpha: 1, duration: 300, delay: 260, ease: 'Back.out',
|
||||||
|
});
|
||||||
|
badge.star.setScale(0);
|
||||||
|
scene.tweens.add({ targets: badge.star, scale: 1, angle: { from: -180, to: 0 }, duration: 380, delay: 420, ease: 'Back.out' });
|
||||||
|
scene.time.delayedCall(300, () => this.dustPuff(p.x, p.y + view.cellH * 0.4, 8));
|
||||||
|
scene.cameras.main.shake(120, 0.003);
|
||||||
|
}
|
||||||
|
|
||||||
|
escape(c, r) {
|
||||||
|
const { scene } = this;
|
||||||
|
const view = this.view;
|
||||||
|
const p = view.cellCenter(c, r);
|
||||||
|
const img = scene.add.image(p.x, p.y, this.sym('bandit'))
|
||||||
|
.setDisplaySize(view.cellW * 0.92, view.cellH * 0.92).setDepth(view.depth + 2);
|
||||||
|
for (let k = 0; k < 4; k++) {
|
||||||
|
const puff = scene.add.image(p.x + (k - 1.5) * 26, p.y + 20, 'slots-glow').setTint(0x9a8f80)
|
||||||
|
.setDisplaySize(50, 50).setAlpha(0.65).setDepth(view.depth + 2.6);
|
||||||
|
scene.tweens.add({
|
||||||
|
targets: puff, displayWidth: 170, displayHeight: 170, alpha: 0, y: puff.y - 30,
|
||||||
|
duration: 800, delay: k * 60, onComplete: () => puff.destroy(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
scene.tweens.add({
|
||||||
|
targets: img, x: p.x + 190, angle: 12, alpha: 0, duration: 560, delay: 120, ease: 'Quad.in',
|
||||||
|
onComplete: () => img.destroy(),
|
||||||
|
});
|
||||||
|
scene.fx?.floatText(p.x, p.y - 30, 'GOT AWAY!', '#ffb36b', 30);
|
||||||
|
this.stage.sound('escape');
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── The BOOM ───────────────────────────────────────────────────────────────
|
||||||
|
// Plunger slams → spark races down the wire into the cabinet → burns through
|
||||||
|
// each dynamite → flash, shake, debris, dust and a burst of gold.
|
||||||
|
async beforePickBonus(result) {
|
||||||
|
const { scene } = this;
|
||||||
|
const view = this.view;
|
||||||
|
const cells = [];
|
||||||
|
result.grid.forEach((col, c) => col.forEach((s, r) => { if (s === this.scatter) cells.push({ c, r }); }));
|
||||||
|
this.stopFuseRun();
|
||||||
|
if (this.boxSparks) { this.boxSparks.destroy(); this.boxSparks = null; }
|
||||||
|
this.setLit(3);
|
||||||
|
this.plunge();
|
||||||
|
await wait(scene, 160);
|
||||||
|
this.stage.sound('fuse');
|
||||||
|
|
||||||
|
const path = [...this.wirePts, ...cells.map(({ c, r }) => view.cellCenter(c, r))];
|
||||||
|
await this.runSpark(path, 700 + cells.length * 180);
|
||||||
|
|
||||||
|
// Flash + shake + debris.
|
||||||
|
this.stage.sound('boom', () => playSound(scene, SFX.SCIFI_EXPLODE));
|
||||||
|
this.stage.lights.setMood('bigWin');
|
||||||
|
this.stage.lights.flashAll(0xffffff, 1);
|
||||||
|
const flash = scene.add.rectangle(GAME_WIDTH / 2, GAME_HEIGHT / 2, GAME_WIDTH, GAME_HEIGHT, 0xfff6e0, 1)
|
||||||
|
.setDepth(this.D.ui + 20);
|
||||||
|
scene.tweens.add({ targets: flash, alpha: 0, duration: 520, ease: 'Quad.out', onComplete: () => flash.destroy() });
|
||||||
|
scene.cameras.main.shake(650, 0.02);
|
||||||
|
for (const { c, r } of cells) {
|
||||||
|
const p = view.cellCenter(c, r);
|
||||||
|
const rocks = scene.add.particles(p.x, p.y, 'slots-gr-rock', {
|
||||||
|
speed: { min: 280, max: 720 }, angle: { min: 200, max: 340 }, gravityY: 1400,
|
||||||
|
rotate: { min: 0, max: 360 }, scale: { min: 0.8, max: 1.8 }, lifespan: 1300, emitting: false,
|
||||||
|
}).setDepth(this.D.ui + 10);
|
||||||
|
rocks.explode(12);
|
||||||
|
scene.time.delayedCall(1400, () => rocks.destroy());
|
||||||
|
for (let k = 0; k < 3; k++) {
|
||||||
|
const cloud = scene.add.image(p.x, p.y, 'slots-glow').setTint(0x8a7560)
|
||||||
|
.setDisplaySize(90, 90).setAlpha(0.75).setDepth(this.D.ui + 9);
|
||||||
|
scene.tweens.add({
|
||||||
|
targets: cloud, displayWidth: 380 + k * 80, displayHeight: 320 + k * 60, alpha: 0,
|
||||||
|
x: p.x + (k - 1) * 40, y: p.y - 30 - k * 20, duration: 1100 + k * 200, ease: 'Quad.out',
|
||||||
|
onComplete: () => cloud.destroy(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
scene.fx?.coinShower(p.x, p.y, 14);
|
||||||
|
}
|
||||||
|
await wait(scene, 1200);
|
||||||
|
}
|
||||||
|
|
||||||
|
// A burning spark that travels a polyline, leaving a glowing scorch trail.
|
||||||
|
runSpark(pts, ms) {
|
||||||
|
const { scene } = this;
|
||||||
|
const trail = scene.add.graphics().setDepth(this.D.ui + 8).setBlendMode(ADD);
|
||||||
|
const head = { x: pts[0].x, y: pts[0].y };
|
||||||
|
const glint = scene.add.image(head.x, head.y, 'slots-glint').setBlendMode(ADD)
|
||||||
|
.setScale(0.7).setDepth(this.D.ui + 8.5);
|
||||||
|
const em = this.sparkEmitter(0, 0, { frequency: 8, quantity: 3 }).setDepth(this.D.ui + 8.4);
|
||||||
|
em.startFollow(head);
|
||||||
|
const carrier = { t: 0 };
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
scene.tweens.add({
|
||||||
|
targets: carrier, t: 1, duration: ms, ease: 'Linear',
|
||||||
|
onUpdate: () => {
|
||||||
|
const q = along(pts, carrier.t);
|
||||||
|
head.x = q.x; head.y = q.y;
|
||||||
|
glint.setPosition(q.x, q.y).setAngle(carrier.t * 720);
|
||||||
|
trail.fillStyle(0xff9a3c, 0.5);
|
||||||
|
trail.fillCircle(q.x, q.y, 5);
|
||||||
|
},
|
||||||
|
onComplete: () => {
|
||||||
|
em.destroy();
|
||||||
|
glint.destroy();
|
||||||
|
scene.tweens.add({ targets: trail, alpha: 0, duration: 500, onComplete: () => trail.destroy() });
|
||||||
|
resolve();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Mine-cart bonus ────────────────────────────────────────────────────────
|
||||||
|
// Nine carts on three rails; picks tip a cart and pour its gold. Payouts are
|
||||||
|
// the engine's pre-drawn prizes via pick().
|
||||||
|
runPickBonus(bonus) {
|
||||||
|
const { scene, stage } = this;
|
||||||
|
const depth = 50;
|
||||||
|
const objs = [];
|
||||||
|
const add = (o) => { objs.push(o); return o; };
|
||||||
|
const bet = Math.max(1, stage.scene.bet ?? 1);
|
||||||
|
stage.lights.setMood('feature');
|
||||||
|
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
const veil = add(scene.add.rectangle(GAME_WIDTH / 2, GAME_HEIGHT / 2, GAME_WIDTH, GAME_HEIGHT, 0x0a0703, 0.58)
|
||||||
|
.setDepth(depth).setInteractive().setAlpha(0));
|
||||||
|
scene.tweens.add({ targets: veil, alpha: 1, duration: 300 });
|
||||||
|
add(scene.add.image(GAME_WIDTH / 2, GAME_HEIGHT / 2, 'slots-vignette')
|
||||||
|
.setDisplaySize(GAME_WIDTH * 1.2, GAME_HEIGHT * 1.3).setAlpha(0.7).setDepth(depth));
|
||||||
|
const title = add(scene.add.text(GAME_WIDTH / 2, 104, 'MINE CART BONUS', {
|
||||||
|
fontFamily: 'Righteous', fontSize: '76px', color: '#ffe27a', stroke: '#14100a', strokeThickness: 12,
|
||||||
|
}).setOrigin(0.5).setDepth(depth + 3).setShadow(0, 0, 'rgba(255,200,80,0.8)', 24).setScale(0.3));
|
||||||
|
scene.tweens.add({ targets: title, scale: 1, duration: 420, ease: 'Back.out' });
|
||||||
|
const sub = add(scene.add.text(GAME_WIDTH / 2, 172, `PICK ${bonus.picksLeft} CARTS`, {
|
||||||
|
fontFamily: '"Julius Sans One"', fontSize: '30px', color: '#f3e2bf', stroke: '#14100a', strokeThickness: 4,
|
||||||
|
}).setOrigin(0.5).setDepth(depth + 3));
|
||||||
|
const totalText = add(scene.add.text(GAME_WIDTH / 2, 935, '', {
|
||||||
|
fontFamily: 'Righteous', fontSize: '48px', color: '#ffe27a', stroke: '#14100a', strokeThickness: 8,
|
||||||
|
}).setOrigin(0.5).setDepth(depth + 3));
|
||||||
|
|
||||||
|
const rowsY = [380, 590, 800];
|
||||||
|
const xs = [640, 960, 1280];
|
||||||
|
const rails = add(scene.add.graphics().setDepth(depth + 1));
|
||||||
|
for (const ry of rowsY) {
|
||||||
|
const y = ry + 60;
|
||||||
|
rails.fillStyle(0x3a2210, 1);
|
||||||
|
for (let x = 300; x < 1620; x += 28) rails.fillRect(x, y + 2, 16, 8);
|
||||||
|
rails.fillStyle(0x8a8378, 1);
|
||||||
|
rails.fillRect(290, y - 3, 1340, 5);
|
||||||
|
rails.fillStyle(0xe8e0d0, 0.7);
|
||||||
|
rails.fillRect(290, y - 3, 1340, 1.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
const cartKey = this.sym('wagon');
|
||||||
|
const carts = [];
|
||||||
|
stage.sound('cartRoll', () => playSound(scene, SFX.ROULETTE));
|
||||||
|
for (let i = 0; i < bonus.prizes.length; i++) {
|
||||||
|
const row = Math.floor(i / 3); const col = i % 3;
|
||||||
|
const tx = xs[col]; const ty = rowsY[row];
|
||||||
|
const c = add(scene.add.container(-240, ty).setDepth(depth + 2));
|
||||||
|
const glow = scene.add.image(0, -40, 'slots-glow').setDisplaySize(320, 320)
|
||||||
|
.setTint(0xffb347).setBlendMode(ADD).setAlpha(0);
|
||||||
|
const img = scene.add.image(0, -20, cartKey).setDisplaySize(190, 190);
|
||||||
|
const label = scene.add.text(0, 24, '?', {
|
||||||
|
fontFamily: 'Righteous', fontSize: '44px', color: '#ffe27a', stroke: '#14100a', strokeThickness: 7,
|
||||||
|
}).setOrigin(0.5);
|
||||||
|
c.add([glow, img, label]);
|
||||||
|
const cart = { c, glow, img, label, tx, ty, idx: i, revealed: false, ready: false };
|
||||||
|
carts.push(cart);
|
||||||
|
scene.tweens.add({
|
||||||
|
targets: c, x: tx, duration: 1000 + col * 150, delay: row * 220 + (2 - col) * 90, ease: 'Cubic.out',
|
||||||
|
onComplete: () => { cart.ready = true; },
|
||||||
|
});
|
||||||
|
scene.tweens.add({ targets: img, y: -23, duration: 70, yoyo: true, repeat: 9, delay: row * 220 });
|
||||||
|
|
||||||
|
c.setSize(200, 190).setInteractive({ useHandCursor: true });
|
||||||
|
c.on('pointerover', () => {
|
||||||
|
if (!cart.ready || cart.revealed) return;
|
||||||
|
scene.tweens.add({ targets: c, y: ty - 10, duration: 120 });
|
||||||
|
scene.tweens.add({ targets: glow, alpha: 0.55, duration: 120 });
|
||||||
|
});
|
||||||
|
c.on('pointerout', () => {
|
||||||
|
if (cart.revealed) return;
|
||||||
|
scene.tweens.add({ targets: c, y: ty, duration: 120 });
|
||||||
|
scene.tweens.add({ targets: glow, alpha: 0, duration: 160 });
|
||||||
|
});
|
||||||
|
c.on('pointerup', () => {
|
||||||
|
if (!cart.ready || cart.revealed || bonus.picksLeft <= 0) return;
|
||||||
|
const res = pick(bonus, i);
|
||||||
|
if (!res) return;
|
||||||
|
cart.revealed = true;
|
||||||
|
this.tipCart(cart, res.prize, bet);
|
||||||
|
totalText.setText(`TOTAL: ${res.totalSoFar.toLocaleString()}`);
|
||||||
|
sub.setText(res.done ? '' : `PICK ${bonus.picksLeft} MORE`);
|
||||||
|
if (res.done) scene.time.delayedCall(900, () => finish());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const finish = () => {
|
||||||
|
playSound(scene, SFX.CASINO_WIN);
|
||||||
|
stage.lights.setMood('bigWin');
|
||||||
|
for (const cart of carts) {
|
||||||
|
if (cart.revealed) continue;
|
||||||
|
cart.revealed = true;
|
||||||
|
cart.label.setText(bonus.prizes[cart.idx].toLocaleString()).setAlpha(0.5).setFontSize(34);
|
||||||
|
cart.img.setAlpha(0.4);
|
||||||
|
}
|
||||||
|
const btn = add(new Button(scene, GAME_WIDTH / 2, 1012, 'COLLECT', () => {
|
||||||
|
btn.disableInteractive();
|
||||||
|
carts.forEach((cart, k) => scene.tweens.add({
|
||||||
|
targets: cart.c, x: cart.c.x + 1500, duration: 750, delay: (k % 3) * 60, ease: 'Cubic.in',
|
||||||
|
}));
|
||||||
|
scene.tweens.add({
|
||||||
|
targets: objs.filter((o) => !carts.some((cart) => cart.c === o)), alpha: 0, duration: 400, delay: 450,
|
||||||
|
onComplete: () => {
|
||||||
|
for (const o of objs) o.destroy();
|
||||||
|
stage.lights.setMood('win');
|
||||||
|
resolve(bonus.total);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}, {
|
||||||
|
width: 300, height: 76, fontSize: 34, bg: 0xe0a92a, bgHover: 0xffe27a,
|
||||||
|
textColor: '#14100a', textHoverColor: '#14100a',
|
||||||
|
}).setDepth(depth + 4));
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
tipCart(cart, prize, bet) {
|
||||||
|
const { scene, stage } = this;
|
||||||
|
const ratio = prize / bet;
|
||||||
|
const size = ratio >= 20 ? 60 : ratio >= 8 ? 50 : 42;
|
||||||
|
scene.tweens.add({ targets: cart.glow, alpha: 0.85, duration: 160 });
|
||||||
|
scene.tweens.chain({
|
||||||
|
targets: cart.c,
|
||||||
|
tweens: [
|
||||||
|
{ angle: -4, duration: 60, yoyo: true, repeat: 2 },
|
||||||
|
{ angle: 24, duration: 200, ease: 'Quad.out' },
|
||||||
|
{ angle: 0, duration: 300, delay: 420, ease: 'Back.out' },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
scene.time.delayedCall(380, () => {
|
||||||
|
const pour = scene.add.particles(cart.c.x + 70, cart.c.y - 80, 'slots-nugget', {
|
||||||
|
speedX: { min: 60, max: 240 }, speedY: { min: -220, max: -40 }, gravityY: 1100,
|
||||||
|
rotate: { min: 0, max: 360 }, scale: { min: 0.8, max: 1.4 }, lifespan: 900, emitting: false,
|
||||||
|
}).setDepth(cart.c.depth + 1);
|
||||||
|
pour.explode(Math.min(40, 10 + Math.round(ratio)));
|
||||||
|
scene.time.delayedCall(1000, () => pour.destroy());
|
||||||
|
stage.sound('cartDump', () => playSound(scene, SFX.COINS));
|
||||||
|
cart.label.setText(prize.toLocaleString()).setFontSize(size).setScale(0.3);
|
||||||
|
scene.tweens.add({ targets: cart.label, scale: 1, duration: 320, ease: 'Back.out' });
|
||||||
|
if (ratio >= 12) {
|
||||||
|
stage.lights.flashAll(0xfff0c0, 1);
|
||||||
|
scene.cameras.main.shake(200, 0.006);
|
||||||
|
}
|
||||||
|
if (ratio >= 20) scene.fx?.coinShower(cart.c.x, cart.c.y - 60, 22);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
shutdown() {
|
||||||
|
this.stopFuseRun();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,591 @@
|
||||||
|
// SlotsLiberty — Liberty Belle props for the attract kit (SlotsAttract.js).
|
||||||
|
//
|
||||||
|
// "The 1899 clockwork original": a working antique you can watch tick. A
|
||||||
|
// cast-iron Victorian cabinet under an iron crest with a 5¢ coin slot (a nickel
|
||||||
|
// drops in on every spin), gas-lamp sconces, sepia paper reels, a split-flap
|
||||||
|
// PAID display, an award card and a brass lever. The left gutter is a glass
|
||||||
|
// inspection window onto the clockwork — four meshed brass gears driven from
|
||||||
|
// one master angle, a pendulum and escapement — that ticks while idle, whirs on
|
||||||
|
// a spin and locks a notch at every reel stop. The right gutter holds a real
|
||||||
|
// brass bell with a striker hammer, and a zigzag coin run that carries every
|
||||||
|
// payout down into a brass cup.
|
||||||
|
//
|
||||||
|
// Hooks: onReels, onSpinStart, onReelStop, onLanded, onSettle, onBigMoment,
|
||||||
|
// onAttract, update. Sets ownsLever so SlotsGame skips its stock lever.
|
||||||
|
|
||||||
|
import * as Phaser from 'phaser';
|
||||||
|
import { GAME_WIDTH } from '../../config.js';
|
||||||
|
import { playSound, SFX } from '../../ui/Sounds.js';
|
||||||
|
import { canvasTex } from './SlotsAttract.js';
|
||||||
|
import { textureKeyFor } from './SlotsSymbols.js';
|
||||||
|
import { ChromeLever } from './SlotsVintage.js';
|
||||||
|
|
||||||
|
const ADD = Phaser.BlendModes.ADD;
|
||||||
|
const TAU = Math.PI * 2;
|
||||||
|
const wait = (scene, ms) => new Promise((r) => scene.time.delayedCall(ms, r));
|
||||||
|
const SERIF = 'Georgia, "Times New Roman", serif';
|
||||||
|
const BRASS = [0x7a5418, 0xc8a04a, 0xf3d58a];
|
||||||
|
|
||||||
|
const brassFill = (g, x, y, w, h, r = 8) => {
|
||||||
|
g.fillStyle(BRASS[0], 1); g.fillRoundedRect(x, y, w, h, r);
|
||||||
|
g.fillStyle(BRASS[2], 1); g.fillRoundedRect(x + 2, y + 2, w - 4, h * 0.42, r);
|
||||||
|
g.fillStyle(BRASS[1], 1); g.fillRoundedRect(x + 2, y + h * 0.48, w - 4, h * 0.48, r);
|
||||||
|
};
|
||||||
|
|
||||||
|
function bakeGear(scene, r, teeth) {
|
||||||
|
const pad = 14;
|
||||||
|
const size = (r + pad) * 2;
|
||||||
|
return canvasTex(scene, `lb-gear-${r}-${teeth}`, size, size, (ctx) => {
|
||||||
|
const c = size / 2;
|
||||||
|
const root = r - 8; const tip = r + 10;
|
||||||
|
const w0 = (Math.PI / teeth) * 0.55; const w1 = (Math.PI / teeth) * 0.32;
|
||||||
|
ctx.beginPath();
|
||||||
|
for (let k = 0; k < teeth; k++) {
|
||||||
|
const a = (k / teeth) * TAU;
|
||||||
|
for (const [rr, da] of [[root, -w0 * 1.6], [root, -w0], [tip, -w1], [tip, w1], [root, w0]]) {
|
||||||
|
ctx.lineTo(c + Math.cos(a + da) * rr, c + Math.sin(a + da) * rr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ctx.closePath();
|
||||||
|
const g = ctx.createRadialGradient(c - r * 0.3, c - r * 0.3, r * 0.1, c, c, tip);
|
||||||
|
g.addColorStop(0, '#f8e2a0'); g.addColorStop(0.5, '#c8a04a'); g.addColorStop(1, '#7a5418');
|
||||||
|
ctx.fillStyle = g; ctx.fill();
|
||||||
|
ctx.strokeStyle = '#3a2608'; ctx.lineWidth = 2; ctx.stroke();
|
||||||
|
ctx.strokeStyle = 'rgba(60,38,8,0.7)'; ctx.lineWidth = 3;
|
||||||
|
ctx.beginPath(); ctx.arc(c, c, r * 0.72, 0, TAU); ctx.stroke();
|
||||||
|
// Spoke windows.
|
||||||
|
ctx.fillStyle = 'rgba(20,14,6,0.9)';
|
||||||
|
for (let k = 0; k < 5; k++) {
|
||||||
|
const a = (k / 5) * TAU + 0.3;
|
||||||
|
ctx.beginPath(); ctx.ellipse(c + Math.cos(a) * r * 0.45, c + Math.sin(a) * r * 0.45, r * 0.17, r * 0.11, a, 0, TAU); ctx.fill();
|
||||||
|
}
|
||||||
|
ctx.fillStyle = '#e8c878';
|
||||||
|
ctx.beginPath(); ctx.arc(c, c, r * 0.18, 0, TAU); ctx.fill();
|
||||||
|
ctx.strokeStyle = '#3a2608'; ctx.lineWidth = 2; ctx.stroke();
|
||||||
|
ctx.fillStyle = '#1a1006';
|
||||||
|
ctx.beginPath(); ctx.arc(c, c, r * 0.06, 0, TAU); ctx.fill();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function bakeBell(scene) {
|
||||||
|
return canvasTex(scene, 'lb-bell', 200, 200, (ctx) => {
|
||||||
|
ctx.strokeStyle = '#3a2608'; ctx.lineWidth = 6;
|
||||||
|
ctx.beginPath(); ctx.arc(100, 18, 12, 0, TAU); ctx.stroke();
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(78, 30);
|
||||||
|
ctx.bezierCurveTo(46, 34, 52, 110, 34, 150);
|
||||||
|
ctx.quadraticCurveTo(22, 168, 12, 176);
|
||||||
|
ctx.lineTo(188, 176);
|
||||||
|
ctx.quadraticCurveTo(178, 168, 166, 150);
|
||||||
|
ctx.bezierCurveTo(148, 110, 154, 34, 122, 30);
|
||||||
|
ctx.closePath();
|
||||||
|
const g = ctx.createLinearGradient(12, 0, 188, 0);
|
||||||
|
g.addColorStop(0, '#5a3a10'); g.addColorStop(0.3, '#f3d58a'); g.addColorStop(0.45, '#fff2c8');
|
||||||
|
g.addColorStop(0.7, '#b08030'); g.addColorStop(1, '#4a2e08');
|
||||||
|
ctx.fillStyle = g; ctx.fill();
|
||||||
|
ctx.strokeStyle = '#3a2608'; ctx.lineWidth = 3; ctx.stroke();
|
||||||
|
ctx.strokeStyle = 'rgba(58,38,8,0.55)'; ctx.lineWidth = 2;
|
||||||
|
for (const y of [56, 150, 164]) {
|
||||||
|
ctx.beginPath(); ctx.moveTo(30, y); ctx.quadraticCurveTo(100, y + 8, 170, y); ctx.stroke();
|
||||||
|
}
|
||||||
|
ctx.fillStyle = '#2a1a06';
|
||||||
|
ctx.beginPath(); ctx.ellipse(100, 178, 86, 10, 0, 0, TAU); ctx.fill();
|
||||||
|
ctx.fillStyle = '#5a3a10';
|
||||||
|
ctx.beginPath(); ctx.arc(100, 186, 11, 0, TAU); ctx.fill();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export class LibertyBelleProps {
|
||||||
|
constructor(stage) {
|
||||||
|
this.stage = stage;
|
||||||
|
this.scene = stage.scene;
|
||||||
|
this.m = stage.m;
|
||||||
|
this.A = stage.A;
|
||||||
|
this.D = stage.D;
|
||||||
|
this.g = stage.g;
|
||||||
|
this.view = null;
|
||||||
|
this.t = 0;
|
||||||
|
this.ownsLever = true;
|
||||||
|
this.below = this.g.win.y + this.g.win.h + 26;
|
||||||
|
// Clockwork state: master angle θ drives every gear.
|
||||||
|
this.theta = 0;
|
||||||
|
this.omega = 0;
|
||||||
|
this.mode = 'tick'; // tick · whir · wind-down
|
||||||
|
this.lastSwing = 1;
|
||||||
|
this.cupCoins = [];
|
||||||
|
this.tingMs = 0;
|
||||||
|
this.plaqueMs = 0;
|
||||||
|
this.leverMs = 0;
|
||||||
|
bakeBell(this.scene);
|
||||||
|
this.buildCrest();
|
||||||
|
this.buildSconces();
|
||||||
|
this.buildClockwork();
|
||||||
|
this.buildBell();
|
||||||
|
this.buildCoinRun();
|
||||||
|
this.buildSplitFlap();
|
||||||
|
this.buildAwardCard();
|
||||||
|
this.buildPlaque();
|
||||||
|
this.lever = new ChromeLever(this, {
|
||||||
|
rod: [0x8a6a2a, 0xf3d58a], knob: [0x2a1406, 0x6a3a18, 0xc08a5a], housing: [0x7a5418, 0xc8a04a],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
sym(id) { return textureKeyFor(this.scene, this.m.id, id); }
|
||||||
|
|
||||||
|
// ── Iron crest with the 5¢ coin slot ───────────────────────────────────────
|
||||||
|
buildCrest() {
|
||||||
|
const { scene } = this;
|
||||||
|
const cx = GAME_WIDTH / 2; const base = this.g.cab.y + 4;
|
||||||
|
const g = scene.add.graphics().setDepth(this.D.cab + 1);
|
||||||
|
const pts = [];
|
||||||
|
for (let i = 0; i <= 40; i++) {
|
||||||
|
const t = i / 40;
|
||||||
|
pts.push({ x: cx - 230 + t * 460, y: base - Math.sin(t * Math.PI) * 70 });
|
||||||
|
}
|
||||||
|
g.fillStyle(0x1c1e1a, 1); g.fillPoints([...pts, { x: cx + 230, y: base }, { x: cx - 230, y: base }], true);
|
||||||
|
g.lineStyle(4, 0xc8a04a, 1); g.strokePoints(pts, false);
|
||||||
|
g.lineStyle(2, 0xc8a04a, 0.8);
|
||||||
|
for (const side of [-1, 1]) {
|
||||||
|
for (let k = 0; k < 2; k++) {
|
||||||
|
const x = cx + side * (120 + k * 60); const y = base - 26;
|
||||||
|
g.beginPath();
|
||||||
|
for (let a = 0; a <= Math.PI * 2.6; a += 0.2) {
|
||||||
|
const rr = 16 * (1 - a / (Math.PI * 3));
|
||||||
|
g.lineTo(x + Math.cos(a * side) * rr, y + Math.sin(a * side) * rr);
|
||||||
|
}
|
||||||
|
g.strokePath();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
brassFill(g, cx - 36, base - 46, 72, 22, 6);
|
||||||
|
g.fillStyle(0x0a0806, 1); g.fillRoundedRect(cx - 24, base - 39, 48, 8, 3);
|
||||||
|
scene.add.text(cx, base - 58, '5¢', {
|
||||||
|
fontFamily: SERIF, fontSize: '20px', color: '#e8c878', fontStyle: 'bold',
|
||||||
|
}).setOrigin(0.5).setDepth(this.D.cab + 1.1);
|
||||||
|
this.slot = { x: cx, y: base - 35 };
|
||||||
|
}
|
||||||
|
|
||||||
|
dropNickel() {
|
||||||
|
const { scene } = this;
|
||||||
|
const s = this.slot;
|
||||||
|
const coin = scene.add.image(s.x, -30, 'slots-coin-p').setScale(1.1).setDepth(this.D.cab + 1.2);
|
||||||
|
scene.tweens.add({
|
||||||
|
targets: coin, y: s.y - 6, angle: 360, duration: 380, ease: 'Quad.in',
|
||||||
|
onComplete: () => {
|
||||||
|
coin.setAngle(0);
|
||||||
|
scene.tweens.add({ targets: coin, y: s.y + 2, scaleY: 0.2, alpha: 0, duration: 130, onComplete: () => coin.destroy() });
|
||||||
|
this.stage.sound('coinIn', () => playSound(scene, SFX.KART_COIN));
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Gas-lamp sconces flanking the marquee ──────────────────────────────────
|
||||||
|
buildSconces() {
|
||||||
|
const { scene } = this;
|
||||||
|
const { cab } = this.g;
|
||||||
|
this.sconces = [cab.x - 36, cab.x + cab.w + 36].map((x, i) => {
|
||||||
|
const y = 196; const edge = i === 0 ? cab.x : cab.x + cab.w;
|
||||||
|
const g = scene.add.graphics().setDepth(this.D.cab + 2.5);
|
||||||
|
g.lineStyle(6, 0x2a1e10, 1); g.lineBetween(edge, y + 44, x, y + 44);
|
||||||
|
g.lineStyle(3, 0xc8a04a, 1); g.lineBetween(edge, y + 41, x, y + 41);
|
||||||
|
brassFill(g, x - 16, y + 34, 32, 16, 4);
|
||||||
|
g.fillStyle(0xfff4d8, 0.35); g.fillRoundedRect(x - 14, y - 22, 28, 56, 10);
|
||||||
|
g.lineStyle(2, 0xc8a04a, 0.9); g.strokeRoundedRect(x - 14, y - 22, 28, 56, 10);
|
||||||
|
const glow = scene.add.image(x, y + 10, 'slots-glow').setDisplaySize(320, 320).setTint(0xffa040)
|
||||||
|
.setBlendMode(ADD).setAlpha(0.45).setDepth(this.D.cab + 2.4);
|
||||||
|
scene.add.particles(x, y + 26, 'slots-glow', {
|
||||||
|
speedY: { min: -60, max: -30 }, speedX: { min: -6, max: 6 }, lifespan: { min: 250, max: 450 },
|
||||||
|
scale: { start: 0.14, end: 0.02 }, alpha: { start: 0.9, end: 0 },
|
||||||
|
tint: [0xfff0a0, 0xffb040, 0x6ab0ff], blendMode: 'ADD', frequency: 40,
|
||||||
|
}).setDepth(this.D.cab + 2.6);
|
||||||
|
return { glow, ph: Math.random() * 10 };
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Clockwork inspection window (left gutter) ──────────────────────────────
|
||||||
|
buildClockwork() {
|
||||||
|
const { scene } = this;
|
||||||
|
const { cab } = this.g;
|
||||||
|
const cx = Math.round(cab.x / 2);
|
||||||
|
const fx = cx - 215; const fy = 150; const fw = 430; const fh = 660;
|
||||||
|
const depth = this.D.cab + 1;
|
||||||
|
const g = scene.add.graphics().setDepth(depth);
|
||||||
|
brassFill(g, fx, fy, fw, fh, 26);
|
||||||
|
g.fillStyle(0x14100a, 1); g.fillRoundedRect(fx + 14, fy + 14, fw - 28, fh - 28, 18);
|
||||||
|
g.fillStyle(0x2a1e10, 0.6); g.fillCircle(cx, fy + fh * 0.45, 200);
|
||||||
|
g.fillStyle(0xc8a04a, 1);
|
||||||
|
for (const [x, y] of [[fx + 26, fy + 26], [fx + fw - 26, fy + 26], [fx + 26, fy + fh - 26], [fx + fw - 26, fy + fh - 26]]) {
|
||||||
|
g.fillCircle(x, y, 6);
|
||||||
|
}
|
||||||
|
// Gear train: centres chained so each pair meshes at pitch radius.
|
||||||
|
const ox = cx - 285; // layout authored for a gutter centre of 285
|
||||||
|
const specs = [
|
||||||
|
{ x: 230, y: 330, r: 110, t: 22 },
|
||||||
|
{ x: 339, y: 460, r: 60, t: 12 },
|
||||||
|
{ x: 264, y: 590, r: 90, t: 18 },
|
||||||
|
{ x: 391, y: 636, r: 45, t: 9 },
|
||||||
|
];
|
||||||
|
this.gears = specs.map((sp, i) => {
|
||||||
|
const img = scene.add.image(sp.x + ox, sp.y, bakeGear(scene, sp.r, sp.t)).setDepth(depth + 0.2 + i * 0.01);
|
||||||
|
return { ...sp, x: sp.x + ox, img, off: 0 };
|
||||||
|
});
|
||||||
|
// Phase offsets so teeth interleave at each contact point.
|
||||||
|
for (let i = 1; i < this.gears.length; i++) {
|
||||||
|
const a = this.gears[i - 1]; const b = this.gears[i];
|
||||||
|
const phi = Math.atan2(b.y - a.y, b.x - a.x);
|
||||||
|
const pitchA = TAU / a.t;
|
||||||
|
const f = (((phi - a.off) % pitchA) + pitchA) % pitchA / pitchA;
|
||||||
|
b.off = phi + Math.PI + (0.5 - f) * (TAU / b.t);
|
||||||
|
}
|
||||||
|
// Pendulum + escapement anchor.
|
||||||
|
this.pend = { x: 130 + ox, y: 560 };
|
||||||
|
this.pendG = scene.add.graphics().setDepth(depth + 0.3);
|
||||||
|
scene.add.image(cx, fy + fh / 2, 'slots-gloss').setDisplaySize(150, fh * 1.4).setAngle(22)
|
||||||
|
.setBlendMode(ADD).setAlpha(0.07).setDepth(depth + 0.5);
|
||||||
|
scene.add.text(cx, fy + fh - 34, 'SAN FRANCISCO · 1899', {
|
||||||
|
fontFamily: SERIF, fontSize: '17px', color: '#e8c878', fontStyle: 'italic',
|
||||||
|
}).setOrigin(0.5).setDepth(depth + 0.4);
|
||||||
|
this.applyGears();
|
||||||
|
}
|
||||||
|
|
||||||
|
applyGears() {
|
||||||
|
const t1 = this.gears[0].t;
|
||||||
|
this.gears.forEach((gr, i) => {
|
||||||
|
const dir = i % 2 === 0 ? 1 : -1;
|
||||||
|
gr.img.setRotation(dir * this.theta * (t1 / gr.t) + gr.off);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
drawPendulum(angle) {
|
||||||
|
const p = this.pend;
|
||||||
|
const L = 170;
|
||||||
|
const bx = p.x + Math.sin(angle) * L; const by = p.y + Math.cos(angle) * L;
|
||||||
|
const g = this.pendG;
|
||||||
|
g.clear();
|
||||||
|
g.lineStyle(5, 0xc8a04a, 1); g.lineBetween(p.x, p.y, bx, by);
|
||||||
|
g.fillStyle(0x7a5418, 1); g.fillCircle(bx, by, 24);
|
||||||
|
g.fillStyle(0xf3d58a, 1); g.fillCircle(bx - 5, by - 5, 16);
|
||||||
|
// Anchor rocking with the pendulum.
|
||||||
|
const aw = 46;
|
||||||
|
const ax = Math.cos(angle) * aw; const ay = -Math.sin(angle) * aw;
|
||||||
|
g.lineStyle(6, 0xb08030, 1);
|
||||||
|
g.lineBetween(p.x - ax, p.y - 26 - ay * 0.4, p.x, p.y - 4);
|
||||||
|
g.lineBetween(p.x + ax, p.y - 26 + ay * 0.4, p.x, p.y - 4);
|
||||||
|
g.fillStyle(0xe8c878, 1); g.fillCircle(p.x, p.y, 7);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── The bell (right gutter) ────────────────────────────────────────────────
|
||||||
|
buildBell() {
|
||||||
|
const { scene } = this;
|
||||||
|
const { cab } = this.g;
|
||||||
|
const bx = cab.x + cab.w + 330; const by = 250;
|
||||||
|
const depth = this.D.cab + 1;
|
||||||
|
const g = scene.add.graphics().setDepth(depth);
|
||||||
|
// Wrought-iron scroll bracket from a wall plate.
|
||||||
|
g.fillStyle(0x1c1e1a, 1); g.fillRoundedRect(bx - 150, by - 40, 22, 120, 6);
|
||||||
|
g.lineStyle(7, 0x1c1e1a, 1);
|
||||||
|
g.beginPath(); g.moveTo(bx - 128, by - 16); g.lineTo(bx + 6, by - 16); g.strokePath();
|
||||||
|
g.beginPath(); g.moveTo(bx - 128, by + 50);
|
||||||
|
for (let a = 0; a <= Math.PI * 0.9; a += 0.1) g.lineTo(bx - 128 + Math.sin(a) * 90, by + 50 - (1 - Math.cos(a)) * 34);
|
||||||
|
g.strokePath();
|
||||||
|
g.lineStyle(2, 0xc8a04a, 0.8);
|
||||||
|
g.beginPath(); g.moveTo(bx - 128, by - 19); g.lineTo(bx + 6, by - 19); g.strokePath();
|
||||||
|
this.bell = scene.add.image(bx, by - 14, 'lb-bell').setOrigin(0.5, 0.06).setDisplaySize(190, 190).setDepth(depth + 0.1);
|
||||||
|
this.bellGlow = scene.add.image(bx, by + 80, 'slots-glow').setDisplaySize(360, 300).setTint(0xffd27a)
|
||||||
|
.setBlendMode(ADD).setAlpha(0).setDepth(depth + 0.05);
|
||||||
|
// Striker hammer on its own arm.
|
||||||
|
this.hammer = { px: bx + 128, py: by + 40, base: -0.9 };
|
||||||
|
this.hammerG = scene.add.graphics().setDepth(depth + 0.2);
|
||||||
|
this.drawHammer(this.hammer.base);
|
||||||
|
this.bellPos = { x: bx, y: by };
|
||||||
|
}
|
||||||
|
|
||||||
|
drawHammer(a) {
|
||||||
|
const h = this.hammer;
|
||||||
|
const L = 74;
|
||||||
|
const ex = h.px - Math.cos(a) * L; const ey = h.py + Math.sin(a) * L;
|
||||||
|
const g = this.hammerG;
|
||||||
|
g.clear();
|
||||||
|
g.lineStyle(6, 0x2a1e10, 1); g.lineBetween(h.px, h.py, ex, ey);
|
||||||
|
g.fillStyle(0x7a5418, 1); g.fillCircle(ex, ey, 11);
|
||||||
|
g.fillStyle(0xf3d58a, 1); g.fillCircle(ex - 3, ey - 3, 6);
|
||||||
|
g.fillStyle(0x1c1e1a, 1); g.fillCircle(h.px, h.py, 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
async ringBell(times = 1, soft = false) {
|
||||||
|
const { scene } = this;
|
||||||
|
for (let k = 0; k < times; k++) {
|
||||||
|
const st = { a: this.hammer.base };
|
||||||
|
await new Promise((res) => scene.tweens.add({
|
||||||
|
targets: st, a: 0.15, duration: 110, ease: 'Quad.in', onUpdate: () => this.drawHammer(st.a), onComplete: res,
|
||||||
|
}));
|
||||||
|
this.stage.sound('bell', () => playSound(scene, SFX.UI_CHIME), soft ? { volume: 0.35 } : undefined);
|
||||||
|
scene.tweens.killTweensOf(this.bell);
|
||||||
|
this.bell.setAngle(0);
|
||||||
|
scene.tweens.chain({ targets: this.bell, tweens: [
|
||||||
|
{ angle: soft ? 3 : 9, duration: 120, ease: 'Sine.out' },
|
||||||
|
{ angle: soft ? -2 : -6, duration: 200, ease: 'Sine.inOut' },
|
||||||
|
{ angle: soft ? 1 : 3, duration: 200, ease: 'Sine.inOut' },
|
||||||
|
{ angle: 0, duration: 220, ease: 'Sine.inOut' },
|
||||||
|
] });
|
||||||
|
if (!soft) {
|
||||||
|
scene.tweens.add({ targets: this.bellGlow, alpha: { from: 0.8, to: 0 }, duration: 700 });
|
||||||
|
for (let r = 0; r < 2; r++) {
|
||||||
|
const ring = scene.add.ellipse(this.bellPos.x, this.bellPos.y + 90, 220, 170).setStrokeStyle(3, 0xffd27a, 0.8)
|
||||||
|
.setDepth(this.D.cab + 1.3);
|
||||||
|
scene.tweens.add({ targets: ring, scale: 1.8, alpha: 0, duration: 800, delay: r * 180, onComplete: () => ring.destroy() });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
scene.tweens.add({ targets: st, a: this.hammer.base, duration: 260, ease: 'Quad.out', onUpdate: () => this.drawHammer(st.a) });
|
||||||
|
await wait(scene, soft ? 200 : 300);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Coin run + payout cup (right gutter, below the bell) ───────────────────
|
||||||
|
buildCoinRun() {
|
||||||
|
const { scene } = this;
|
||||||
|
const { cab } = this.g;
|
||||||
|
const depth = this.D.cab + 1;
|
||||||
|
const x0 = cab.x + cab.w + 14; const x1 = 1864;
|
||||||
|
const spout = { x: cab.x + cab.w - 4, y: 652 };
|
||||||
|
this.runPath = [
|
||||||
|
{ x: spout.x + 18, y: spout.y + 6 }, { x: x1, y: 700 }, // rail A (down to the right)
|
||||||
|
{ x: x1, y: 742 }, { x: x0 + 110, y: 790 }, // drop, rail B (down to the left)
|
||||||
|
{ x: x0 + 110, y: 850 }, // drop into the cup
|
||||||
|
];
|
||||||
|
const g = scene.add.graphics().setDepth(depth);
|
||||||
|
brassFill(g, spout.x - 6, spout.y - 14, 40, 26, 6);
|
||||||
|
const rail = (a, b) => {
|
||||||
|
g.lineStyle(9, 0x3a2608, 1); g.lineBetween(a.x, a.y + 14, b.x, b.y + 14);
|
||||||
|
g.lineStyle(5, 0xc8a04a, 1); g.lineBetween(a.x, a.y + 12, b.x, b.y + 12);
|
||||||
|
g.lineStyle(2, 0xf3d58a, 0.9); g.lineBetween(a.x, a.y + 10, b.x, b.y + 10);
|
||||||
|
};
|
||||||
|
rail(this.runPath[0], this.runPath[1]);
|
||||||
|
rail(this.runPath[2], this.runPath[3]);
|
||||||
|
g.lineStyle(5, 0x3a2608, 1); g.lineBetween(x1 + 8, 690, x1 + 8, 760); // end stop
|
||||||
|
// Cup.
|
||||||
|
const cx = x0 + 110; const cy = 868;
|
||||||
|
this.cup = { x: cx, y: cy, depth };
|
||||||
|
g.fillStyle(0x1a1006, 1); g.fillEllipse(cx, cy - 22, 130, 26);
|
||||||
|
this.cupFront = scene.add.graphics().setDepth(depth + 0.3);
|
||||||
|
this.cupFront.fillStyle(BRASS[1], 1);
|
||||||
|
this.cupFront.beginPath();
|
||||||
|
this.cupFront.moveTo(cx - 66, cy - 22); this.cupFront.lineTo(cx + 66, cy - 22);
|
||||||
|
this.cupFront.lineTo(cx + 46, cy + 30); this.cupFront.lineTo(cx - 46, cy + 30);
|
||||||
|
this.cupFront.closePath(); this.cupFront.fillPath();
|
||||||
|
this.cupFront.fillStyle(BRASS[2], 0.8); this.cupFront.fillRect(cx - 62, cy - 22, 124, 8);
|
||||||
|
this.cupFront.lineStyle(2, 0x3a2608, 1); this.cupFront.strokeRect(cx - 62, cy - 22, 124, 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
rollCoins(n) {
|
||||||
|
const { scene } = this;
|
||||||
|
const pts = this.runPath;
|
||||||
|
let L = 0;
|
||||||
|
const seg = [];
|
||||||
|
for (let i = 1; i < pts.length; i++) { const d = Math.hypot(pts[i].x - pts[i - 1].x, pts[i].y - pts[i - 1].y); seg.push(d); L += d; }
|
||||||
|
const at = (s) => {
|
||||||
|
let i = 0;
|
||||||
|
while (i < seg.length - 1 && s > seg[i]) { s -= seg[i]; i++; }
|
||||||
|
const f = Math.min(1, s / seg[i]);
|
||||||
|
return { x: pts[i].x + (pts[i + 1].x - pts[i].x) * f, y: pts[i].y + (pts[i + 1].y - pts[i].y) * f };
|
||||||
|
};
|
||||||
|
for (let k = 0; k < n; k++) {
|
||||||
|
scene.time.delayedCall(k * 150, () => {
|
||||||
|
const coin = scene.add.image(pts[0].x, pts[0].y, 'slots-coin-p').setScale(0.85).setDepth(this.D.cab + 1.25);
|
||||||
|
const carrier = { s: 0 };
|
||||||
|
scene.tweens.add({
|
||||||
|
targets: carrier, s: L, duration: (L / 560) * 1000, ease: 'Linear',
|
||||||
|
onUpdate: () => { const p = at(carrier.s); coin.setPosition(p.x, p.y); coin.rotation = carrier.s / 11; },
|
||||||
|
onComplete: () => {
|
||||||
|
const c = this.cup;
|
||||||
|
coin.setDepth(c.depth + 0.1 + this.cupCoins.length * 0.0001).setRotation(0).setScale(0.85, 0.5);
|
||||||
|
const y = c.y - 24 - Math.min(16, this.cupCoins.length * 0.6) - Math.random() * 4;
|
||||||
|
coin.setPosition(c.x + (Math.random() - 0.5) * 80, y);
|
||||||
|
this.cupCoins.push(coin);
|
||||||
|
if (this.cupCoins.length > 36) {
|
||||||
|
const old = this.cupCoins.shift();
|
||||||
|
scene.tweens.add({ targets: old, alpha: 0, duration: 300, onComplete: () => old.destroy() });
|
||||||
|
}
|
||||||
|
if (k % 2 === 0) this.stage.sound('coins', () => playSound(scene, SFX.COINS));
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Split-flap PAID display ────────────────────────────────────────────────
|
||||||
|
buildSplitFlap() {
|
||||||
|
const { scene } = this;
|
||||||
|
const cx = GAME_WIDTH / 2; const y = this.below + 30;
|
||||||
|
const depth = this.D.cab + 3;
|
||||||
|
const g = scene.add.graphics().setDepth(depth);
|
||||||
|
brassFill(g, cx - 190, y - 28, 380, 56, 10);
|
||||||
|
scene.add.text(cx - 118, y, 'PAID', {
|
||||||
|
fontFamily: SERIF, fontSize: '24px', color: '#2a1406', fontStyle: 'bold',
|
||||||
|
}).setOrigin(0.5).setDepth(depth + 0.1);
|
||||||
|
this.flaps = Array.from({ length: 4 }, (_, k) => {
|
||||||
|
const x = cx - 40 + k * 44;
|
||||||
|
const ct = scene.add.container(x, y).setDepth(depth + 0.1);
|
||||||
|
const card = scene.add.graphics();
|
||||||
|
card.fillStyle(0x14100a, 1); card.fillRoundedRect(-19, -22, 38, 44, 4);
|
||||||
|
card.fillStyle(0x2a2218, 1); card.fillRoundedRect(-17, -20, 34, 19, 3);
|
||||||
|
const txt = scene.add.text(0, 1, '0', { fontFamily: SERIF, fontSize: '30px', color: '#f2e2b8' }).setOrigin(0.5);
|
||||||
|
const line = scene.add.rectangle(0, 0, 38, 2, 0x000000, 0.9);
|
||||||
|
ct.add([card, txt, line]);
|
||||||
|
return { ct, txt, d: '0' };
|
||||||
|
});
|
||||||
|
this.flapValue = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
setFlaps(v, animate = true) {
|
||||||
|
const s = String(Math.min(9999, Math.floor(v))).padStart(4, '0');
|
||||||
|
this.flaps.forEach((f, i) => {
|
||||||
|
const d = s[i];
|
||||||
|
if (d === f.d) return;
|
||||||
|
f.d = d;
|
||||||
|
if (!animate) { f.txt.setText(d); return; }
|
||||||
|
this.scene.tweens.add({
|
||||||
|
targets: f.ct, scaleY: 0, duration: 55, ease: 'Quad.in',
|
||||||
|
onComplete: () => {
|
||||||
|
f.txt.setText(d);
|
||||||
|
this.scene.tweens.add({ targets: f.ct, scaleY: 1, duration: 55, ease: 'Quad.out' });
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async countFlaps(total) {
|
||||||
|
const steps = Math.min(30, Math.max(1, Math.ceil(total)));
|
||||||
|
for (let k = 1; k <= steps; k++) {
|
||||||
|
this.setFlaps((total * k) / steps);
|
||||||
|
if (k % 2 === 0) playSound(this.scene, SFX.PIECE_CLICK);
|
||||||
|
await wait(this.scene, 70);
|
||||||
|
}
|
||||||
|
this.setFlaps(total);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Award card + plaque ────────────────────────────────────────────────────
|
||||||
|
buildAwardCard() {
|
||||||
|
const { scene } = this;
|
||||||
|
const cx = GAME_WIDTH / 2; const top = this.below + 62; const w = 600; const h = 118;
|
||||||
|
const depth = this.D.cab + 3;
|
||||||
|
const g = scene.add.graphics().setDepth(depth);
|
||||||
|
brassFill(g, cx - w / 2 - 8, top - 8, w + 16, h + 16, 10);
|
||||||
|
g.fillStyle(0xf2e2b8, 1); g.fillRect(cx - w / 2, top, w, h);
|
||||||
|
g.lineStyle(2, 0x7a5418, 0.8); g.strokeRect(cx - w / 2 + 6, top + 6, w - 12, h - 12);
|
||||||
|
scene.add.text(cx, top + 18, '~ PAYS FOR ONE NICKEL ~', {
|
||||||
|
fontFamily: SERIF, fontSize: '15px', color: '#5a2a0a', fontStyle: 'italic',
|
||||||
|
}).setOrigin(0.5).setDepth(depth + 0.1);
|
||||||
|
const pt = this.m.paytable;
|
||||||
|
const syms = ['bell', 'horseshoe', 'star', 'heart', 'diamond', 'spade'];
|
||||||
|
syms.forEach((sym, i) => {
|
||||||
|
const col = i < 3 ? 0 : 1; const r = i % 3;
|
||||||
|
const x = cx - w / 4 + col * (w / 2) - 120; const y = top + 46 + r * 26;
|
||||||
|
scene.add.image(x, y, this.sym(sym)).setDisplaySize(24, 24).setDepth(depth + 0.1);
|
||||||
|
scene.add.text(x + 20, y, `×3 ${pt[sym][3]}`, { fontFamily: SERIF, fontSize: '16px', color: '#2a1406' })
|
||||||
|
.setOrigin(0, 0.5).setDepth(depth + 0.1);
|
||||||
|
if (pt[sym][2] !== undefined) {
|
||||||
|
scene.add.text(x + 130, y, `×2 ${pt[sym][2]}`, { fontFamily: SERIF, fontSize: '16px', color: '#5a3a1a' })
|
||||||
|
.setOrigin(0, 0.5).setDepth(depth + 0.1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
buildPlaque() {
|
||||||
|
const { scene } = this;
|
||||||
|
const cx = GAME_WIDTH / 2; const y = this.below + 214;
|
||||||
|
const depth = this.D.cab + 3;
|
||||||
|
const g = scene.add.graphics().setDepth(depth);
|
||||||
|
brassFill(g, cx - 140, y - 16, 280, 32, 6);
|
||||||
|
scene.add.text(cx, y, 'PULL THE LEVER', {
|
||||||
|
fontFamily: SERIF, fontSize: '17px', color: '#2a1406', fontStyle: 'bold',
|
||||||
|
}).setOrigin(0.5).setDepth(depth + 0.1);
|
||||||
|
const maskG = scene.make.graphics({ add: false });
|
||||||
|
maskG.fillStyle(0xffffff); maskG.fillRect(cx - 140, y - 16, 280, 32);
|
||||||
|
this.plaqueGlint = scene.add.image(cx - 180, y, 'slots-gloss').setDisplaySize(50, 80).setAngle(20)
|
||||||
|
.setBlendMode(ADD).setAlpha(0.8).setDepth(depth + 0.2).setMask(maskG.createGeometryMask());
|
||||||
|
this.plaqueX = cx;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Hooks ──────────────────────────────────────────────────────────────────
|
||||||
|
onReels(view) { this.view = view; }
|
||||||
|
|
||||||
|
onSpinStart() {
|
||||||
|
this.dropNickel();
|
||||||
|
if (!this.lever.pulling) this.lever.pull();
|
||||||
|
this.setFlaps(0, false);
|
||||||
|
this.mode = 'whir';
|
||||||
|
this.stage.sound('whir');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Each reel stop locks the clockwork down a notch with a jolt.
|
||||||
|
onReelStop() {
|
||||||
|
this.omega *= 0.62;
|
||||||
|
this.theta -= 0.06;
|
||||||
|
}
|
||||||
|
|
||||||
|
onLanded() { this.mode = 'wind-down'; }
|
||||||
|
|
||||||
|
onSettle(total, bet) {
|
||||||
|
const ratio = total / Math.max(1, bet);
|
||||||
|
this.countFlaps(total);
|
||||||
|
this.rollCoins(Math.min(24, 2 + Math.round(Math.sqrt(ratio) * 3)));
|
||||||
|
// 10×+ wins get the full peal from onBigMoment instead.
|
||||||
|
if (ratio < 10) this.ringBell(ratio >= 5 ? 3 : 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
async onBigMoment() {
|
||||||
|
for (const s of this.sconces) this.scene.tweens.add({ targets: s.glow, alpha: 1, duration: 200, yoyo: true, repeat: 5 });
|
||||||
|
await this.ringBell(8);
|
||||||
|
}
|
||||||
|
|
||||||
|
onAttract(on) { if (on) { this.tingMs = 5000; this.leverMs = 6000; } }
|
||||||
|
|
||||||
|
update(dt) {
|
||||||
|
const sec = dt / 1000;
|
||||||
|
this.t += sec;
|
||||||
|
// Pendulum swings continuously; each extreme advances the train one tooth.
|
||||||
|
const swing = Math.sin(this.t * Math.PI);
|
||||||
|
this.drawPendulum(swing * 0.24);
|
||||||
|
const tooth = TAU / this.gears[0].t;
|
||||||
|
if (this.mode === 'whir') {
|
||||||
|
this.omega = Math.min(11, this.omega + sec * 30);
|
||||||
|
this.theta += this.omega * sec;
|
||||||
|
} else if (this.mode === 'wind-down') {
|
||||||
|
this.omega = Math.max(0, this.omega - sec * 14);
|
||||||
|
this.theta += this.omega * sec;
|
||||||
|
if (this.omega === 0) this.mode = 'tick';
|
||||||
|
}
|
||||||
|
const extreme = Math.sign(Math.cos(this.t * Math.PI));
|
||||||
|
if (extreme !== this.lastSwing) {
|
||||||
|
this.lastSwing = extreme;
|
||||||
|
if (this.mode === 'tick') {
|
||||||
|
const from = this.theta;
|
||||||
|
const carrier = { v: from };
|
||||||
|
this.scene.tweens.add({ targets: carrier, v: from + tooth, duration: 180, ease: 'Back.out',
|
||||||
|
onUpdate: () => { if (this.mode === 'tick') { this.theta = carrier.v; } } });
|
||||||
|
if (this.stage.attracting) this.stage.sound('tick');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.applyGears();
|
||||||
|
|
||||||
|
for (const s of this.sconces) {
|
||||||
|
const f = 0.82 + 0.1 * Math.sin(this.t * 9 + s.ph) + 0.08 * Math.sin(this.t * 5.3 + s.ph * 2);
|
||||||
|
if (!this.scene.tweens.isTweening(s.glow)) s.glow.setAlpha(0.42 * f);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.plaqueMs += dt;
|
||||||
|
if (this.plaqueMs > 7000) {
|
||||||
|
this.plaqueMs = 0;
|
||||||
|
this.plaqueGlint.setX(this.plaqueX - 180);
|
||||||
|
this.scene.tweens.add({ targets: this.plaqueGlint, x: this.plaqueX + 180, duration: 900, ease: 'Sine.inOut' });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.stage.busy || !this.stage.attracting) return;
|
||||||
|
this.tingMs += dt;
|
||||||
|
if (this.tingMs > 14000) { this.tingMs = 0; this.ringBell(1, true); }
|
||||||
|
this.leverMs += dt;
|
||||||
|
if (this.leverMs > 12000) { this.leverMs = 0; this.lever.wiggle(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
shutdown() {}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,373 @@
|
||||||
|
// SlotsLucky — Lucky Sevens props for the attract kit (SlotsAttract.js).
|
||||||
|
//
|
||||||
|
// A 1975 electromechanical upright: everything is lamps, chrome and moving
|
||||||
|
// metal rather than modern animation. Top to bottom: the two-tier "candle"
|
||||||
|
// light, the bulb marquee, reel drums with the strip peeking above and below a
|
||||||
|
// red payline wire under glass glare, a "WINNER PAID" odometer whose digit
|
||||||
|
// drums roll, a backlit belly glass (pays for 1 coin, COINS PLAYED lamps, WILD
|
||||||
|
// ×2/×4 lamps), and a chrome coin tray that fills with clattering coins. A
|
||||||
|
// chrome pull lever spins the reels. The wide gutters hold Fremont-Street bulb
|
||||||
|
// signs — a giant "LUCKY 7" and a chasing arrow — wired into the same
|
||||||
|
// LightShow as the cabinet bulbs.
|
||||||
|
//
|
||||||
|
// Hooks: onReels, onSpinStart, onLanded, onSettle(total, bet), onBigMoment,
|
||||||
|
// onBet(idx, bet), onAttract, update. Nothing here decides an outcome.
|
||||||
|
|
||||||
|
import * as Phaser from 'phaser';
|
||||||
|
import { GAME_WIDTH } from '../../config.js';
|
||||||
|
import { playSound, SFX } from '../../ui/Sounds.js';
|
||||||
|
import { outline, chromeFill, ChromeLever } from './SlotsVintage.js';
|
||||||
|
|
||||||
|
const ADD = Phaser.BlendModes.ADD;
|
||||||
|
const wait = (scene, ms) => new Promise((r) => scene.time.delayedCall(ms, r));
|
||||||
|
const CREAM = '#fff4d8';
|
||||||
|
const INK = '#7a1018';
|
||||||
|
|
||||||
|
export class LuckySevensProps {
|
||||||
|
constructor(stage) {
|
||||||
|
this.stage = stage;
|
||||||
|
this.scene = stage.scene;
|
||||||
|
this.m = stage.m;
|
||||||
|
this.A = stage.A;
|
||||||
|
this.D = stage.D;
|
||||||
|
this.g = stage.g;
|
||||||
|
this.view = null;
|
||||||
|
this.t = 0;
|
||||||
|
this.coins = [];
|
||||||
|
this.odoValue = 0;
|
||||||
|
this.leverMs = 0;
|
||||||
|
this.peek = (this.g.win.h - this.g.rows * this.g.cellH) / 2;
|
||||||
|
this.paylineY = this.g.win.y + this.peek + this.g.cellH / 2;
|
||||||
|
this.below = this.g.win.y + this.g.win.h + 26; // bottom of the reel bezel
|
||||||
|
this.buildCandle();
|
||||||
|
this.buildPaylineAndGlass();
|
||||||
|
this.buildOdometer();
|
||||||
|
this.buildBelly();
|
||||||
|
this.buildTray();
|
||||||
|
this.lever = new ChromeLever(this);
|
||||||
|
this.buildSevenSign();
|
||||||
|
this.buildArrow();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Candle (two-tier light on top of the cabinet) ──────────────────────────
|
||||||
|
buildCandle() {
|
||||||
|
const { scene } = this;
|
||||||
|
const x = GAME_WIDTH / 2; const base = this.g.cab.y;
|
||||||
|
const g = scene.add.graphics().setDepth(this.D.cab + 1);
|
||||||
|
chromeFill(g, x - 30, base - 14, 60, 14, 4);
|
||||||
|
chromeFill(g, x - 34, 18, 68, 10, 4);
|
||||||
|
const tier = (y, col) => {
|
||||||
|
g.fillStyle(col, 0.85); g.fillRoundedRect(x - 28, y, 56, 33, 6);
|
||||||
|
g.lineStyle(2, 0xc8ccd4, 1); g.strokeRoundedRect(x - 28, y, 56, 33, 6);
|
||||||
|
g.lineStyle(1, 0xffffff, 0.25);
|
||||||
|
for (let k = 1; k < 4; k++) g.lineBetween(x - 28 + k * 14, y + 3, x - 28 + k * 14, y + 30);
|
||||||
|
return scene.add.image(x, y + 16, 'slots-glow').setDisplaySize(170, 120).setBlendMode(ADD)
|
||||||
|
.setTint(col).setAlpha(0.15).setDepth(this.D.cab + 1.1);
|
||||||
|
};
|
||||||
|
this.candleTop = tier(28, 0xff3a2a);
|
||||||
|
this.candleLow = tier(60, 0xfff0c8);
|
||||||
|
}
|
||||||
|
|
||||||
|
candle(mode) {
|
||||||
|
const { scene } = this;
|
||||||
|
for (const t of [this.candleTop, this.candleLow]) scene.tweens.killTweensOf(t);
|
||||||
|
if (mode === 'win') {
|
||||||
|
scene.tweens.add({ targets: this.candleLow, alpha: { from: 1, to: 0.2 }, duration: 160, yoyo: true, repeat: 5,
|
||||||
|
onComplete: () => this.candleLow.setAlpha(0.15) });
|
||||||
|
} else if (mode === 'jackpot') {
|
||||||
|
scene.tweens.add({ targets: this.candleTop, alpha: { from: 1, to: 0.1 }, duration: 200, yoyo: true, repeat: 9,
|
||||||
|
onComplete: () => this.candleTop.setAlpha(0.15) });
|
||||||
|
scene.tweens.add({ targets: this.candleLow, alpha: { from: 0.1, to: 1 }, duration: 200, yoyo: true, repeat: 9,
|
||||||
|
onComplete: () => this.candleLow.setAlpha(0.15) });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Payline wire + glass glare over the reel window ────────────────────────
|
||||||
|
buildPaylineAndGlass() {
|
||||||
|
const { scene } = this;
|
||||||
|
const { win } = this.g;
|
||||||
|
const y = this.paylineY;
|
||||||
|
const depth = this.D.reel + 2.6;
|
||||||
|
const g = scene.add.graphics().setDepth(depth);
|
||||||
|
g.lineStyle(5, 0xff3a2a, 0.35); g.lineBetween(win.x - 14, y, win.x + win.w + 14, y);
|
||||||
|
g.lineStyle(2, 0xff6a4a, 0.9); g.lineBetween(win.x - 14, y, win.x + win.w + 14, y);
|
||||||
|
chromeFill(g, win.x - 30, y - 12, 18, 24, 4);
|
||||||
|
chromeFill(g, win.x + win.w + 12, y - 12, 18, 24, 4);
|
||||||
|
const maskG = scene.make.graphics({ add: false });
|
||||||
|
maskG.fillStyle(0xffffff); maskG.fillRect(win.x, win.y, win.w, win.h);
|
||||||
|
scene.add.image(win.x + win.w * 0.3, win.y + win.h / 2, 'slots-gloss')
|
||||||
|
.setDisplaySize(150, win.h * 1.8).setAngle(24).setBlendMode(ADD).setAlpha(0.1).setDepth(depth + 0.1)
|
||||||
|
.setMask(maskG.createGeometryMask());
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── WINNER PAID odometer: five rolling digit drums ─────────────────────────
|
||||||
|
buildOdometer() {
|
||||||
|
const { scene } = this;
|
||||||
|
const cx = GAME_WIDTH / 2; const y = this.below + 30;
|
||||||
|
const depth = this.D.cab + 3;
|
||||||
|
const dw = 30; const dh = 40; const n = 5;
|
||||||
|
const x0 = cx - 40;
|
||||||
|
const g = scene.add.graphics().setDepth(depth);
|
||||||
|
chromeFill(g, cx - 200, y - 26, 400, 52, 10);
|
||||||
|
g.fillStyle(0x14100a, 1); g.fillRoundedRect(x0 - 6, y - dh / 2 - 4, n * dw + 12, dh + 8, 6);
|
||||||
|
scene.add.text(cx - 118, y, 'WINNER\nPAID', {
|
||||||
|
fontFamily: 'Righteous', fontSize: '15px', color: '#3a1010', align: 'center', lineSpacing: -4,
|
||||||
|
}).setOrigin(0.5).setDepth(depth + 0.1);
|
||||||
|
const maskG = scene.make.graphics({ add: false });
|
||||||
|
maskG.fillStyle(0xffffff); maskG.fillRect(x0, y - dh / 2, n * dw, dh);
|
||||||
|
const mask = maskG.createGeometryMask();
|
||||||
|
this.odoDigits = [];
|
||||||
|
for (let k = 0; k < n; k++) {
|
||||||
|
const x = x0 + k * dw + dw / 2;
|
||||||
|
const drum = scene.add.graphics().setDepth(depth + 0.05);
|
||||||
|
drum.fillStyle(0xf6f0e0, 1); drum.fillRect(x - dw / 2 + 1, y - dh / 2, dw - 2, dh);
|
||||||
|
const col = scene.add.container(x, y).setDepth(depth + 0.1).setMask(mask);
|
||||||
|
for (let d = 0; d <= 10; d++) {
|
||||||
|
col.add(scene.add.text(0, d * dh, String(d % 10), {
|
||||||
|
fontFamily: 'Righteous', fontSize: '30px', color: '#1a1410',
|
||||||
|
}).setOrigin(0.5));
|
||||||
|
}
|
||||||
|
this.odoDigits.push(col);
|
||||||
|
}
|
||||||
|
const shade = scene.add.graphics().setDepth(depth + 0.2);
|
||||||
|
shade.fillGradientStyle(0x000000, 0x000000, 0x000000, 0x000000, 0.55, 0.55, 0, 0);
|
||||||
|
shade.fillRect(x0, y - dh / 2, n * dw, 12);
|
||||||
|
shade.fillGradientStyle(0x000000, 0x000000, 0x000000, 0x000000, 0, 0, 0.55, 0.55);
|
||||||
|
shade.fillRect(x0, y + dh / 2 - 12, n * dw, 12);
|
||||||
|
this.odoDh = dh;
|
||||||
|
this.setOdometer(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// True odometer motion: the ones drum turns continuously, higher drums
|
||||||
|
// only advance as the drum below rolls from 9 to 0.
|
||||||
|
setOdometer(v) {
|
||||||
|
this.odoValue = v;
|
||||||
|
const n = this.odoDigits.length;
|
||||||
|
for (let k = 0; k < n; k++) {
|
||||||
|
const place = 10 ** k;
|
||||||
|
let pos;
|
||||||
|
if (k === 0) pos = v % 10;
|
||||||
|
else {
|
||||||
|
const base = Math.floor(v / place) % 10;
|
||||||
|
const carry = Math.max(0, (v % place) - (place - 1));
|
||||||
|
pos = base + carry;
|
||||||
|
}
|
||||||
|
this.odoDigits[n - 1 - k].y = this.below + 30 - pos * this.odoDh;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rollOdometer(to) {
|
||||||
|
const carrier = { v: 0 };
|
||||||
|
this.scene.tweens.add({
|
||||||
|
targets: carrier, v: to, duration: Math.min(2200, 400 + to * 3), ease: 'Sine.out',
|
||||||
|
onUpdate: () => this.setOdometer(carrier.v),
|
||||||
|
onComplete: () => this.setOdometer(to),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Backlit belly glass ────────────────────────────────────────────────────
|
||||||
|
buildBelly() {
|
||||||
|
const { scene } = this;
|
||||||
|
const { cab } = this.g;
|
||||||
|
const top = this.below + 60; const h = 120;
|
||||||
|
const x0 = cab.x + 46; const w = cab.w - 92;
|
||||||
|
const depth = this.D.cab + 3;
|
||||||
|
const g = scene.add.graphics().setDepth(depth);
|
||||||
|
chromeFill(g, x0 - 8, top - 8, w + 16, h + 16, 12);
|
||||||
|
g.fillStyle(0xfff4d8, 1); g.fillRoundedRect(x0, top, w, h, 8);
|
||||||
|
g.fillStyle(0xffd88a, 0.35); g.fillRoundedRect(x0 + 6, top + 6, w - 12, h - 12, 6);
|
||||||
|
this.bellyGlow = scene.add.image(x0 + w / 2, top + h / 2, 'slots-glow').setDisplaySize(w * 1.1, h * 1.6)
|
||||||
|
.setTint(0xffe8b0).setBlendMode(ADD).setAlpha(0.25).setDepth(depth + 0.05);
|
||||||
|
const txt = (x, y, str, size, color = INK, ox = 0.5) => scene.add.text(x, y, str, {
|
||||||
|
fontFamily: 'Righteous', fontSize: `${size}px`, color,
|
||||||
|
}).setOrigin(ox, 0.5).setDepth(depth + 0.2);
|
||||||
|
|
||||||
|
// Pay table for 1 coin.
|
||||||
|
const pt = this.m.paytable;
|
||||||
|
const rows = [
|
||||||
|
['WILD WILD WILD', pt.wild[3]], ['RED 7 7 7', pt['seven-red'][3]], ['WHITE 7 7 7', pt['seven-white'][3]],
|
||||||
|
['BLUE 7 7 7', pt['seven-blue'][3]], ['ANY 7 7 7', pt['any-seven'][3]],
|
||||||
|
['BAR BAR BAR ³', pt.bar3[3]], ['BAR BAR BAR ²', pt.bar2[3]], ['BAR BAR BAR', pt.bar1[3]], ['ANY BAR ×3', pt['any-bar'][3]],
|
||||||
|
];
|
||||||
|
const pcx = x0 + w / 2;
|
||||||
|
txt(pcx, top + 13, 'PAYS FOR 1 COIN', 13, '#a02030');
|
||||||
|
const colW = 220;
|
||||||
|
rows.forEach(([label, pay], i) => {
|
||||||
|
const col = i < 5 ? 0 : 1; const r = i < 5 ? i : i - 5;
|
||||||
|
const cx = pcx + (col === 0 ? -colW / 2 - 12 : colW / 2 + 12);
|
||||||
|
const y = top + 32 + r * 20;
|
||||||
|
txt(cx - colW / 2, y, label, 14, INK, 0);
|
||||||
|
txt(cx + colW / 2, y, String(pay), 14, '#14100a', 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
// COINS PLAYED lamps (left).
|
||||||
|
const lx = x0 + 34;
|
||||||
|
txt(lx, top + 13, 'COINS', 12, '#a02030');
|
||||||
|
this.betLamps = this.m.betLevels.map((b, i) => {
|
||||||
|
const y = top + 32 + i * 20;
|
||||||
|
const lamp = scene.add.circle(lx, y, 9, 0x5a3a20).setDepth(depth + 0.2).setStrokeStyle(1.5, 0x3a2010);
|
||||||
|
const glow = scene.add.image(lx, y, 'slots-glow').setDisplaySize(44, 44).setTint(0xffb030).setBlendMode(ADD)
|
||||||
|
.setAlpha(0).setDepth(depth + 0.25);
|
||||||
|
const t = txt(lx, y, String(b), 11, '#fff4d8').setDepth(depth + 0.3);
|
||||||
|
return { lamp, glow, t };
|
||||||
|
});
|
||||||
|
|
||||||
|
// WILD ×2 / ×4 lamps (right).
|
||||||
|
const rx = x0 + w - 40;
|
||||||
|
this.wildLamps = [2, 4].map((mult, i) => {
|
||||||
|
const y = top + 38 + i * 46;
|
||||||
|
const box = scene.add.rectangle(rx, y, 64, 36, 0x3a1a2a).setStrokeStyle(2, 0x8fd8ff).setDepth(depth + 0.2);
|
||||||
|
const glow = scene.add.image(rx, y, 'slots-glow').setDisplaySize(120, 80).setTint(0x8fd8ff).setBlendMode(ADD)
|
||||||
|
.setAlpha(0).setDepth(depth + 0.25);
|
||||||
|
const t = txt(rx, y, `WILD\n×${mult}`, 12, '#cfefff').setAlign('center').setDepth(depth + 0.3);
|
||||||
|
return { mult, box, glow, t };
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
setWildLamp(mult) {
|
||||||
|
for (const l of this.wildLamps) {
|
||||||
|
this.scene.tweens.killTweensOf(l.glow);
|
||||||
|
const on = l.mult === mult;
|
||||||
|
l.box.setFillStyle(on ? 0x2a6a9a : 0x3a1a2a);
|
||||||
|
if (on) this.scene.tweens.add({ targets: l.glow, alpha: { from: 1, to: 0.3 }, duration: 260, yoyo: true, repeat: -1 });
|
||||||
|
else l.glow.setAlpha(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Coin tray ──────────────────────────────────────────────────────────────
|
||||||
|
buildTray() {
|
||||||
|
const { scene } = this;
|
||||||
|
const cx = GAME_WIDTH / 2; const top = this.below + 192; const w = 380; const h = 44;
|
||||||
|
const depth = this.D.cab + 3;
|
||||||
|
const g = scene.add.graphics().setDepth(depth);
|
||||||
|
g.fillStyle(0x0a0806, 1); g.fillRoundedRect(cx - w / 2, top, w, h, 10);
|
||||||
|
g.fillStyle(0x1a1410, 1); g.fillRect(cx - 34, top - 4, 68, 10); // chute slot
|
||||||
|
this.trayFront = scene.add.graphics().setDepth(depth + 0.3);
|
||||||
|
chromeFill(this.trayFront, cx - w / 2 - 8, top + h - 14, w + 16, 22, 8);
|
||||||
|
this.tray = { cx, top, w, h, depth };
|
||||||
|
}
|
||||||
|
|
||||||
|
dropCoins(n) {
|
||||||
|
const { scene } = this;
|
||||||
|
const T = this.tray;
|
||||||
|
for (let i = 0; i < n; i++) {
|
||||||
|
scene.time.delayedCall(i * 70, () => {
|
||||||
|
const x = T.cx + (Math.random() - 0.5) * (T.w - 50);
|
||||||
|
const layer = Math.min(3, Math.floor(this.coins.length / 14));
|
||||||
|
const y = T.top + T.h - 18 - layer * 4 - Math.random() * 4;
|
||||||
|
const coin = scene.add.image(T.cx, T.top - 4, 'slots-coin-p').setScale(0.9).setDepth(T.depth + 0.1 + this.coins.length * 0.0001);
|
||||||
|
scene.tweens.add({ targets: coin, x, duration: 380, ease: 'Sine.out' });
|
||||||
|
scene.tweens.add({ targets: coin, y, duration: 380, ease: 'Bounce.out', onComplete: () => coin.setScale(0.9, 0.55) });
|
||||||
|
this.coins.push(coin);
|
||||||
|
if (this.coins.length > 44) {
|
||||||
|
const old = this.coins.shift();
|
||||||
|
scene.tweens.add({ targets: old, alpha: 0, duration: 300, onComplete: () => old.destroy() });
|
||||||
|
}
|
||||||
|
if (i % 3 === 0) this.stage.sound('coins', () => playSound(scene, SFX.COINS));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Gutter bulb signs ──────────────────────────────────────────────────────
|
||||||
|
buildSevenSign() {
|
||||||
|
const { scene } = this;
|
||||||
|
const { cab } = this.g;
|
||||||
|
const cx = Math.round(cab.x / 2);
|
||||||
|
const depth = this.D.cab + 1;
|
||||||
|
const g = scene.add.graphics().setDepth(depth);
|
||||||
|
chromeFill(g, cx - 198, 152, 396, 636, 22);
|
||||||
|
g.fillStyle(0x1a0a10, 1); g.fillRoundedRect(cx - 188, 162, 376, 616, 18);
|
||||||
|
g.fillStyle(0x3a0a14, 1); g.fillRoundedRect(cx - 176, 174, 352, 592, 14);
|
||||||
|
scene.add.text(cx, 232, 'LUCKY', {
|
||||||
|
fontFamily: 'Righteous', fontSize: '72px', color: CREAM, stroke: '#c0101e', strokeThickness: 8,
|
||||||
|
}).setOrigin(0.5).setDepth(depth + 0.1);
|
||||||
|
scene.add.text(cx, 734, '★ SLOTS ★', {
|
||||||
|
fontFamily: 'Righteous', fontSize: '34px', color: '#ffd27a',
|
||||||
|
}).setOrigin(0.5).setDepth(depth + 0.1);
|
||||||
|
// The 7: painted enamel shape, outlined in bulbs.
|
||||||
|
const bx = cx - 130; const by = 300;
|
||||||
|
const seven = [[0, 0], [260, 0], [260, 62], [120, 380], [50, 380], [180, 74], [0, 74]]
|
||||||
|
.map(([x, y]) => ({ x: bx + x, y: by + y }));
|
||||||
|
g.fillStyle(0xc0101e, 1); g.fillPoints(seven, true);
|
||||||
|
g.lineStyle(4, 0xffd27a, 1); g.strokePoints(seven, true, true);
|
||||||
|
this.stage.lights.addStrip('sign7', [outline(seven, 26)], {
|
||||||
|
size: 30, depth: depth + 0.5, channel: 0x2a0a10, channelWidth: 10, closed: true, texture: 'slots-bulb',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
buildArrow() {
|
||||||
|
const { scene } = this;
|
||||||
|
const { cab } = this.g;
|
||||||
|
const tipX = cab.x + cab.w + 120; const y = 470; const depth = this.D.cab + 1;
|
||||||
|
const arrow = [[tipX, y], [tipX + 150, y - 150], [tipX + 150, y - 55], [1880, y - 55], [1880, y + 55],
|
||||||
|
[tipX + 150, y + 55], [tipX + 150, y + 150]].map(([px, py]) => ({ x: px, y: py }));
|
||||||
|
const g = scene.add.graphics().setDepth(depth);
|
||||||
|
g.fillStyle(0xc0101e, 1); g.fillPoints(arrow, true);
|
||||||
|
g.lineStyle(10, 0xc8ccd4, 1); g.strokePoints(arrow, true, true);
|
||||||
|
g.lineStyle(3, 0xffd27a, 1); g.strokePoints(arrow, true, true);
|
||||||
|
scene.add.text((tipX + 150 + 1880) / 2, y, 'PLAY', {
|
||||||
|
fontFamily: 'Righteous', fontSize: '60px', color: CREAM, stroke: '#5a0a10', strokeThickness: 6,
|
||||||
|
}).setOrigin(0.5).setDepth(depth + 0.1);
|
||||||
|
const strip = this.stage.lights.addStrip('arrow', [outline(arrow, 26)], {
|
||||||
|
size: 30, depth: depth + 0.5, channel: 0x2a0a10, channelWidth: 10, closed: true, texture: 'slots-bulb',
|
||||||
|
});
|
||||||
|
if (strip.override) strip.override.tip = { x: tipX, y };
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Hooks ──────────────────────────────────────────────────────────────────
|
||||||
|
onReels(view) { this.view = view; }
|
||||||
|
|
||||||
|
onBet(idx) {
|
||||||
|
this.betLamps.forEach((l, i) => {
|
||||||
|
const on = i <= idx;
|
||||||
|
l.lamp.setFillStyle(on ? 0xffb030 : 0x5a3a20);
|
||||||
|
this.scene.tweens.add({ targets: l.glow, alpha: on ? 0.7 : 0, duration: 120 });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onSpinStart() {
|
||||||
|
this.setOdometer(0);
|
||||||
|
this.setWildLamp(0);
|
||||||
|
if (!this.lever.pulling) this.lever.pull();
|
||||||
|
}
|
||||||
|
|
||||||
|
onLanded(result) {
|
||||||
|
let mult = 0;
|
||||||
|
for (const st of result?.steps ?? []) {
|
||||||
|
if (st.type !== 'lineWins') continue;
|
||||||
|
for (const w of st.wins) mult = Math.max(mult, w.wildMult ?? 1);
|
||||||
|
}
|
||||||
|
if (mult > 1) this.setWildLamp(mult);
|
||||||
|
if (result?.totalWin > 0) this.candle('win');
|
||||||
|
}
|
||||||
|
|
||||||
|
onSettle(total, bet) {
|
||||||
|
this.rollOdometer(total);
|
||||||
|
const ratio = total / Math.max(1, bet);
|
||||||
|
this.dropCoins(Math.min(40, 3 + Math.round(Math.sqrt(ratio) * 3)));
|
||||||
|
}
|
||||||
|
|
||||||
|
async onBigMoment() {
|
||||||
|
this.candle('jackpot');
|
||||||
|
for (let k = 0; k < 6; k++) {
|
||||||
|
this.stage.sound('bell', () => playSound(this.scene, SFX.UI_CHIME));
|
||||||
|
await wait(this.scene, 380);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onAttract(on) { if (on) this.leverMs = 8000; }
|
||||||
|
|
||||||
|
update(dt) {
|
||||||
|
this.t += dt / 1000;
|
||||||
|
this.bellyGlow.setAlpha(0.22 + 0.04 * Math.sin(this.t * 2.2));
|
||||||
|
if (this.stage.busy || !this.stage.attracting) return;
|
||||||
|
// A little "come play" wiggle of the lever now and then.
|
||||||
|
this.leverMs += dt;
|
||||||
|
if (this.leverMs >= 12000) {
|
||||||
|
this.leverMs = 0;
|
||||||
|
this.lever.wiggle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
shutdown() {}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,666 @@
|
||||||
|
// SlotsPharaoh — Pharaoh's Fortune props for the attract kit (SlotsAttract.js).
|
||||||
|
//
|
||||||
|
// "Temple of the sun": a winged sun disk spreads from the cabinet's top
|
||||||
|
// corners, two obelisks stand in the gutters (left = pyramid scatter counter,
|
||||||
|
// right = free-spin counter), fire braziers flank the cabinet, Khepri the
|
||||||
|
// scarab rolls the sun along the control bar, and the marquee pharaoh's eyes
|
||||||
|
// glint. Free spins open with carved tomb doors sliding shut over the reels,
|
||||||
|
// the world shifting to a golden dusk (optional feature video), and reel 3
|
||||||
|
// framed as the Pharaoh's reel; the expanding wild arrives as a pillar of light
|
||||||
|
// (or a golden sarcophagus when art is supplied).
|
||||||
|
//
|
||||||
|
// Hook contract matches the other props, plus onScatterAward(step),
|
||||||
|
// onFreeSpins('start'|'end', n) → Promise, makeFreeSpinBanner(), and
|
||||||
|
// playExpandWild(step) → Promise. Nothing here decides an outcome.
|
||||||
|
|
||||||
|
import * as Phaser from 'phaser';
|
||||||
|
import { GAME_WIDTH, GAME_HEIGHT } from '../../config.js';
|
||||||
|
import { playSound, SFX } from '../../ui/Sounds.js';
|
||||||
|
import { textureKeyFor } from './SlotsSymbols.js';
|
||||||
|
import { canvasTex, roundRectPath } from './SlotsAttract.js';
|
||||||
|
|
||||||
|
const ADD = Phaser.BlendModes.ADD;
|
||||||
|
const TAU = Math.PI * 2;
|
||||||
|
const wait = (scene, ms) => new Promise((r) => scene.time.delayedCall(ms, r));
|
||||||
|
const GOLD = 0xffd86b;
|
||||||
|
const LAPIS = 0x1f4fb8;
|
||||||
|
const FIRE = [0xfff0a0, 0xff9a2a, 0xff4a1a];
|
||||||
|
const BLUE_FIRE = [0xeaffff, 0x6ad8ff, 0x2a6aff];
|
||||||
|
|
||||||
|
function glyphPath(ctx, k) {
|
||||||
|
ctx.beginPath();
|
||||||
|
switch (k % 6) {
|
||||||
|
case 0: ctx.arc(24, 14, 8, 0, TAU); ctx.moveTo(24, 22); ctx.lineTo(24, 42); ctx.moveTo(13, 28); ctx.lineTo(35, 28); break;
|
||||||
|
case 1: ctx.ellipse(24, 22, 16, 9, 0, 0, TAU); ctx.moveTo(28, 22); ctx.arc(24, 22, 4, 0, TAU); ctx.moveTo(14, 30); ctx.lineTo(10, 40); break;
|
||||||
|
case 2: for (let q = 0; q <= 4; q++) ctx.lineTo(6 + q * 9, q % 2 ? 18 : 28); ctx.moveTo(6, 36); for (let q = 0; q <= 4; q++) ctx.lineTo(6 + q * 9, q % 2 ? 32 : 40); break;
|
||||||
|
case 3: ctx.arc(24, 24, 13, 0, TAU); ctx.moveTo(28, 24); ctx.arc(24, 24, 4, 0, TAU); break;
|
||||||
|
case 4: ctx.moveTo(14, 42); ctx.lineTo(24, 6); ctx.lineTo(34, 42); ctx.moveTo(18, 26); ctx.lineTo(30, 26); break;
|
||||||
|
default: ctx.moveTo(8, 32); ctx.quadraticCurveTo(18, 6, 40, 14); ctx.lineTo(32, 36); ctx.lineTo(16, 40); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function bakePharaohTextures(scene) {
|
||||||
|
for (let k = 0; k < 6; k++) {
|
||||||
|
canvasTex(scene, `ph-glyph-${k}`, 48, 48, (ctx) => {
|
||||||
|
ctx.strokeStyle = '#ffffff'; ctx.lineWidth = 4.5; ctx.lineCap = 'round'; ctx.lineJoin = 'round';
|
||||||
|
glyphPath(ctx, k);
|
||||||
|
ctx.stroke();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// One wing of the winged sun disk: root on the right, tip on the left.
|
||||||
|
canvasTex(scene, 'ph-wing', 420, 200, (ctx) => {
|
||||||
|
const top = (x) => 30 + ((412 - x) / 404) * 40;
|
||||||
|
const bot = (x) => 70 + ((x - 8) / 404) * 110;
|
||||||
|
ctx.save();
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(412, top(412));
|
||||||
|
for (let x = 412; x >= 8; x -= 8) ctx.lineTo(x, top(x));
|
||||||
|
for (let x = 8, k = 0; x <= 412; x += 22, k++) {
|
||||||
|
ctx.lineTo(x, bot(x) + 10);
|
||||||
|
ctx.lineTo(x + 11, bot(x + 11) - 2);
|
||||||
|
}
|
||||||
|
ctx.lineTo(412, bot(412));
|
||||||
|
ctx.closePath();
|
||||||
|
ctx.clip();
|
||||||
|
const bands = [['#f0c441', 16], ['#1f4fb8', 14], ['#3ad8d0', 12], ['#c8402a', 12], ['#f0c441', 10]];
|
||||||
|
let off = 0;
|
||||||
|
for (const [col, th] of bands) {
|
||||||
|
ctx.fillStyle = col;
|
||||||
|
ctx.beginPath();
|
||||||
|
for (let x = 0; x <= 420; x += 8) ctx.lineTo(x, top(x) + off);
|
||||||
|
for (let x = 420; x >= 0; x -= 8) ctx.lineTo(x, top(x) + off + th);
|
||||||
|
ctx.closePath(); ctx.fill();
|
||||||
|
off += th;
|
||||||
|
}
|
||||||
|
// Long flight feathers.
|
||||||
|
for (let x = 0, k = 0; x < 420; x += 22, k++) {
|
||||||
|
ctx.fillStyle = k % 2 ? '#1f4fb8' : '#f0c441';
|
||||||
|
ctx.fillRect(x, top(x) + off, 22, 200);
|
||||||
|
ctx.strokeStyle = 'rgba(40,20,0,0.6)'; ctx.lineWidth = 2;
|
||||||
|
ctx.beginPath(); ctx.moveTo(x, top(x) + off); ctx.lineTo(x, 200); ctx.stroke();
|
||||||
|
}
|
||||||
|
ctx.restore();
|
||||||
|
ctx.strokeStyle = '#5a3a08'; ctx.lineWidth = 3;
|
||||||
|
ctx.beginPath();
|
||||||
|
for (let x = 412; x >= 8; x -= 8) ctx.lineTo(x, top(x));
|
||||||
|
ctx.stroke();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Obelisk: gold pyramidion, tapering sandstone shaft, plinth.
|
||||||
|
canvasTex(scene, 'ph-obelisk', 150, 600, (ctx) => {
|
||||||
|
ctx.fillStyle = (() => {
|
||||||
|
const g = ctx.createLinearGradient(15, 0, 135, 0);
|
||||||
|
g.addColorStop(0, '#f2d49a'); g.addColorStop(0.55, '#d8b070'); g.addColorStop(1, '#9a7038');
|
||||||
|
return g;
|
||||||
|
})();
|
||||||
|
ctx.beginPath(); ctx.moveTo(32, 60); ctx.lineTo(118, 60); ctx.lineTo(132, 572); ctx.lineTo(18, 572); ctx.closePath();
|
||||||
|
ctx.fill();
|
||||||
|
ctx.strokeStyle = '#5a3a10'; ctx.lineWidth = 3; ctx.stroke();
|
||||||
|
ctx.strokeStyle = 'rgba(90,58,16,0.45)'; ctx.lineWidth = 2;
|
||||||
|
ctx.beginPath(); ctx.moveTo(44, 80); ctx.lineTo(36, 552); ctx.moveTo(106, 80); ctx.lineTo(114, 552); ctx.stroke();
|
||||||
|
const p = ctx.createLinearGradient(30, 0, 120, 0);
|
||||||
|
p.addColorStop(0, '#fff3b0'); p.addColorStop(0.5, '#f0c441'); p.addColorStop(1, '#9a6a12');
|
||||||
|
ctx.fillStyle = p;
|
||||||
|
ctx.beginPath(); ctx.moveTo(75, 2); ctx.lineTo(120, 62); ctx.lineTo(30, 62); ctx.closePath(); ctx.fill();
|
||||||
|
ctx.strokeStyle = '#5a3a08'; ctx.stroke();
|
||||||
|
ctx.fillStyle = '#b89058';
|
||||||
|
ctx.fillRect(2, 570, 146, 28);
|
||||||
|
ctx.strokeStyle = '#5a3a10'; ctx.strokeRect(2, 570, 146, 28);
|
||||||
|
});
|
||||||
|
|
||||||
|
canvasTex(scene, 'ph-brazier', 100, 170, (ctx) => {
|
||||||
|
ctx.strokeStyle = '#3a2410'; ctx.lineWidth = 7; ctx.lineCap = 'round';
|
||||||
|
ctx.beginPath(); ctx.moveTo(50, 40); ctx.lineTo(50, 160); ctx.moveTo(50, 110); ctx.lineTo(18, 166); ctx.moveTo(50, 110); ctx.lineTo(82, 166); ctx.stroke();
|
||||||
|
const g = ctx.createLinearGradient(0, 10, 0, 50);
|
||||||
|
g.addColorStop(0, '#f0c441'); g.addColorStop(1, '#8a5a12');
|
||||||
|
ctx.fillStyle = g;
|
||||||
|
ctx.beginPath(); ctx.moveTo(6, 14); ctx.quadraticCurveTo(50, 70, 94, 14); ctx.closePath(); ctx.fill();
|
||||||
|
ctx.strokeStyle = '#4a2a08'; ctx.lineWidth = 3; ctx.stroke();
|
||||||
|
ctx.fillStyle = '#1f4fb8'; ctx.fillRect(14, 20, 72, 5);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Khepri the scarab, side view, two leg frames for a walk cycle.
|
||||||
|
for (const [key, ph] of [['ph-scarab-a', 0], ['ph-scarab-b', 1]]) {
|
||||||
|
canvasTex(scene, key, 110, 80, (ctx) => {
|
||||||
|
ctx.strokeStyle = '#1a1206'; ctx.lineWidth = 4; ctx.lineCap = 'round';
|
||||||
|
const legs = ph ? [[30, -0.5], [55, 0.4], [80, -0.3]] : [[30, 0.4], [55, -0.4], [80, 0.4]];
|
||||||
|
for (const [x, a] of legs) { ctx.beginPath(); ctx.moveTo(x, 50); ctx.lineTo(x + Math.sin(a) * 18, 76); ctx.stroke(); }
|
||||||
|
const g = ctx.createLinearGradient(20, 10, 80, 60);
|
||||||
|
g.addColorStop(0, '#3ad8d0'); g.addColorStop(0.5, '#1a4a6a'); g.addColorStop(1, '#0a1428');
|
||||||
|
ctx.fillStyle = g;
|
||||||
|
ctx.beginPath(); ctx.ellipse(52, 38, 40, 24, 0, Math.PI, TAU); ctx.lineTo(92, 50); ctx.lineTo(12, 50); ctx.closePath(); ctx.fill();
|
||||||
|
ctx.strokeStyle = '#f0c441'; ctx.lineWidth = 3; ctx.stroke();
|
||||||
|
ctx.beginPath(); ctx.moveTo(52, 14); ctx.lineTo(52, 50); ctx.stroke();
|
||||||
|
ctx.fillStyle = '#0a1428';
|
||||||
|
ctx.beginPath(); ctx.ellipse(98, 42, 11, 9, 0, 0, TAU); ctx.fill();
|
||||||
|
ctx.strokeStyle = '#f0c441'; ctx.lineWidth = 2; ctx.stroke();
|
||||||
|
ctx.strokeStyle = '#1a1206'; ctx.lineWidth = 2.5;
|
||||||
|
ctx.beginPath(); ctx.moveTo(104, 36); ctx.lineTo(108, 24); ctx.stroke();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
canvasTex(scene, 'ph-sun', 64, 64, (ctx) => {
|
||||||
|
const g = ctx.createRadialGradient(26, 24, 2, 32, 32, 30);
|
||||||
|
g.addColorStop(0, '#fffbe0'); g.addColorStop(0.4, '#ffd23f'); g.addColorStop(0.9, '#d0801a'); g.addColorStop(1, 'rgba(208,128,26,0)');
|
||||||
|
ctx.fillStyle = g;
|
||||||
|
ctx.beginPath(); ctx.arc(32, 32, 30, 0, TAU); ctx.fill();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Carved stone tomb door (sized to half the reel window).
|
||||||
|
function bakeDoor(scene, w, h) {
|
||||||
|
const key = `ph-door-${w}x${h}`;
|
||||||
|
return canvasTex(scene, key, w, h, (ctx) => {
|
||||||
|
const g = ctx.createLinearGradient(0, 0, w, h);
|
||||||
|
g.addColorStop(0, '#e2c48a'); g.addColorStop(1, '#a8804a');
|
||||||
|
ctx.fillStyle = g;
|
||||||
|
ctx.fillRect(0, 0, w, h);
|
||||||
|
for (let i = 0; i < 900; i++) {
|
||||||
|
ctx.fillStyle = Math.random() < 0.5 ? 'rgba(90,60,20,0.12)' : 'rgba(255,240,200,0.12)';
|
||||||
|
ctx.fillRect(Math.random() * w, Math.random() * h, 2, 2);
|
||||||
|
}
|
||||||
|
ctx.strokeStyle = '#f0c441'; ctx.lineWidth = 10;
|
||||||
|
ctx.strokeRect(5, 5, w - 10, h - 10);
|
||||||
|
ctx.strokeStyle = '#1f4fb8'; ctx.lineWidth = 4;
|
||||||
|
ctx.strokeRect(16, 16, w - 32, h - 32);
|
||||||
|
ctx.fillStyle = 'rgba(80,50,15,0.18)';
|
||||||
|
roundRectPath(ctx, 34, 34, w - 68, h - 68, 10);
|
||||||
|
ctx.fill();
|
||||||
|
// Carved glyph grid.
|
||||||
|
let k = 0;
|
||||||
|
for (let y = 60; y < h - 50; y += 62) {
|
||||||
|
for (let x = 50; x < w - 60; x += 70) {
|
||||||
|
ctx.save(); ctx.translate(x, y);
|
||||||
|
for (const [col, off] of [['rgba(255,240,200,0.45)', 2], ['rgba(70,40,10,0.55)', 0]]) {
|
||||||
|
ctx.save(); ctx.translate(off, off);
|
||||||
|
ctx.strokeStyle = col; ctx.lineWidth = 3.5; ctx.lineCap = 'round';
|
||||||
|
glyphPath(ctx, k);
|
||||||
|
ctx.stroke();
|
||||||
|
ctx.restore();
|
||||||
|
}
|
||||||
|
ctx.restore();
|
||||||
|
k++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export class PharaohProps {
|
||||||
|
constructor(stage) {
|
||||||
|
this.stage = stage;
|
||||||
|
this.scene = stage.scene;
|
||||||
|
this.m = stage.m;
|
||||||
|
this.A = stage.A;
|
||||||
|
this.D = stage.D;
|
||||||
|
this.g = stage.g;
|
||||||
|
this.view = null;
|
||||||
|
this.t = 0;
|
||||||
|
this.pyramids = 0;
|
||||||
|
this.eyeMs = 4000;
|
||||||
|
this.scarabMs = 0;
|
||||||
|
this.wingMs = 0;
|
||||||
|
this.halos = [];
|
||||||
|
this.inFeature = false;
|
||||||
|
this.scatter = this.m.scatter.symbol;
|
||||||
|
this.wildCol = this.m.scatter.expandingWildReel;
|
||||||
|
bakePharaohTextures(this.scene);
|
||||||
|
this.buildWings();
|
||||||
|
this.buildObelisks();
|
||||||
|
this.buildBraziers();
|
||||||
|
this.buildMarqueeEyes();
|
||||||
|
this.moodGrade = this.scene.add.rectangle(GAME_WIDTH / 2, GAME_HEIGHT / 2, GAME_WIDTH, GAME_HEIGHT, 0xff9a30, 0)
|
||||||
|
.setBlendMode(ADD).setDepth(this.D.bg + 4.65);
|
||||||
|
}
|
||||||
|
|
||||||
|
sym(id) { return textureKeyFor(this.scene, this.m.id, id); }
|
||||||
|
|
||||||
|
// ── Winged sun disk ────────────────────────────────────────────────────────
|
||||||
|
buildWings() {
|
||||||
|
const { scene } = this;
|
||||||
|
const { cab } = this.g;
|
||||||
|
const depth = this.D.cab - 0.05;
|
||||||
|
this.sunGlow = scene.add.image(GAME_WIDTH / 2, 110, 'slots-glow').setDisplaySize(1500, 420)
|
||||||
|
.setTint(0xffb030).setBlendMode(ADD).setAlpha(0.35).setDepth(this.D.cab - 0.45);
|
||||||
|
scene.tweens.add({ targets: this.sunGlow, alpha: 0.55, duration: 2600, yoyo: true, repeat: -1, ease: 'Sine.inOut' });
|
||||||
|
this.wings = [-1, 1].map((side) => {
|
||||||
|
const x = side < 0 ? cab.x + 40 : cab.x + cab.w - 40;
|
||||||
|
const img = scene.add.image(x, 118, 'ph-wing').setOrigin(side < 0 ? 1 : 0, 0.5)
|
||||||
|
.setDisplaySize(380, 181).setFlipX(side > 0).setDepth(depth);
|
||||||
|
const shine = scene.add.image(x, 118, 'ph-wing').setOrigin(side < 0 ? 1 : 0, 0.5)
|
||||||
|
.setDisplaySize(380, 181).setFlipX(side > 0).setDepth(depth + 0.01)
|
||||||
|
.setTintFill(0xffffff).setBlendMode(ADD).setAlpha(0);
|
||||||
|
return { img, shine };
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
flashWings(level = 0.5) {
|
||||||
|
this.wings.forEach((w, k) => this.scene.tweens.add({
|
||||||
|
targets: w.shine, alpha: level, duration: 220, yoyo: true, delay: k * 120,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Obelisks ───────────────────────────────────────────────────────────────
|
||||||
|
buildObelisks() {
|
||||||
|
const { scene } = this;
|
||||||
|
const { cab } = this.g;
|
||||||
|
const depth = this.D.cab + 3;
|
||||||
|
const make = (x, label) => {
|
||||||
|
scene.add.image(x, 250, 'ph-obelisk').setOrigin(0.5, 0).setDepth(depth);
|
||||||
|
const glyphs = Array.from({ length: 9 }, (_, k) => {
|
||||||
|
const y = 790 - k * 58;
|
||||||
|
const glow = scene.add.image(x, y, 'slots-glow').setDisplaySize(90, 90).setTint(GOLD)
|
||||||
|
.setBlendMode(ADD).setAlpha(0).setDepth(depth + 0.1);
|
||||||
|
const img = scene.add.image(x, y, `ph-glyph-${k % 6}`).setDisplaySize(40, 40)
|
||||||
|
.setTint(0x6a4a20).setAlpha(0.8).setDepth(depth + 0.2);
|
||||||
|
return { img, glow, lit: false };
|
||||||
|
});
|
||||||
|
scene.add.text(x, 835, label, {
|
||||||
|
fontFamily: 'Righteous', fontSize: '17px', color: '#4a2a0e',
|
||||||
|
}).setOrigin(0.5).setDepth(depth + 0.2);
|
||||||
|
const tipGlow = scene.add.image(x, 292, 'slots-glow').setDisplaySize(140, 140).setTint(GOLD)
|
||||||
|
.setBlendMode(ADD).setAlpha(0).setDepth(depth + 0.1);
|
||||||
|
return { x, glyphs, tipGlow };
|
||||||
|
};
|
||||||
|
this.left = make(Math.round(cab.x / 2), 'PYRAMIDS');
|
||||||
|
this.right = make(Math.round((cab.x + cab.w + GAME_WIDTH) / 2), 'FREE SPINS');
|
||||||
|
// The Eye of Ra on the left pyramidion — it opens when pyramids tease.
|
||||||
|
this.eye = scene.add.image(this.left.x, 296, this.sym('eye')).setDisplaySize(44, 44).setAlpha(0.25)
|
||||||
|
.setDepth(depth + 0.3);
|
||||||
|
|
||||||
|
// Right obelisk info plate (base game) / live counter (free spins).
|
||||||
|
const r = this.right;
|
||||||
|
this.infoPlate = scene.add.graphics().setDepth(depth + 0.3);
|
||||||
|
this.infoPlate.fillStyle(0x1a1430, 0.82);
|
||||||
|
this.infoPlate.fillRoundedRect(r.x - 62, 450, 124, 190, 14);
|
||||||
|
this.infoPlate.lineStyle(3, GOLD, 0.9);
|
||||||
|
this.infoPlate.strokeRoundedRect(r.x - 62, 450, 124, 190, 14);
|
||||||
|
const st = (y, str, size, color) => scene.add.text(r.x, y, str, {
|
||||||
|
fontFamily: 'Righteous', fontSize: `${size}px`, color, align: 'center',
|
||||||
|
}).setOrigin(0.5).setDepth(depth + 0.4);
|
||||||
|
this.info = [
|
||||||
|
st(478, '3 · 4 · 5', 22, '#ffd86b'),
|
||||||
|
st(506, 'PYRAMIDS', 15, '#cfd8ff'),
|
||||||
|
st(546, '8 · 12 · 20', 22, '#ffd86b'),
|
||||||
|
st(574, 'FREE SPINS', 15, '#cfd8ff'),
|
||||||
|
st(612, '+ WILD REEL 3', 13, '#9ad8ff'),
|
||||||
|
];
|
||||||
|
this.fsTitle = st(476, 'SPINS LEFT', 15, '#cfd8ff').setVisible(false);
|
||||||
|
this.fsNum = st(530, '0', 58, '#ffffff').setVisible(false).setShadow(0, 0, '#ffd86b', 16);
|
||||||
|
this.fsWin = st(600, '', 18, '#ffd86b').setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
lightGlyphs(ob, n) {
|
||||||
|
ob.glyphs.forEach((g, k) => {
|
||||||
|
const want = k < n;
|
||||||
|
if (want === g.lit) return;
|
||||||
|
g.lit = want;
|
||||||
|
if (want) {
|
||||||
|
g.img.setTint(0xfff3c0).setAlpha(1);
|
||||||
|
this.scene.tweens.add({ targets: g.glow, alpha: 0.85, duration: 200 });
|
||||||
|
this.scene.tweens.add({ targets: g.img, scale: g.img.scale * 1.4, duration: 130, yoyo: true });
|
||||||
|
} else {
|
||||||
|
g.img.setTint(0x6a4a20).setAlpha(0.8);
|
||||||
|
g.glow.setAlpha(0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
setPyramids(n) {
|
||||||
|
this.pyramids = n;
|
||||||
|
this.lightGlyphs(this.left, Math.min(9, n * 3));
|
||||||
|
if (n >= 3) {
|
||||||
|
this.scene.tweens.add({ targets: this.left.tipGlow, alpha: 1, duration: 200 });
|
||||||
|
this.eye.setAlpha(1);
|
||||||
|
this.skyBeam(this.left.x, 270);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resetPyramids() {
|
||||||
|
this.pyramids = 0;
|
||||||
|
this.lightGlyphs(this.left, 0);
|
||||||
|
this.left.tipGlow.setAlpha(0);
|
||||||
|
this.eye.setAlpha(0.25);
|
||||||
|
}
|
||||||
|
|
||||||
|
// A shaft of light from a point straight up into the sky.
|
||||||
|
skyBeam(x, y, width = 70) {
|
||||||
|
const { scene } = this;
|
||||||
|
const beam = scene.add.image(x, y, 'slots-gloss').setOrigin(0.5, 1).setDisplaySize(width, y + 40)
|
||||||
|
.setTint(0xfff0c0).setBlendMode(ADD).setAlpha(0).setDepth(this.D.ui - 2);
|
||||||
|
scene.tweens.add({ targets: beam, alpha: 0.9, duration: 160, yoyo: true, hold: 500, onComplete: () => beam.destroy() });
|
||||||
|
this.stage.sound('beam');
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Braziers ───────────────────────────────────────────────────────────────
|
||||||
|
buildBraziers() {
|
||||||
|
const { scene } = this;
|
||||||
|
const { cab } = this.g;
|
||||||
|
this.braziers = [cab.x - 58, cab.x + cab.w + 58].map((x) => {
|
||||||
|
const y = 770;
|
||||||
|
scene.add.image(x, y, 'ph-brazier').setOrigin(0.5, 0).setDisplaySize(84, 143).setDepth(this.D.cab + 3);
|
||||||
|
const glow = scene.add.image(x, y, 'slots-glow').setDisplaySize(300, 300).setTint(0xff9a30)
|
||||||
|
.setBlendMode(ADD).setAlpha(0.5).setDepth(this.D.cab + 2.9);
|
||||||
|
const cfg = (tint) => ({
|
||||||
|
speedY: { min: -110, max: -50 }, speedX: { min: -16, max: 16 }, lifespan: { min: 350, max: 700 },
|
||||||
|
scale: { start: 0.3, end: 0.04 }, alpha: { start: 0.95, end: 0 }, tint, blendMode: 'ADD',
|
||||||
|
frequency: 20, quantity: 1,
|
||||||
|
});
|
||||||
|
const fire = scene.add.particles(x, y + 10, 'slots-glow', cfg(FIRE)).setDepth(this.D.cab + 3.1);
|
||||||
|
const blue = scene.add.particles(x, y + 10, 'slots-glow', cfg(BLUE_FIRE)).setDepth(this.D.cab + 3.1);
|
||||||
|
blue.stop();
|
||||||
|
return { glow, fire, blue };
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
setBlueFire(on) {
|
||||||
|
for (const b of this.braziers) {
|
||||||
|
if (on) { b.fire.stop(); b.blue.start(); b.glow.setTint(0x4aa8ff); } else { b.blue.stop(); b.fire.start(); b.glow.setTint(0xff9a30); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Marquee eyes ───────────────────────────────────────────────────────────
|
||||||
|
buildMarqueeEyes() {
|
||||||
|
const mq = this.g.marquee;
|
||||||
|
const sx = mq.w / 800; const sy = mq.h / 120;
|
||||||
|
this.mEyes = [[174, 55], [221, 55]].map(([ex, ey]) => {
|
||||||
|
const x = mq.x + ex * sx; const y = mq.y + ey * sy;
|
||||||
|
const glow = this.scene.add.image(x, y, 'slots-glow').setDisplaySize(46, 34).setTint(GOLD)
|
||||||
|
.setBlendMode(ADD).setAlpha(0).setDepth(this.D.cab + 0.7);
|
||||||
|
const glint = this.scene.add.image(x, y, 'slots-glint').setBlendMode(ADD).setScale(0).setDepth(this.D.cab + 0.71);
|
||||||
|
return { glow, glint };
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
eyeGlint() {
|
||||||
|
for (const e of this.mEyes) {
|
||||||
|
this.scene.tweens.add({ targets: e.glow, alpha: 1, duration: 260, yoyo: true, hold: 420 });
|
||||||
|
this.scene.tweens.add({ targets: e.glint, scale: 0.32, angle: 90, duration: 300, yoyo: true, hold: 200,
|
||||||
|
onComplete: () => e.glint.setAngle(0) });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Khepri rolls the sun along the control bar ─────────────────────────────
|
||||||
|
scarabRoll() {
|
||||||
|
if (this.scarab) return;
|
||||||
|
const { scene } = this;
|
||||||
|
const y = 932;
|
||||||
|
const bug = scene.add.image(-160, y, 'ph-scarab-a').setOrigin(0.5, 1).setDisplaySize(88, 64).setDepth(this.D.ui - 0.5);
|
||||||
|
const sun = scene.add.image(-100, y - 22, 'ph-sun').setDisplaySize(46, 46).setDepth(this.D.ui - 0.49);
|
||||||
|
const halo = scene.add.image(-100, y - 22, 'slots-glow').setDisplaySize(120, 120).setTint(GOLD)
|
||||||
|
.setBlendMode(ADD).setAlpha(0.6).setDepth(this.D.ui - 0.51);
|
||||||
|
this.scarab = { bug, sun, halo, step: 0 };
|
||||||
|
this.stage.sound('scarab');
|
||||||
|
const carrier = { x: -160 };
|
||||||
|
scene.tweens.add({
|
||||||
|
targets: carrier, x: GAME_WIDTH + 160, duration: 10000,
|
||||||
|
onUpdate: () => {
|
||||||
|
bug.x = carrier.x;
|
||||||
|
sun.x = carrier.x + 64; halo.x = sun.x;
|
||||||
|
sun.rotation = carrier.x / 23;
|
||||||
|
const frame = Math.floor(carrier.x / 14) % 2 ? 'ph-scarab-b' : 'ph-scarab-a';
|
||||||
|
if (bug.texture.key !== frame) bug.setTexture(frame);
|
||||||
|
},
|
||||||
|
onComplete: () => { bug.destroy(); sun.destroy(); halo.destroy(); this.scarab = null; },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Hooks ──────────────────────────────────────────────────────────────────
|
||||||
|
onReels(view) { this.view = view; }
|
||||||
|
|
||||||
|
onAttract(on) { if (on) { this.scarabMs = 12000; this.eyeMs = 2000; } }
|
||||||
|
|
||||||
|
update(dt) {
|
||||||
|
this.t += dt / 1000;
|
||||||
|
for (const b of this.braziers) b.glow.setAlpha(0.42 + 0.1 * Math.sin(this.t * 11 + b.glow.x) + 0.06 * Math.sin(this.t * 7));
|
||||||
|
if (this.reelFrame) this.reelFrame.setAlpha(0.7 + 0.3 * Math.sin(this.t * 4));
|
||||||
|
const att = this.stage.attracting;
|
||||||
|
this.eyeMs += dt;
|
||||||
|
this.wingMs += dt;
|
||||||
|
if (this.eyeMs >= (att ? 5000 : 9000)) { this.eyeMs = 0; this.eyeGlint(); }
|
||||||
|
if (this.wingMs >= (att ? 4000 : 8000)) { this.wingMs = 0; this.flashWings(0.35); }
|
||||||
|
if (this.stage.busy || !this.view) return;
|
||||||
|
this.scarabMs += dt;
|
||||||
|
if (this.scarabMs >= (att ? 16000 : 45000)) { this.scarabMs = 0; this.scarabRoll(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
clearHalos() {
|
||||||
|
for (const h of this.halos) { this.scene.tweens.killTweensOf(h); h.destroy(); }
|
||||||
|
this.halos = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
onSpinStart() {
|
||||||
|
this.resetPyramids();
|
||||||
|
this.clearHalos();
|
||||||
|
this.stopSand();
|
||||||
|
}
|
||||||
|
|
||||||
|
countThrough(c) {
|
||||||
|
const grid = this.stage.pendingResult?.grid;
|
||||||
|
if (!grid) return 0;
|
||||||
|
let n = 0;
|
||||||
|
for (let k = 0; k <= c && k < grid.length; k++) n += grid[k].filter((s) => s === this.scatter).length;
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
onReelStop(c) {
|
||||||
|
const view = this.view;
|
||||||
|
const grid = this.stage.pendingResult?.grid;
|
||||||
|
if (!view || !grid) return;
|
||||||
|
const n = this.countThrough(c);
|
||||||
|
grid[c].forEach((s, r) => {
|
||||||
|
const p = view.cellCenter(c, r);
|
||||||
|
if (s === this.scatter) {
|
||||||
|
const apex = p.y - view.cellH * 0.38;
|
||||||
|
const beam = this.scene.add.image(p.x, apex, 'slots-gloss').setOrigin(0.5, 1).setDisplaySize(46, apex + 30)
|
||||||
|
.setTint(0xfff0c0).setBlendMode(ADD).setAlpha(0).setDepth(view.depth + 4);
|
||||||
|
this.scene.tweens.add({ targets: beam, alpha: 0.85, duration: 140, yoyo: true, hold: 600, onComplete: () => beam.destroy() });
|
||||||
|
}
|
||||||
|
if (s === this.m.wild.symbol) {
|
||||||
|
// A rotating sunburst behind the pharaoh, held until the next spin.
|
||||||
|
const h = this.scene.add.image(p.x, p.y, 'slots-rays').setDisplaySize(view.cellH * 1.8, view.cellH * 1.8)
|
||||||
|
.setTint(GOLD).setBlendMode(ADD).setAlpha(0.55).setDepth(view.depth - 1).setMask(view.mask);
|
||||||
|
this.scene.tweens.add({ targets: h, angle: 360, duration: 9000, repeat: -1 });
|
||||||
|
this.halos.push(h);
|
||||||
|
this.flashWings(0.6);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (n > this.pyramids) this.setPyramids(Math.min(3, n));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tease: the Eye of Ra opens and sand pours down the teased reel.
|
||||||
|
onAnticipate(c) {
|
||||||
|
const view = this.view;
|
||||||
|
if (!view) return;
|
||||||
|
this.eye.setAlpha(1);
|
||||||
|
this.scene.tweens.add({ targets: this.left.tipGlow, alpha: 0.6, duration: 200 });
|
||||||
|
this.stopSand();
|
||||||
|
const x = view.reelX(c);
|
||||||
|
this.sand = this.scene.add.particles(0, view.y - 10, 'slots-led', {
|
||||||
|
x: { min: x, max: x + view.cellW }, speedY: { min: 160, max: 320 }, speedX: { min: -20, max: 20 },
|
||||||
|
lifespan: 1700, frequency: 8, quantity: 2, scale: { min: 0.05, max: 0.11 },
|
||||||
|
tint: [0xe8c890, 0xffd86b], alpha: { start: 0.9, end: 0.2 }, blendMode: 'ADD',
|
||||||
|
}).setDepth(view.depth + 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
stopSand() {
|
||||||
|
if (!this.sand) return;
|
||||||
|
const s = this.sand;
|
||||||
|
this.sand = null;
|
||||||
|
s.stop();
|
||||||
|
this.scene.time.delayedCall(1800, () => s.destroy());
|
||||||
|
}
|
||||||
|
|
||||||
|
onLanded() {
|
||||||
|
const teased = !!this.sand;
|
||||||
|
this.stopSand();
|
||||||
|
if (teased && this.pyramids < 3) {
|
||||||
|
this.scene.tweens.add({ targets: this.eye, alpha: 0.25, duration: 500, delay: 300 });
|
||||||
|
this.scene.tweens.add({ targets: this.left.tipGlow, alpha: 0, duration: 500, delay: 300 });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrigger during free spins: "+N SPINS" flies into the right obelisk.
|
||||||
|
onScatterAward(step) {
|
||||||
|
if (!step.freeSpins || !this.inFeature) return;
|
||||||
|
const { scene } = this;
|
||||||
|
const view = this.view;
|
||||||
|
const from = view.cellCenter(step.cells[0].c, step.cells[0].r);
|
||||||
|
const t = scene.add.text(from.x, from.y, `+${step.freeSpins} SPINS`, {
|
||||||
|
fontFamily: 'Righteous', fontSize: '44px', color: '#ffd86b', stroke: '#2a1400', strokeThickness: 8,
|
||||||
|
}).setOrigin(0.5).setDepth(this.D.ui + 2);
|
||||||
|
scene.tweens.add({
|
||||||
|
targets: t, x: this.right.x, y: 530, scale: 0.6, duration: 900, delay: 400, ease: 'Cubic.in',
|
||||||
|
onComplete: () => { t.destroy(); this.skyBeam(this.right.x, 270); },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Free spins: the tomb opens ─────────────────────────────────────────────
|
||||||
|
makeFreeSpinBanner() {
|
||||||
|
const r = this.right;
|
||||||
|
for (const o of this.info) o.setVisible(false);
|
||||||
|
this.fsTitle.setVisible(true); this.fsNum.setVisible(true); this.fsWin.setVisible(true);
|
||||||
|
return {
|
||||||
|
update: (remaining, total, win) => {
|
||||||
|
this.fsNum.setText(String(remaining));
|
||||||
|
this.fsWin.setText(`WIN ${win.toLocaleString()}`);
|
||||||
|
this.lightGlyphs(r, Math.ceil((remaining / Math.max(1, total)) * 9));
|
||||||
|
this.scene.tweens.add({ targets: this.fsNum, scale: 1.2, duration: 120, yoyo: true });
|
||||||
|
},
|
||||||
|
destroy: () => {
|
||||||
|
for (const o of this.info) o.setVisible(true);
|
||||||
|
this.fsTitle.setVisible(false); this.fsNum.setVisible(false); this.fsWin.setVisible(false);
|
||||||
|
this.lightGlyphs(r, 0);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
async onFreeSpins(phase, n) {
|
||||||
|
const start = phase === 'start';
|
||||||
|
const msg = start ? `${n} FREE SPINS` : `FREE SPINS WIN\n${Number(n).toLocaleString()}`;
|
||||||
|
await this.tombDoors(msg, () => this.setFeatureMood(start));
|
||||||
|
}
|
||||||
|
|
||||||
|
setFeatureMood(on) {
|
||||||
|
this.inFeature = on;
|
||||||
|
this.stage.setFeature(on);
|
||||||
|
this.setBlueFire(on);
|
||||||
|
this.scene.tweens.add({ targets: this.moodGrade, fillAlpha: on ? 0.1 : 0, duration: 800 });
|
||||||
|
if (on) {
|
||||||
|
this.stage.sound('choir', () => playSound(this.scene, SFX.SCIFI_REVEAL));
|
||||||
|
this.buildReelFrame();
|
||||||
|
} else if (this.reelFrame) {
|
||||||
|
this.reelFrame.destroy(); this.reelLabel.destroy();
|
||||||
|
this.reelFrame = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
buildReelFrame() {
|
||||||
|
const view = this.view;
|
||||||
|
if (!view || this.reelFrame) return;
|
||||||
|
const x = view.reelX(this.wildCol);
|
||||||
|
const g = this.scene.add.graphics().setDepth(view.depth + 3);
|
||||||
|
g.lineStyle(10, GOLD, 0.35);
|
||||||
|
g.strokeRoundedRect(x - 4, view.y - 4, view.cellW + 8, view.height() + 8, 12);
|
||||||
|
g.lineStyle(4, 0xfff3c0, 1);
|
||||||
|
g.strokeRoundedRect(x - 2, view.y - 2, view.cellW + 4, view.height() + 4, 10);
|
||||||
|
this.reelFrame = g;
|
||||||
|
this.reelLabel = this.scene.add.text(x + view.cellW / 2, view.y - 13, 'WILD REEL', {
|
||||||
|
fontFamily: 'Righteous', fontSize: '18px', color: '#ffd86b', stroke: '#1a1430', strokeThickness: 5,
|
||||||
|
}).setOrigin(0.5).setDepth(this.D.cab + 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stone doors slide shut over the reels, show a cartouche, then open.
|
||||||
|
async tombDoors(message, whileClosed) {
|
||||||
|
const { scene } = this;
|
||||||
|
const view = this.view;
|
||||||
|
const { win } = this.g;
|
||||||
|
const pad = 26;
|
||||||
|
const dw = Math.ceil(win.w / 2) + pad; const dh = win.h + pad * 2;
|
||||||
|
const key = bakeDoor(scene, dw, dh);
|
||||||
|
const maskG = scene.make.graphics({ add: false });
|
||||||
|
maskG.fillStyle(0xffffff);
|
||||||
|
maskG.fillRect(win.x - pad, win.y - pad, win.w + pad * 2, dh);
|
||||||
|
const mask = maskG.createGeometryMask();
|
||||||
|
const depth = view.depth + 21;
|
||||||
|
const L = scene.add.image(win.x - pad - dw, win.y - pad, key).setOrigin(0).setDepth(depth).setMask(mask);
|
||||||
|
const R = scene.add.image(win.x + win.w + pad, win.y - pad, key).setOrigin(0).setFlipX(true).setDepth(depth).setMask(mask);
|
||||||
|
const midX = win.x + win.w / 2;
|
||||||
|
this.stage.sound('doors', () => playSound(scene, SFX.ENGINE_HEAVY));
|
||||||
|
await new Promise((res) => {
|
||||||
|
scene.tweens.add({ targets: L, x: midX - dw, duration: 650, ease: 'Quad.in' });
|
||||||
|
scene.tweens.add({ targets: R, x: midX, duration: 650, ease: 'Quad.in', onComplete: res });
|
||||||
|
});
|
||||||
|
scene.cameras.main.shake(260, 0.008);
|
||||||
|
const dust = scene.add.particles(midX, win.y + win.h / 2, 'slots-glow', {
|
||||||
|
y: { min: -win.h / 2, max: win.h / 2 }, speedX: { min: -140, max: 140 }, speedY: { min: -30, max: 30 },
|
||||||
|
lifespan: 900, scale: { start: 0.12, end: 0.35 }, alpha: { start: 0.5, end: 0 }, tint: 0xc8a878, emitting: false,
|
||||||
|
}).setDepth(depth + 1);
|
||||||
|
dust.explode(40);
|
||||||
|
scene.time.delayedCall(1000, () => dust.destroy());
|
||||||
|
|
||||||
|
// Cartouche.
|
||||||
|
const cy = win.y + win.h / 2;
|
||||||
|
const plate = scene.add.graphics().setDepth(depth + 2);
|
||||||
|
plate.fillStyle(0x1a1430, 0.92);
|
||||||
|
plate.fillRoundedRect(midX - 330, cy - 90, 660, 180, 90);
|
||||||
|
plate.lineStyle(8, GOLD, 1);
|
||||||
|
plate.strokeRoundedRect(midX - 330, cy - 90, 660, 180, 90);
|
||||||
|
plate.lineStyle(3, LAPIS, 1);
|
||||||
|
plate.strokeRoundedRect(midX - 316, cy - 76, 632, 152, 76);
|
||||||
|
const txt = scene.add.text(midX, cy, message, {
|
||||||
|
fontFamily: 'Righteous', fontSize: '58px', color: '#ffd86b', align: 'center',
|
||||||
|
stroke: '#2a1400', strokeThickness: 8,
|
||||||
|
}).setOrigin(0.5).setDepth(depth + 3).setScale(0.3).setShadow(0, 0, 'rgba(255,200,80,0.9)', 22);
|
||||||
|
plate.setAlpha(0);
|
||||||
|
scene.tweens.add({ targets: plate, alpha: 1, duration: 250 });
|
||||||
|
scene.tweens.add({ targets: txt, scale: 1, duration: 380, ease: 'Back.out' });
|
||||||
|
whileClosed?.();
|
||||||
|
await wait(scene, 1700);
|
||||||
|
scene.tweens.add({ targets: [plate, txt], alpha: 0, duration: 250 });
|
||||||
|
await wait(scene, 250);
|
||||||
|
plate.destroy(); txt.destroy();
|
||||||
|
|
||||||
|
this.stage.sound('doors', () => playSound(scene, SFX.ENGINE_HEAVY));
|
||||||
|
await new Promise((res) => {
|
||||||
|
scene.tweens.add({ targets: L, x: win.x - pad - dw, duration: 800, ease: 'Sine.inOut' });
|
||||||
|
scene.tweens.add({ targets: R, x: win.x + win.w + pad, duration: 800, ease: 'Sine.inOut', onComplete: res });
|
||||||
|
});
|
||||||
|
L.destroy(); R.destroy(); maskG.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Expanding wild: a pillar of light slams down reel 3 and it turns to pharaohs.
|
||||||
|
async playExpandWild(step) {
|
||||||
|
const { scene } = this;
|
||||||
|
const view = this.view;
|
||||||
|
const x = view.reelX(step.col) + view.cellW / 2;
|
||||||
|
this.stage.sound('beam', () => playSound(scene, SFX.SCIFI_RISER));
|
||||||
|
const pillar = scene.add.image(x, 0, 'slots-gloss').setOrigin(0.5, 0).setDisplaySize(view.cellW * 1.3, 10)
|
||||||
|
.setTint(0xfff3c0).setBlendMode(ADD).setDepth(view.depth + 5);
|
||||||
|
await new Promise((res) => scene.tweens.add({
|
||||||
|
targets: pillar, displayHeight: view.y + view.height() + 20, duration: 260, ease: 'Quad.in', onComplete: res,
|
||||||
|
}));
|
||||||
|
scene.cameras.main.shake(200, 0.006);
|
||||||
|
this.stage.lights.flashAll(0xfff3c0, 1);
|
||||||
|
const art = this.stage.artKey('sarcophagus');
|
||||||
|
if (art) {
|
||||||
|
const s = scene.add.image(x, view.y - view.height(), art).setOrigin(0.5, 0)
|
||||||
|
.setDisplaySize(view.cellW * 0.96, view.height()).setDepth(view.depth + 1.5).setMask(view.mask);
|
||||||
|
view.overlays.push(s);
|
||||||
|
scene.tweens.add({ targets: s, y: view.y, duration: 520, ease: 'Bounce.out' });
|
||||||
|
}
|
||||||
|
const wildKey = this.sym(this.m.wild.symbol);
|
||||||
|
for (const { c, r } of step.cells) {
|
||||||
|
const img = view.image(c, r);
|
||||||
|
img.setTexture(wildKey);
|
||||||
|
img.setDisplaySize(view.cellW * 0.88, view.cellH * 0.88);
|
||||||
|
img.baseScaleX = img.scaleX; img.baseScaleY = img.scaleY;
|
||||||
|
const p = view.cellCenter(c, r);
|
||||||
|
scene.fx?.burst(p.x, p.y, 10, GOLD);
|
||||||
|
await wait(scene, 140);
|
||||||
|
}
|
||||||
|
scene.tweens.add({ targets: pillar, alpha: 0, duration: 500, onComplete: () => pillar.destroy() });
|
||||||
|
await wait(scene, 300);
|
||||||
|
}
|
||||||
|
|
||||||
|
shutdown() {}
|
||||||
|
}
|
||||||
|
|
@ -7,15 +7,23 @@
|
||||||
// notch stops. The view only ever displays what the engine decided.
|
// notch stops. The view only ever displays what the engine decided.
|
||||||
|
|
||||||
import { textureKeyFor } from './SlotsSymbols.js';
|
import { textureKeyFor } from './SlotsSymbols.js';
|
||||||
|
import { bakeGlassTexture } from './SlotsAttract.js';
|
||||||
import { playSound, SFX } from '../../ui/Sounds.js';
|
import { playSound, SFX } from '../../ui/Sounds.js';
|
||||||
|
|
||||||
const SPIN_SPEED = 0.024; // cells per ms at full speed
|
const SPIN_SPEED = 0.024; // cells per ms at full speed
|
||||||
const ACCEL_MS = 160;
|
const ACCEL_MS = 160;
|
||||||
const STAGGER_MS = 220;
|
const STAGGER_MS = 220;
|
||||||
const ANTICIPATION_MS = 1500;
|
const ANTICIPATION_MS = 1500;
|
||||||
|
const WINDUP_MS = 110;
|
||||||
|
|
||||||
export class ReelView {
|
export class ReelView {
|
||||||
constructor(scene, machine, { x, y, cellW, cellH, gap = 10, depth = 10 }) {
|
// glass (optional, attract machines): themed reel backplates instead of the
|
||||||
|
// black frame — { frame, frameAlpha, top, bottom, stripe, stripeAlpha,
|
||||||
|
// edge, edgeAlpha, shade, shadeAlpha }.
|
||||||
|
// peek (px, vintage machines): the window also shows this much of the strip
|
||||||
|
// above and below the paylines — the real neighbouring symbols, as on a
|
||||||
|
// physical drum — with heavier curvature shading.
|
||||||
|
constructor(scene, machine, { x, y, cellW, cellH, gap = 10, depth = 10, glass = null, peek = 0 }) {
|
||||||
this.scene = scene;
|
this.scene = scene;
|
||||||
this.machine = machine;
|
this.machine = machine;
|
||||||
this.x = x; this.y = y;
|
this.x = x; this.y = y;
|
||||||
|
|
@ -26,23 +34,42 @@ export class ReelView {
|
||||||
this.spinningCount = 0;
|
this.spinningCount = 0;
|
||||||
this.overlays = []; // value texts pinned to cells
|
this.overlays = []; // value texts pinned to cells
|
||||||
this.stickyImgs = []; // "stuck to the glass" wild overlays
|
this.stickyImgs = []; // "stuck to the glass" wild overlays
|
||||||
|
this.wobbleAmp = 0; // idle jelly wobble (attract machines)
|
||||||
|
this.wobbleT = 0;
|
||||||
|
this.stopSound = null; // optional (c) => void replacing the stop click
|
||||||
|
this.onReelStop = null; // (c, anticipating) => void
|
||||||
|
this.onAnticipationStart = null; // (c) => void, reel c is now the one being teased
|
||||||
|
this.peek = peek;
|
||||||
|
// Image stack covers rows lo..hi (one spare above/below; two with peek).
|
||||||
|
const extra = peek > 0 ? 1 : 0;
|
||||||
|
this.lo = -1 - extra;
|
||||||
|
this.hi = this.rows + extra;
|
||||||
|
|
||||||
const w = this.width(); const h = this.height();
|
const w = this.width(); const h = this.height();
|
||||||
|
const vy = y - peek; const vh = h + peek * 2; // visible window
|
||||||
|
|
||||||
// Reel backplates + window frame.
|
// Reel backplates + window frame.
|
||||||
const g = scene.add.graphics().setDepth(depth - 2);
|
const g = scene.add.graphics().setDepth(depth - 2);
|
||||||
g.fillStyle(0x000000, 0.85);
|
g.fillStyle(glass ? glass.frame : 0x000000, glass ? (glass.frameAlpha ?? 1) : 0.85);
|
||||||
g.fillRoundedRect(x - 10, y - 10, w + 20, h + 20, 18);
|
g.fillRoundedRect(x - 10, vy - 10, w + 20, vh + 20, 18);
|
||||||
for (let c = 0; c < this.nReels; c++) {
|
this.glassImgs = [];
|
||||||
g.fillStyle(machine.theme.reelBg, 1);
|
if (glass) {
|
||||||
g.fillRoundedRect(this.reelX(c), y, cellW, h, 10);
|
const key = bakeGlassTexture(scene, machine.id, cellW, vh, glass);
|
||||||
|
for (let c = 0; c < this.nReels; c++) {
|
||||||
|
this.glassImgs.push(scene.add.image(this.reelX(c), vy, key).setOrigin(0).setDepth(depth - 2));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (let c = 0; c < this.nReels; c++) {
|
||||||
|
g.fillStyle(machine.theme.reelBg, 1);
|
||||||
|
g.fillRoundedRect(this.reelX(c), y, cellW, h, 10);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.frame = g;
|
this.frame = g;
|
||||||
|
|
||||||
// Shared window mask.
|
// Shared window mask.
|
||||||
const maskG = scene.make.graphics({ add: false });
|
const maskG = scene.make.graphics({ add: false });
|
||||||
maskG.fillStyle(0xffffff);
|
maskG.fillStyle(0xffffff);
|
||||||
maskG.fillRect(x, y, w, h);
|
maskG.fillRect(x, vy, w, vh);
|
||||||
this.mask = maskG.createGeometryMask();
|
this.mask = maskG.createGeometryMask();
|
||||||
this.maskG = maskG;
|
this.maskG = maskG;
|
||||||
|
|
||||||
|
|
@ -50,7 +77,7 @@ export class ReelView {
|
||||||
this.reels = [];
|
this.reels = [];
|
||||||
for (let c = 0; c < this.nReels; c++) {
|
for (let c = 0; c < this.nReels; c++) {
|
||||||
const imgs = [];
|
const imgs = [];
|
||||||
for (let i = -1; i <= this.rows; i++) {
|
for (let i = this.lo; i <= this.hi; i++) {
|
||||||
const img = scene.add.image(this.reelX(c) + cellW / 2, 0, '__DEFAULT')
|
const img = scene.add.image(this.reelX(c) + cellW / 2, 0, '__DEFAULT')
|
||||||
.setDepth(depth).setMask(this.mask);
|
.setDepth(depth).setMask(this.mask);
|
||||||
imgs.push(img);
|
imgs.push(img);
|
||||||
|
|
@ -63,11 +90,14 @@ export class ReelView {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shade strips top/bottom for reel curvature.
|
// Shade strips top/bottom for reel curvature.
|
||||||
|
const sc = glass?.shade ?? 0x000000;
|
||||||
|
const sa = glass?.shadeAlpha ?? 0.45;
|
||||||
|
const sh = peek > 0 ? peek + 28 : Math.min(34, h * 0.18);
|
||||||
const shade = scene.add.graphics().setDepth(depth + 1).setMask(this.mask);
|
const shade = scene.add.graphics().setDepth(depth + 1).setMask(this.mask);
|
||||||
shade.fillGradientStyle(0x000000, 0x000000, 0x000000, 0x000000, 0.45, 0.45, 0, 0);
|
shade.fillGradientStyle(sc, sc, sc, sc, sa, sa, 0, 0);
|
||||||
shade.fillRect(x, y, w, Math.min(34, h * 0.18));
|
shade.fillRect(x, vy, w, sh);
|
||||||
shade.fillGradientStyle(0x000000, 0x000000, 0x000000, 0x000000, 0, 0, 0.45, 0.45);
|
shade.fillGradientStyle(sc, sc, sc, sc, 0, 0, sa, sa);
|
||||||
shade.fillRect(x, y + h - Math.min(34, h * 0.18), w, Math.min(34, h * 0.18));
|
shade.fillRect(x, vy + vh - sh, w, sh);
|
||||||
this.shade = shade;
|
this.shade = shade;
|
||||||
|
|
||||||
this.updateHandler = (time, delta) => this.update(delta);
|
this.updateHandler = (time, delta) => this.update(delta);
|
||||||
|
|
@ -81,7 +111,7 @@ export class ReelView {
|
||||||
cellCenter(c, r) {
|
cellCenter(c, r) {
|
||||||
return { x: this.reelX(c) + this.cellW / 2, y: this.y + r * this.cellH + this.cellH / 2 };
|
return { x: this.reelX(c) + this.cellW / 2, y: this.y + r * this.cellH + this.cellH / 2 };
|
||||||
}
|
}
|
||||||
image(c, r) { return this.reels[c].imgs[r + 1]; }
|
image(c, r) { return this.reels[c].imgs[r - this.lo]; }
|
||||||
|
|
||||||
symKey(symbolId) { return textureKeyFor(this.scene, this.machine.id, symbolId); }
|
symKey(symbolId) { return textureKeyFor(this.scene, this.machine.id, symbolId); }
|
||||||
|
|
||||||
|
|
@ -92,8 +122,8 @@ export class ReelView {
|
||||||
const len = strip.length;
|
const len = strip.length;
|
||||||
const top = Math.floor(reel.pos);
|
const top = Math.floor(reel.pos);
|
||||||
const frac = reel.pos - top;
|
const frac = reel.pos - top;
|
||||||
for (let i = -1; i <= this.rows; i++) {
|
for (let i = this.lo; i <= this.hi; i++) {
|
||||||
const img = reel.imgs[i + 1];
|
const img = reel.imgs[i - this.lo];
|
||||||
const stripIdx = ((top + i) % len + len) % len;
|
const stripIdx = ((top + i) % len + len) % len;
|
||||||
const key = this.symKey(strip[stripIdx]);
|
const key = this.symKey(strip[stripIdx]);
|
||||||
if (img.texture.key !== key) {
|
if (img.texture.key !== key) {
|
||||||
|
|
@ -117,6 +147,79 @@ export class ReelView {
|
||||||
reel.pos = ((reel.pos - reel.speed * delta) % len + len) % len;
|
reel.pos = ((reel.pos - reel.speed * delta) % len + len) % len;
|
||||||
this.applyReel(c);
|
this.applyReel(c);
|
||||||
}
|
}
|
||||||
|
if (this.wobbleAmp > 0) this.applyWobble(delta);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Idle jelly wobble: a diagonal squash-and-stretch wave, bottom-anchored ──
|
||||||
|
setWobble(amp) {
|
||||||
|
if (amp === this.wobbleAmp) return;
|
||||||
|
this.wobbleAmp = amp;
|
||||||
|
if (!amp) this.restoreWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
applyWobble(delta) {
|
||||||
|
if (this.reels.some((r) => r.spinning)) return;
|
||||||
|
this.wobbleT += delta;
|
||||||
|
for (let c = 0; c < this.nReels; c++) {
|
||||||
|
for (let r = 0; r < this.rows; r++) {
|
||||||
|
const img = this.image(c, r);
|
||||||
|
if (img.baseScaleX === undefined) continue;
|
||||||
|
const s = Math.sin(this.wobbleT * 0.0032 - (c * 0.62 + r * 0.48)) * this.wobbleAmp;
|
||||||
|
img.scaleX = img.baseScaleX * (1 + s);
|
||||||
|
img.scaleY = img.baseScaleY * (1 - s);
|
||||||
|
img.y = this.y + r * this.cellH + this.cellH / 2 + s * this.cellH * 0.44;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
restoreWindow() {
|
||||||
|
for (let c = 0; c < this.nReels; c++) {
|
||||||
|
for (let r = 0; r < this.rows; r++) {
|
||||||
|
const img = this.image(c, r);
|
||||||
|
if (img.baseScaleX !== undefined) { img.scaleX = img.baseScaleX; img.scaleY = img.baseScaleY; }
|
||||||
|
img.y = this.y + r * this.cellH + this.cellH / 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Highlighting ────────────────────────────────────────────────────────────
|
||||||
|
// Dim every window cell except the given ones (win presentation).
|
||||||
|
dimExcept(cells, alpha = 0.38) {
|
||||||
|
const keep = new Set(cells.map(({ c, r }) => `${c},${r}`));
|
||||||
|
for (let c = 0; c < this.nReels; c++) {
|
||||||
|
for (let r = 0; r < this.rows; r++) {
|
||||||
|
this.image(c, r).alpha = keep.has(`${c},${r}`) ? 1 : alpha;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
undim() {
|
||||||
|
for (let c = 0; c < this.nReels; c++) {
|
||||||
|
for (let r = 0; r < this.rows; r++) this.image(c, r).alpha = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Anticipation: dim the settled reels so the teased one owns the stage.
|
||||||
|
// c < 0 restores everything.
|
||||||
|
spotlightReel(c) {
|
||||||
|
for (let k = 0; k < this.nReels; k++) {
|
||||||
|
if (k === c || this.reels[k].spinning) continue;
|
||||||
|
for (const img of this.reels[k].imgs) img.alpha = c < 0 ? 1 : 0.45;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Jelly landing: squash the given cells then spring back to rest.
|
||||||
|
squash(cells) {
|
||||||
|
for (const { c, r } of cells) {
|
||||||
|
const img = this.image(c, r);
|
||||||
|
if (img.baseScaleX === undefined) continue;
|
||||||
|
img.scaleX = img.baseScaleX * 1.16;
|
||||||
|
img.scaleY = img.baseScaleY * 0.78;
|
||||||
|
this.scene.tweens.add({
|
||||||
|
targets: img, scaleX: img.baseScaleX, scaleY: img.baseScaleY,
|
||||||
|
duration: 320, ease: 'Back.out',
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show a resolved grid instantly (used after spins/tumbles to make the
|
// Show a resolved grid instantly (used after spins/tumbles to make the
|
||||||
|
|
@ -127,8 +230,8 @@ export class ReelView {
|
||||||
reel.spinning = false; reel.speed = 0; reel.blur = 0; reel.bounce = 0;
|
reel.spinning = false; reel.speed = 0; reel.blur = 0; reel.bounce = 0;
|
||||||
const strip = this.machine.strips[c];
|
const strip = this.machine.strips[c];
|
||||||
const len = strip.length;
|
const len = strip.length;
|
||||||
for (let i = -1; i <= this.rows; i++) {
|
for (let i = this.lo; i <= this.hi; i++) {
|
||||||
const img = reel.imgs[i + 1];
|
const img = reel.imgs[i - this.lo];
|
||||||
const inWindow = i >= 0 && i < this.rows;
|
const inWindow = i >= 0 && i < this.rows;
|
||||||
const symbolId = inWindow
|
const symbolId = inWindow
|
||||||
? grid[c][i]
|
? grid[c][i]
|
||||||
|
|
@ -145,7 +248,10 @@ export class ReelView {
|
||||||
// Spin all reels to the given stops. Resolves when the last reel settles.
|
// Spin all reels to the given stops. Resolves when the last reel settles.
|
||||||
// opts: { anticipationFrom: reelIndex|null, stepped: bool, held: bool[] }
|
// opts: { anticipationFrom: reelIndex|null, stepped: bool, held: bool[] }
|
||||||
spin(stops, opts = {}) {
|
spin(stops, opts = {}) {
|
||||||
const { anticipationFrom = null, stepped = false, held = [] } = opts;
|
const {
|
||||||
|
anticipationFrom = null, stepped = false, held = [], windup = false,
|
||||||
|
anticipationMs = ANTICIPATION_MS,
|
||||||
|
} = opts;
|
||||||
this.clearOverlays();
|
this.clearOverlays();
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
let remaining = 0;
|
let remaining = 0;
|
||||||
|
|
@ -154,11 +260,16 @@ export class ReelView {
|
||||||
if (held[c]) continue;
|
if (held[c]) continue;
|
||||||
remaining++;
|
remaining++;
|
||||||
const anticipate = anticipationFrom !== null && c >= anticipationFrom;
|
const anticipate = anticipationFrom !== null && c >= anticipationFrom;
|
||||||
if (anticipate) extra += ANTICIPATION_MS;
|
if (anticipate) extra += anticipationMs;
|
||||||
const stopDelay = 520 + c * STAGGER_MS + (anticipate ? extra : 0);
|
const stopDelay = 520 + c * STAGGER_MS + (anticipate ? extra : 0);
|
||||||
this.startReel(c, stops[c], stopDelay, stepped, anticipate, () => {
|
this.startReel(c, stops[c], stopDelay, stepped, anticipate, windup, () => {
|
||||||
playSound(this.scene, SFX.PIECE_CLICK);
|
if (this.stopSound) this.stopSound(c);
|
||||||
|
else playSound(this.scene, SFX.PIECE_CLICK);
|
||||||
if (this.onReelStop) this.onReelStop(c, anticipate);
|
if (this.onReelStop) this.onReelStop(c, anticipate);
|
||||||
|
const next = c + 1;
|
||||||
|
if (anticipationFrom !== null && next >= anticipationFrom && next < this.nReels && !held[next]) {
|
||||||
|
this.onAnticipationStart?.(next);
|
||||||
|
}
|
||||||
if (--remaining === 0) resolve();
|
if (--remaining === 0) resolve();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -166,16 +277,24 @@ export class ReelView {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
startReel(c, stop, stopDelay, stepped, anticipate, done) {
|
startReel(c, stop, stopDelay, stepped, anticipate, windup, done) {
|
||||||
const scene = this.scene;
|
const scene = this.scene;
|
||||||
const reel = this.reels[c];
|
const reel = this.reels[c];
|
||||||
const len = this.machine.strips[c].length;
|
const len = this.machine.strips[c].length;
|
||||||
reel.spinning = true;
|
reel.spinning = true;
|
||||||
|
|
||||||
|
// Optional wind-up: the reel tugs upward before it lets go.
|
||||||
|
if (windup) {
|
||||||
|
scene.tweens.add({
|
||||||
|
targets: reel, bounce: -16, duration: WINDUP_MS, ease: 'Quad.out',
|
||||||
|
onComplete: () => scene.tweens.add({ targets: reel, bounce: 0, duration: 150, ease: 'Quad.in' }),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Accelerate into the blur.
|
// Accelerate into the blur.
|
||||||
scene.tweens.add({
|
scene.tweens.add({
|
||||||
targets: reel, speed: SPIN_SPEED, blur: 1,
|
targets: reel, speed: SPIN_SPEED, blur: 1,
|
||||||
duration: ACCEL_MS, ease: 'Quad.in',
|
duration: ACCEL_MS, ease: 'Quad.in', delay: windup ? WINDUP_MS : 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
scene.time.delayedCall(stopDelay, () => {
|
scene.time.delayedCall(stopDelay, () => {
|
||||||
|
|
@ -253,8 +372,25 @@ export class ReelView {
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A glow/ring image behind a cell's symbol (e.g. rainbow multipliers);
|
||||||
|
// cleared with the other overlays when the next spin starts.
|
||||||
|
addCellHalo(c, r, key, { size = 1, spinMs = 0, alpha = 1, tint = null, add = false } = {}) {
|
||||||
|
const { x, y } = this.cellCenter(c, r);
|
||||||
|
const s = Math.min(this.cellW, this.cellH) * size;
|
||||||
|
const img = this.scene.add.image(x, y, key).setDisplaySize(s, s).setAlpha(alpha)
|
||||||
|
.setDepth(this.depth - 1).setMask(this.mask);
|
||||||
|
if (tint !== null) img.setTint(tint);
|
||||||
|
if (add) img.setBlendMode('ADD');
|
||||||
|
if (spinMs) this.scene.tweens.add({ targets: img, angle: 360, duration: spinMs, repeat: -1 });
|
||||||
|
this.overlays.push(img);
|
||||||
|
return img;
|
||||||
|
}
|
||||||
|
|
||||||
clearOverlays() {
|
clearOverlays() {
|
||||||
for (const t of this.overlays) t.destroy();
|
for (const t of this.overlays) {
|
||||||
|
this.scene.tweens.killTweensOf(t);
|
||||||
|
t.destroy();
|
||||||
|
}
|
||||||
this.overlays = [];
|
this.overlays = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -267,6 +403,7 @@ export class ReelView {
|
||||||
const img = this.scene.add.image(x, y, this.symKey(symbolId))
|
const img = this.scene.add.image(x, y, this.symKey(symbolId))
|
||||||
.setDepth(this.depth + 2);
|
.setDepth(this.depth + 2);
|
||||||
img.setDisplaySize(this.cellW * 0.92, this.cellH * 0.92);
|
img.setDisplaySize(this.cellW * 0.92, this.cellH * 0.92);
|
||||||
|
img.cell = { c, r };
|
||||||
this.stickyImgs.push(img);
|
this.stickyImgs.push(img);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -277,6 +414,7 @@ export class ReelView {
|
||||||
for (const reel of this.reels) for (const img of reel.imgs) img.destroy();
|
for (const reel of this.reels) for (const img of reel.imgs) img.destroy();
|
||||||
this.clearOverlays();
|
this.clearOverlays();
|
||||||
this.setSticky([], null);
|
this.setSticky([], null);
|
||||||
|
for (const gi of this.glassImgs) gi.destroy();
|
||||||
this.frame.destroy(); this.shade.destroy(); this.maskG.destroy();
|
this.frame.destroy(); this.shade.destroy(); this.maskG.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,101 @@
|
||||||
|
// SlotsVintage — shared pieces for the vintage (electromechanical) attract
|
||||||
|
// machines: chrome fills, bulb-outline sampling and the chrome pull lever.
|
||||||
|
// Used by SlotsLucky.js and SlotsFruit.js.
|
||||||
|
|
||||||
|
import { playSound, SFX } from '../../ui/Sounds.js';
|
||||||
|
|
||||||
|
// Evenly spaced points along a closed polygon (for bulb strips).
|
||||||
|
export function outline(poly, spacing) {
|
||||||
|
const pts = [...poly, poly[0]];
|
||||||
|
let L = 0;
|
||||||
|
const seg = [];
|
||||||
|
for (let i = 1; i < pts.length; i++) {
|
||||||
|
const d = Math.hypot(pts[i].x - pts[i - 1].x, pts[i].y - pts[i - 1].y);
|
||||||
|
seg.push(d); L += d;
|
||||||
|
}
|
||||||
|
const n = Math.round(L / spacing);
|
||||||
|
const out = [];
|
||||||
|
let si = 0; let acc = 0;
|
||||||
|
for (let k = 0; k < n; k++) {
|
||||||
|
const s = (k / n) * L;
|
||||||
|
while (si < seg.length - 1 && acc + seg[si] < s) { acc += seg[si]; si++; }
|
||||||
|
const f = seg[si] ? (s - acc) / seg[si] : 0;
|
||||||
|
out.push({ x: pts[si].x + (pts[si + 1].x - pts[si].x) * f, y: pts[si].y + (pts[si + 1].y - pts[si].y) * f, u: s / L });
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
// A polished-chrome rounded block (light top half, darker bottom half).
|
||||||
|
export const chromeFill = (g, x, y, w, h, r = 6) => {
|
||||||
|
g.fillStyle(0x6a6e76, 1); g.fillRoundedRect(x, y, w, h, r);
|
||||||
|
g.fillStyle(0xe8ecf2, 1); g.fillRoundedRect(x + 2, y + 2, w - 4, h * 0.45, r);
|
||||||
|
g.fillStyle(0x9aa0aa, 1); g.fillRoundedRect(x + 2, y + h * 0.5, w - 4, h * 0.45, r);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Chrome pull lever on the cabinet's right side, red ball knob. Pulling it
|
||||||
|
// spins (scene.onSpin); it registers itself as scene.lever so SlotsGame
|
||||||
|
// disables it with the other controls. `style` restyles it (e.g. brass rod
|
||||||
|
// and a turned-wood knob for Liberty Belle).
|
||||||
|
const CHROME_STYLE = { rod: [0x8a9098, 0xf4f6fa], knob: [0x8a0a14, 0xd4313f, 0xffb0b8], housing: null };
|
||||||
|
|
||||||
|
export class ChromeLever {
|
||||||
|
constructor(props, style = {}) {
|
||||||
|
const S = { ...CHROME_STYLE, ...style };
|
||||||
|
const { scene, stage } = props;
|
||||||
|
const { cab, win } = props.g;
|
||||||
|
this.scene = scene;
|
||||||
|
this.stage = stage;
|
||||||
|
this.pulling = false;
|
||||||
|
const x = cab.x + cab.w + 34; const y0 = win.y + 50; const y1 = win.y + win.h - 20;
|
||||||
|
const depth = props.D.cab + 3;
|
||||||
|
const g = scene.add.graphics().setDepth(depth);
|
||||||
|
if (S.housing) {
|
||||||
|
g.fillStyle(S.housing[0], 1); g.fillRoundedRect(cab.x + cab.w - 4, y1 - 40, 44, 80, 10);
|
||||||
|
g.fillStyle(S.housing[1], 1); g.fillRoundedRect(cab.x + cab.w - 2, y1 - 38, 40, 34, 9);
|
||||||
|
} else {
|
||||||
|
chromeFill(g, cab.x + cab.w - 4, y1 - 40, 44, 80, 10);
|
||||||
|
}
|
||||||
|
g.fillStyle(0x14100a, 1); g.fillRoundedRect(x - 7, y0 - 10, 14, y1 - y0 + 20, 7);
|
||||||
|
const arm = scene.add.graphics().setDepth(depth + 0.1);
|
||||||
|
this.state = { t: 0 };
|
||||||
|
this.draw = () => {
|
||||||
|
arm.clear();
|
||||||
|
const ky = y0 + (y1 - y0 - 40) * this.state.t;
|
||||||
|
arm.lineStyle(14, S.rod[0], 1); arm.lineBetween(x, y1, x, ky + 10);
|
||||||
|
arm.lineStyle(5, S.rod[1], 0.9); arm.lineBetween(x - 3, y1, x - 3, ky + 10);
|
||||||
|
arm.fillStyle(S.knob[0], 1); arm.fillCircle(x, ky, 26);
|
||||||
|
arm.fillStyle(S.knob[1], 1); arm.fillCircle(x - 2, ky - 2, 22);
|
||||||
|
arm.fillStyle(S.knob[2], 0.85); arm.fillCircle(x - 9, ky - 9, 7);
|
||||||
|
};
|
||||||
|
this.draw();
|
||||||
|
let enabled = true;
|
||||||
|
const zone = scene.add.zone(x, (y0 + y1) / 2, 90, y1 - y0 + 60).setInteractive({ useHandCursor: true })
|
||||||
|
.setDepth(depth + 0.2);
|
||||||
|
zone.on('pointerdown', () => { if (enabled) this.pull(() => scene.onSpin()); });
|
||||||
|
scene.lever = { setEnabled: (v) => { enabled = v; } };
|
||||||
|
}
|
||||||
|
|
||||||
|
pull(then) {
|
||||||
|
if (this.pulling) return;
|
||||||
|
this.pulling = true;
|
||||||
|
const { scene } = this;
|
||||||
|
this.stage.sound('lever', () => playSound(scene, SFX.PIECE_CLICK));
|
||||||
|
scene.tweens.add({
|
||||||
|
targets: this.state, t: 1, duration: 220, ease: 'Quad.in', onUpdate: this.draw,
|
||||||
|
onComplete: () => {
|
||||||
|
then?.();
|
||||||
|
scene.tweens.add({
|
||||||
|
targets: this.state, t: 0, duration: 520, ease: 'Bounce.out', delay: 160, onUpdate: this.draw,
|
||||||
|
onComplete: () => { this.pulling = false; },
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// A little "come play" dip.
|
||||||
|
wiggle() {
|
||||||
|
if (this.pulling) return;
|
||||||
|
this.scene.tweens.add({ targets: this.state, t: 0.14, duration: 160, yoyo: true, repeat: 1,
|
||||||
|
ease: 'Sine.inOut', onUpdate: this.draw });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -100,6 +100,45 @@ export const MACHINES = [
|
||||||
cabinet: 0x5a3a1e, cabinetHi: 0x7a5430, trim: 0xc8a84b, glow: 0xffd98a,
|
cabinet: 0x5a3a1e, cabinetHi: 0x7a5430, trim: 0xc8a84b, glow: 0xffd98a,
|
||||||
screenTop: 0x2b1d10, screenBot: 0x191009, accentHex: '#ffd98a', reelBg: 0xf3ead2,
|
screenTop: 0x2b1d10, screenBot: 0x191009, accentHex: '#ffd98a', reelBg: 0xf3ead2,
|
||||||
},
|
},
|
||||||
|
// Attract kit (SlotsAttract.js) + the 1899 clockwork original (SlotsLiberty.js):
|
||||||
|
// visible gear train, a real bell, a coin run — iron, brass and gaslight.
|
||||||
|
attract: {
|
||||||
|
layout: { cellW: 210, cellH: 180, gap: 18, windowY: 350, marqueeH: 120, cabTop: 104, peek: 0.38, belly: 228 },
|
||||||
|
environment: 'parlor',
|
||||||
|
props: 'liberty',
|
||||||
|
media: { bgVideo: 'assets/videos/slots/background-1960s-casino.mp4', marqueeVideo: null },
|
||||||
|
sounds: {
|
||||||
|
ambient: null, lever: null, coinIn: null, tick: null, whir: null, stop: null,
|
||||||
|
bell: null, coins: null, winSmall: null, winMedium: null, winBig: null, attract: null,
|
||||||
|
},
|
||||||
|
cabinet: {
|
||||||
|
style: 'castIron', body: [0x2c302a, 0x0e100e], rim: 0xc8a04a, marqueeBack: 0x1a120a,
|
||||||
|
bezel: 'brass', bezelColors: [0x8a6a2a, 0xf3d58a], bezelWidth: 26, ledChannel: 0x0a0a08,
|
||||||
|
},
|
||||||
|
// Aged sepia paper reel strips on drums.
|
||||||
|
glass: {
|
||||||
|
frame: 0x14100a, frameAlpha: 1, top: 0xf6ecd2, bottom: 0xe2cfa0,
|
||||||
|
stripeAlpha: 0, edge: 0x5a3a14, edgeAlpha: 0.45, shade: 0x1a1008, shadeAlpha: 0.85,
|
||||||
|
},
|
||||||
|
lights: {
|
||||||
|
// 1899: only a sparse row of carbon-filament bulbs round the marquee.
|
||||||
|
palette: [0xffb04a, 0xffe0a0, 0xff7a2a],
|
||||||
|
texture: 'slots-bulb', lag: 0.25, spacingScale: 2.0, sizeScale: 1.3,
|
||||||
|
skipStrips: ['perimeter', 'window', 'dividers'],
|
||||||
|
idle: 'gaslight', attract: 'edisonSwell', spin: 'edisonSwell', anticipation: 'gaslight',
|
||||||
|
win: 'bulbWin', bigWin: 'bulbFrenzy', feature: 'gaslight', flash: 0xffe0a0,
|
||||||
|
},
|
||||||
|
bar: { fill: 0x1a120a, trim: 0xc8a04a, button: 0xb08030, buttonHover: 0xf3d58a, spinTextHex: '#1a120a' },
|
||||||
|
chainMeter: false,
|
||||||
|
symbolColors: {},
|
||||||
|
lineStyle: 'lamp',
|
||||||
|
lampColors: [0xffb04a, 0xffd27a, 0xfff6d8],
|
||||||
|
glints: false,
|
||||||
|
bigWinLabels: ['WINNER!', 'HANDSOME WIN!', 'GRAND PRIZE!'],
|
||||||
|
glintTint: 0xffe0a0,
|
||||||
|
wobble: 0,
|
||||||
|
spill: 0.45,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
// ── 2. Fruit Frenzy — 1960s fruit machine, HOLD & NUDGE ─────────────────────
|
// ── 2. Fruit Frenzy — 1960s fruit machine, HOLD & NUDGE ─────────────────────
|
||||||
|
|
@ -147,6 +186,46 @@ export const MACHINES = [
|
||||||
cabinet: 0x8c1d2f, cabinetHi: 0xb53247, trim: 0xe8e4da, glow: 0xff7da0,
|
cabinet: 0x8c1d2f, cabinetHi: 0xb53247, trim: 0xe8e4da, glow: 0xff7da0,
|
||||||
screenTop: 0x241016, screenBot: 0x14080c, accentHex: '#ffb3c7', reelBg: 0xfdf6e6,
|
screenTop: 0x241016, screenBot: 0x14080c, accentHex: '#ffb3c7', reelBg: 0xfdf6e6,
|
||||||
},
|
},
|
||||||
|
// Attract kit (SlotsAttract.js) + 1965 fruit-stand props (SlotsFruit.js).
|
||||||
|
// Vintage: lamps, chrome, neon and moving things — no modern animation.
|
||||||
|
attract: {
|
||||||
|
// Upright under a fruit-stand awning; belly holds the HOLD/NUDGE buttons.
|
||||||
|
layout: { cellW: 210, cellH: 150, gap: 18, windowY: 300, marqueeH: 120, cabTop: 110, belly: 106 },
|
||||||
|
environment: 'oldVegas',
|
||||||
|
props: 'fruit',
|
||||||
|
media: { bgVideo: 'assets/videos/slots/background-freemont-street.mp4', marqueeVideo: null },
|
||||||
|
sounds: {
|
||||||
|
ambient: null, lever: null, spin: null, stop: null, hold: null, nudge: null,
|
||||||
|
neon: null, fruit: null, coins: null, bell: null,
|
||||||
|
winSmall: null, winMedium: null, winBig: null, attract: null,
|
||||||
|
},
|
||||||
|
cabinet: {
|
||||||
|
style: 'chrome', woodSides: true, body: [0xc81e32, 0x7a0e1c], rim: 0xd8dce4, marqueeBack: 0x2a1408,
|
||||||
|
bezel: 'chrome', bezelColors: [0x6a6e76, 0xf4f6fa], bezelWidth: 26, ledChannel: 0x1a0a0a,
|
||||||
|
},
|
||||||
|
// Cream paper reel strips.
|
||||||
|
glass: {
|
||||||
|
frame: 0x14100a, frameAlpha: 1, top: 0xfff8ea, bottom: 0xf4e8cc,
|
||||||
|
stripeAlpha: 0, edge: 0x5a4020, edgeAlpha: 0.35, shade: 0x1a1008, shadeAlpha: 0.45,
|
||||||
|
},
|
||||||
|
lights: {
|
||||||
|
// Coloured glass bulb caps: cherry, lemon, orange, lime, plum, warm white.
|
||||||
|
palette: [0xff3040, 0xffe040, 0xff9020, 0x60e040, 0xb050ff, 0xfff0c8],
|
||||||
|
texture: 'slots-bulb', lag: 0.09, spacingScale: 1.3, sizeScale: 1.1,
|
||||||
|
idle: 'fruitChase', attract: 'fruitTwinkle', spin: 'marqueeRace', anticipation: 'bulbAlternate',
|
||||||
|
win: 'bulbWin', bigWin: 'bulbFrenzy', feature: 'fruitChase', flash: 0xfff0c8,
|
||||||
|
strips: { dividers: { idle: 'bulbDrip', attract: 'bulbDrip' } },
|
||||||
|
},
|
||||||
|
bar: { fill: 0x2a0a10, trim: 0xf4ead2, button: 0xc81e32, buttonHover: 0xffe040, spinTextHex: '#fff4d8' },
|
||||||
|
chainMeter: false,
|
||||||
|
symbolColors: {},
|
||||||
|
lineStyle: 'lamp',
|
||||||
|
glints: false,
|
||||||
|
bigWinLabels: ['SWEET WIN!', 'JUICY WIN!', 'TUTTI FRUTTI!'],
|
||||||
|
glintTint: 0xfff0c8,
|
||||||
|
wobble: 0,
|
||||||
|
spill: 0.5,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
// ── 3. Lucky Sevens — 1970s Vegas, doubling wild diamonds ───────────────────
|
// ── 3. Lucky Sevens — 1970s Vegas, doubling wild diamonds ───────────────────
|
||||||
|
|
@ -194,6 +273,56 @@ export const MACHINES = [
|
||||||
cabinet: 0x1b2440, cabinetHi: 0x2c3a66, trim: 0xd4313f, glow: 0x6fa8ff,
|
cabinet: 0x1b2440, cabinetHi: 0x2c3a66, trim: 0xd4313f, glow: 0x6fa8ff,
|
||||||
screenTop: 0x10162b, screenBot: 0x080b16, accentHex: '#8fb8ff', reelBg: 0xf2f2f2,
|
screenTop: 0x10162b, screenBot: 0x080b16, accentHex: '#8fb8ff', reelBg: 0xf2f2f2,
|
||||||
},
|
},
|
||||||
|
// Attract kit (SlotsAttract.js) + 1975 electromechanical props (SlotsLucky.js).
|
||||||
|
// Deliberately lamps, chrome and moving metal — no modern animation.
|
||||||
|
attract: {
|
||||||
|
// Tall upright: candle above, strip peeking around the payline, and a
|
||||||
|
// belly (odometer, backlit pay glass, coin tray) below the reels.
|
||||||
|
layout: { cellW: 210, cellH: 180, gap: 18, windowY: 350, marqueeH: 120, cabTop: 104, peek: 0.38, belly: 228 },
|
||||||
|
environment: 'oldVegas',
|
||||||
|
props: 'lucky',
|
||||||
|
media: { bgVideo: 'assets/videos/slots/background-old-vegas.mp4', marqueeVideo: null },
|
||||||
|
sounds: {
|
||||||
|
ambient: null, lever: null, spin: null, stop: null, bell: null, coins: null,
|
||||||
|
winSmall: null, winMedium: null, winBig: null, attract: null,
|
||||||
|
},
|
||||||
|
cabinet: {
|
||||||
|
style: 'chrome', body: [0xb01828, 0x5a0a14], rim: 0xd8dce4, marqueeBack: 0x14100a,
|
||||||
|
bezel: 'chrome', bezelColors: [0x6a6e76, 0xf4f6fa], bezelWidth: 26, ledChannel: 0x1a0a0a,
|
||||||
|
},
|
||||||
|
// Printed paper reel strips on drums.
|
||||||
|
glass: {
|
||||||
|
frame: 0x14100a, frameAlpha: 1, top: 0xfff8ea, bottom: 0xf0e4c4,
|
||||||
|
stripeAlpha: 0, edge: 0x5a4020, edgeAlpha: 0.4, shade: 0x1a1008, shadeAlpha: 0.85,
|
||||||
|
},
|
||||||
|
lights: {
|
||||||
|
// Incandescent only: [warm white, white-hot, red].
|
||||||
|
palette: [0xffd27a, 0xfff3d0, 0xff3a2a],
|
||||||
|
texture: 'slots-bulb', lag: 0.09, spacingScale: 1.3, sizeScale: 1.15,
|
||||||
|
idle: 'bulbChase', attract: 'vegasSign', spin: 'marqueeRace', anticipation: 'bulbAlternate',
|
||||||
|
win: 'bulbWin', bigWin: 'bulbFrenzy', feature: 'bulbSpin', flash: 0xfff3d0,
|
||||||
|
strips: {
|
||||||
|
dividers: { idle: 'bulbDrip', attract: 'bulbDrip' },
|
||||||
|
sign7: {
|
||||||
|
palette: [0xff4a3a, 0xfff0c0, 0xffb030],
|
||||||
|
idle: 'bulbChase', attract: 'vegasSign', spin: 'marqueeRace', win: 'bulbWin', bigWin: 'bulbFrenzy',
|
||||||
|
},
|
||||||
|
arrow: {
|
||||||
|
palette: [0xffe08a, 0xfff3d0, 0xff3a2a],
|
||||||
|
idle: 'arrowChase', attract: 'arrowChase', spin: 'arrowChase', win: 'bulbWin', bigWin: 'bulbFrenzy',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
bar: { fill: 0x1a0a0e, trim: 0xd8dce4, button: 0xd4313f, buttonHover: 0xffd27a, spinTextHex: '#fff4d8' },
|
||||||
|
chainMeter: false,
|
||||||
|
symbolColors: {},
|
||||||
|
lineStyle: 'lamp',
|
||||||
|
glints: false, // no modern sparkle on the paper reels
|
||||||
|
bigWinLabels: ['WINNER!', 'BIG WINNER!', 'JACKPOT!'],
|
||||||
|
glintTint: 0xfff3d0,
|
||||||
|
wobble: 0,
|
||||||
|
spill: 0.5,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
// ── 4. Pharaoh's Fortune — free spins + expanding wild ──────────────────────
|
// ── 4. Pharaoh's Fortune — free spins + expanding wild ──────────────────────
|
||||||
|
|
@ -239,6 +368,55 @@ export const MACHINES = [
|
||||||
cabinet: 0x223047, cabinetHi: 0x32486b, trim: 0xe6b94d, glow: 0xffd86b,
|
cabinet: 0x223047, cabinetHi: 0x32486b, trim: 0xe6b94d, glow: 0xffd86b,
|
||||||
screenTop: 0x2c2410, screenBot: 0x120d05, accentHex: '#ffd86b', reelBg: 0x1c1507,
|
screenTop: 0x2c2410, screenBot: 0x120d05, accentHex: '#ffd86b', reelBg: 0x1c1507,
|
||||||
},
|
},
|
||||||
|
// Attract kit (SlotsAttract.js) + temple of the sun props (SlotsPharaoh.js).
|
||||||
|
attract: {
|
||||||
|
layout: { cellW: 210, cellH: 176, gap: 12, windowY: 248, marqueeH: 132 },
|
||||||
|
environment: 'desert',
|
||||||
|
props: 'pharaoh',
|
||||||
|
// Drop-in media — set a path to enable (null = procedural / stock SFX).
|
||||||
|
// featureVideo crossfades in for free spins (e.g. the tomb's treasure chamber).
|
||||||
|
media: {
|
||||||
|
bgVideo: 'assets/videos/slots/background-pharaohs-fortune.mp4',
|
||||||
|
featureVideo: null, marqueeVideo: null,
|
||||||
|
},
|
||||||
|
// Optional art: a golden sarcophagus (~220×560) that slides down the wild reel.
|
||||||
|
art: { sarcophagus: null },
|
||||||
|
sounds: {
|
||||||
|
ambient: null, spin: null, stop: null, anticipation: null,
|
||||||
|
sandGust: null, doors: null, beam: null, choir: null, scarab: null,
|
||||||
|
winSmall: null, winMedium: null, winBig: null, attract: null,
|
||||||
|
},
|
||||||
|
cabinet: {
|
||||||
|
style: 'temple', body: [0xe0bc80, 0xa87a40], rim: 0xf0c441, marqueeBack: 0x1a1430,
|
||||||
|
bezel: 'stripes', bezelColors: [0x1f4fb8, 0xf0c441], bezelWidth: 26, ledChannel: 0x2a1a08,
|
||||||
|
},
|
||||||
|
// Tomb shadow warming to gold.
|
||||||
|
glass: {
|
||||||
|
frame: 0x0e0a1c, frameAlpha: 1, top: 0x1c2a5a, bottom: 0x3a2410,
|
||||||
|
stripeAlpha: 0, edge: 0x000000, edgeAlpha: 0.35, shade: 0x0a0818, shadeAlpha: 0.45,
|
||||||
|
},
|
||||||
|
lights: {
|
||||||
|
// [gold, lapis, white-gold, turquoise].
|
||||||
|
palette: [0xffc83a, 0x2a5cff, 0xfff3c0, 0x3ad8d0], lag: 0.05,
|
||||||
|
idle: 'sunPulse', attract: 'lapisWave', spin: 'scarabChase', anticipation: 'ra',
|
||||||
|
win: 'paletteChase', bigWin: 'bulbJackpot', feature: 'goldenStorm', flash: 0xfff3c0,
|
||||||
|
// During free spins.
|
||||||
|
featureMoods: { idle: 'goldenStorm', attract: 'goldenStorm', spin: 'scarabChase' },
|
||||||
|
},
|
||||||
|
windowSheen: { every: 7000, tint: 0xffe9a8 },
|
||||||
|
bar: { fill: 0x1a1430, trim: 0xf0c441, button: 0xf0c441, buttonHover: 0xfff3c0 },
|
||||||
|
symbolColors: {
|
||||||
|
pharaoh: 0xffd86b, pyramid: 0xe8b860, sphinx: 0xe0bc80, ankh: 0xffd86b, eye: 0x3a7aff,
|
||||||
|
cat: 0x8a8aa0, ace: 0xffd86b, king: 0xffd86b, queen: 0xffd86b, jack: 0xffd86b,
|
||||||
|
},
|
||||||
|
tease: { symbol: 'pyramid', after: 2, ms: 1000 },
|
||||||
|
lineStyle: { wild: 'sunbeam', default: 'goldVein' },
|
||||||
|
coinTexture: 'slots-coin-p',
|
||||||
|
bigWinLabels: ['GOLDEN BLESSING', "PHARAOH'S FAVOR", 'RICHES OF RA'],
|
||||||
|
glintTint: 0xfff3c0,
|
||||||
|
wobble: 0,
|
||||||
|
spill: 0.55,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
// ── 5. Abyssal Treasures — cascading reels + multiplier ladder ──────────────
|
// ── 5. Abyssal Treasures — cascading reels + multiplier ladder ──────────────
|
||||||
|
|
@ -278,6 +456,46 @@ export const MACHINES = [
|
||||||
cabinet: 0x0d2f3d, cabinetHi: 0x15485e, trim: 0x3fd6c0, glow: 0x59e7ff,
|
cabinet: 0x0d2f3d, cabinetHi: 0x15485e, trim: 0x3fd6c0, glow: 0x59e7ff,
|
||||||
screenTop: 0x06222e, screenBot: 0x020d13, accentHex: '#59e7ff', reelBg: 0x04161f,
|
screenTop: 0x06222e, screenBot: 0x020d13, accentHex: '#59e7ff', reelBg: 0x04161f,
|
||||||
},
|
},
|
||||||
|
// Attract kit (SlotsAttract.js) + Marina the mermaid & sea life (SlotsAbyssal.js).
|
||||||
|
attract: {
|
||||||
|
layout: { cellW: 210, cellH: 176, gap: 12, windowY: 248, marqueeH: 132 },
|
||||||
|
environment: 'abyss',
|
||||||
|
props: 'abyssal',
|
||||||
|
chainMeter: false, // the pearl ladder shows the cascade multiplier instead
|
||||||
|
// Drop-in media — set a path to enable (null = procedural / stock SFX).
|
||||||
|
media: { bgVideo: 'assets/videos/slots/background-abyssal-treasures.mp4', marqueeVideo: null },
|
||||||
|
sounds: {
|
||||||
|
ambient: null, spin: null, stop: null, pop: null, sonar: null, sing: null, giggle: null,
|
||||||
|
splash: null, pearl: null, winSmall: null, winMedium: null, winBig: null, attract: null,
|
||||||
|
},
|
||||||
|
cabinet: {
|
||||||
|
style: 'nautical', body: [0x0f4a5e, 0x062432], rim: 0xd9c27a, marqueeBack: 0x04202c,
|
||||||
|
bezel: 'brass', bezelColors: [0x2f6a5e, 0xd9c27a], bezelWidth: 26, ledChannel: 0x021018,
|
||||||
|
},
|
||||||
|
glass: {
|
||||||
|
frame: 0x021018, frameAlpha: 1, top: 0x1a6aa8, bottom: 0x062a52,
|
||||||
|
stripeAlpha: 0, edge: 0x000000, edgeAlpha: 0.3, shade: 0x021a3a, shadeAlpha: 0.4,
|
||||||
|
},
|
||||||
|
lights: {
|
||||||
|
// Bioluminescent: [cyan, violet, white, aqua].
|
||||||
|
palette: [0x39e6ff, 0x8a5cff, 0xffffff, 0x2affc0], lag: 0.04,
|
||||||
|
idle: 'ripple', attract: 'bubbleRise', spin: 'current', anticipation: 'sonarPing',
|
||||||
|
win: 'paletteChase', bigWin: 'bulbJackpot', feature: 'sonarPing', flash: 0xdff8ff,
|
||||||
|
},
|
||||||
|
windowCaustics: { alpha: 0.12, tint: 0xcff4ff },
|
||||||
|
bar: { fill: 0x041a2a, trim: 0x59e7ff, button: 0x2ad0e0, buttonHover: 0x9af6ff },
|
||||||
|
symbolColors: {
|
||||||
|
pearl: 0xf3eefa, mermaid: 0x2affc0, octopus: 0xff6a9a, seahorse: 0xffb347, angler: 0x6a8cff,
|
||||||
|
starfish: 0xff8c5a, shell: 0xffc8a8, coral: 0xff5fa8, bubble: 0x9af6ff,
|
||||||
|
},
|
||||||
|
tumbleStyle: 'bubbles',
|
||||||
|
lineStyle: 'bubbles',
|
||||||
|
coinTexture: 'slots-pearl',
|
||||||
|
bigWinLabels: ['BIG CATCH', 'SUNKEN TREASURE', 'ABYSSAL!'],
|
||||||
|
glintTint: 0xdff8ff,
|
||||||
|
wobble: 0,
|
||||||
|
spill: 0.5,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
// ── 6. Dragon's Hoard — hold-and-spin coins + progressive jackpot ───────────
|
// ── 6. Dragon's Hoard — hold-and-spin coins + progressive jackpot ───────────
|
||||||
|
|
@ -328,6 +546,64 @@ export const MACHINES = [
|
||||||
cabinet: 0x33121c, cabinetHi: 0x55202e, trim: 0xe8483f, glow: 0xff8c3b,
|
cabinet: 0x33121c, cabinetHi: 0x55202e, trim: 0xe8483f, glow: 0xff8c3b,
|
||||||
screenTop: 0x2a0f08, screenBot: 0x120503, accentHex: '#ff9d4d', reelBg: 0x190a06,
|
screenTop: 0x2a0f08, screenBot: 0x120503, accentHex: '#ff9d4d', reelBg: 0x190a06,
|
||||||
},
|
},
|
||||||
|
// Attract kit (SlotsAttract.js) + dragon/knight props (SlotsDragon.js).
|
||||||
|
attract: {
|
||||||
|
// Cells are a little shorter so the jackpot plaques fit above the reels.
|
||||||
|
layout: { cellW: 210, cellH: 160, gap: 12, windowY: 320, marqueeH: 132 },
|
||||||
|
environment: 'dragonCave',
|
||||||
|
props: 'dragonHoard',
|
||||||
|
// Drop-in media — set a path to enable (null = procedural / stock SFX).
|
||||||
|
media: { bgVideo: 'assets/videos/slots/background-dragons-hoard.mp4', marqueeVideo: null },
|
||||||
|
// Character art (null = stand-ins built from the symbol art). See SlotsDragon.js.
|
||||||
|
art: {
|
||||||
|
dragonSleep: null, dragonWake: null, dragonRoar: null, dragonWing: null,
|
||||||
|
knightSneak: null, knightRun: null, knightVictory: null,
|
||||||
|
coinMini: null, coinMinor: null, coinMajor: null, coinGrand: null,
|
||||||
|
},
|
||||||
|
// Placement tuning: `standin` applies to the symbol-art stand-in, `art`
|
||||||
|
// to supplied dragon art (anchors are fractions of the image).
|
||||||
|
characters: {
|
||||||
|
dragon: { standin: {}, art: {} },
|
||||||
|
wing: {},
|
||||||
|
knight: {},
|
||||||
|
},
|
||||||
|
sounds: {
|
||||||
|
ambient: null, spin: null, stop: null, anticipation: null,
|
||||||
|
snore: null, stir: null, roar: null, fire: null, raid: null,
|
||||||
|
coinLand: null, jackpotLand: null, collectTick: null, sneak: null, slash: null,
|
||||||
|
winSmall: null, winMedium: null, winBig: null, attract: null,
|
||||||
|
},
|
||||||
|
cabinet: {
|
||||||
|
style: 'obsidian', body: [0x3a0f18, 0x12050a], rim: 0xe0b040, marqueeBack: 0x12050a,
|
||||||
|
bezel: 'brass', bezelColors: [0x9a6a12, 0xffd86b], bezelWidth: 26, ledChannel: 0x0a0306,
|
||||||
|
},
|
||||||
|
// Deep cave-blue glass so the red dragon and gold coins pop.
|
||||||
|
glass: {
|
||||||
|
frame: 0x0a0306, frameAlpha: 1, top: 0x1c2450, bottom: 0x0a0e24,
|
||||||
|
stripeAlpha: 0, edge: 0x000000, edgeAlpha: 0.4, shade: 0x000000, shadeAlpha: 0.45,
|
||||||
|
},
|
||||||
|
lights: {
|
||||||
|
// Molten: [lava, white-hot, blood red].
|
||||||
|
palette: [0xff6a1a, 0xffe08a, 0xd0101a], lag: 0.05,
|
||||||
|
idle: 'lavaPulse', attract: 'moltenComets', spin: 'fireSweep',
|
||||||
|
anticipation: 'dragonWake', win: 'paletteChase', bigWin: 'bulbJackpot',
|
||||||
|
feature: 'fireSweep', flash: 0xffe08a,
|
||||||
|
},
|
||||||
|
windowSheen: { every: 7000, tint: 0xffe9a8 },
|
||||||
|
bar: { fill: 0x14060a, trim: 0xe0b040, button: 0xe8582a, buttonHover: 0xffb347 },
|
||||||
|
symbolColors: {
|
||||||
|
dragon: 0xff3a1a, coin: 0xffd23f, knight: 0xcfe6ff, castle: 0x9ab0d0, chest: 0xffb347,
|
||||||
|
gem: 0x6ad0ff, ace: 0xff9d4d, king: 0xff9d4d, queen: 0xff9d4d, jack: 0xff9d4d,
|
||||||
|
},
|
||||||
|
tierColors: { mini: 0x2ecc71, minor: 0x3a8cff, major: 0xb04aff, grand: 0xff2a3a },
|
||||||
|
tease: { symbol: 'coin', after: 4, ms: 1000 },
|
||||||
|
lineStyle: { wild: 'fire', knight: 'slash', default: 'goldVein' },
|
||||||
|
coinTexture: 'slots-coin-p',
|
||||||
|
bigWinLabels: ['BIG WIN', 'DRAGON WIN', 'LEGENDARY!'],
|
||||||
|
glintTint: 0xffe9a8,
|
||||||
|
wobble: 0,
|
||||||
|
spill: 0.55,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
// ── 7. Gold Rush Gulch — sticky wilds + pick-a-cart bonus ───────────────────
|
// ── 7. Gold Rush Gulch — sticky wilds + pick-a-cart bonus ───────────────────
|
||||||
|
|
@ -372,6 +648,49 @@ export const MACHINES = [
|
||||||
cabinet: 0x4a3217, cabinetHi: 0x6e4c24, trim: 0xf0c441, glow: 0xffe27a,
|
cabinet: 0x4a3217, cabinetHi: 0x6e4c24, trim: 0xf0c441, glow: 0xffe27a,
|
||||||
screenTop: 0x271c0c, screenBot: 0x110c05, accentHex: '#ffe27a', reelBg: 0x1c1409,
|
screenTop: 0x271c0c, screenBot: 0x110c05, accentHex: '#ffe27a', reelBg: 0x1c1409,
|
||||||
},
|
},
|
||||||
|
// Attract kit (SlotsAttract.js) + gold-mine props (SlotsGoldRush.js).
|
||||||
|
attract: {
|
||||||
|
layout: { cellW: 210, cellH: 176, gap: 12, windowY: 248, marqueeH: 132 },
|
||||||
|
environment: 'goldMine',
|
||||||
|
props: 'goldRush',
|
||||||
|
// Drop-in media — set a path to enable (null = procedural / stock SFX).
|
||||||
|
media: { bgVideo: 'assets/videos/slots/background-gold-rush-gulch.mp4', marqueeVideo: null },
|
||||||
|
sounds: {
|
||||||
|
ambient: null, spin: null, stop: null, anticipation: null,
|
||||||
|
fuse: null, boom: null, sticky: null, escape: null, cartRoll: null, cartDump: null,
|
||||||
|
winSmall: null, winMedium: null, winBig: null, attract: null,
|
||||||
|
},
|
||||||
|
cabinet: {
|
||||||
|
style: 'wood', body: [0x7a4f26, 0x4a2d12], rim: 0xd9a441, marqueeBack: 0x24150a,
|
||||||
|
bezel: 'brass', bezelColors: [0xb07a22, 0xf3cf6a], bezelWidth: 26, ledChannel: 0x1c1007,
|
||||||
|
},
|
||||||
|
glass: {
|
||||||
|
frame: 0x1c1007, frameAlpha: 1, top: 0x6b4622, bottom: 0x24160a,
|
||||||
|
stripeAlpha: 0, edge: 0x000000, edgeAlpha: 0.35, shade: 0x0d0703, shadeAlpha: 0.5,
|
||||||
|
},
|
||||||
|
lights: {
|
||||||
|
// Warm incandescent marquee bulbs: [lit, hot white, fuse alarm].
|
||||||
|
palette: [0xffc65a, 0xfff0c0, 0xff5a1f],
|
||||||
|
texture: 'slots-bulb', lag: 0.09, spacingScale: 1.3, sizeScale: 1.15,
|
||||||
|
idle: 'bulbChase', attract: 'vegasSign', spin: 'bulbSpin',
|
||||||
|
anticipation: 'fuseAnticipation', win: 'bulbWin', bigWin: 'bulbJackpot',
|
||||||
|
feature: 'bulbSpin', flash: 0xfff0c0,
|
||||||
|
strips: { dividers: { idle: 'bulbDrip', attract: 'bulbDrip' } },
|
||||||
|
},
|
||||||
|
windowSheen: { every: 6000, tint: 0xffe9a8 },
|
||||||
|
bar: { fill: 0x24150a, trim: 0xd9a441, button: 0xe0a92a, buttonHover: 0xffe27a },
|
||||||
|
symbolColors: {
|
||||||
|
bandit: 0xff6a2a, dynamite: 0xff3b2a, sheriff: 0xffd23f, saloon: 0xc8843a,
|
||||||
|
wagon: 0xffd23f, pickaxe: 0xb8c4d0, ace: 0xffe27a, king: 0xffe27a, queen: 0xffe27a, jack: 0xffe27a,
|
||||||
|
},
|
||||||
|
tease: { symbol: 'dynamite', after: 2, ms: 1000 },
|
||||||
|
lineStyle: 'goldVein',
|
||||||
|
coinTexture: 'slots-nugget',
|
||||||
|
bigWinLabels: ['BIG STRIKE', 'MOTHER LODE', 'GOLD RUSH!'],
|
||||||
|
glintTint: 0xffe9a8,
|
||||||
|
wobble: 0,
|
||||||
|
spill: 0.6,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
// ── 8. Sugar Spin — 6×5 scatter-pays tumble + rainbow multipliers ───────────
|
// ── 8. Sugar Spin — 6×5 scatter-pays tumble + rainbow multipliers ───────────
|
||||||
|
|
@ -420,6 +739,48 @@ export const MACHINES = [
|
||||||
cabinet: 0x6e2160, cabinetHi: 0x933582, trim: 0xff8ad2, glow: 0xffa3e0,
|
cabinet: 0x6e2160, cabinetHi: 0x933582, trim: 0xff8ad2, glow: 0xffa3e0,
|
||||||
screenTop: 0x35103a, screenBot: 0x16071d, accentHex: '#ffa3e0', reelBg: 0x230b2a,
|
screenTop: 0x35103a, screenBot: 0x16071d, accentHex: '#ffa3e0', reelBg: 0x230b2a,
|
||||||
},
|
},
|
||||||
|
// Attract kit (SlotsAttract.js): centred cabinet, LED show, candy sky.
|
||||||
|
attract: {
|
||||||
|
layout: { cellW: 150, cellH: 114, gap: 10, windowY: 248, marqueeH: 132 },
|
||||||
|
environment: 'sugarSky',
|
||||||
|
// Drop-in media — set a path to enable (null = procedural / stock SFX).
|
||||||
|
media: { bgVideo: null, marqueeVideo: null },
|
||||||
|
sounds: {
|
||||||
|
ambient: null, spin: null, stop: null, anticipation: null,
|
||||||
|
winSmall: null, winMedium: null, winBig: null,
|
||||||
|
pop: null, rainbow: null, attract: null,
|
||||||
|
},
|
||||||
|
cabinet: {
|
||||||
|
body: [0xff8fd0, 0xd8459f], rim: 0xfff0fa, marqueeBack: 0xffffff,
|
||||||
|
bezel: 'stripes', bezelColors: [0xff3d7f, 0xffffff], bezelWidth: 24,
|
||||||
|
ledChannel: 0x4a1240,
|
||||||
|
},
|
||||||
|
glass: {
|
||||||
|
frame: 0xffffff, frameAlpha: 0.95, top: 0xfff0f8, bottom: 0xffcfe9,
|
||||||
|
stripe: 0xffffff, stripeAlpha: 0.35, edge: 0xc2408f, edgeAlpha: 0.18,
|
||||||
|
shade: 0xc2408f, shadeAlpha: 0.22,
|
||||||
|
},
|
||||||
|
lights: {
|
||||||
|
palette: [0xff5fa8, 0xffd23f, 0x5fe0ff, 0x9b7bff, 0x7dffb0, 0xffffff],
|
||||||
|
idle: 'rainbowWave', attract: 'rainbowComets', spin: 'rainbowRace',
|
||||||
|
anticipation: 'anticipation', win: 'paletteChase', bigWin: 'rainbowStrobe',
|
||||||
|
feature: 'rainbowRace', flash: 0xffffff,
|
||||||
|
strips: {
|
||||||
|
dividers: {
|
||||||
|
idle: 'candyStripe', attract: 'candyStripe', spin: 'candyStripeFast',
|
||||||
|
feature: 'candyStripeFast', colors: [0xff2a6a, 0xffffff],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
bar: { fill: 0x3a0f3a, trim: 0xff8ad2, button: 0xff5fb8, buttonHover: 0xffd23f },
|
||||||
|
chainMeter: { fill: 0x3a0f3a, trim: 0xff8ad2, label: 'TUMBLES', labelHex: '#ffd23f' },
|
||||||
|
symbolColors: {
|
||||||
|
chocolate: 0x9a5a32, 'candy-cane': 0xff3b4f, gummy: 0x9be22f, lollipop: 0xff5fd0,
|
||||||
|
jelly: 0xff2a3a, mint: 0x3fe07a, berry: 0xe0303a, sugar: 0xdff0ff, rainbow: 0xffa3e0,
|
||||||
|
},
|
||||||
|
wobble: 0.045,
|
||||||
|
spill: 0.5,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue