diff --git a/archiv/mitschrieb/beispiele/turnierlage.txt b/archiv/mitschrieb/beispiele/turnierlage.txt new file mode 100644 index 00000000..4e424a5e --- /dev/null +++ b/archiv/mitschrieb/beispiele/turnierlage.txt @@ -0,0 +1,4 @@ +"EventName":"receive_from_tournament_lobby","RequestId":null,"Data":{"room_name":"Comm_Tournament_117632","request_id":"tournamentlobby.rank_list","data":"{\"rankList\":[{\"rank\":1,\"chips\":162560.53,\"playerName\":\"amanpoker\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1816483,\"instanceNumber\":1},{\"rank\":2,\"chips\":69052.91,\"playerName\":\"KleinCalvin\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":488150,\"instanceNumber\":1},{\"rank\":3,\"chips\":52380.58,\"playerName\":\"timeGambler\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":143942,\"instanceNumber\":1},{\"rank\":4,\"chips\":40381.60,\"playerName\":\"mortadella\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1616671,\"instanceNumber\":1},{\"rank\":5,\"chips\":39263.68,\"playerName\":\"Nick272727\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":380532,\"instanceNumber\":1},{\"rank\":6,\"chips\":36338.76,\"playerName\":\"smwilkinson\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1777756,\"instanceNumber\":1},{\"rank\":7,\"chips\":34265.03,\"playerName\":\"Kilares\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1807298,\"instanceNumber\":1},{\"rank\":8,\"chips\":33788.93,\"playerName\":\"cosmoid\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1639331,\"instanceNumber\":1},{\"rank\":9,\"chips\":31408.69,\"playerName\":\"QaQom\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1554658,\"instanceNumber\":1},{\"rank\":10,\"chips\":29303.88,\"playerName\":\"Williamson1986\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":375571,\"instanceNumber\":1},{\"rank\":11,\"chips\":24518.66,\"playerName\":\"RYANS321\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":334312,\"instanceNumber\":1},{\"rank\":12,\"chips\":21134.29,\"playerName\":\"Leander77\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1842778,\"instanceNumber\":1},{\"rank\":13,\"chips\":19554.34,\"playerName\":\"kethauthi\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1741026,\"instanceNumber\":1},{\"rank\":14,\"chips\":18804.00,\"playerName\":\"MagnusMidtbo\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1836618,\"instanceNumber\":1},{\"rank\":15,\"chips\":18477.00,\"playerName\":\"ecstatic9310749\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1864925,\"instanceNumber\":1},{\"rank\":16,\"chips\":16690.00,\"playerName\":\"wtfreallydonk\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":228027,\"instanceNumber\":3},{\"rank\":17,\"chips\":13714.00,\"playerName\":\"prickly21206125\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1865966,\"instanceNumber\":2},{\"rank\":18,\"chips\":3363.12,\"playerName\":\"Maozzz\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1800002,\"instanceNumber\":2},{\"rank\":19,\"chips\":0.00,\"playerName\":\"tmffjtl\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1883732,\"instanceNumber\":1},{\"rank\":20,\"chips\":0.00,\"playerName\":\"JohnnyWins\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":180057,\"instanceNumber\":1},{\"rank\":21,\"chips\":0.00,\"playerName\":\"andruchiha\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":451719,\"instanceNumber\":1},{\"rank\":22,\"chips\":0.00,\"playerName\":\"yuxi19\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1817904,\"instanceNumber\":1},{\"rank\":23,\"chips\":0.00,\"playerName\":\"OLADOG\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1757033,\"instanceNumber\":2},{\"rank\":24,\"chips\":0.00,\"playerName\":\"Uwuwudiver\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1810348,\"instanceNumber\":1},{\"rank\":25,\"chips\":0.00,\"playerName\":\"skaner13\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1800127,\"instanceNumber\":1},{\"rank\":26,\"chips\":0.00,\"playerName\":\"LordMax888\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":231514,\"instanceNumber\":1},{\"rank\":27,\"chips\":0.00,\"playerName\":\"jafarbw\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":236882,\"instanceNumber\":2},{\"rank\":28,\"chips\":0.00,\"playerName\":\"vilen040\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1880580,\"instanceNumber\":1},{\"rank\":29,\"chips\":0.00,\"playerName\":\"ZEBS\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":448654,\"instanceNumber\":1},{\"rank\":30,\"chips\":0.00,\"playerName\":\"LoungeAct\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1521707,\"instanceNumber\":1},{\"rank\":31,\"chips\":0.00,\"playerName\":\"Daisal\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1880889,\"instanceNumber\":1},{\"rank\":32,\"chips\":0.00,\"playerName\":\"Maker9592\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":459100,\"instanceNumber\":1},{\"rank\":33,\"chips\":0.00,\"playerName\":\"bkfllover42\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1599064,\"instanceNumber\":1},{\"rank\":34,\"chips\":0.00,\"playerName\":\"muenshi1kk\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1834114,\"instanceNumber\":1},{\"rank\":35,\"chips\":0.00,\"playerName\":\"RJSS\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":308875,\"instanceNumber\":1},{\"rank\":36,\"chips\":0.00,\"playerName\":\"Kimdrew\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1851085,\"instanceNumber\":1},{\"rank\":37,\"chips\":0.00,\"playerName\":\"Bullit\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1859117,\"instanceNumber\":2},{\"rank\":38,\"chips\":0.00,\"playerName\":\"SeaDealer\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1810189,\"instanceNumber\":2},{\"rank\":39,\"chips\":0.00,\"playerName\":\"Testicall\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":77600,\"instanceNumber\":1},{\"rank\":40,\"chips\":0.00,\"playerName\":\"functional55888\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1712652,\"instanceNumber\":1},{\"rank\":41,\"chips\":0.00,\"playerName\":\"Nikolaa\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":205629,\"instanceNumber\":1},{\"rank\":42,\"chips\":0.00,\"playerName\":\"theslush69\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1681675,\"instanceNumber\":1},{\"rank\":43,\"chips\":0.00,\"playerName\":\"fearful69263586\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1751367,\"instanceNumber\":2},{\"rank\":44,\"chips\":0.00,\"playerName\":\"UwUegirl420K\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1532769,\"instanceNumber\":1},{\"rank\":45,\"chips\":0.00,\"playerName\":\"zalley\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1562482,\"instanceNumber\":1},{\"rank\":46,\"chips\":0.00,\"playerName\":\"average61074993\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1743015,\"instanceNumber\":1},{\"rank\":47,\"chips\":0.00,\"playerName\":\"foxdog\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1582838,\"instanceNumber\":1},{\"rank\":48,\"chips\":0.00,\"playerName\":\"dzzdzz\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1815668,\"instanceNumber\":2},{\"rank\":49,\"chips\":0.00,\"playerName\":\"JirenTheGray\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":644597,\"instanceNumber\":1},{\"rank\":50,\"chips\":0.00,\"playerName\":\"Kiril911\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1871618,\"instanceNumber\":2},{\"rank\":51,\"chips\":0.00,\"playerName\":\"AvonTz\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1845369,\"instanceNumber\":2},{\"rank\":52,\"chips\":0.00,\"playerName\":\"whddudyoon\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1883851,\"instanceNumber\":1},{\"rank\":53,\"chips\":0.00,\"playerName\":\"Betelgeuse723\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1884166,\"instanceNumber\":1},{\"rank\":54,\"chips\":0.00,\"playerName\":\"fabioq65\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":102752,\"instanceNumber\":1},{\"rank\":55,\"chips\":0.00,\"playerName\":\"AlinM22\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":273015,\"instanceNumber\":1},{\"rank\":56,\"chips\":0.00,\"playerName\":\"DaveBaxterise\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1823258,\"instanceNumber\":1},{\"rank\":57,\"chips\":0.00,\"playerName\":\"Denzil\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":447137,\"instanceNumber\":1},{\"rank\":58,\"chips\":0.00,\"playerName\":\"Attack64pilot\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":533005,\"instanceNumber\":2},{\"rank\":59,\"chips\":0.00,\"playerName\":\"fishvera\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1817857,\"instanceNumber\":1},{\"rank\":60,\"chips\":0.00,\"playerName\":\"Amayzesm\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1685408,\"instanceNumber\":1},{\"rank\":61,\"chips\":0.00,\"playerName\":\"NoelPoker101\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":179135,\"instanceNumber\":1},{\"rank\":62,\"chips\":0.00,\"playerName\":\"3names\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":609443,\"instanceNumber\":1},{\"rank\":63,\"chips\":0.00,\"playerName\":\"MrsSpyair\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":710124,\"instanceNumber\":1},{\"rank\":64,\"chips\":0.00,\"playerName\":\"scoobyroo\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":424440,\"instanceNumber\":1},{\"rank\":65,\"chips\":0.00,\"playerName\":\"NoRegretsGG\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1845135,\"instanceNumber\":1},{\"rank\":66,\"chips\":0.00,\"playerName\":\"mmintel\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"us 2026-10-28 11:51:13:851 [info] [UNITY] Stdout: erId\":1671088,\"instanceNumber\":1},{\"rank\":67,\"chips\":0.00,\"playerName\":\"THEJC\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1671553,\"instanceNumber\":1},{\"rank\":68,\"chips\":0.00,\"playerName\":\"Lentils7\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":263390,\"instanceNumber\":1},{\"rank\":69,\"chips\":0.00,\"playerName\":\"Lxtti\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":357464,\"instanceNumber\":1},{\"rank\":70,\"chips\":0.00,\"playerName\":\"Freedoom8\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":502108,\"instanceNumber\":1},{\"rank\":71,\"chips\":0.00,\"playerName\":\"grouchy75285313\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1838383,\"instanceNumber\":2},{\"rank\":72,\"chips\":0.00,\"playerName\":\"BannedBro\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1538330,\"instanceNumber\":1},{\"rank\":73,\"chips\":0.00,\"playerName\":\"Zembe\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":549602,\"instanceNumber\":2},{\"rank\":74,\"chips\":0.00,\"playerName\":\"WildCardHandler\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1574455,\"instanceNumber\":2},{\"rank\":75,\"chips\":0.00,\"playerName\":\"welcome26686455\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1694331,\"instanceNumber\":1},{\"rank\":76,\"chips\":0.00,\"playerName\":\"texsasdolly\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1853172,\"instanceNumber\":1},{\"rank\":77,\"chips\":0.00,\"playerName\":\"nandibluffs\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":1654650,\"instanceNumber\":1},{\"rank\":78,\"chips\":0.00,\"playerName\":\"slave69\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":67132,\"instanceNumber\":1},{\"rank\":79,\"chips\":0.00,\"playerName\":\"thewizardofmarn\",\"location\":\"\",\"bounty\":0.0,\"tableId\":null,\"userId\":635393,\"instanceNumber\":1}],\"gameHandId\":null,\"initTimeStamp\":null}" +"EventName":"receive_from_tournament_lobby","RequestId":null,"Data":{"room_name":"Comm_Tournament_117632","request_id":"tournamentlobby.prize_list","data":"{\"prizeList\":[{\"rank\":1,\"prizePercent\":28.38000,\"amount\":27.76,\"coinTypeId\":1},{\"rank\":2,\"prizePercent\":18.68000,\"amount\":18.28,\"coinTypeId\":1},{\"rank\":3,\"prizePercent\":12.49000,\"amount\":12.22,\"coinTypeId\":1},{\"rank\":4,\"prizePercent\":8.56000,\"amount\":8.38,\"coinTypeId\":1},{\"rank\":5,\"prizePercent\":6.09000,\"amount\":5.96,\"coinTypeId\":1},{\"rank\":6,\"prizePercent\":4.55000,\"amount\":4.45,\"coinTypeId\":1},{\"rank\":7,\"prizePercent\":3.57000,\"amount\":3.49,\"coinTypeId\":1},{\"rank\":8,\"prizePercent\":2.95000,\"amount\":2.89,\"coinTypeId\":1},{\"rank\":9,\"prizePercent\":2.95000,\"amount\":2.89,\"coinTypeId\":1},{\"rank\":10,\"prizePercent\":2.53000,\"amount\":2.48,\"coinTypeId\":1},{\"rank\":11,\"prizePercent\":2.53000,\"amount\":2.48,\"coinTypeId\":1},{\"rank\":12,\"prizePercent\":2.24000,\"amount\":2.19,\"coinTypeId\":1},{\"rank\":13,\"prizePercent\":2.24000,\"amount\":2.19,\"coinTypeId\":1},{\"rank\":14,\"prizePercent\":2.24000,\"amount\":2.19,\"coinTypeId\":1}],\"gameHandId\":null,\"initTimeStamp\":null}" +"EventName":"receive_from_tournament_lobby","RequestId":null,"Data":{"room_name":"Comm_Tournament_117632","request_id":"tournamentlobby.dynamic_lobby_data","data":"{\"currentBlindLevel\":{\"tournamentLevel\":17,\"smallBlind\":800,\"bigBlind\":1600,\"ante\":200,\"timeBank\":0},\"nextBlindLevel\":{\"tournamentLevel\":18,\"smallBlind\":1000,\"bigBlind\":2000,\"ante\":250,\"timeBank\":0},\"nextLevelInSec\":174,\"remainingPlayerCount\":18,\"uniquePlayerCount\":79,\"reentryRebuyCount\":16,\"lateRegistrationEndingTimeStamp\":0,\"isLateRegistrationActive\":false,\"averageStack\":36944.45,\"largestStack\":162560.53,\"smallestStack\":3363.12,\"nextPayJumpAmount\":2.48,\"nextPayJumpRank\":11,\"nextPayJumpCoinTypeId\":1,\"topRanks\":[{\"userId\":1816483,\"avatarId\":1,\"rank\":1,\"playerName\":\"amanpoker\",\"chips\":162560.53,\"bounty\":false,\"location\":\"\",\"initTimeStamp\":1793184674989},{\"userId\":488150,\"avatarId\":1,\"rank\":2,\"playerName\":\"KleinCalvin\",\"chips\":69052.91,\"bounty\":false,\"location\":\"\",\"initTimeStamp\":1793184674989},{\"userId\":143942,\"avatarId\":2006,\"rank\":3,\"playerName\":\"timeGambler\",\"chips\":52380.58,\"bounty\":false,\"location\":\"\",\"initTimeStamp\":1793184674990},{\"userId\":1616671,\"avatarId\":7,\"rank\":4,\"playerName\":\"mortadella\",\"chips\":40381.6,\"bounty\":false,\"location\":\"\",\"initTimeStamp\":1793184674990},{\"userId\":380532,\"avatarId\":1,\"rank\":5,\"playerName\":\"Nick272727\",\"chips\":39263.68,\"bounty\":false,\"location\":\"\",\"initTimeStamp\":1793184674990}],\"firstPrizeAmount\":27.76,\"firstPrizeCoinTypeId\":1,\"nextPrizeAmount\":2.19,\"nextPrizeRank\":14,\"nextPrizeCoinTypeId\":1,\"totalPrizePool\":97.85,\"tournamentName\":\"₮1.10 6-Max Hyper\",\"paidPlaces\":14,\"isTourneyOnBreak\":false,\"tournamentStatus\":\"started\",\"startingStack\":7000.0,\"nextBreakInSeconds\":228,\"rebuyFinishLevel\":9,\"isBounty\":false,\"initTimeStamp\":1793094102762,\"nextBreakInTimestamp\":1793184900409,\"breakEndTimestamp\":0,\"nextblindupInTimestamp\":null,\"prizePoolAdjustmentAmount\":57.0,\"isTournamentPrizePoolOverlay\":false,\"bubbleProtectedPlaces\":1,\"isBubbleActive\":false,\"tournamentTypeId\":null,\"pauseResponseData\":null,\"multiDayFinalPayoutUpdated\":0,\"multiDayQualifierTarget\":0,\"mysteryBountyData\":{\"bountyAmountPool\":null,\"approxTopBountyAmount\":null,\"topBountyWinnerName\":null,\"topBountyGameId\":null,\"mysteryBountyDistribution\":null,\"totalBountyBoxes\":0,\"totalRemainingBoxes\":0},\"gameHandId\":null}" +"EventName":"receive_from_tournament_lobby","RequestId":null,"Data":{"room_name":"Comm_Tournament_117632","request_id":"tournamentlobby.user_dynamic_lobby_data","data":"{\"myRank\":66,\"remainingPlayerCount\":18,\"totalPlayerCount\":95,\"paidPlaces\":14,\"isUserBurstout\":true,\"playerName\":\"mmintel\",\"bountyAmount\":0.0,\"bountyCount\":0,\"isBubbleProtectionEligible\":false,\"gameHandId\":null,\"initTimeStamp\":\"1793184674989\"}" diff --git a/lesen/turnierlage.py b/lesen/turnierlage.py new file mode 100644 index 00000000..6266efb0 --- /dev/null +++ b/lesen/turnierlage.py @@ -0,0 +1,190 @@ +#!/usr/bin/env python3 +"""Die volle Turnierlage aus den Lobby-Raehmen - was der Client anzeigt, als Daten. + +`lesen/turnier.py` baut aus denselben Raehmen die Lage FUER DEN KERN (ICM: payouts + stacks, s. +`turnier.kern_feld`). Hier wird das ANGEZEIGTE drumherum lesbar, das der Client ohnehin pusht und +turnier.py nicht herausgibt: + + rangliste(text, raum=None) -> [{rang, name, kennung, stapel, bounty, tisch, instanz}] + stapel_je_spieler(text, raum) -> {kennung: groesster Stapel} (Wiedereinstiege zusammengefasst) + preise(text, raum=None) -> {plaetze, preise:{rang:{betrag, anteil, waehrung_id}}, waehrung_id} + lage(text, raum=None) -> {restspieler, bezahlte_plaetze, bubble_abstand, schnitt/gross/klein, + pool, overlay(Ja/Nein), naechster_sprung, blind(mit Zeitbank), ...} + icm_eingang(text, raum=None) -> {feld:[Stapel], payouts:[Betrag], blind} + +Die Raehmen kommen ueber `receive_from_tournament_lobby` (Relaisweg); das Lesen uebernimmt +`turnier.meldungen` unveraendert (dieselbe klammergerechte, entmaskierende Technik). Reihenfolge wie +im Auftrag: erst die Rangliste, dann die Payouts, dann die dynamische Lage mit dem Overlay. + +GRENZE (belegt am Bestand, nicht geraten): `tableId` ist in allen rank_list-Eintraegen des +Bestands `null` -> `tisch` ist None, nie geschaetzt. Einen eigenen `tournamentlobby.room_properties`- +Rahmen (volle Blindstruktur, Buy-in-Zerlegung, `isBubbleProtectionAllowed`) pusht die Turnier-Lobby +im Bestand NICHT (0 Treffer) - diese Felder fallen hier aus; die aktuelle Blindstufe samt Zeitbank +steht dagegen in `dynamic_lobby_data.currentBlindLevel` und wird gelesen. + +Rein: nur Text -> Daten, kein Netz, keine Datei. Spezifikation: tests/turnierlage_spec.py. +""" +import os +import sys + +_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) +_q = os.path.join(_w, "lesen") +if _q not in sys.path: + sys.path.insert(0, _q) + +import turnier # meldungen/ereignisse wiederverwenden (nur lesen, turnier.py bleibt unveraendert) + + +def _zahl(x): + """Eine echte Zahl (kein bool)? - der Pruefstein fuer die Zahlenfelder.""" + return x if isinstance(x, (int, float)) and not isinstance(x, bool) else None + + +def _stand(text, raum=None): + """{art: letzte Meldung} des gewaehlten Raums (art: dyn/user/preise/rang). + + `raum=None` nimmt den zuletzt im Text auftretenden Turnierraum - im Bestand gibt es genau einen. + """ + zustand, reihen = {}, [] + for r, art, d in turnier.ereignisse(text or ""): + if r not in zustand: + reihen.append(r) + zustand.setdefault(r, {})[art] = d + if raum is not None: + return zustand.get(raum, {}) + return zustand.get(reihen[-1], {}) if reihen else {} + + +def rangliste(text, raum=None): + """Die ganze Rangliste je Spieler aus dem letzten `rank_list`-Rahmen, nach Rang sortiert. + + Jeder Eintrag: Rang, Name, Kennung, Stapel (`chips`), Bounty, Tisch (`tableId`) und die + Instanznummer (Wiedereinstiege haben mehrere Eintraege). Fehlendes bleibt None, nie geraten.""" + rang = _stand(text, raum).get("rang") + if not isinstance(rang, dict): + return [] + aus = [] + for e in rang.get("rankList") or []: + if not isinstance(e, dict): + continue + kennung = _zahl(e.get("userId")) + aus.append({ + "rang": e.get("rank") if isinstance(e.get("rank"), int) else None, + "name": e.get("playerName"), + "kennung": str(int(kennung)) if kennung is not None else None, + "stapel": _zahl(e.get("chips")), + "bounty": _zahl(e.get("bounty")), + "tisch": e.get("tableId"), + "instanz": e.get("instanceNumber"), + }) + aus.sort(key=lambda x: (x["rang"] is None, x["rang"] if x["rang"] is not None else 0)) + return aus + + +def stapel_je_spieler(text, raum=None): + """{kennung-oder-Name: groesster Stapel} - Wiedereinstiege zusammengefasst. + + Schluessel ist die Kennung (`userId`), wo sie steht - im Bestand fehlt sie am eigenen Eintrag + (`mmintel`, userId null), dort faellt der Name ein, damit auch der eigene Stapel ins Feld kommt.""" + je = {} + for e in rangliste(text, raum): + k = e["kennung"] or e["name"] + s = e["stapel"] + if k is None or s is None: + continue + if k not in je or s > je[k]: + je[k] = s + return je + + +def preise(text, raum=None): + """Die Preisliste als eigene Tabelle aus dem letzten `prize_list`-Rahmen. + + -> {plaetze, preise:{rang:{betrag, anteil, waehrung_id}}, waehrung_id} - oder None ohne Rahmen. + `anteil` ist `prizePercent`/100 (auf 6 Stellen), `betrag` in Geld (nicht Chips).""" + pr = _stand(text, raum).get("preise") + liste = pr.get("prizeList") if isinstance(pr, dict) else None + if not isinstance(liste, list) or not liste: + return None + tabelle = {} + for p in liste: + if not isinstance(p, dict) or not isinstance(p.get("rank"), int): + continue + proz = _zahl(p.get("prizePercent")) + tabelle[p["rank"]] = {"betrag": _zahl(p.get("amount")), + "anteil": round(proz / 100.0, 6) if proz is not None else None, + "waehrung_id": p.get("coinTypeId")} + if not tabelle: + return None + return {"plaetze": len(tabelle), "preise": tabelle, "waehrung_id": liste[0].get("coinTypeId")} + + +def _blind(b): + """Eine Blindstufe mit Zeitbank - None, wenn der Rahmen sie nicht traegt.""" + if not isinstance(b, dict): + return None + return {"level": b.get("tournamentLevel"), "sb": b.get("smallBlind"), + "bb": b.get("bigBlind"), "ante": b.get("ante"), "zeitbank": b.get("timeBank")} + + +def lage(text, raum=None): + """Die dynamische Lage aus dem letzten `dynamic_lobby_data`-Rahmen - None ohne Rahmen. + + Traegt Restspieler, bezahlte Plaetze und den Bubble-Abstand, die Stapel-Kennzahlen, den Pool, + das Overlay als Ja/Nein (`isTournamentPrizePoolOverlay`), den naechsten Pay-Jump, die aktuelle + und naechste Blindstufe (mit Zeitbank) und ob es ein Bounty-Turnier ist.""" + st = _stand(text, raum) + dyn = st.get("dyn") + if not isinstance(dyn, dict): + return None + feld = _zahl(dyn.get("remainingPlayerCount")) + bezahlt = _zahl(dyn.get("paidPlaces")) + if bezahlt is None: + bezahlt = _zahl((st.get("user") or {}).get("paidPlaces")) + overlay = dyn.get("isTournamentPrizePoolOverlay") + bounty = dyn.get("isBounty") + aktiv = dyn.get("isBubbleActive") + return { + "restspieler": feld, + "bezahlte_plaetze": bezahlt, + "bubble_abstand": max(0, int(feld - bezahlt)) if feld is not None and bezahlt is not None else None, + "schnitt": _zahl(dyn.get("averageStack")), + "gross": _zahl(dyn.get("largestStack")), + "klein": _zahl(dyn.get("smallestStack")), + "pool": _zahl(dyn.get("totalPrizePool")), + "overlay": overlay if isinstance(overlay, bool) else None, + "naechster_sprung": {"platz": _zahl(dyn.get("nextPayJumpRank")), + "betrag": _zahl(dyn.get("nextPayJumpAmount")), + "waehrung_id": dyn.get("nextPayJumpCoinTypeId")}, + "blind": _blind(dyn.get("currentBlindLevel")), + "naechster_blind": _blind(dyn.get("nextBlindLevel")), + "bounty_turnier": bounty if isinstance(bounty, bool) else None, + "bubble": {"geschuetzt": _zahl(dyn.get("bubbleProtectedPlaces")), + "aktiv": aktiv if isinstance(aktiv, bool) else None}, + } + + +def icm_eingang(text, raum=None): + """Der ICM-Eingang aus den Lobby-Raehmen: Feld (ein Stapel je Spieler, groesster zuerst), + Payouts (Betrag nach Rang) und die aktuelle Blindstufe. None, wenn eine der drei Quellen fehlt. + + Anders als `turnier.kern_feld` nutzt das Feld die ganze Rangliste je Spieler (Wiedereinstiege + zusammengefasst) - die Bounty-Spalte steht in `rangliste` daneben fuer die Bounty-EV.""" + je = stapel_je_spieler(text, raum) + p = preise(text, raum) + lg = lage(text, raum) + if not je or not p or not lg: + return None + payouts = [p["preise"][r]["betrag"] for r in range(1, p["plaetze"] + 1) if r in p["preise"]] + return {"feld": sorted(je.values(), reverse=True), "payouts": payouts, "blind": lg["blind"]} + + +if __name__ == "__main__": + import gzip + import json + pfad = os.path.join(_w, "archiv", "mitschrieb", "main.6.log.gz") + text = gzip.open(pfad, "rt", encoding="utf-8", errors="replace").read() if os.path.exists(pfad) else "" + print(json.dumps({"rangliste_n": len(rangliste(text)), "preise": preise(text), + "lage": lage(text)}, indent=1, ensure_ascii=False)[:2000]) diff --git a/tests/turnierlage_spec.py b/tests/turnierlage_spec.py new file mode 100644 index 00000000..b60ac286 --- /dev/null +++ b/tests/turnierlage_spec.py @@ -0,0 +1,126 @@ +#!/usr/bin/env python3 +"""Spezifikation lesen/turnierlage.py - die volle Turnierlage aus den Lobby-Raehmen. + +`lesen/turnier.py` liest die Lage fuer den Kern (ICM: payouts + stacks). Hier wird das +ANGEZEIGTE drumherum lesbar, was der Client ohnehin pusht und turnier.py nicht herausgibt: +die ganze Rangliste je Spieler (Rang, Stapel, BOUNTY, tableId, Kennung), die Preisliste als +eigene Tabelle, und die dynamische Lage mit dem Overlay-Ja/Nein und dem naechsten Pay-Jump. + +Beleg WOERTLICH aus dem echten Log (archiv/mitschrieb/beispiele/turnierlage.txt): vier gepushte +`receive_from_tournament_lobby`-Raehmen des Turniers 117632 "Tâ,¬1.10 6-Max Hyper" (main.6.log.gz, +28.10.2026) - rank_list (79 Eintraege), prize_list (14 Plaetze), dynamic_lobby_data, +user_dynamic_lobby_data. Reine Rechnung, kein Netz. + + python3 tests/turnierlage_spec.py -v +""" +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) +sys.path.append(os.path.join(_w, "lesen")) +import turnierlage + +BELEG = os.path.join(_w, "archiv", "mitschrieb", "beispiele", "turnierlage.txt") +TEXT = open(BELEG, encoding="utf-8").read() +RAUM = "Comm_Tournament_117632" + + +class Rangliste(unittest.TestCase): + def test_alle_spieler_mit_rang_und_stapel(self): + rl = turnierlage.rangliste(TEXT) + self.assertEqual(len(rl), 79) + self.assertEqual(rl[0]["rang"], 1) + self.assertEqual(rl[0]["name"], "amanpoker") + self.assertEqual(rl[0]["stapel"], 162560.53) + self.assertEqual(rl[0]["kennung"], "1816483") + + def test_rangliste_ist_nach_rang_sortiert(self): + rl = turnierlage.rangliste(TEXT) + self.assertEqual([e["rang"] for e in rl], sorted(e["rang"] for e in rl)) + + def test_bounty_und_tisch_werden_gelesen(self): + rl = turnierlage.rangliste(TEXT) + self.assertIn("bounty", rl[0]) + self.assertEqual(rl[0]["bounty"], 0.0) + # tableId ist im ganzen Bestand null - das wird als None gelesen, nicht geraten. + self.assertIsNone(rl[0]["tisch"]) + + def test_fremder_text_leere_liste(self): + self.assertEqual(turnierlage.rangliste("nichts hier"), []) + + def test_raum_filtert(self): + self.assertEqual(turnierlage.rangliste(TEXT, raum="Comm_Tournament_999"), []) + self.assertEqual(len(turnierlage.rangliste(TEXT, raum=RAUM)), 79) + + def test_stapel_je_spieler_fasst_wiedereinstiege_zum_groessten(self): + # Kein Spieler mit mehrfachem Eintrag in diesem Beleg -> je Kennung genau ein Stapel, + # und die Summe der Felder entspricht der Rangliste. + je = turnierlage.stapel_je_spieler(TEXT) + self.assertEqual(len(je), 79) + self.assertEqual(je["1816483"], 162560.53) + + +class Preise(unittest.TestCase): + def test_preisliste_tabelle(self): + p = turnierlage.preise(TEXT) + self.assertEqual(p["plaetze"], 14) + self.assertEqual(p["preise"][1]["betrag"], 27.76) + self.assertAlmostEqual(p["preise"][1]["anteil"], 0.2838, places=4) + self.assertEqual(p["waehrung_id"], 1) + + def test_leer_ohne_preisrahmen(self): + self.assertIsNone(turnierlage.preise("nichts")) + + +class Lage(unittest.TestCase): + def test_dynamische_lage(self): + lg = turnierlage.lage(TEXT) + self.assertEqual(lg["restspieler"], 18) + self.assertEqual(lg["bezahlte_plaetze"], 14) + self.assertEqual(lg["bubble_abstand"], 4) # 18 - 14 + self.assertEqual(lg["pool"], 97.85) + + def test_overlay_als_ja_nein(self): + lg = turnierlage.lage(TEXT) + self.assertIs(lg["overlay"], False) # isTournamentPrizePoolOverlay + + def test_naechster_sprung(self): + lg = turnierlage.lage(TEXT) + self.assertEqual(lg["naechster_sprung"]["platz"], 11) + self.assertEqual(lg["naechster_sprung"]["betrag"], 2.48) + + def test_blindstufe_mit_zeitbank(self): + lg = turnierlage.lage(TEXT) + self.assertEqual(lg["blind"]["level"], 17) + self.assertEqual(lg["blind"]["bb"], 1600) + self.assertEqual(lg["blind"]["ante"], 200) + self.assertIn("zeitbank", lg["blind"]) # timeBank ist belegt (hier 0) + + def test_stapel_schnitt_gross_klein(self): + lg = turnierlage.lage(TEXT) + self.assertEqual(lg["schnitt"], 36944.45) + self.assertEqual(lg["gross"], 162560.53) + self.assertEqual(lg["klein"], 3363.12) + + def test_leer_ohne_dynamik(self): + self.assertIsNone(turnierlage.lage("nichts")) + + +class IcmEingang(unittest.TestCase): + def test_feld_payouts_blind(self): + icm = turnierlage.icm_eingang(TEXT) + self.assertEqual(len(icm["feld"]), 79) # ein Stapel je Spieler + self.assertEqual(icm["feld"][0], 162560.53) # groesster zuerst + self.assertEqual(len(icm["payouts"]), 14) + self.assertEqual(icm["payouts"][0], 27.76) + self.assertEqual(icm["blind"]["bb"], 1600) + + def test_none_wenn_etwas_fehlt(self): + self.assertIsNone(turnierlage.icm_eingang("nur text")) + + +if __name__ == "__main__": + unittest.main(verbosity=2)