diff --git a/src/game/engine.ts b/src/game/engine.ts index 2bc96d4..6b2fdd6 100644 --- a/src/game/engine.ts +++ b/src/game/engine.ts @@ -41,17 +41,13 @@ export function shuffle(arr: T[]): T[] { export function findCaptures(played: Card, table: Card[]): Card[][] { const results: Card[][] = []; - // Check for direct value matches + // Each direct-match card is a separate single-card capture option const directMatches = table.filter(c => c.value === played.value); - if (directMatches.length > 0) { - // Must capture exactly one matching card (Italian rules: take one direct match) - // Actually: if there's one direct match take it; if multiple, still take all that match - // Standard Italian rule: take ALL cards of matching value - results.push([...directMatches]); - return results; // direct match takes priority, no sum captures allowed + for (const dm of directMatches) { + results.push([dm]); } - // No direct matches — find subsets that sum to played.value + // Also find multi-card subsets that sum to played.value const subsets = getSubsets(table); for (const subset of subsets) { if (subset.length >= 2) { diff --git a/src/scenes/GameScene.ts b/src/scenes/GameScene.ts index 3dcff8d..1e8434c 100644 --- a/src/scenes/GameScene.ts +++ b/src/scenes/GameScene.ts @@ -674,32 +674,45 @@ export class GameScene extends Phaser.Scene { private highlightMultipleCaptures(captures: Card[][]): void { this.clearHighlights(); const W = this.scale.width; + + // Distinct color palette for each capture option + const palette = [ + { fill: 0x00cc66, stroke: 0x00ff88, text: '#00ffaa', bg: 0x001a0a }, + { fill: 0x3399ff, stroke: 0x66bbff, text: '#88ccff', bg: 0x001020 }, + { fill: 0xff8833, stroke: 0xffaa55, text: '#ffcc88', bg: 0x1a0d00 }, + { fill: 0xcc44cc, stroke: 0xff66ff, text: '#ff88ff', bg: 0x1a001a }, + { fill: 0x00cccc, stroke: 0x44ffff, text: '#88ffff', bg: 0x001a1a }, + ]; + captures.forEach((cap, i) => { + const color = palette[i % palette.length]; const label = cap.map(cardName).join(' + '); const y = SCOREBAR_H + 70 + i * 36; const bg = this.add.graphics().setDepth(20); - bg.fillStyle(0x001a0a, 0.9); + bg.fillStyle(color.bg, 0.9); bg.fillRoundedRect(W / 2 - 180, y - 14, 360, 28, 7); - bg.lineStyle(1, 0x00ff88, 0.7); + bg.lineStyle(2, color.stroke, 0.8); bg.strokeRoundedRect(W / 2 - 180, y - 14, 360, 28, 7); const btn = this.add.zone(W / 2, y, 360, 28).setInteractive({ useHandCursor: true }).setDepth(21); const txt = this.add.text(W / 2, y, `Cattura: ${label}`, { - fontFamily: 'serif', fontSize: '14px', color: '#00ffaa', + fontFamily: 'serif', fontSize: '14px', color: color.text, }).setOrigin(0.5).setDepth(21); btn.on('pointerdown', () => this.confirmMove(this.selectedCard!, cap)); (bg as any)._captureBtn = true; this.tableHighlights.push(bg, btn, txt); - }); - for (const cap of captures) { + + // Highlight table cards belonging to this option with the matching color for (const c of cap) { const img = this.cardImages.get(c.id); if (img) { - const hl = this.add.rectangle(img.x, img.y, CW_H + 8, CH_H + 8, 0xffff00, 0.15) - .setStrokeStyle(2, 0xffff00, 0.8).setDepth(4); + const hl = this.add.rectangle(img.x, img.y, CW_H + 8, CH_H + 8, color.fill, 0.2) + .setStrokeStyle(2, color.stroke, 0.9).setDepth(4); this.tableHighlights.push(hl); + img.setInteractive({ useHandCursor: true }); + img.once('pointerdown', () => this.confirmMove(this.selectedCard!, cap)); } } - } + }); } private highlightTableForDump(card: Card): void {