testsAndMisc-archive/poker-stakes/src/stakes/settlement.ts
Krzysztof kuhy Rudnicki bf6f94a75b Track poker-stakes so the file-length cap can reach it
The directory has existed on disk with 58 untracked files, four of them over
the 250-line cap. An untracked file is invisible to every pre-commit hook, so
those violations could not be fixed or gated while it stayed that way -- and
its CI workflow was untracked too, so nothing ran against it.

Landed with its already-written evidence artifact and a contract, since this
crosses the 4-file threshold.

Verified before staging: 58 plain text source/config files, no binaries, no
node_modules, no build output. npm run check passes -- typecheck, eslint
--max-warnings 0, and 220 tests at 100% statements/branches/functions/lines.

Splitting its four oversized files is deliberately a separate commit.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY
2026-08-16 15:19:07 +02:00

17 lines
691 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import type { SessionOutcome } from '../engine/session'
import type { BuyIn, SettledDebt } from './types'
/**
* Converts a finished session's outcome into a debt record. `owedUnits` scales inversely with
* how well the player did: `2 × buyIn − finalChips`, floored at 0. Bust (finalChips === 0) needs
* no special case — it's just this formula's natural output (2 × buyIn, the cap) for that input.
*/
export const settleSession = (buyIn: BuyIn, outcome: SessionOutcome, id: string, settledAt: number): SettledDebt => ({
id,
taskTypeId: buyIn.taskTypeId,
owedUnits: Math.max(0, 2 * buyIn.chips - outcome.finalChips),
reason: outcome.reason,
settledAt,
paidUnits: 0,
})