Bisher 12 an fuenf Stellen (geld, spielplan, Rust/WinUI/Swift-Cockpit), laufwache 6, harter Prozessdeckel 14 per Umgebung. Jetzt eine Zahl in lesen/geld.py; spielplan, laufwache und tischdeckel (hart = Grenze + 2 Tauschluft) lesen sie, der Server liefert sie als kopf.tische_hoechstens, die drei Cockpits lesen sie von dort. Wie viele Tische wirklich laufen, entscheidet weiter der Spielplan. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
176 lines
7.7 KiB
Python
176 lines
7.7 KiB
Python
#!/usr/bin/env python3
|
|
"""Spielplan je Format (plans/2026-10-30_formate.md): Tischzahl je Format, der Läufer füllt je Format.
|
|
|
|
* `formate` {format: tische}: unbekannte Formate und Unsinn fallen weg, die Summe bleibt unter
|
|
HOECHSTENS (spätere Formate in der Reihenfolge von formate.ALLE werden gekürzt).
|
|
* Ein alter Plan ohne `formate` heißt: Cash mit seiner Tischzahl.
|
|
* naechster_schritt mit `offen_je_format`: das erste Format unter seiner Zahl, dessen Reiter im
|
|
Modus gemessen ist, öffnet; ungemessene sagen warum - nie raten.
|
|
* format_passt: an einem Tisch eines Formats mit 0 Tischen wird nicht gesetzt (unbekannt: kein Urteil).
|
|
* Der Tisch kennt sein Format (hand/sitzen.Lage.format) aus roomProperties - Log.
|
|
|
|
python3 tests/spielplan_formate_spec.py -v
|
|
"""
|
|
import gzip
|
|
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, "lesen")):
|
|
_w = os.path.dirname(_w)
|
|
for _u in ("betrieb", "lesen", "hand", "client"):
|
|
sys.path.insert(0, os.path.join(_w, _u))
|
|
|
|
import formate
|
|
import sitzen
|
|
import spielplan
|
|
from spielplan import Spielplan
|
|
|
|
|
|
def plan(d):
|
|
return spielplan.aus_dict(dict({"modus": "echt", "tische": 1}, **d))
|
|
|
|
|
|
def schritt(p, offen_je_format, guthaben=5000.0):
|
|
return spielplan.naechster_schritt(p, offen=sum(offen_je_format.values()), in_arbeit=False, schluss=False,
|
|
gestoppt=False, letzter_versuch=None, jetzt=1000.0, fehlversuche={},
|
|
guthaben=guthaben, offen_je_format=offen_je_format)
|
|
|
|
|
|
class Formate(unittest.TestCase):
|
|
def test_alter_plan_ist_cash(self):
|
|
p = plan({"tische": 3})
|
|
self.assertEqual(spielplan.formate_von(p), {"cash": 3})
|
|
self.assertEqual(p.tische, 3)
|
|
|
|
def test_formate_und_summe(self):
|
|
p = plan({"formate": {"cash": 2, "aof": 1, "bombpot": 0, "erfunden": 4, "vip": -2, "turnier": "x"}})
|
|
self.assertEqual(spielplan.formate_von(p), {"cash": 2, "aof": 1})
|
|
self.assertEqual(p.tische, 3)
|
|
|
|
def test_summe_bleibt_unter_hoechstens(self):
|
|
n = spielplan.HOECHSTENS - 2
|
|
p = plan({"formate": {"cash": n, "aof": 10}})
|
|
self.assertEqual(spielplan.formate_von(p), {"cash": n, "aof": 2})
|
|
self.assertEqual(p.tische, spielplan.HOECHSTENS)
|
|
|
|
def test_alles_null_oeffnet_nichts(self):
|
|
p = plan({"formate": {"cash": 0}})
|
|
self.assertEqual(p.tische, 0)
|
|
self.assertEqual(schritt(p, {})[0], "warten")
|
|
|
|
def test_datei_rundweg(self):
|
|
p = plan({"formate": {"cash": 2, "aof": 1}})
|
|
self.assertEqual(spielplan.aus_dict(spielplan.als_dict(p)), p)
|
|
|
|
|
|
class Auffuellen(unittest.TestCase):
|
|
def test_cash_unter_der_zahl_oeffnet_cash(self):
|
|
self.assertEqual(schritt(plan({"formate": {"cash": 2}}), {"cash": 1}), ("oeffnen", "Cash Games"))
|
|
|
|
def test_uebung_oeffnet_practice(self):
|
|
p = spielplan.aus_dict({"modus": "uebung", "tische": 1, "formate": {"cash": 1}})
|
|
self.assertEqual(schritt(p, {}), ("oeffnen", "Practice Games"))
|
|
|
|
def test_bomb_pot_uebung_oeffnet_ueber_die_uebungsliste(self):
|
|
# Eigentuemer 5.11. abends: Bomb-Pot-Uebungstische zulassen. Sie stehen in derselben
|
|
# Uebungsliste (coinTypeId 2, isBombpot) wie die Cash-Uebung und werden ueber den Kanal
|
|
# beigetreten - der Reiter "Practice Games" fuehrt hin.
|
|
p = spielplan.aus_dict({"modus": "uebung", "tische": 1, "formate": {"bombpot": 1}})
|
|
self.assertEqual(schritt(p, {}), ("oeffnen", "Practice Games"))
|
|
|
|
def test_bomb_pot_um_geld_ist_jetzt_gemessen(self):
|
|
# Bomb Pot Echt ist jetzt GEMESSEN (Reiter Cash Games, Liste + Kanal). Die harte Tür gegen das
|
|
# SPIELEN (PLO5, kein Glücksspiel) sitzt im Läufer (runner.tisch_aus_api / _modus_ok), nicht hier.
|
|
self.assertEqual(schritt(plan({"formate": {"bombpot": 1}}), {}), ("oeffnen", "Cash Games"))
|
|
|
|
def test_aof_ist_jetzt_gemessen(self):
|
|
# AoF Echt ist jetzt gemessen: ist Cash voll, öffnet der Spielplan AoF (Reiter Cash Games).
|
|
self.assertEqual(schritt(plan({"formate": {"cash": 1, "aof": 1}}), {"cash": 1}),
|
|
("oeffnen", "Cash Games"))
|
|
|
|
def test_gemessenes_format_in_fuellfolge(self):
|
|
# cash und aof sind beide gemessen; cash steht in der Füllfolge (formate.ALLE) vor aof
|
|
self.assertEqual(schritt(plan({"formate": {"aof": 1, "cash": 1}}), {}), ("oeffnen", "Cash Games"))
|
|
|
|
def test_jedes_format_voll(self):
|
|
was, text = schritt(plan({"formate": {"cash": 1, "aof": 1}}), {"cash": 1, "aof": 1})
|
|
self.assertEqual(was, "warten")
|
|
self.assertIn("Tischzahl erreicht", text)
|
|
|
|
def test_ohne_formatangabe_wie_bisher(self):
|
|
# der Läufer ohne offen_je_format: wie bisher nach der Gesamtzahl
|
|
p = plan({"formate": {"cash": 2}})
|
|
self.assertEqual(spielplan.naechster_schritt(p, offen=1, in_arbeit=False, schluss=False, gestoppt=False,
|
|
letzter_versuch=None, jetzt=0.0, fehlversuche={},
|
|
guthaben=10.0), ("oeffnen", "Cash Games"))
|
|
|
|
|
|
class FormatPasst(unittest.TestCase):
|
|
def test_gewaehltes_format(self):
|
|
self.assertTrue(spielplan.format_passt(plan({"formate": {"cash": 1}}), "cash"))
|
|
|
|
def test_nicht_gewaehltes_format(self):
|
|
self.assertFalse(spielplan.format_passt(plan({"formate": {"cash": 1}}), "aof"))
|
|
|
|
def test_ohne_plan_oder_unbekannt(self):
|
|
self.assertTrue(spielplan.format_passt(None, "aof"))
|
|
self.assertTrue(spielplan.format_passt(plan({"formate": {"cash": 1}}), None))
|
|
|
|
|
|
MAIN6 = os.path.join(_w, "archiv", "mitschrieb", "main.6.log.gz")
|
|
|
|
|
|
@unittest.skipUnless(os.path.exists(MAIN6), "Archiv fehlt")
|
|
class FormatAmTisch(unittest.TestCase):
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
cls.text = gzip.open(MAIN6, "rt", encoding="utf-8", errors="replace").read()
|
|
|
|
def test_echter_ring_tisch_ist_cash(self):
|
|
lagen, _ = sitzen.lesen(self.text)
|
|
self.assertEqual(lagen["Big Ben 1664572"].format, "cash")
|
|
|
|
def test_echter_aof_tisch(self):
|
|
lagen, _ = sitzen.lesen(self.text)
|
|
self.assertEqual(lagen["Statue of Liberty 224829"].format, "aof")
|
|
|
|
def test_format_bleibt_im_gedaechtnis(self):
|
|
g = {}
|
|
sitzen.lesen(self.text, gedaechtnis=g)
|
|
ohne = "\n".join(z for z in self.text.splitlines() if "game.game_alldata" not in z)
|
|
lagen, _ = sitzen.lesen(ohne, gedaechtnis=g)
|
|
self.assertEqual(lagen["Big Ben 1664572"].format, "cash")
|
|
|
|
|
|
class TurnierFalten(unittest.TestCase):
|
|
"""Alt-Plaene mit eigenen freeroll/vip-Formaten -> EIN Turnier-Format (Owner 9.11., Typ in
|
|
turnier.kategorie). Eine gesetzte Turnier-Zahl bleibt massgeblich; nur-Alt faltet in turnier."""
|
|
|
|
def test_freeroll_neben_turnier_bleibt_turnier(self): # der gemeldete Fall: 1 gewaehlt, oben stand 2
|
|
p = plan({"formate": {"freeroll": 1, "turnier": 1}, "reihenfolge": ["freeroll", "turnier"]})
|
|
self.assertEqual(spielplan.formate_von(p), {"turnier": 1})
|
|
self.assertEqual(p.tische, 1)
|
|
|
|
def test_nur_freeroll_wird_turnier(self):
|
|
p = plan({"formate": {"freeroll": 2}})
|
|
self.assertEqual(spielplan.formate_von(p), {"turnier": 2})
|
|
|
|
def test_vip_faltet_ebenfalls(self):
|
|
p = plan({"formate": {"vip": 1}})
|
|
self.assertEqual(spielplan.formate_von(p), {"turnier": 1})
|
|
|
|
def test_cash_bleibt_neben_gefaltetem_turnier(self):
|
|
p = plan({"formate": {"cash": 1, "freeroll": 1}})
|
|
self.assertEqual(spielplan.formate_von(p), {"cash": 1, "turnier": 1})
|
|
self.assertEqual(p.tische, 2)
|
|
|
|
def test_ohne_turnierformate_unveraendert(self):
|
|
p = plan({"formate": {"cash": 2, "aof": 1}})
|
|
self.assertEqual(spielplan.formate_von(p), {"cash": 2, "aof": 1})
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|