first commit

This commit is contained in:
ysj7705 committed 2026-06-22 15:17:05 +09:00
commit 8bf1d1b928
47 files changed
+8648

No files matched your search

+42
View File
@@ -0,0 +1,42 @@
import type { Card, CardColor, CardValue } from './types'
export function getEffectiveColor(card: Card, activeColor: CardColor | null): CardColor {
if (card.color !== 'wild' && card.color) return card.color
return activeColor ?? 'wild'
}
export function canPlayCard(
card: Card,
topCard: Card,
activeColor: CardColor | null,
drawPenalty: number,
): boolean {
if (drawPenalty > 0) {
return card.value === 'draw2' || card.value === 'wild4'
}
if (card.color === 'wild') return true
const topColor = getEffectiveColor(topCard, activeColor)
if (card.color === topColor) return true
if (card.value === topCard.value) return true
return false
}
export function getPlayableCards(
hand: Card[],
topCard: Card,
activeColor: CardColor | null,
drawPenalty: number,
): Card[] {
return hand.filter((c) => canPlayCard(c, topCard, activeColor, drawPenalty))
}
export function isActionCard(value: CardValue): boolean {
return value === 'skip' || value === 'reverse' || value === 'draw2' || value === 'wild' || value === 'wild4'
}
export function cardNeedsColorChoice(card: Card): boolean {
return card.color === 'wild'
}