miaoda-game-canasta-analysis-core
v0.2.0
Published
Pure Classic Canasta card values, meld candidates, initial meld thresholds, and discard-pile checks.
Maintainers
Readme
miaoda-game-canasta-analysis-core
Pure Classic Canasta helpers for card values, opening thresholds, meld candidates, discard-pile pickup validation, Canasta classification, and team-hand scoring. Use canasta-rules for complete turns, zones, partnerships, and match state.
pnpm add miaoda-game-canasta-analysis-core miaoda-game-meld-coreconst candidates = generateCanastaMeldCandidates(hand);
const analysis = analyzeCanastaMelds(hand);
const opening = validateCanastaOpeningMeldPlan([
{targetRank: 4, naturalCardIds: ['4c-a', '4c-b'], wildCardIds: ['wild-2']},
], hand, teamScore);Generated candidates overlap and are alternatives, not one combined action. Submit intended disjoint rank groups to validateCanastaOpeningMeldPlan. For post-pickup UI use getCanastaMeldPlanResources, which exposes natural groups and a shared wild pool without enumerating a large hand.
Call validateCanastaDiscardPickupPlan immediately before an atomic whole-pile transaction. It checks the public top card, current hand IDs, frozen-pile natural requirement, rank matching, and wild limit but moves no cards. scoreCanastaTeamHand returns each score component; render those fields instead of recalculating them.
