- 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
262 lines
10 KiB
Python
262 lines
10 KiB
Python
#!/usr/bin/env python3
|
|
"""Sonderformen der Buehne: jede Form traegt ihr ECHTES Client-Feld und ihren Rahmen.
|
|
|
|
Der Client hat mehr Formen, als die Buehne bisher abbildete. Je Form steht hier EIN Fall, der
|
|
zwei Dinge zugleich prueft: das Merkmal im Tischbau (woertlicher Feldname aus dem Client) UND den
|
|
eigenen Rahmen (woertlicher Rahmen-Name aus dem Client-Log bzw. aus dem Bean-Namen). Fundort je
|
|
Feld und Rahmen: archiv/mitschrieb/SPECIALFAELLE.md, gelesen aus Assembly-CSharp.dll/PBCommon.dll
|
|
und app.asar - nichts geraten, Annahmen dort gekennzeichnet.
|
|
|
|
python3 tests/specialfaelle_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 geber # noqa: E402
|
|
|
|
|
|
def cmd(umschlag):
|
|
return umschlag["Data"]["cmd_bean"]["Cmd"]
|
|
|
|
|
|
def bean(umschlag):
|
|
return json.loads(umschlag["Data"]["cmd_bean"]["BeanData"])
|
|
|
|
|
|
_SZENEN = [None]
|
|
|
|
|
|
def S():
|
|
"""Alle Szenen einmal bauen (sonst baut jeder Aufruf 27 Szenen neu)."""
|
|
if _SZENEN[0] is None:
|
|
_SZENEN[0] = geber.szenen()
|
|
return _SZENEN[0]
|
|
|
|
|
|
def alldata(name):
|
|
"""Der Tischbau (game_alldata) einer Szene - der Traeger der Merkmale."""
|
|
folge = geber.rahmen(S()[name])
|
|
return bean(next(u for u in folge if cmd(u) == "game.game_alldata"))
|
|
|
|
|
|
def namen(name):
|
|
return [cmd(u) for u in geber.rahmen(S()[name])]
|
|
|
|
|
|
def rahmen_mit(name, rahmenname):
|
|
return [bean(u) for u in geber.rahmen(S()[name]) if cmd(u) == rahmenname]
|
|
|
|
|
|
class SplashThePot(unittest.TestCase):
|
|
"""Splash the Pot - Merkmal im Tischbau, Rahmen game.splash_the_pot (12x im Bestand)."""
|
|
|
|
def test_merkmal_im_tischbau(self):
|
|
b = alldata("splash")
|
|
self.assertTrue(b["gameDynamicPropertiesResponseData"]["isSplashThePotEnabled"])
|
|
self.assertGreater(b["roomProperties"]["splashSharedBonusPercentage"], 0)
|
|
|
|
def test_rahmen_und_feld(self):
|
|
treffer = rahmen_mit("splash", "game.splash_the_pot")
|
|
self.assertEqual(len(treffer), 1)
|
|
self.assertFalse(treffer[0]["megaSplash"])
|
|
self.assertIn("dropAmount", treffer[0])
|
|
|
|
def test_mega_splash_ist_illusion_und_eigenes_bein(self):
|
|
b = alldata("mega_splash")
|
|
self.assertTrue(b["gameDynamicPropertiesResponseData"]["isSplashThePotEnabled"])
|
|
splash = rahmen_mit("mega_splash", "game.splash_the_pot")[0]
|
|
self.assertTrue(splash["megaSplash"])
|
|
self.assertTrue(splash["isIllusion"])
|
|
mega = rahmen_mit("mega_splash", "game.mega_splash")[0]
|
|
self.assertEqual(mega["message"], "MEGA SPLASH OCCUR ")
|
|
self.assertGreater(mega["amount"], 0)
|
|
|
|
def test_aof_splash_ist_ein_eigener_tisch(self):
|
|
self.assertTrue(S()["aof_splash"]["thema"].endswith("desk-aof-mega-splash-0.jpg"))
|
|
|
|
|
|
class BigAnte(unittest.TestCase):
|
|
"""Big Ante - ante >= bigAnteBBRatioThreshold * bigBlind (Schwelle 0.2 aus AnteConfig)."""
|
|
|
|
def test_grosser_ante_traegt_min_max(self):
|
|
rp = alldata("big_ante")["roomProperties"]
|
|
self.assertGreaterEqual(rp["ante"], 0.2 * rp["bigBlind"])
|
|
self.assertEqual(rp["minAnte"], rp["ante"])
|
|
self.assertEqual(rp["maxAnte"], rp["ante"])
|
|
|
|
def test_kleiner_ante_traegt_kein_big_ante_merkmal(self):
|
|
rp = alldata("ante")["roomProperties"]
|
|
self.assertLess(rp["ante"], 0.2 * rp["bigBlind"])
|
|
self.assertIsNone(rp["minAnte"])
|
|
|
|
|
|
class Straddle(unittest.TestCase):
|
|
"""Interaktives Straddle - Caption "Straddle" am Sitz, game.auto_post_bb (3x im Bestand)."""
|
|
|
|
def test_straddle_ist_echtes_geld(self):
|
|
s = S()["straddle"]
|
|
straddel = [z for z in s["ablauf"] if z["art"] == "straddle"]
|
|
self.assertEqual(len(straddel), 1)
|
|
self.assertEqual(straddel[0]["betrag"], 2 * s["blinds"][1])
|
|
|
|
def test_merkmal_und_rahmen(self):
|
|
b = alldata("straddle")
|
|
self.assertTrue(b["roomProperties"]["isStraddle"])
|
|
self.assertTrue(b["straddleResponseData"]["straddle"])
|
|
sitz = [x for x in rahmen_mit("straddle", "game.seat") if x["caption"] == "Straddle"]
|
|
self.assertEqual(len(sitz), 1)
|
|
self.assertEqual(sitz[0]["betAmout"], 2 * S()["straddle"]["blinds"][1])
|
|
auto = rahmen_mit("straddle", "game.auto_post_bb")
|
|
self.assertTrue(auto and auto[0]["showAutoPostBB"])
|
|
|
|
|
|
class MustShow(unittest.TestCase):
|
|
"""Must-Show - roomProperties.isMustShowEnabled, Sieger zeigen (game.show_cards, 161x)."""
|
|
|
|
def test_merkmal_im_tischbau(self):
|
|
self.assertTrue(alldata("must_show")["roomProperties"]["isMustShowEnabled"])
|
|
|
|
def test_sieger_zeigen_ihre_karten(self):
|
|
zeigen = rahmen_mit("must_show", "game.show_cards")
|
|
self.assertTrue(zeigen)
|
|
for z in zeigen:
|
|
self.assertEqual(len(z["showCardsList"]), 2)
|
|
self.assertEqual(len(z["showCardIndexMap"]), 2)
|
|
|
|
|
|
class FixedHandBombpot(unittest.TestCase):
|
|
"""Fixed-Hand-Bombpot - isFixedHandBombpot/handsInBombpot, bombpot_info mit Handzahl."""
|
|
|
|
def test_merkmal_im_tischbau(self):
|
|
rp = alldata("fixed_bombpot")["roomProperties"]
|
|
self.assertTrue(rp["isFixedHandBombpot"])
|
|
self.assertTrue(rp["isBombpot"])
|
|
self.assertEqual(rp["handsInBombpot"], 3)
|
|
|
|
def test_bombpot_info_traegt_die_handzahl(self):
|
|
info = rahmen_mit("fixed_bombpot", "game.bombpot_info")[0]
|
|
self.assertTrue(info["isBombpotHand"])
|
|
self.assertEqual(info["totalHandCount"], 3)
|
|
self.assertIsNotNone(info["currentHandNumber"])
|
|
|
|
|
|
class RabbitRun(unittest.TestCase):
|
|
"""Rabbit Run - roomProperties.isRabbitRunAllowed, Rahmen game.rabbit_run_new."""
|
|
|
|
def test_merkmal_im_tischbau(self):
|
|
self.assertTrue(alldata("rabbit")["roomProperties"]["isRabbitRunAllowed"])
|
|
|
|
def test_rahmen_traegt_die_restkarten(self):
|
|
lauf = rahmen_mit("rabbit", "game.rabbit_run_new")
|
|
self.assertEqual(len(lauf), 1)
|
|
self.assertIn("rabbitRunCards", lauf[0])
|
|
self.assertIn("rabbitRunCardsDoubleBoard", lauf[0])
|
|
|
|
|
|
class Bounty(unittest.TestCase):
|
|
"""Mystery Bounty - tourneyTableProperties.isBountyTournament, Rahmen game.bounty_winner.
|
|
|
|
ANNAHME: der Rahmen-Name game.bounty_winner ist aus dem Bean-Namen (BountyWinnerBean) und dem
|
|
Muster game.<bean> gebildet - im Bestand gab es keine Bounty-Hand."""
|
|
|
|
def test_merkmal_im_tischbau(self):
|
|
self.assertTrue(alldata("bounty")["tourneyTableProperties"]["isBountyTournament"])
|
|
|
|
def test_rahmen_mit_bounty_feldern(self):
|
|
b = rahmen_mit("bounty", "game.bounty_winner")
|
|
self.assertTrue(b)
|
|
self.assertTrue(b[0]["bountyWinnerData"] or b[0]["mysteryBountyWinnerData"])
|
|
self.assertIn("bountyType", b[0]["mysteryBountyWinnerData"][0])
|
|
|
|
|
|
class HandForHand(unittest.TestCase):
|
|
"""Hand-for-Hand - handForHandTournamentResponseData, Rahmen tournamentgame.hand_for_hand.
|
|
|
|
Der Rahmen-Name ist gelesen (5.11., PBClient BeanAndClientEventMap: tournamentgame.hand_for_hand
|
|
-> HandForHandBean -> 'hand-for-hand'); die fruehere Annahme game.hand_for_hand kannte der
|
|
Client nicht ("Unknown event received at unity side")."""
|
|
|
|
def test_merkmal_im_tischbau(self):
|
|
b = alldata("hand_for_hand")
|
|
self.assertIn("handForHandTournamentResponseData", b)
|
|
self.assertTrue(b["handForHandTournamentResponseData"]["handForHandStatus"])
|
|
|
|
def test_rahmen(self):
|
|
self.assertTrue(rahmen_mit("hand_for_hand", "tournamentgame.hand_for_hand"))
|
|
|
|
def test_kein_rahmen_unter_dem_falschen_namen(self):
|
|
self.assertFalse(rahmen_mit("hand_for_hand", "game.hand_for_hand"))
|
|
|
|
|
|
class MehrtagesTurnier(unittest.TestCase):
|
|
"""Mehrtages-Turnier - roomProperties.isMultiDayTournament/MultiDayStackType/FinishLevel."""
|
|
|
|
def test_merkmal_im_tischbau(self):
|
|
rp = alldata("multi_day")["roomProperties"]
|
|
self.assertTrue(rp["isMultiDayTournament"])
|
|
self.assertGreater(rp["multiDayFinishLevel"], 0)
|
|
|
|
def test_der_stapeltyp_ist_nie_text(self):
|
|
# Der Client liest multiDayStackType als Nullable<int> (PBCommon RoomPropertiesBean); Text
|
|
# ("FREEZE") brach den GANZEN Tischbau (JsonReaderException, 5.11. am Buehnentisch).
|
|
stapeltyp = alldata("multi_day")["roomProperties"]["multiDayStackType"]
|
|
self.assertTrue(stapeltyp is None or type(stapeltyp) is int, repr(stapeltyp))
|
|
|
|
|
|
class EigeneTische(unittest.TestCase):
|
|
"""Arena, CGWC, Battle - je eigenes Merkmal und (wo der Client eins hat) eigenes Tischbild."""
|
|
|
|
def test_arena_merkmal_und_bild(self):
|
|
rt = alldata("arena")["roomProperties"]["restrictedTableData"]
|
|
self.assertTrue(rt["isArena"])
|
|
self.assertFalse(rt["isCgwc"])
|
|
self.assertTrue(S()["arena"]["thema"].endswith("desk-arena-1.jpg"))
|
|
|
|
def test_cgwc_merkmal_und_bild(self):
|
|
rt = alldata("cgwc")["roomProperties"]["restrictedTableData"]
|
|
self.assertTrue(rt["isCgwc"])
|
|
self.assertFalse(rt["isArena"])
|
|
self.assertTrue(S()["cgwc"]["thema"].endswith("desk-cgwc-1.jpg"))
|
|
|
|
def test_battle_merkmal(self):
|
|
# ANNAHME: Battle Cap steht im Client als tableSpecs.battleCap; auf dem Draht bleibt
|
|
# roomProperties.dynamicRakeConfig als Merkmal.
|
|
self.assertEqual(alldata("battle")["roomProperties"]["dynamicRakeConfig"], 1)
|
|
|
|
|
|
class KeinRueckfall(unittest.TestCase):
|
|
"""Keine Form schadet den schon abgebildeten - jede neue Szene baut und schliesst sauber."""
|
|
|
|
NEU = ("splash", "mega_splash", "aof_splash", "big_ante", "straddle", "must_show",
|
|
"fixed_bombpot", "rabbit", "hand_for_hand", "multi_day", "arena", "cgwc", "battle",
|
|
"bounty")
|
|
|
|
def test_jede_neue_szene_baut_und_schliesst(self):
|
|
szenen = S()
|
|
for n in self.NEU:
|
|
with self.subTest(name=n):
|
|
self.assertIn(n, szenen)
|
|
folge = namen(n)
|
|
self.assertEqual(folge[0], "game.game_alldata")
|
|
self.assertIn("game.winnerInfo", folge)
|
|
self.assertEqual(folge[-2], "game.reset_data") # danach: Wartezustand
|
|
self.assertEqual(folge[-1], "game.auto_post_bb")
|
|
|
|
def test_thema_ist_gesetzt(self):
|
|
for n, s in S().items():
|
|
with self.subTest(name=n):
|
|
self.assertTrue(s["thema"].endswith(".jpg"))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main(verbosity=2)
|