The dealer table is a two-handed, big-screen tool. A dealer standing over a chopped pot with a phone in one hand and players waiting needs an answer in seconds, not a table to set up first — so /casino/texasholdem/quicksplit is the whole job on one screen: type the pot, tap how many ways, tap the smallest chip in play, read the payout. Nothing to configure, nothing saved. It splits in whole chips rather than raw arithmetic, because a dealer can't push half a chip across the felt: everyone gets the same stack and the remainder is called out as odd chips going one at a time to the first players left of the button. A pot that doesn't divide into the chosen denomination says so instead of quietly hiding the difference. Money formatting moves out of render.js into its own file so this screen can use it without pulling in the whole seat/chip UI. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_015bnp7xKUPFFSpwkYNFaPgb
54 lines
2.0 KiB
JavaScript
54 lines
2.0 KiB
JavaScript
// Pure math for chopping one pot between tied players. No DOM.
|
|
//
|
|
// A dealer can't push half a chip across the felt, so this works in whole chips of
|
|
// whatever the smallest denomination in play is: everyone gets the same stack, and
|
|
// whatever won't divide is called out separately as odd chips. House rule for those
|
|
// is that they go to the first player left of the button, one at a time.
|
|
const SplitCalculator = {
|
|
// Everything is done in cents to keep 0.1 + 0.2 out of a payout.
|
|
toCents(amount) {
|
|
return Math.round((Number(amount) || 0) * 100);
|
|
},
|
|
|
|
split(potAmount, ways, chipAmount) {
|
|
const potCents = this.toCents(potAmount);
|
|
const chipCents = Math.max(1, this.toCents(chipAmount));
|
|
const players = Math.max(1, Math.floor(Number(ways) || 0));
|
|
|
|
if (potCents <= 0) {
|
|
return { valid: false, each: 0, oddChips: 0, chip: chipCents / 100, dust: 0, players };
|
|
}
|
|
|
|
const wholeChips = Math.floor(potCents / chipCents);
|
|
// Left over when the pot itself isn't a whole number of the smallest chip —
|
|
// usually means the dealer picked the wrong denomination, so it's surfaced
|
|
// rather than silently rolled into someone's stack.
|
|
const dustCents = potCents - wholeChips * chipCents;
|
|
|
|
const chipsEach = Math.floor(wholeChips / players);
|
|
const oddChips = wholeChips - chipsEach * players;
|
|
|
|
return {
|
|
valid: true,
|
|
players,
|
|
each: (chipsEach * chipCents) / 100,
|
|
oddChips,
|
|
chip: chipCents / 100,
|
|
dust: dustCents / 100,
|
|
};
|
|
},
|
|
|
|
// Sanity check for the UI: what the split actually hands out has to equal the pot.
|
|
accountedFor(result) {
|
|
return (
|
|
Math.round(result.each * 100) * result.players +
|
|
Math.round(result.chip * 100) * result.oddChips +
|
|
Math.round(result.dust * 100)
|
|
) / 100;
|
|
},
|
|
};
|
|
|
|
if (typeof module !== "undefined" && module.exports) {
|
|
module.exports = SplitCalculator;
|
|
}
|