derivePlayStyle() in src/lib/playStyle.ts is the function behind the quadrant on /stats. It takes your lifetime tendencies and works out which of the four archetypes you are: The Shark, The Maniac, The Rock, The Station.
It is pure, it is 76 lines, and it currently has no tests. A clean first PR on real code that people actually see the output of.
The task
Add an AVA test file (tests/playStyle.test.ts) covering derivePlayStyle():
- The four quadrants. Build a
SeatStats for each corner and check you get the right key and name. The splits are in the file: looseness at 0.42, aggression at 0.5. Include a hand that lands exactly on a split, since >= decides it.
- Divide by zero. A player with
handsDealt: 0 must not produce NaN. Same for raises + calls === 0 and betsFaced === 0. Assert the actual returned numbers.
- The
ready gate. STYLE_MIN_HANDS is 20. Check ready is false below it, true at it, and that an archetype is still named either way.
emptySeatStats() in src/lib/reads.ts gives you a zeroed starting point to spread over.
Getting started
pnpm install
pnpm test # the AVA suite
Follow the style of the existing files in tests/ (useMoney.test.ts is a short one to copy the shape from). Tests describe what the code does, so read the function and assert its real behaviour rather than what you think it should do. If you find something that looks wrong, say so in the PR rather than fixing it quietly, and we will talk about it.
Done when
pnpm test:all passes and the four quadrants, the zero cases and the ready gate are all covered.
New here? See CONTRIBUTING.md. Merged work puts your name on playpip.io/credits.
derivePlayStyle()insrc/lib/playStyle.tsis the function behind the quadrant on/stats. It takes your lifetime tendencies and works out which of the four archetypes you are: The Shark, The Maniac, The Rock, The Station.It is pure, it is 76 lines, and it currently has no tests. A clean first PR on real code that people actually see the output of.
The task
Add an AVA test file (
tests/playStyle.test.ts) coveringderivePlayStyle():SeatStatsfor each corner and check you get the rightkeyandname. The splits are in the file: looseness at 0.42, aggression at 0.5. Include a hand that lands exactly on a split, since>=decides it.handsDealt: 0must not produceNaN. Same forraises + calls === 0andbetsFaced === 0. Assert the actual returned numbers.readygate.STYLE_MIN_HANDSis 20. Checkreadyis false below it, true at it, and that an archetype is still named either way.emptySeatStats()insrc/lib/reads.tsgives you a zeroed starting point to spread over.Getting started
Follow the style of the existing files in
tests/(useMoney.test.tsis a short one to copy the shape from). Tests describe what the code does, so read the function and assert its real behaviour rather than what you think it should do. If you find something that looks wrong, say so in the PR rather than fixing it quietly, and we will talk about it.Done when
pnpm test:allpasses and the four quadrants, the zero cases and thereadygate are all covered.New here? See CONTRIBUTING.md. Merged work puts your name on playpip.io/credits.