feat(SCOPONE-0003): allow player to choose capture target

- findCaptures() returns each direct match as separate option plus sum subsets
- highlightMultipleCaptures() uses distinct colors per capture option
- clicking highlighted table cards confirms that option's capture
This commit is contained in:
Giancarmine Salucci
2026-03-31 19:59:38 +02:00
parent 3d1f3e5eb4
commit 9524161481
2 changed files with 25 additions and 16 deletions

View File

@@ -41,17 +41,13 @@ export function shuffle<T>(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) {