diff --git a/hand/theater.py b/hand/theater.py index b4d2a481..0c18739e 100644 --- a/hand/theater.py +++ b/hand/theater.py @@ -41,6 +41,8 @@ SPIEL = ("/Applications/CoinPoker.app/Contents/Resources/unity-resources-arm64/" THEME = "/Users/marcmintel/Library/Application Support/CoinPoker/image-cache/desk-1.jpg" ANS_SPIEL = "ans-spiel" ZUR_BRUECKE = "zur-bruecke" +# Der Mittler (`hand/mittler.py`) nennt denselben Weg "ans-bruecke" - beide Namen gelten. +AUFWAERTS_NAMEN = (ZUR_BRUECKE, "ans-bruecke") # ---- Drehbuch: reine Teile ---- @@ -60,9 +62,10 @@ def lesen(text): abstand = float(teile[0]) except ValueError: continue - if teile[1] not in (ANS_SPIEL, ZUR_BRUECKE): + if teile[1] not in (ANS_SPIEL,) + AUFWAERTS_NAMEN: continue - raus.append((abstand, teile[1], teile[2].encode("utf-8"))) + richtung = ANS_SPIEL if teile[1] == ANS_SPIEL else ZUR_BRUECKE + raus.append((abstand, richtung, teile[2].encode("utf-8"))) return raus @@ -86,6 +89,7 @@ class Aufnahme: self.zaehler = {ANS_SPIEL: 0, ZUR_BRUECKE: 0} def __call__(self, richtung, roh): + richtung = ANS_SPIEL if richtung == ANS_SPIEL else ZUR_BRUECKE if richtung == ANS_SPIEL and not self.mit_spiel: return if richtung == ZUR_BRUECKE and not self.mit_bruecke: diff --git a/tests/theater_spec.py b/tests/theater_spec.py index b338f6cc..42feb0cf 100644 --- a/tests/theater_spec.py +++ b/tests/theater_spec.py @@ -36,6 +36,14 @@ class Zeilen(unittest.TestCase): gelesen = theater.lesen(theater.zeile(0.0, theater.ANS_SPIEL, roh)) self.assertEqual(gelesen[0][2].decode("utf-8"), roh) + def test_der_mittler_nennt_die_richtung_anders(self): + """`hand/mittler.py` schreibt "ans-bruecke" - derselbe Weg, anderer Name. + + Ohne das starb jede Aufnahme aus dem Mittler: die Aufwaertsrahmen fielen beim Lesen weg. + """ + gelesen = theater.lesen(theater.zeile(0.5, "ans-bruecke", '{"EventName":"send_to_lobby"}')) + self.assertEqual(gelesen[0][1], theater.ZUR_BRUECKE) + def test_kaputte_zeilen_fallen_weg(self): text = "\n".join(["", "kein tab hier", "abc\tans-spiel\t{}", "1.0\twoanders\t{}", "2.0\tans-spiel\t{}", "3.0\tzur-bruecke\t{}"])