Compare commits

..

No commits in common. "4b6593b074714135ec8e332625afd627c1edf1e6" and "036298227f3bf5fbf955de0fc8286a50008c1867" have entirely different histories.

11 changed files with 43 additions and 172 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -23,9 +23,6 @@
"cybro-upset-03", "cybro-upset-03",
"cybro-upset-04", "cybro-upset-04",
"cybro-upset-05" "cybro-upset-05"
],
"pick": [
"cybro-pick"
] ]
} }
}, },
@ -81,9 +78,6 @@
"victor-upset-03", "victor-upset-03",
"victor-upset-04", "victor-upset-04",
"victor-upset-05" "victor-upset-05"
],
"pick": [
"victor-pick"
] ]
} }
}, },
@ -110,9 +104,6 @@
"croc-upset-03", "croc-upset-03",
"croc-upset-04", "croc-upset-04",
"croc-upset-05" "croc-upset-05"
],
"pick": [
"croc-pick"
] ]
} }
}, },
@ -132,9 +123,6 @@
"upset": [ "upset": [
"mario-upset-01", "mario-upset-01",
"mario-upset-02" "mario-upset-02"
],
"pick": [
"mario-upset-01"
] ]
} }
}, },
@ -161,9 +149,6 @@
"ethel-upset-03", "ethel-upset-03",
"ethel-upset-04", "ethel-upset-04",
"ethel-upset-05" "ethel-upset-05"
],
"pick": [
"ethel-pick"
] ]
} }
}, },
@ -190,9 +175,6 @@
"jeff-upset-03", "jeff-upset-03",
"jeff-upset-04", "jeff-upset-04",
"jeff-upset-05" "jeff-upset-05"
],
"pick": [
"jeff-pick"
] ]
} }
}, },
@ -248,9 +230,6 @@
"fireball-upset-03", "fireball-upset-03",
"fireball-upset-04", "fireball-upset-04",
"fireball-upset-05" "fireball-upset-05"
],
"pick": [
"fireball-pick"
] ]
} }
}, },
@ -270,9 +249,6 @@
"upset": [ "upset": [
"bernie-upset-01", "bernie-upset-01",
"bernie-upset-02" "bernie-upset-02"
],
"pick": [
"bernie-happy-01"
] ]
} }
} }

View File

