Scoundrel CLI
The card game from Classic Scoundrel, as a command line game. This page runs the same logic two ways: a terminal simulation, and a tiny React component. One core, no rewrites.
Play it in the terminal
Type commands just like the Node CLI. Cards are numbered, f flees, h helps, q quits. The buttons below the terminal send the same commands, for tapping.
Same game, React UI
The component below holds one game state and calls the same three functions: newGame, playCard, flee. No game logic lives in the component. Click a card to play it.
Loading the React demo...
const [game, setGame] = useState(() => newGame());
function doPlay(i) {
const next = structuredClone(game);
playCard(next, i);
setGame(next);
}
How it fits together
game-core.jsis the whole game as pure functions: no DOM, no Node APIs, no input or output. It is the ES module twin ofscoundrel.js, and an equivalence check runs the same seeds and moves through both and requires identical results.- The terminal above is a thin shell around the core: it prints
render(game)and feeds typed commands toplayCardandflee, exactly like the Node CLI. - The React component is a thinner shell: one
useState, one clone per move, and the same three core calls. Swap the shell and the game does not notice. - Get the CLI itself at github.com/SydBal/scoundrel-CLI. The full graphical game is classicscoundrel.com.