44 lines
1.7 KiB
Python
44 lines
1.7 KiB
Python
"""Regeln eines Tisches aus `roomProperties` - was dieser Tisch anders macht als Standard.
|
|
|
|
Quelle der Namen: Client-Code (`archiv/echt/SPIELARTEN.md`, `CLIENT-LUECKEN.md`), Form aus dem
|
|
Log. Reine Funktion; Spezifikation: tests/funde_spec.py.
|
|
|
|
regeln(text) -> dict der Schalter, die gesetzt sind klartext(regeln) -> ein Satz
|
|
"""
|
|
import re
|
|
|
|
SCHALTER = {
|
|
"mustShow": ("must_show", "man muss aufdecken"),
|
|
"anonymous": ("anonymous", "Namen verdeckt"),
|
|
"noLimp": ("no_limp", "kein Limp erlaubt"),
|
|
"straddle": ("straddle", "Straddle moeglich"),
|
|
"antiBanking": ("anti_banking", "Anti-Banking mit Frist"),
|
|
"evCashout": ("ev_cashout", "EV-Auszahlung im All-in"),
|
|
"isEvChop": ("ev_chop", "EV-Chop moeglich"),
|
|
"splash": ("splash", "Splash-Pot"),
|
|
"bombPot": ("bomb_pot", "Bomb Pot"),
|
|
"kPoker": ("k_poker", "K-Poker-Menue"),
|
|
"isBombpotHand": ("bomb_pot_hand", "diese Hand ist ein Bomb Pot"),
|
|
"dynamicRakeBattleCap": ("dynamic_rake", "Rake-Cap haengt am Battle"),
|
|
}
|
|
|
|
|
|
def regeln(text):
|
|
t = (text or "").replace('\\"', '"')
|
|
raus = {}
|
|
for muster, (name, satz) in SCHALTER.items():
|
|
if re.search(rf'"{muster}"\s*:\s*(true|True|1)|"{muster}"\s*:\s*\{{', t):
|
|
raus[name] = satz
|
|
for muster, name in (("ante", "ante"), ("minPotPf", "min_pot_vorflop")):
|
|
m = re.search(rf'"{muster}"\s*:\s*([\d.]+)', t)
|
|
if m and float(m.group(1)) > 0:
|
|
raus[name] = float(m.group(1))
|
|
return raus
|
|
|
|
|
|
def klartext(r):
|
|
if not r: return "Standardtisch"
|
|
fest = [v for v in r.values() if isinstance(v, str)]
|
|
zahlen = [f"{k}={v:g}" for k, v in r.items() if isinstance(v, float)]
|
|
return " · ".join(fest + zahlen)
|