@ -39,12 +39,6 @@ export const RESOURCE_BAG = [
// 18 number chits for the 18 non-desert hexes. // 18 number chits for the 18 non-desert hexes.
export const CHIT_BAG = [2, 3, 3, 4, 4, 5, 5, 6, 6, 8, 8, 9, 9, 10, 10, 11, 11, 12]; export const CHIT_BAG = [2, 3, 3, 4, 4, 5, 5, 6, 6, 8, 8, 9, 9, 10, 10, 11, 11, 12];
// Hex IDs visited in the standard Catan clockwise spiral (outer ring → inner ring → centre).
// Rows [3,4,5,4,3] assign IDs left-to-right, top-to-bottom: 0-2, 3-6, 7-11, 12-15, 16-18.
export const CHIT_SPIRAL = [0, 1, 2, 6, 11, 15, 18, 17, 16, 12, 7, 3, 4, 5, 10, 14, 13, 8, 9];
// Standard chit values A–R placed in spiral order; desert hex is skipped when assigning.
export const CHIT_SEQUENCE = [5, 2, 6, 3, 8, 10, 9, 12, 11, 4, 8, 10, 9, 4, 5, 6, 3, 11];
// 9 ports: 4 generic 3:1, one 2:1 per resource. // 9 ports: 4 generic 3:1, one 2:1 per resource.
export const PORT_BAG = ['any', 'any', 'any', 'any', 'brick', 'lumber', 'wool', 'grain', 'ore']; export const PORT_BAG = ['any', 'any', 'any', 'any', 'brick', 'lumber', 'wool', 'grain', 'ore'];

View File

@ -254,7 +254,7 @@ export default class CatanGame extends Phaser.Scene {
fontFamily: '"Julius Sans One"', fontSize: '14px', color: COLORS.mutedHex, fontFamily: '"Julius Sans One"', fontSize: '14px', color: COLORS.mutedHex,
}).setOrigin(0, 0.5).setDepth(D.hud); }).setOrigin(0, 0.5).setDepth(D.hud);
// cost legend (bottom bar, right of dice) // cost legend (right, above buttons)
this.buildCostLegend(); this.buildCostLegend();
// action buttons (vertical column, right) // action buttons (vertical column, right)
@ -273,45 +273,19 @@ export default class CatanGame extends Phaser.Scene {
} }
buildCostLegend() { buildCostLegend() {
const panelRight = 1900; const x = 1600, y = 230;
const panelW = 320;
const cx = panelRight - panelW / 2;
const bgCy = 980, bgH = 164;
const panel = this.add.container(0, 0).setDepth(D.hud); const panel = this.add.container(0, 0).setDepth(D.hud);
panel.add(this.add.rectangle(cx, bgCy, panelW, bgH, 0x000000, 0.3).setStrokeStyle(1, COLORS.accent, 0.5)); panel.add(this.add.rectangle(x, y + 80, 180, 200, 0x000000, 0.3).setStrokeStyle(1, COLORS.accent, 0.5));
panel.add(this.add.text(cx, bgCy - bgH / 2 + 7, 'Build Costs', { panel.add(this.add.text(x, y - 4, 'Build Costs', { fontFamily: 'Righteous', fontSize: '16px', color: COLORS.goldHex }).setOrigin(0.5));
fontFamily: 'Righteous', fontSize: '20px', color: COLORS.goldHex, const lines = [
}).setOrigin(0.5, 0)); ['Road', 'Brick Lumber'],
['Settle', 'Br Lu Wo Gr'],
const rows = [ ['City', '2 Grain 3 Ore'],
{ name: 'Road', resources: ['brick', 'lumber'] }, ['Dev', 'Wool Grain Ore'],
{ name: 'Settlement', resources: ['brick', 'lumber', 'wool', 'grain'] },
{ name: 'City', resources: ['grain', 'grain', 'ore', 'ore', 'ore'] },
{ name: 'Dev Card', resources: ['wool', 'grain', 'ore'] },
]; ];
lines.forEach((ln, i) => {
const lx = panelRight - panelW + 14; panel.add(this.add.text(x - 78, y + 30 + i * 38, ln[0], { fontFamily: '"Julius Sans One"', fontSize: '15px', color: COLORS.textHex }).setOrigin(0, 0.5));
const rx = panelRight - 14; panel.add(this.add.text(x - 78, y + 48 + i * 38, ln[1], { fontFamily: '"Julius Sans One"', fontSize: '12px', color: COLORS.mutedHex }).setOrigin(0, 0.5));
const rowY0 = bgCy - bgH / 2 + 44;
const rowStep = (bgH - 44 - 14) / (rows.length - 1);
const SW = 16, SH = 16, SG = 4, SR = 3; // swatch w/h/gap/radius
const g = this.add.graphics();
panel.add(g);
rows.forEach(({ name, resources }, i) => {
const ry = rowY0 + i * rowStep;
panel.add(this.add.text(lx, ry, name, {
fontFamily: '"Julius Sans One"', fontSize: '19px', color: COLORS.textHex,
}).setOrigin(0, 0.5));
const totalW = resources.length * SW + (resources.length - 1) * SG;
let sx = rx - totalW;
for (const r of resources) {
g.fillStyle(RESOURCE_INFO[r].swatch, 1);
g.fillRoundedRect(sx, ry - SH / 2, SW, SH, SR);
sx += SW + SG;
}
}); });
} }

View File

