1
0
Fork 0
polaris-task-force/tests/int/poker-hand-hint.int.spec.ts
Z8MB1E 1b0e4ed074 feat(poker): grade hand ranks on a progressive style ladder
Every made hand maps to a presentation tier from high card (no styling) through brass, silver, and gold pairs to a sapphire straight flush and a royal flush prismatic treatment. The live hand hint carries the tier, so the you-have placard glows with your hand's rank, and royals now read as royal flush.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-09-11 17:30:03 -04:00

49 lines
1.6 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { describeHandStrength } from "@/lib/minigames/poker/handHint";
import type { Card, Rank, Suit } from "@/lib/minigames/poker";
const c = (rank: Rank, suit: Suit): Card => ({ rank, suit });
describe("poker hand strength hints", () => {
it("describes a preflop pair", () => {
expect(describeHandStrength([c(13, "s"), c(13, "h")], [])).toEqual({
label: "Pair of Kings",
bestCardKeys: ["13-s", "13-h"],
tier: 1,
});
});
it("describes a preflop high card", () => {
expect(describeHandStrength([c(14, "s"), c(9, "h")], [])).toEqual({
label: "High card Ace",
bestCardKeys: ["14-s"],
tier: 0,
});
});
it("describes flop two pair and returns the exact best cards", () => {
const hint = describeHandStrength([c(13, "s"), c(9, "h")], [c(13, "d"), c(9, "c"), c(2, "s")]);
expect(hint?.label).toBe("Two pair, Kings and Nines");
expect(new Set(hint?.bestCardKeys)).toEqual(new Set(["13-s", "9-h", "13-d", "9-c", "2-s"]));
});
it("describes a river straight that uses one hole card", () => {
const hint = describeHandStrength(
[c(6, "s"), c(14, "h")],
[c(2, "c"), c(3, "d"), c(4, "h"), c(5, "s"), c(13, "c")],
);
expect(hint?.label).toBe("Straight, Six high");
expect(new Set(hint?.bestCardKeys)).toEqual(new Set(["6-s", "2-c", "3-d", "4-h", "5-s"]));
});
it("labels a wheel straight as five high", () => {
expect(
describeHandStrength(
[c(14, "s"), c(13, "h")],
[c(2, "c"), c(3, "d"), c(4, "h"), c(5, "s"), c(9, "c")],
)?.label,
).toBe("Straight, Five high");
});
});