miaoda-game-bridge-react
v0.1.1
Published
React DOM bindings and a safe-view controller for Duplicate Bridge.
Maintainers
Readme
miaoda-game-bridge-react
React bindings and a framework-neutral controller for one Duplicate Bridge board.
pnpm add miaoda-game-bridge-reactimport { BridgeController, createBridgeGame, useBridgeView } from 'miaoda-game-bridge-react';
const controller = new BridgeController(
createBridgeGame({ playerIds: ['north', 'east', 'south', 'west'], seed: 2026 }),
'north',
);
function BridgeControls() {
const view = useBridgeView(controller);
return view.legalActions.calls.map((call) => (
<button
key={JSON.stringify(call)}
onClick={() => controller.dispatch({ type: 'call', playerId: view.viewerId, call })}
>
{call.type}
</button>
));
}Render actions only from legalActions. The view contains the viewer's hand and, after the opening
lead, dummy's hand. It never contains the deck snapshot or other concealed hands. Successful
dispatches advance revision; rejected actions do not publish. Use replaceSnapshot for validated
reconnect state and onCommit to feed ordered public events to UI animation adapters.