@ -3,8 +3,7 @@
import { import {
NODES, EDGES, HEXES, PORT_SLOTS, edgeBetween, NODES, EDGES, HEXES, PORT_SLOTS, edgeBetween,
RESOURCE_BAG, PORT_BAG, COSTS, DEV_DECK, RESOURCE_TYPES, WIN_VP, RESOURCE_BAG, CHIT_BAG, PORT_BAG, COSTS, DEV_DECK, RESOURCE_TYPES, WIN_VP,
CHIT_SPIRAL, CHIT_SEQUENCE,
} from './CatanBoard.js'; } from './CatanBoard.js';
// ── small utilities ───────────────────────────────────────────────────────── // ── small utilities ─────────────────────────────────────────────────────────
@ -27,6 +26,16 @@ export function handSize(player) {
return RESOURCE_TYPES.reduce((s, r) => s + player.resources[r], 0); return RESOURCE_TYPES.reduce((s, r) => s + player.resources[r], 0);
} }
// Hex adjacency (share an edge → share 2 corner nodes).
const HEX_NEIGHBORS = HEXES.map(() => []);
for (const e of EDGES) {
if (e.hexes.length === 2) {
const [h1, h2] = e.hexes;
if (!HEX_NEIGHBORS[h1].includes(h2)) HEX_NEIGHBORS[h1].push(h2);
if (!HEX_NEIGHBORS[h2].includes(h1)) HEX_NEIGHBORS[h2].push(h1);
}
}
// ── occupancy queries ──────────────────────────────────────────────────────── // ── occupancy queries ────────────────────────────────────────────────────────
export function nodeBuilding(state, nodeId) { export function nodeBuilding(state, nodeId) {
for (const p of state.players) { for (const p of state.players) {
@ -56,12 +65,21 @@ export function createInitialState(playerCount = 3) {
const desertHex = hexes.find((h) => h.resource === 'desert'); const desertHex = hexes.find((h) => h.resource === 'desert');
desertHex.hasRobber = true; desertHex.hasRobber = true;
// Number chits: walk the standard spiral, skip desert, assign fixed sequence A–R. // Number chits onto non-desert hexes, 6/8 never adjacent.
let chitIdx = 0; const nonDesert = hexes.filter((h) => h.resource !== 'desert');
for (const hexId of CHIT_SPIRAL) { for (let attempt = 0; attempt < 500; attempt++) {
if (hexes[hexId].resource !== 'desert') { const chits = shuffle(CHIT_BAG);
hexes[hexId].number = CHIT_SEQUENCE[chitIdx++]; nonDesert.forEach((h, i) => { h.number = chits[i]; });
let ok = true;
for (const h of nonDesert) {
if (h.number !== 6 && h.number !== 8) continue;
for (const nb of HEX_NEIGHBORS[h.id]) {
const other = hexes[nb];
if (other.number === 6 || other.number === 8) { ok = false; break; }
} }
if (!ok) break;
}
if (ok) break;
} }
// Port types onto fixed slots. // Port types onto fixed slots.
@ -91,9 +109,10 @@ export function createInitialState(playerCount = 3) {
}); });
} }
// Snake setup order: randomized forward then reverse. // Snake setup order: 0..n-1 then n-1..0.
const seats = shuffle([...Array(n).keys()]); const order = [];
const order = [...seats, ...[...seats].reverse()]; for (let s = 0; s < n; s++) order.push(s);
for (let s = n - 1; s >= 0; s--) order.push(s);
return { return {
playerCount: n, playerCount: n,

View File

@ -1,8 +1,7 @@
import * as Phaser from 'phaser'; import * as Phaser from 'phaser';
import { GAME_HEIGHT, GAME_WIDTH, COLORS } from '../config.js'; import { GAME_HEIGHT, GAME_WIDTH, COLORS } from '../config.js';
import { Button } from '../ui/Button.js'; import { Button } from '../ui/Button.js';
import { playMenuMusic, stopMenuMusic, setMenuMusicVolume } from '../ui/MenuMusic.js'; import { playMenuMusic, stopMenuMusic } from '../ui/MenuMusic.js';
import { enqueue as enqueueSpeech, resetQueue as resetSpeechQueue } from '../ui/SpeechQueue.js';
// Option tile dimensions — playfield rows // Option tile dimensions — playfield rows
const TILE_W = 190; const TILE_W = 190;
@ -31,12 +30,10 @@ export default class OpponentSelectScene extends Phaser.Scene {
this.playfieldTiles = []; this.playfieldTiles = [];
this.selectedCardBack = null; this.selectedCardBack = null;
this.cardBackTiles = []; this.cardBackTiles = [];
this._initializing = false;
} }
async create() { async create() {
playMenuMusic(); playMenuMusic();
setMenuMusicVolume(0.25);
const cx = GAME_WIDTH / 2; const cx = GAME_WIDTH / 2;
const bgKey = this.gameDef.category === 'casino' ? 'bg-casino' : 'bg-room'; const bgKey = this.gameDef.category === 'casino' ? 'bg-casino' : 'bg-room';
@ -93,15 +90,7 @@ export default class OpponentSelectScene extends Phaser.Scene {
this.buildOpponentGrid(opponents); this.buildOpponentGrid(opponents);
const max = this.gameDef.maxOpponents ?? 1; const max = this.gameDef.maxOpponents ?? 1;
this._initializing = true;
this.cards.slice(0, max).forEach(({ opp, el }) => this.toggleOpponent(opp, el)); this.cards.slice(0, max).forEach(({ opp, el }) => this.toggleOpponent(opp, el));
this._initializing = false;
this.events.once('shutdown', () => {
resetSpeechQueue();
this.cards.forEach(c => c.destroyViz?.());
if (!this._startingGame) setMenuMusicVolume(0.6);
});
this.buildOptionSection('Playfield', 630, this.cache.json.get('playfields')?.playfields ?? [], this.buildOptionSection('Playfield', 630, this.cache.json.get('playfields')?.playfields ?? [],
'selectedPlayfield', 'playfieldTiles', (pf) => this.selectPlayfield(pf)); 'selectedPlayfield', 'playfieldTiles', (pf) => this.selectPlayfield(pf));
@ -239,71 +228,8 @@ export default class OpponentSelectScene extends Phaser.Scene {
canvas.style.display = 'block'; canvas.style.display = 'block';
}); });
// Spectrum visualizer canvas — overlays portrait when pick audio plays
const vizCanvas = document.createElement('canvas');
vizCanvas.width = portraitSize;
vizCanvas.height = portraitSize;
vizCanvas.style.cssText = `position:absolute;top:0;left:0;width:${portraitSize}px;height:${portraitSize}px;border-radius:50%;pointer-events:none;opacity:0;transition:opacity 0.2s ease;`;
const vizCtx = vizCanvas.getContext('2d');
const vsz = portraitSize;
const BAR_COUNT = 6;
const bars = Array.from({ length: BAR_COUNT }, () => ({ cur: 0.1, target: 0.5 }));
let vizActive = false;
let rafId = null;
let retargetTimer = null;
function _vizFrame() {
if (!vizActive) { rafId = null; vizCtx.clearRect(0, 0, vsz, vsz); return; }
vizCtx.clearRect(0, 0, vsz, vsz);
const gy = vsz * 0.58;
const grad = vizCtx.createLinearGradient(0, gy, 0, vsz);
grad.addColorStop(0, 'rgba(0,0,0,0)');
grad.addColorStop(1, 'rgba(0,0,0,0.38)');
vizCtx.fillStyle = grad;
vizCtx.fillRect(0, gy, vsz, vsz - gy);
const barW = vsz * 0.072;
const gap = vsz * 0.03;
const totalW = BAR_COUNT * barW + (BAR_COUNT - 1) * gap;
const startX = (vsz - totalW) / 2;
const maxH = vsz * 0.36;
const baseY = vsz * 0.88;
bars.forEach((bar, i) => {
bar.cur += (bar.target - bar.cur) * 0.14;
const h = Math.max(bar.cur * maxH, vsz * 0.04);
const x = startX + i * (barW + gap);
vizCtx.shadowColor = 'rgba(0,200,255,0.7)';
vizCtx.shadowBlur = 5;
vizCtx.fillStyle = 'rgba(0,200,255,0.88)';
vizCtx.beginPath();
vizCtx.roundRect(x, baseY - h, barW, h, 2);
vizCtx.fill();
});
vizCtx.shadowBlur = 0;
rafId = requestAnimationFrame(_vizFrame);
}
function startViz() {
vizActive = true;
vizCanvas.style.opacity = '1';
if (!retargetTimer) retargetTimer = setInterval(() => { bars.forEach(b => { b.target = 0.2 + Math.random() * 0.8; }); }, 120);
if (!rafId) rafId = requestAnimationFrame(_vizFrame);
}
function stopViz() {
vizActive = false;
vizCanvas.style.opacity = '0';
clearInterval(retargetTimer);
retargetTimer = null;
}
function destroyViz() {
stopViz();
if (rafId) { cancelAnimationFrame(rafId); rafId = null; }
}
portraitWrap.appendChild(canvas); portraitWrap.appendChild(canvas);
portraitWrap.appendChild(video); portraitWrap.appendChild(video);
portraitWrap.appendChild(vizCanvas);
// Text block // Text block
const info = document.createElement('div'); const info = document.createElement('div');
@ -342,7 +268,7 @@ export default class OpponentSelectScene extends Phaser.Scene {
el.addEventListener('click', () => this.toggleOpponent(opp, el)); el.addEventListener('click', () => this.toggleOpponent(opp, el));
this.cards.push({ opp, el, canvas, video, startViz, stopViz, destroyViz }); this.cards.push({ opp, el, canvas, video });
return el; return el;
} }
@ -355,12 +281,10 @@ export default class OpponentSelectScene extends Phaser.Scene {
this.applyOpponentStyle(el, false); this.applyOpponentStyle(el, false);
const card = this.cards.find((c) => c.opp.id === opp.id); const card = this.cards.find((c) => c.opp.id === opp.id);
if (card) { if (card) {
card.stopViz();
card.video.pause(); card.video.pause();
card.video.style.display = 'none'; card.video.style.display = 'none';
card.canvas.style.display = 'block'; card.canvas.style.display = 'block';
} }
resetSpeechQueue();
} else { } else {
// If already at max, bump the oldest selection out first // If already at max, bump the oldest selection out first
if (this.selected.size >= max) { if (this.selected.size >= max) {
@ -368,7 +292,6 @@ export default class OpponentSelectScene extends Phaser.Scene {
this.selected.delete(oldestId); this.selected.delete(oldestId);
const oldCard = this.cards.find((c) => c.opp.id === oldestId); const oldCard = this.cards.find((c) => c.opp.id === oldestId);
if (oldCard) { if (oldCard) {
oldCard.stopViz();
this.applyOpponentStyle(oldCard.el, false); this.applyOpponentStyle(oldCard.el, false);
oldCard.video.pause(); oldCard.video.pause();
oldCard.video.style.display = 'none'; oldCard.video.style.display = 'none';
@ -386,16 +309,6 @@ export default class OpponentSelectScene extends Phaser.Scene {
card.canvas.style.display = 'block'; card.canvas.style.display = 'block';
}); });
} }
if (!this._initializing) {
const pickClips = opp.speech?.pick;
if (pickClips?.length) {
resetSpeechQueue();
enqueueSpeech(pickClips[Math.floor(Math.random() * pickClips.length)], {
onStart: () => this.cards.find(c => c.opp.id === opp.id)?.startViz(),
onEnd: () => this.cards.find(c => c.opp.id === opp.id)?.stopViz(),
});
}
}
} }
this.startBtn.setEnabled(this.selected.size >= min); this.startBtn.setEnabled(this.selected.size >= min);
} }
@ -509,7 +422,6 @@ export default class OpponentSelectScene extends Phaser.Scene {
startGame() { startGame() {
if (this.selected.size === 0) return; if (this.selected.size === 0) return;
this._startingGame = true;
stopMenuMusic(); stopMenuMusic();
const opponents = this.cards const opponents = this.cards
.filter(({ opp }) => this.selected.has(opp.id)) .filter(({ opp }) => this.selected.has(opp.id))

View File

@ -18,7 +18,3 @@ export function playMenuMusic() {
export function stopMenuMusic() { export function stopMenuMusic() {
if (_audio) _audio.pause(); if (_audio) _audio.pause();
} }
export function setMenuMusicVolume(vol) {
_getAudio().volume = vol;
}