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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user