Files
pokerfreak-shell/tests/sicht_modus_spec.py
T
mmintelandClaude Opus 5.5 0fcf356c42 Modi: Turnierlage an den Kern, K-Poker setzt aus, Modus in der Ansicht
The tournament lobby was already parsed but never reached the core. Each
tournament table is now linked to its lobby (tourneyLobbyName or
tournamentId) and the request carries `tournament`; a missing price or
rank list makes the turn unclear instead of guessing. K-Poker tables
(roomProperties.isKPoker) abstain until the key table is measured
(mock/vorlage/kpoker-tasten.md). The clone writes the rank list with each
lobby update and the tournament ids where the real log has them; the
view shows level, field and bubble, or menu and clock.

klonmaus appends mock/ to sys.path so mock/turnier.py no longer shadows
lesen/turnier.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 09:50:12 +01:00

90 lines
4.1 KiB
Python
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.
#!/usr/bin/env python3
"""Spezifikation: der Modus eines Tisches in der Ansicht (sicht/ansicht.py: modus).
Quelle ist die Anfrage an den Kern - was angezeigt wird, ist genau das, womit entschieden wurde.
* Cash {"art": "Cash", "text": "Cash · 0.05/0.1"}
* Turnier Anfrage mit `tournament`: Level, Big Blind, Ante, Feld (= Zahl der Stapel), bezahlt
(= Zahl der Preise), bis_geld (Feld - bezahlt, nie unter 0), bubble (bis_geld == 1),
im_geld (bis_geld == 0); Text "Turnier · Level 19 · BB 2500 Ante 312 · Feld 15 · 14 bezahlt · Bubble"
* K-Poker variant K_POKER: menue = legalActions mit den Größen (allowedSizes), uhr_s aus der
Entscheidung; Text "K-Poker · Fold, Call, Raise 0.8/2.4 · Uhr 10 s"
* Keine Anfrage -> None.
* Die Entscheidungszeilen und `jetzt` tragen `modus`.
python3 tests/sicht_modus_spec.py -v
"""
import os
import sys
import unittest
_w = os.path.dirname(os.path.abspath(__file__))
while _w != "/" and not os.path.isdir(os.path.join(_w, "hand")):
_w = os.path.dirname(_w)
for _u in ("sicht", "lesen", "betrieb", "hand"):
sys.path.insert(0, os.path.join(_w, _u))
import ansicht
CASH = {"variant": "NLHE", "bigBlind": 0.1, "legalActions": ["FOLD", "CALL", "RAISE"]}
TURNIER = {"variant": "NLHE", "bigBlind": 2500.0, "legalActions": ["FOLD", "CALL"],
"tournament": {"payouts": [10.0] * 14, "stacks": [20000.0] * 15, "heroIndex": 0,
"ante": 312, "level": 19}}
KPOKER = {"variant": "K_POKER", "bigBlind": 0.1, "legalActions": ["FOLD", "CALL", "RAISE"],
"allowedSizes": [0.8, 2.4]}
def mit_feld(feld, bezahlt=14):
t = dict(TURNIER["tournament"], stacks=[1000.0] * feld, payouts=[1.0] * bezahlt)
return dict(TURNIER, tournament=t)
class Modus(unittest.TestCase):
def test_cash(self):
self.assertEqual(ansicht.modus(CASH), {"art": "Cash", "text": "Cash · 0.05/0.1"})
def test_turnier_auf_der_bubble(self):
m = ansicht.modus(TURNIER)
self.assertEqual((m["art"], m["level"], m["bb"], m["ante"], m["feld"], m["bezahlt"]),
("Turnier", 19, 2500.0, 312, 15, 14))
self.assertEqual((m["bis_geld"], m["bubble"], m["im_geld"]), (1, True, False))
self.assertEqual(m["text"], "Turnier · Level 19 · BB 2500 Ante 312 · Feld 15 · 14 bezahlt · Bubble")
def test_turnier_vor_der_bubble_und_im_geld(self):
vor, geld = ansicht.modus(mit_feld(18)), ansicht.modus(mit_feld(9))
self.assertEqual((vor["bis_geld"], vor["bubble"], vor["im_geld"]), (4, False, False))
self.assertTrue(vor["text"].endswith("· 4 bis zum Geld"), vor["text"])
self.assertEqual((geld["bis_geld"], geld["bubble"], geld["im_geld"]), (0, False, True))
self.assertTrue(geld["text"].endswith("· im Geld"), geld["text"])
def test_kpoker_menue_und_uhr(self):
m = ansicht.modus(KPOKER, uhr_s=10)
self.assertEqual(m["menue"], [{"aktion": "FOLD"}, {"aktion": "CALL"},
{"aktion": "RAISE", "groessen": [0.8, 2.4]}])
self.assertEqual(m["uhr_s"], 10)
self.assertEqual(m["text"], "K-Poker · Fold, Call, Raise 0.8/2.4 · Uhr 10 s")
def test_kpoker_ohne_menue_sagt_es(self):
m = ansicht.modus(dict(KPOKER, legalActions=[], allowedSizes=None))
self.assertEqual(m["menue"], [])
self.assertEqual(m["text"], "K-Poker · Menü unbekannt · Uhr –")
def test_ohne_anfrage(self):
self.assertIsNone(ansicht.modus(None))
self.assertIsNone(ansicht.modus({}))
class InDerAnsicht(unittest.TestCase):
def test_zeile_und_jetzt_tragen_den_modus(self):
schatten = [{"zeit": "2026-10-30T10:00:00Z", "raum": "T1", "kurz": "h1", "uhr_s": 10,
"anfrage": dict(TURNIER, heroCards=[], street="PREFLOP", pot=1.0, toCall=0.5),
"antwort": {"action": "FOLD", "reason": "x"}}]
a = ansicht.bauen({"schatten": schatten}, jetzt=1793354400.0)
zeile = a["entscheidungen"]["zeilen"][-1]
self.assertEqual(zeile["modus"]["art"], "Turnier")
self.assertEqual(a["jetzt"]["modus"]["art"], "Turnier")
if __name__ == "__main__":
unittest.main()