miaoda-game-euchre-rules
v0.3.0
Published
Verified four-player partnership Euchre rules with bidding, bowers, legal play and scoring.
Downloads
493
Maintainers
Readme
miaoda-game-euchre-rules
Immutable, engine-neutral rules for fixed profile pagat-4p-partnership-no-loner-5points: a
24-card deck, two bidding rounds, dealer discard, bowers, follow-suit enforcement, trick scoring,
and first team to 5. Lone hands and stick-the-dealer are excluded.
pnpm add miaoda-game-euchre-rulesRun a game
import {
applyEuchreAction,
createEuchreGame,
createEuchrePlayerView,
} from 'miaoda-game-euchre-rules';
let state = createEuchreGame({
playerIds: ['north', 'east', 'south', 'west'],
seed: 2026,
});
const playerId = state.activePlayerId;
const view = createEuchrePlayerView(state, playerId);
if (view.legalActions.canOrderUp) {
const result = applyEuchreAction(state, { type: 'order-up', playerId });
if (result.ok) state = result.state;
}Use the exhaustive canOrderUp, callSuits, discardCardIds, playCardIds, and
canStartNextHand values. UI and bots should not duplicate left-bower effective suit or follow-suit
logic.
Public events
import { projectEuchreEvents } from 'miaoda-game-euchre-rules';
if (result.ok) broadcast(projectEuchreEvents(result.events));The projector rebuilds and detaches bidding, played-card, completed-trick, scoring, and hand-start events. Dealer discard produces no public event, so the discarded card id remains private. Unknown runtime event types throw instead of being forwarded.
Restore a snapshot
import { restoreEuchreState } from 'miaoda-game-euchre-rules';
state = restoreEuchreState(JSON.parse(savedJson));Restore validation reconstructs the initial deal and replays accepted actions before trusting trump,
tricks, scoring, or winner state. Use validateEuchreState for a non-throwing result.
Keep authoritative state on a trusted host. Send each player only
createEuchrePlayerView(state, playerId) and projected events; these omit opponent hands, stock, and
the dealer discard.
