Files
pokerfreak/tests/buehne_stapel_spec.py
T
mmintel f2650dc3be Cockpit and runner 5.11. late: no ESC stop, hidden tables stay open, gapless tiling, teacher core
- ESC no longer triggers the emergency stop (an ESC in another app stopped the run at 20:29);
  stopping only via ctrl-opt-cmd-S or the stop button
- a table whose program runs counts as open even when its window is not visible (other
  desktop, Cockpit without screen recording): no reopening, no giving up, correct table
  count; teardown and closing a full table work over the channel
- Cockpit checks and requests the screen recording permission
- gapless tiling (sicht/kacheln.py): tables fill the full height, the Cockpit bar takes the
  rest and never goes below its minimum width; own animated resize no longer stored as minimum
- earlier today: top-up safety net, leave after the hand (sit out next hand), tournament lock,
  waitlist left on close, Cockpit start lock, warning throttle, preflop raise-war reading,
  Bomb Pot practice, tournament break and level-up on the stage
- teacher core for the streamer mode (betrieb/lehrer.py, betrieb/grund_lesen.py) and its plan
2026-11-05 22:39:41 +01:00

98 lines
4.2 KiB
Python

#!/usr/bin/env python3
"""Die Stapel am Buehnentisch: jeder Sitz rechnet von SEINEM Stapel.
In einer Folgehand wandern die Stapel (`geber.plan`, `geber.naechste_hand`): wer die Vorhand
gewann, sitzt mit mehr als dem Anfangsstapel des Tisches da. Die Sitzrahmen (`game.seat`) zeigten
den Rest aber vom Anfangsstapel des TISCHES aus - so stand am 5.11. im Turnier-Level 2 ein Gegner
bei -390, nachdem er seine 3390 gesetzt hatte. Der Rest eines Sitzes ist sein eigener Stapel zu
Beginn der Hand minus alles, was er in dieser Hand schon gesetzt hat.
python3 tests/buehne_stapel_spec.py -v
"""
import json
import os
import sys
import unittest
HIER = os.path.dirname(os.path.abspath(__file__))
WURZEL = os.path.dirname(HIER)
for p in (os.path.join(WURZEL, "hand"), os.path.join(WURZEL, "client")):
if p in sys.path:
sys.path.remove(p)
sys.path.insert(0, p)
import buehnenrahmen # noqa: E402
import geber # noqa: E402
ANTE = 10.0
STAPEL = [3000.0, 3000.0, 3000.0, 3000.0, 3390.0, 2610.0] # Sitz 5 gewann die Vorhand
DEALER = 4 # Small Blind Sitz 5, Big Blind Sitz 6
def folgehand(stapel=STAPEL):
vorlage = geber.szene(seed=120, politik="mitgehen", stapel=3000, blinds=(50, 100), ante=ANTE,
turnier=True)
return geber.naechste_hand(vorlage, stapel, seed=120 + 7919, dealer=DEALER)
def sitzrahmen(stueck):
return [json.loads(u["Data"]["cmd_bean"]["BeanData"]) for u in buehnenrahmen.rahmen(stueck)
if u["Data"]["cmd_bean"]["Cmd"] == "game.seat"]
def anfang(bild):
return STAPEL[bild["seatId"] - 1]
class JederSitzRechnetVonSeinemStapel(unittest.TestCase):
def setUp(self):
self.bilder = sitzrahmen(folgehand())
def test_die_ante_geht_vom_eigenen_stapel_ab(self):
antes = {b["seatId"]: b["userChips"] for b in self.bilder if b["caption"] == "Ante"}
self.assertEqual(antes, {i + 1: s - ANTE for i, s in enumerate(STAPEL)})
def test_die_blinds_gehen_vom_eigenen_stapel_ab(self):
blinds = {b["seatId"]: b["userChips"] for b in self.bilder if b["caption"] in ("SB", "BB")}
self.assertEqual(blinds, {5: 3390.0 - ANTE - 50.0, 6: 2610.0 - ANTE - 100.0})
def test_jeder_zug_zeigt_den_eigenen_rest(self):
# Ein Zug traegt alles, was der Sitz in der Hand gesetzt hat (betAmout, mit Ante und Blind).
zuege = [b for b in self.bilder if b["caption"] not in ("Ante", "SB", "BB", "Straddle")]
self.assertTrue(zuege, "die Folgehand hat keine Zuege")
for b in zuege:
self.assertEqual(b["userChips"], anfang(b) - b["betAmout"], b)
class GepostetWirdNurWasDaIst(unittest.TestCase):
"""Antes und Blinds zeigt der Tisch so, wie die Hand sie wirklich gesetzt hat: die Hand
(`selbstspiel`) deckelt jeden Einsatz am Stapel - ein kurzer Stapel postet nur, was er hat."""
def test_eine_ante_ueber_dem_stapel_ist_alles_was_er_hat(self):
kurz = [3000.0, 3000.0, 5.0, 3000.0, 3000.0, 3000.0]
antes = {b["seatId"]: (b["betAmout"], b["userChips"])
for b in sitzrahmen(folgehand(kurz)) if b["caption"] == "Ante"}
self.assertEqual(antes[3], (5.0, 0.0))
def test_ein_big_blind_ueber_dem_rest_ist_alles_was_er_hat(self):
kurz = [3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 30.0] # Sitz 6 ist der Big Blind
bb = [(b["betAmout"], b["userChips"]) for b in sitzrahmen(folgehand(kurz)) if b["caption"] == "BB"]
self.assertEqual(bb, [(30.0 - ANTE, 0.0)])
class WerPleiteIstKauftNach(unittest.TestCase):
"""Wer eine Hand mit nichts beendet, sitzt nicht mit null in der naechsten: er kauft auf den
Anfangsstapel des Tisches nach (der Buehnen-Turniertisch erlaubt Rebuys)."""
def test_nur_der_leere_stapel_wird_aufgefuellt(self):
self.assertEqual(geber.nachkaufen([0.0, 4200.0, 5.0], 3000.0), [3000.0, 4200.0, 5.0])
def test_keine_hand_beginnt_mit_einem_leeren_sitz(self):
plan = geber.plan(haende=2, spieler=3, seed=7, politik="zufall", stapel=[3000.0, 0.0, 3000.0],
blinds=(50, 100))
self.assertEqual([[s["chips"] > 0 for s in h["sitze"]] for h in plan], [[True] * 3] * 2)
if __name__ == "__main__":
unittest.main()