Owner 27.11.: besides AoF, which other CoinPoker modes are worth it? The first question is whether a mode has players at all. The lobby list the sammler fetches every 5 minutes already holds every real-money table; it now keeps them in a new `modi` block per mode (format, variant, seats) and stake: tables, running, players, full, pools. No table is opened. The existing `stufen` block is unchanged. The report (messung/sammler/bericht.py) gains a "Modi" table, busiest first, and sorts AoF stages by big blind (AOF25 sorted after NL50 before). Spec: tests/sammler_modi_spec.py. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
126 lines
5.6 KiB
Python
126 lines
5.6 KiB
Python
#!/usr/bin/env python3
|
|
"""Spezifikation: die Lobby-Zaehlung des Sammlers fuehrt ALLE Modi (plans/2026-11-25_aof.md, Owner 27.11.).
|
|
|
|
Ziel: wissen, wo Verkehr ist - je Modus und Stufe Tische und Spieler ueber den Tag -, bevor ein Modus
|
|
gebaut oder gespielt wird. Die Lobbyliste traegt alle Echtgeld-Tische; gezaehlt wird nur, kein Tisch
|
|
geht auf.
|
|
|
|
* Modus = Format, Spielart, Tischgroesse: "cash NLHE 6", "aof NLHE 4", "bombpot PLO5 6",
|
|
"kpoker NLHE 7", "cash SHORT_DECK 6". Unbekanntes Format oder unbekannte Spielart heisst "?".
|
|
* Je Modus und Stufe (Big Blind, "0.25"): Tische, besetzte, laufende (>= 2 Spieler), Spieler, volle,
|
|
Pools (ein Eintrag mit mehr Spielern als Plaetzen) und ihre Spieler. Ein Tisch zaehlt einmal.
|
|
* Uebungschips zaehlen nie. Der Block `stufen` (NLHE 6-max Cash und AoF) bleibt, wie er war.
|
|
* Der Bericht (messung/sammler/bericht.py) zeigt je Modus und Stufe die Mittel, die vollsten zuerst.
|
|
|
|
python3 tests/sammler_modi_spec.py -v
|
|
"""
|
|
import importlib.util
|
|
import json
|
|
import os
|
|
import sys
|
|
import tempfile
|
|
import unittest
|
|
from unittest import mock
|
|
|
|
_w = os.path.dirname(os.path.abspath(__file__))
|
|
sys.path.insert(0, _w)
|
|
from sammler_spec import Z, tisch # noqa: E402
|
|
|
|
WURZEL = os.path.dirname(_w)
|
|
|
|
|
|
def bericht_modul():
|
|
spec = importlib.util.spec_from_file_location("sammler_bericht",
|
|
os.path.join(WURZEL, "messung", "sammler", "bericht.py"))
|
|
m = importlib.util.module_from_spec(spec)
|
|
spec.loader.exec_module(m)
|
|
return m
|
|
|
|
|
|
LOBBY = [
|
|
tisch("NL 0.1-0.25 1", bb=0.25, spieler=6),
|
|
tisch("NL 0.1-0.25 2", bb=0.25, spieler=1),
|
|
tisch("17th-TX AOF 0.10-0.25 3", bb=0.25, spieler=4, groesse=4, gameType="Allinfold"),
|
|
tisch("PLO5 0.05-0.10 BPF 4", bb=0.1, spieler=5, gameVarient="5CardPLO", miniGameTypeId=17, isBombpot=True),
|
|
tisch("KP-NL 0.10 7MAX 5", bb=0.1, spieler=3, groesse=7, isKPoker=True),
|
|
tisch("14R NL6 0.02 6", bb=0.02, spieler=2, gameVarient="TexasSixPlus", miniGameTypeId=18),
|
|
tisch("PLO 0.25-0.5 7", bb=0.5, spieler=40, gameVarient="Omaha", miniGameTypeId=2), # Pool-Eintrag
|
|
tisch("Uebung 8", bb=500, spieler=4, coinTypeId=2),
|
|
tisch("Raetsel 9", bb=1.0, spieler=2, gameType="Neu", gameVarient="Neu", miniGameTypeId=99),
|
|
]
|
|
|
|
|
|
class Modus(unittest.TestCase):
|
|
def test_name_aus_format_spielart_und_groesse(self):
|
|
self.assertEqual([Z.modus(t) for t in LOBBY[:7]],
|
|
["cash NLHE 6", "cash NLHE 6", "aof NLHE 4", "bombpot PLO5 6", "kpoker NLHE 7",
|
|
"cash SHORT_DECK 6", "cash PLO4 6"])
|
|
|
|
def test_unbekanntes_heisst_fragezeichen(self):
|
|
self.assertEqual(Z.modus(LOBBY[8]), "? ? 6")
|
|
|
|
|
|
class Zaehlung(unittest.TestCase):
|
|
def setUp(self):
|
|
self.zeile = Z.zaehlen(LOBBY, 0.0)
|
|
self.modi = self.zeile["modi"]
|
|
|
|
def test_je_modus_und_stufe(self):
|
|
c = self.modi["cash NLHE 6"]["0.25"]
|
|
self.assertEqual((c["bb"], c["tische"], c["besetzt"], c["laufend"], c["voll"], c["spieler"]),
|
|
(0.25, 2, 2, 1, 1, 7))
|
|
self.assertEqual((self.modi["aof NLHE 4"]["0.25"]["voll"], self.modi["aof NLHE 4"]["0.25"]["spieler"]), (1, 4))
|
|
self.assertEqual(self.modi["bombpot PLO5 6"]["0.1"]["laufend"], 1)
|
|
self.assertEqual(self.modi["kpoker NLHE 7"]["0.1"]["voll"], 0)
|
|
self.assertEqual(self.modi["cash SHORT_DECK 6"]["0.02"]["spieler"], 2)
|
|
|
|
def test_pool_eintrag_zaehlt_als_pool(self):
|
|
p = self.modi["cash PLO4 6"]["0.5"]
|
|
self.assertEqual((p["tische"], p["pools"], p["pool_spieler"]), (0, 1, 40))
|
|
|
|
def test_uebungschips_zaehlen_nie(self):
|
|
self.assertNotIn("500", json.dumps(self.modi))
|
|
|
|
def test_unbekanntes_wird_mitgezaehlt(self):
|
|
self.assertEqual(self.modi["? ? 6"]["1"]["tische"], 1)
|
|
|
|
def test_doppelter_tisch_einmal(self):
|
|
t = LOBBY[0]
|
|
self.assertEqual(Z.zaehlen([t, dict(t)], 0.0)["modi"]["cash NLHE 6"]["0.25"]["tische"], 1)
|
|
|
|
def test_stufen_bleiben_wie_sie_waren(self):
|
|
s = self.zeile["stufen"]
|
|
self.assertEqual(set(s), {"NL10", "NL25", "NL50", "AOF25"})
|
|
self.assertEqual((s["NL25"]["tische"], s["NL25"]["spieler"]), (2, 7))
|
|
self.assertEqual(s["NL10"]["tische"], 0, "Bomb Pot und K-Poker zaehlen nicht als NL10")
|
|
|
|
def test_keine_namen(self):
|
|
self.assertNotIn("roomName", json.dumps(self.zeile))
|
|
self.assertNotIn("Raetsel", json.dumps(self.zeile))
|
|
|
|
|
|
class Bericht(unittest.TestCase):
|
|
def test_modi_tabelle_die_vollsten_zuerst(self):
|
|
b = bericht_modul()
|
|
zeilen = [Z.zaehlen(LOBBY, 0.0), Z.zaehlen(LOBBY[:1], 300.0)]
|
|
with tempfile.TemporaryDirectory() as o:
|
|
with open(os.path.join(o, "zaehlung.jsonl"), "w", encoding="utf-8") as f:
|
|
f.write("\n".join(json.dumps(z) for z in zeilen) + "\n")
|
|
with mock.patch.object(b, "HIER", o):
|
|
text = b.bericht()
|
|
teil = text[text.index("## Modi"):]
|
|
reihe = [z.split("|")[1].strip() + " " + z.split("|")[2].strip()
|
|
for z in teil.splitlines() if z.startswith("| ") and not z.startswith("| Modus")]
|
|
self.assertEqual(reihe[0], "cash PLO4 6 0.5", "40 Spieler im Pool: am vollsten")
|
|
self.assertEqual(reihe[1], "cash NLHE 6 0.25")
|
|
self.assertIn("| aof NLHE 4 | 0.25 | 0.5 | 2.0 / 4 |", teil, "Mittel ueber beide Zaehlungen, fehlt = 0")
|
|
|
|
def test_aof_stufe_sortiert_nach_big_blind(self):
|
|
b = bericht_modul()
|
|
self.assertEqual(b.zaehl_stufen([{"stufen": {"AOF25": {}, "NL50": {}, "NL10": {}}}]),
|
|
["NL10", "AOF25", "NL50"])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|