Files
pokerfreak/mac/Sources/CockpitKern/Modelle.swift
T
mmintelandClaude Fable 5.2 f827e4fcb9 Cockpit: ein Betriebszustand aus Fakten (kopf.betrieb), Karte und Sperren mit Grund in Swift und WinUI
Owner 01.12.: Starten/Stoppen und was dabei noch offen ist (Haende, Tische, Turniere,
Anmeldungen, Pause) war in beiden Apps mehrdeutig. Die Datenschicht leitet jetzt genau einen
Zustand ab (sicht/betriebszustand.py, rein): aus, aus_offen, startet, spielt, pausiert, stoppt,
not_aus, fehler - mit Satz, offenen Punkten, naechstem Schritt und je Aktion erlaubt/gesperrt
mit Grund. Beide Apps lesen den Block und ueberlagern nur Server weg, veraltet und den
optimistischen Not-Aus (Betrieb.swift, Betrieb.cs).

Dazu: Stoppweg (Windows: kein sanftes Signal fuer einen Laeufer, der nicht Kind des Servers
ist - Aufhoeren wird gesperrt statt still hart zu beenden, die Meldung sagt die Wahrheit),
Pause als Fakt des Servers, Puls alle 2 s gegen eingefrorene Anzeigen, WinUI schreibt die
Not-Aus-Dateien selbst. Am Laeufer aendert sich nichts.

Eine Falltabelle fuer alle drei Seiten: tests/fixtures/betriebszustand.json.
Python 33 Tests OK, Swift 249 Tests in 60 Suites OK. WinUI ist noch nicht gebaut (SDK fehlt
auf dem Windows-Rechner), siehe docs/notizen/UI-ZUSTAENDE.md.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 00:04:45 +01:00

775 lines
33 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import Foundation
// Die Bereiche der Ansicht, wie sicht/ANSICHT.md sie beschreibt. Alles ist nachsichtig dekodiert:
// fehlende Felder sind nil oder leer, nie ein Fehler - die Datenschicht darf wachsen.
public enum Bereich: String, CaseIterable, Sendable {
case kopf, jetzt, wachstum, entscheidungen, geld, sitzen, stil, ticker, zuschauer, trainer
}
public enum Ton: String, Sendable {
case rot, gelb, gruen, blau, grau
public init(farbe: String?) {
self = farbe.flatMap(Ton.init(rawValue:)) ?? .grau
}
}
public struct Status: Decodable, Equatable, Sendable {
public var zustand: String?
public var farbe: String?
public var satz: String?
public var ton: Ton { Ton(farbe: farbe) }
}
/// Die Sitzungsleiste (sicht/abgeleitet.py `sitzungsleiste`, Owner 14.11.: "oben direkt eine
/// Session-Uebersicht"): das Ergebnis der laufenden, sonst letzten Sitzung in Geld und BB, neun
/// Kennzahlen, Abstand zum Stop. Fertig gerechnet im Server - die App zeichnet nur (wie WinUI/Rust).
public struct Sitzungsleiste: Decodable, Equatable, Sendable {
public struct Zelle: Decodable, Equatable, Sendable {
public var titel = ""
public var wert = ""
/// Farbname des Servers: gruen, rot, orange, blau, grau, "" = Text.
public var ton = ""
enum CodingKeys: String, CodingKey { case titel, wert, ton }
public init(from d: Decoder) throws {
let c = try d.container(keyedBy: CodingKeys.self)
titel = c.text(.titel) ?? ""
wert = c.text(.wert) ?? "–"
ton = c.text(.ton) ?? ""
}
}
/// false: es gab noch keine Sitzung - dann zeigt die App nichts.
public var da = false
public var laeuft = false
public var titel = ""
public var geld = ""
public var bb = ""
public var ton = ""
public var zellen: [Zelle] = []
/// 0...1 verbrauchter Sitzungs-Stop; nil ohne Sitzungs-Stop.
public var stoppAnteil: Double?
public var stoppTon = ""
public var stoppText = ""
/// Hinweise (Haende erst ab ..., Ende: ...), leer ohne.
public var ende = ""
/// true: Kontostand und Handsumme weichen ab (oder Kontostand unbekannt) - `ende` erklaert es.
public var warn = false
enum CodingKeys: String, CodingKey {
case da, laeuft, titel, geld, bb, ton, zellen, stoppAnteil = "stopp_anteil", stoppTon = "stopp_ton"
case stoppText = "stopp_text", ende, warn
}
public init(from d: Decoder) throws {
let c = try d.container(keyedBy: CodingKeys.self)
da = c.wahr(.da)
laeuft = c.wahr(.laeuft)
titel = c.text(.titel) ?? ""
geld = c.text(.geld) ?? ""
bb = c.text(.bb) ?? ""
ton = c.text(.ton) ?? ""
zellen = c.objekte(.zellen)
stoppAnteil = c.zahl(.stoppAnteil)
stoppTon = c.text(.stoppTon) ?? ""
stoppText = c.text(.stoppText) ?? ""
ende = c.text(.ende) ?? ""
warn = c.wahr(.warn)
}
}
/// Eine eigene Turnieranmeldung (lesen/turnier_verwaltung.uebersicht) fuer die Cockpit-Uebersicht.
/// Der Server liefert die Zeilen fertig; die GUI zeigt nur und bietet "Abmelden" je Raum an.
public struct TurnierAnmeldung: Decodable, Equatable, Sendable, Identifiable {
public var raum: String
public var name: String?
public var status: String?
public var id: String { raum }
}
public struct Kopf: Decodable, Equatable, Sendable {
public var leer: String?
public var laeuft = false
/// Er laeuft noch, hat sein Ende aber gemeldet: Aufhoeren laeuft aus (tests/zwei_stopps_spec.py).
public var hoertAuf = false
public var text: String?
public var seit: Double?
public var zuletzt: Double?
public var laufzeitS: Double?
public var tische: [String] = []
public var tischeOffen: Int?
/// DIE Tisch-Obergrenze des Servers (lesen/geld.py HOECHSTENS_TISCHE, SSOT).
public var tischeHoechstens: Int?
public var tischeText: String?
public var modus: String?
public var modusQuelle: String?
public var klon = false
public var notAus = false
public var guthaben: Double?
public var pid: Int?
public var status: Status?
/// Laeuft der CoinPoker-Client? nil: unbekannt (Klon, aeltere Datenschicht).
public var client: Bool?
/// Laeuft der Client mit Debug-Port? false: Lobby-Steuerung (Tische oeffnen) geht nicht.
public var clientPort: Bool?
/// Wie der letzte Lauf endete (nil, solange er laeuft oder nie lief).
public var ende: Ende?
/// Der Spielplan, den der Laeufer liest (nil: keiner gesetzt).
public var spielplan: Spielplan?
/// Streamer-Modus: die Maus ist an (nil: aeltere Datenschicht).
public var maus: Bool?
/// Streamer-Modus: der virtuelle Zeiger ist an (nil: aeltere Datenschicht).
public var streamer: Bool?
public var phase: Phase?
/// Kontostatus des Raums: Betrugsverdacht, Sperre, Ruhezeit, Rake - was uns gefaehrlich wird.
public var konto: Konto?
/// Die eigenen Turnieranmeldungen (leer: keine). Fuer die Cockpit-Uebersicht + Abmelden-Knopf.
public var turnierAnmeldungen: [TurnierAnmeldung] = []
/// Die Sitzungsleiste ueber den Tischen (nil: aeltere Datenschicht).
public var sitzungsleiste: Sitzungsleiste?
/// Die Stufen je Modus ("cash", "uebung") mit dem Urteil des Servers (betrieb/stufenwahl.py).
public var stufen: [String: StufenStand] = [:]
/// Was der Laeufer gerade anstrebt (Turniere angemeldet, Cash wartet ...), fertig als Text.
public var warteschlange: [WarteEintrag] = []
/// Der Betriebszustand, wie der Server ihn ableitet (nil: aeltere Datenschicht) - gelesen von `Betrieb.bestimmen`.
public var betrieb: BetriebBlock?
/// Liegt die Pause-Datei? (nil: aeltere Datenschicht - dann weiss es nur die App selbst)
public var pausiert: Bool?
enum CodingKeys: String, CodingKey {
case leer, laeuft, hoertAuf = "hoert_auf", text, seit, zuletzt, laufzeitS = "laufzeit_s", tische, tischeOffen = "tische_offen"
case tischeHoechstens = "tische_hoechstens"
case tischeText = "tische_text", modus, modusQuelle = "modus_quelle", klon, notAus = "not_aus"
case guthaben, pid, status, client, ende, spielplan, maus, streamer, phase, clientPort = "client_port", konto
case turnierAnmeldungen = "turnier_anmeldungen", sitzungsleiste, stufen, warteschlange, betrieb, pausiert
}
public init(from d: Decoder) throws {
let c = try d.container(keyedBy: CodingKeys.self)
leer = c.text(.leer)
laeuft = c.wahr(.laeuft)
hoertAuf = c.wahr(.hoertAuf)
text = c.text(.text)
seit = c.zahl(.seit)
zuletzt = c.zahl(.zuletzt)
laufzeitS = c.zahl(.laufzeitS)
tische = c.liste(.tische)
tischeOffen = c.zahl(.tischeOffen).map { Int($0) }
tischeHoechstens = c.zahl(.tischeHoechstens).map { Int($0) }
tischeText = c.text(.tischeText)
modus = c.text(.modus)
modusQuelle = c.text(.modusQuelle)
klon = c.wahr(.klon)
notAus = c.wahr(.notAus)
guthaben = c.zahl(.guthaben)
pid = c.zahl(.pid).map { Int($0) }
status = try? c.decodeIfPresent(Status.self, forKey: .status)
client = (try? c.decodeIfPresent(Bool.self, forKey: .client)) ?? nil
clientPort = (try? c.decodeIfPresent(Bool.self, forKey: .clientPort)) ?? nil
ende = try? c.decodeIfPresent(Ende.self, forKey: .ende)
spielplan = (try? c.decodeIfPresent(Spielplan.self, forKey: .spielplan)) ?? nil
maus = (try? c.decodeIfPresent(Bool.self, forKey: .maus)) ?? nil
streamer = (try? c.decodeIfPresent(Bool.self, forKey: .streamer)) ?? nil
phase = (try? c.decodeIfPresent(Phase.self, forKey: .phase)) ?? nil
konto = (try? c.decodeIfPresent(Konto.self, forKey: .konto)) ?? nil
turnierAnmeldungen = (try? c.decodeIfPresent([TurnierAnmeldung].self, forKey: .turnierAnmeldungen)) ?? []
sitzungsleiste = (try? c.decodeIfPresent(Sitzungsleiste.self, forKey: .sitzungsleiste)) ?? nil
stufen = ((try? c.decodeIfPresent([String: StufenStand].self, forKey: .stufen)) ?? nil) ?? [:]
warteschlange = c.objekte(.warteschlange)
betrieb = (try? c.decodeIfPresent(BetriebBlock.self, forKey: .betrieb)) ?? nil
pausiert = (try? c.decodeIfPresent(Bool.self, forKey: .pausiert)) ?? nil
}
}
/// `kopf.stufen.<modus>`: jede waehlbare Stufe mit dem Urteil (geht/nicht), ohne Wahl der Satz der Automatik.
public struct StufenStand: Decodable, Equatable, Sendable {
public struct Turnier: Decodable, Equatable, Sendable {
public var zeile = ""
public var stand = ""
public var grund = ""
enum CodingKeys: String, CodingKey { case zeile, stand, grund }
public init(from d: Decoder) throws {
let c = try d.container(keyedBy: CodingKeys.self)
zeile = c.text(.zeile) ?? ""; stand = c.text(.stand) ?? ""; grund = c.text(.grund) ?? ""
}
}
public var stufen: [StufeInfo] = []
public var auto = ""
public var turnier: Turnier?
enum CodingKeys: String, CodingKey { case stufen, auto, turnier }
public init(from d: Decoder) throws {
let c = try d.container(keyedBy: CodingKeys.self)
stufen = c.objekte(.stufen); auto = c.text(.auto) ?? ""
turnier = try? c.decodeIfPresent(Turnier.self, forKey: .turnier)
}
public func info(_ bb: Double) -> StufeInfo? { stufen.first { $0.bb == bb } }
}
/// Eine Stufe: Big Blind (> 0 Cash; -1 Freeroll bis -4 Turnier-Buy-ins), Name, Text, Urteil, Lobby-Zahlen.
/// Auch fuer den Sammler (dort mit `an`, `rang`, `haende`).
public struct StufeInfo: Decodable, Equatable, Sendable, Identifiable {
public var bb = 0.0
public var name = ""
public var text = ""
/// nil: kein Urteil (Uebung); false: die Reserve traegt sie nicht (rot), geht nicht.
public var geht: Bool?
/// Ampel der Bankroll-Regel (Owner 01.12., betrieb/stufenwahl.ampel): "gruen" Empfehlung erfuellt, "gelb" spielbar unter
/// der Empfehlung (30/35 Buy-ins), "rot" die Reserve traegt sie nicht; nil ohne Urteil.
public var ampel: String?
public var offen = 0
public var sitzt = 0
public var an = false
public var rang = 0
public var haende = 0
public var id: Double { bb }
public var turnier: Bool { bb <= 0 }
public init(bb: Double, name: String) { self.bb = bb; self.name = name }
enum CodingKeys: String, CodingKey { case bb, name, text, geht, ampel, offen, sitzt, an, rang, haende }
public init(from d: Decoder) throws {
let c = try d.container(keyedBy: CodingKeys.self)
bb = c.zahl(.bb) ?? 0; name = c.text(.name) ?? Format.roh(bb); text = c.text(.text) ?? ""
geht = (try? c.decodeIfPresent(Bool.self, forKey: .geht)) ?? nil
ampel = c.text(.ampel)
offen = c.zahl(.offen).map { Int($0) } ?? 0; sitzt = c.zahl(.sitzt).map { Int($0) } ?? 0
an = c.wahr(.an); rang = c.zahl(.rang).map { Int($0) } ?? 0; haende = c.zahl(.haende).map { Int($0) } ?? 0
}
}
/// Ein Eintrag der Warteschlange (`kopf.warteschlange`): Text, Turnier?, Art (spielt|angemeldet|wartet|aus|...).
public struct WarteEintrag: Decodable, Equatable, Sendable {
public var text = ""
public var turnier = false
public var art = ""
enum CodingKeys: String, CodingKey { case text, turnier, art }
public init(from d: Decoder) throws {
let c = try d.container(keyedBy: CodingKeys.self)
text = c.text(.text) ?? ""; turnier = c.wahr(.turnier); art = c.text(.art) ?? ""
}
}
/// Konto- und Raumstatus (hand/fraud.py, lesen/vorteile.py, lesen/rake.py). Die Zeilen kommen
/// fertig vom Server - die GUI rechnet nichts nach, sie zeigt nur.
public struct Konto: Decodable, Equatable, Sendable {
public var status: String?
public var felder: [String] = []
public var warn = false
public var verdacht: Bool?
public var gesperrt: Bool?
/// Diese Tische laufen gerade in der Ruhezeit des Raums - kein neuer Tisch.
public var schwarzJetzt = false
public var schwarzeStunden: [Int] = []
/// Nur was gerade gefaehrlich ist: das gehoert in die Kopfzeile, der Rest in die Konto-Karte.
public var alarme: [String] {
felder.filter { $0.hasPrefix("Verdacht: ja") || $0.hasPrefix("Gesperrt: ja") || $0.contains("(JETZT)") }
}
enum CodingKeys: String, CodingKey {
case status, felder, warn, verdacht, gesperrt
case schwarzJetzt = "schwarz_jetzt", schwarzeStunden = "schwarze_stunden"
}
public init(from d: Decoder) throws {
let c = try d.container(keyedBy: CodingKeys.self)
status = c.text(.status)
felder = c.liste(.felder)
warn = c.wahr(.warn)
verdacht = (try? c.decodeIfPresent(Bool.self, forKey: .verdacht)) ?? nil
gesperrt = (try? c.decodeIfPresent(Bool.self, forKey: .gesperrt)) ?? nil
schwarzJetzt = c.wahr(.schwarzJetzt)
schwarzeStunden = c.liste(.schwarzeStunden).compactMap(Int.init)
}
}
public struct Ende: Decodable, Equatable, Sendable {
public var zeit: Double?
public var abbruch = false
public var grund: String?
enum CodingKeys: String, CodingKey { case zeit, abbruch, grund }
public init(from d: Decoder) throws {
let c = try d.container(keyedBy: CodingKeys.self)
zeit = c.zahl(.zeit); abbruch = c.wahr(.abbruch); grund = c.text(.grund)
}
}
public struct Zug: Decodable, Equatable, Sendable {
public var offen = false
public var fristS: Double?
public var bis: Double?
public var seit: Double?
public init(offen: Bool, fristS: Double?, bis: Double?, seit: Double?) {
self.offen = offen; self.fristS = fristS; self.bis = bis; self.seit = seit
}
enum CodingKeys: String, CodingKey { case offen, fristS = "frist_s", bis, seit }
public init(from d: Decoder) throws {
let c = try d.container(keyedBy: CodingKeys.self)
offen = c.wahr(.offen); fristS = c.zahl(.fristS); bis = c.zahl(.bis); seit = c.zahl(.seit)
}
}
public struct Entscheidung: Decodable, Equatable, Sendable {
public var aktion: String?
public var aktionText: String?
public var betrag: Double?
public var betragBB: Double?
public var grund: String?
public var klartext: String?
public var equity: Double?
public var confidence: Double?
public var gedenkzeitS: Double?
public var zeit: Double?
enum CodingKeys: String, CodingKey {
case aktion, aktionText = "aktion_text", betrag, betragBB = "betrag_bb", grund, klartext, equity
case confidence, gedenkzeitS = "gedenkzeit_s", zeit
}
public init(from d: Decoder) throws {
let c = try d.container(keyedBy: CodingKeys.self)
aktion = c.text(.aktion); aktionText = c.text(.aktionText); betrag = c.zahl(.betrag)
betragBB = c.zahl(.betragBB); grund = c.text(.grund); klartext = c.text(.klartext)
equity = c.zahl(.equity); confidence = c.zahl(.confidence); gedenkzeitS = c.zahl(.gedenkzeitS)
zeit = c.zahl(.zeit)
}
}
public struct Klick: Decodable, Equatable, Sendable {
public var status: String?
public var warum: String?
public var beleg: String?
public init(status: String?, warum: String?, beleg: String?) {
self.status = status; self.warum = warum; self.beleg = beleg
}
}
public struct Jetzt: Decodable, Equatable, Sendable {
public var leer: String?
public var raum: String?
public var hand: String?
public var strasse: String?
public var karten: [String] = []
public var board: [String] = []
public var topf: Double?
public var zuZahlen: Double?
public var stack: Double?
public var zug: Zug?
public var entscheidung: Entscheidung?
public var klick: Klick?
public var modus: TischModus?
enum CodingKeys: String, CodingKey {
case leer, raum, hand, strasse, karten, board, topf, zuZahlen = "zu_zahlen", stack, zug, entscheidung, klick, modus
}
public init(from d: Decoder) throws {
let c = try d.container(keyedBy: CodingKeys.self)
leer = c.text(.leer); raum = c.text(.raum); hand = c.text(.hand); strasse = c.text(.strasse)
karten = c.liste(.karten); board = c.liste(.board); topf = c.zahl(.topf); zuZahlen = c.zahl(.zuZahlen)
stack = c.zahl(.stack)
zug = try? c.decodeIfPresent(Zug.self, forKey: .zug)
entscheidung = try? c.decodeIfPresent(Entscheidung.self, forKey: .entscheidung)
klick = try? c.decodeIfPresent(Klick.self, forKey: .klick)
modus = try? c.decodeIfPresent(TischModus.self, forKey: .modus)
}
}
public struct EntscheidungsZeile: Decodable, Equatable, Sendable, Identifiable {
public var zeit: Double?
public var raum: String?
public var hand: String?
public var strasse: String?
public var karten: [String]
public var board: [String]
public var aktion: String?
public var aktionText: String?
public var betragBB: Double?
public var grund: String?
public var klartext: String?
public var equity: Double?
public var confidence: Double?
public var stake: String?
public var spielart: String?
public var ergebnisBB: Double?
public var ergebnisText: String?
public var klick: String?
public var klickWarum: String?
public var beleg: String?
public var gedenkzeitS: Double?
public var modus: TischModus?
public var id: String { "\(zeit ?? 0)|\(hand ?? "")|\(raum ?? "")|\(aktion ?? "")" }
public init(zeit: Double?, raum: String?, hand: String?, strasse: String?, karten: [String], board: [String],
aktion: String?, aktionText: String?, betragBB: Double?, grund: String?, klartext: String?,
equity: Double?, confidence: Double?, stake: String?, spielart: String?, ergebnisBB: Double?,
ergebnisText: String?, klick: String?, klickWarum: String?, beleg: String?, gedenkzeitS: Double?) {
self.zeit = zeit; self.raum = raum; self.hand = hand; self.strasse = strasse; self.karten = karten
self.board = board; self.aktion = aktion; self.aktionText = aktionText; self.betragBB = betragBB
self.grund = grund; self.klartext = klartext; self.equity = equity; self.confidence = confidence
self.stake = stake; self.spielart = spielart; self.ergebnisBB = ergebnisBB; self.ergebnisText = ergebnisText
self.klick = klick; self.klickWarum = klickWarum; self.beleg = beleg; self.gedenkzeitS = gedenkzeitS
}
enum CodingKeys: String, CodingKey {
case zeit, raum, hand, strasse, karten, board, aktion, aktionText = "aktion_text", betragBB = "betrag_bb"
case grund, klartext, equity, confidence, stake, spielart, ergebnisBB = "ergebnis_bb"
case ergebnisText = "ergebnis_text", klick, klickWarum = "klick_warum", beleg, gedenkzeitS = "gedenkzeit_s", modus
}
public init(from d: Decoder) throws {
let c = try d.container(keyedBy: CodingKeys.self)
self.init(zeit: c.zahl(.zeit), raum: c.text(.raum), hand: c.text(.hand), strasse: c.text(.strasse),
karten: c.liste(.karten), board: c.liste(.board), aktion: c.text(.aktion),
aktionText: c.text(.aktionText), betragBB: c.zahl(.betragBB), grund: c.text(.grund),
klartext: c.text(.klartext), equity: c.zahl(.equity), confidence: c.zahl(.confidence),
stake: c.text(.stake), spielart: c.text(.spielart), ergebnisBB: c.zahl(.ergebnisBB),
ergebnisText: c.text(.ergebnisText), klick: c.text(.klick), klickWarum: c.text(.klickWarum),
beleg: c.text(.beleg), gedenkzeitS: c.zahl(.gedenkzeitS))
modus = try? c.decodeIfPresent(TischModus.self, forKey: .modus)
}
}
public struct Facetten: Decodable, Equatable, Sendable {
public var aktion: [String] = []
public var stake: [String] = []
public var spielart: [String] = []
public var ergebnis: [String] = []
enum CodingKeys: String, CodingKey { case aktion, stake, spielart, ergebnis }
public init(from d: Decoder) throws {
let c = try d.container(keyedBy: CodingKeys.self)
aktion = c.liste(.aktion); stake = c.liste(.stake); spielart = c.liste(.spielart); ergebnis = c.liste(.ergebnis)
}
}
public struct Entscheidungen: Decodable, Equatable, Sendable {
public var leer: String?
public var zeilen: [EntscheidungsZeile] = []
public var facetten: Facetten?
public var gesamt: Int?
public var angezeigt: Int?
public var gekappt = false
public var ausschnitt = false
public var hinweis: String?
/// "Gerade eben", fertig in Bloecken (sicht/abgeleitet.feed).
public var feed: [FeedBlock] = []
enum CodingKeys: String, CodingKey { case leer, zeilen, facetten, gesamt, angezeigt, gekappt, ausschnitt, hinweis, feed }
public init(from d: Decoder) throws {
let c = try d.container(keyedBy: CodingKeys.self)
leer = c.text(.leer); zeilen = c.objekte(.zeilen)
facetten = try? c.decodeIfPresent(Facetten.self, forKey: .facetten)
gesamt = c.zahl(.gesamt).map { Int($0) }; angezeigt = c.zahl(.angezeigt).map { Int($0) }
gekappt = c.wahr(.gekappt); ausschnitt = c.wahr(.ausschnitt); hinweis = c.text(.hinweis)
feed = c.objekte(.feed)
}
}
public struct GeldZeile: Decodable, Equatable, Sendable, Identifiable {
public var zeit: Double?
public var raum: String?
public var art: String?
public var betrag: Double?
public var betragBB: Double?
public var grund: String?
public var uebung: Bool?
public var id: String { "\(zeit ?? 0)|\(raum ?? "")|\(art ?? "")|\(grund ?? "")" }
enum CodingKeys: String, CodingKey { case zeit, raum, art, betrag, betragBB = "betrag_bb", grund, uebung }
public init(from d: Decoder) throws {
let c = try d.container(keyedBy: CodingKeys.self)
zeit = c.zahl(.zeit); raum = c.text(.raum); art = c.text(.art); betrag = c.zahl(.betrag)
betragBB = c.zahl(.betragBB); grund = c.text(.grund); uebung = try? c.decodeIfPresent(Bool.self, forKey: .uebung)
}
}
public struct Geld: Decodable, Equatable, Sendable {
public var leer: String?
public var zeilen: [GeldZeile] = []
public var uebung = false
public var regeln: GeldRegeln?
public var stand: GeldStand?
/// Ergebnis, Rake, Rakeback und netto in einer Zeile - brutto ist keine Zahl, auf die man spielt.
public var netto: String?
/// Persistenter Verlustdeckel (O4); hier nur Sperre, Satz und der Halteknopf zum Zuruecksetzen.
public var deckel: GeldDeckel?
/// Sitzung und Tische gegen die Stops, fertig (sicht/abgeleitet.geld_anzeige).
public var anzeige: GeldAnzeige?
enum CodingKeys: String, CodingKey { case leer, zeilen, uebung, regeln, stand, netto, deckel, anzeige }
public init(from d: Decoder) throws {
let c = try d.container(keyedBy: CodingKeys.self)
leer = c.text(.leer); zeilen = c.objekte(.zeilen); uebung = c.wahr(.uebung)
regeln = try? c.decodeIfPresent(GeldRegeln.self, forKey: .regeln)
stand = try? c.decodeIfPresent(GeldStand.self, forKey: .stand)
netto = c.text(.netto)
deckel = try? c.decodeIfPresent(GeldDeckel.self, forKey: .deckel)
anzeige = try? c.decodeIfPresent(GeldAnzeige.self, forKey: .anzeige)
}
}
/// Der Verlustdeckel aus sicht/ansicht.deckel_: gesperrt, Satz und - nur bei einer Sitzungs- oder
/// Tagessperre - was der Halteknopf zuruecksetzt (Owner 16.11.).
public struct GeldDeckel: Decodable, Equatable, Sendable {
public var gesperrt = false
public var satz: String?
public var zuruecksetzen: DeckelZurueck?
/// Sitzungs- und Tagesdeckel zum Einstellen (Owner 17.11.), fertig mit Optionen und Empfehlung.
public var einstellen: [DeckelStufe] = []
/// Je Deckel (Sitzung, Tag, Stufe) Verbrauch und Farbe; die ersten zwei gehoeren zu `einstellen`.
public var kacheln: [DeckelKachel] = []
enum CodingKeys: String, CodingKey { case gesperrt, satz, zuruecksetzen, einstellen, kacheln }
public init(from d: Decoder) throws {
let c = try d.container(keyedBy: CodingKeys.self)
gesperrt = c.wahr(.gesperrt)
satz = c.text(.satz)
zuruecksetzen = try? c.decodeIfPresent(DeckelZurueck.self, forKey: .zuruecksetzen)
einstellen = c.objekte(.einstellen); kacheln = c.objekte(.kacheln)
}
}
/// Ein einstellbarer Verlustdeckel: `was` (sitzung|tag) fuer `deckel_einstellen`, die Stufen als Optionen.
public struct DeckelStufe: Decodable, Equatable, Sendable, Identifiable {
public struct Option: Decodable, Equatable, Sendable {
public var text = ""
public var bb = 0.0
public var empfohlen = false
public var gewaehlt = false
enum CodingKeys: String, CodingKey { case text, bb, empfohlen, gewaehlt }
public init(from d: Decoder) throws {
let c = try d.container(keyedBy: CodingKeys.self)
text = c.text(.text) ?? ""; bb = c.zahl(.bb) ?? 0; empfohlen = c.wahr(.empfohlen); gewaehlt = c.wahr(.gewaehlt)
}
}
public var was = ""
public var name = ""
public var bb = 0.0
public var optionen: [Option] = []
public var empfohlenBB: Double?
public var empfehlung = ""
public var id: String { was }
enum CodingKeys: String, CodingKey { case was, name, bb, optionen, empfohlenBB = "empfohlen_bb", empfehlung }
public init(from d: Decoder) throws {
let c = try d.container(keyedBy: CodingKeys.self)
was = c.text(.was) ?? ""; name = c.text(.name) ?? was; bb = c.zahl(.bb) ?? 0
optionen = c.objekte(.optionen); empfohlenBB = c.zahl(.empfohlenBB); empfehlung = c.text(.empfehlung) ?? ""
}
}
public struct DeckelKachel: Decodable, Equatable, Sendable {
/// Ergebnis gegen den Deckel (negativ = Verlust).
public var bb = 0.0
public var anteil = 0.0
public var ton = ""
enum CodingKeys: String, CodingKey { case bb, anteil, ton }
public init(from d: Decoder) throws {
let c = try d.container(keyedBy: CodingKeys.self)
bb = c.zahl(.bb) ?? 0; anteil = c.zahl(.anteil) ?? 0; ton = c.text(.ton) ?? ""
}
}
public struct DeckelZurueck: Decodable, Equatable, Sendable {
public var was: String
public var text: String?
public var hinweis: String?
}
public struct Handlung: Decodable, Equatable, Sendable {
public var art: String?
public var grund: String?
public var zeit: Double?
enum CodingKeys: String, CodingKey { case art, grund, zeit }
public init(from d: Decoder) throws {
let c = try d.container(keyedBy: CodingKeys.self)
art = c.text(.art); grund = c.text(.grund); zeit = c.zahl(.zeit)
}
}
public struct Raum: Decodable, Equatable, Sendable, Identifiable {
public var raum: String
/// Der Name wie im Spiel ("NLH 1676973 - 1K/2K") - `raum` ist die interne Kennung.
public var titel: String?
public var zustand: String?
public var platz: String?
public var stack: Double?
public var groesse: Int?
public var bb: String?
public var modus: String?
public var handlung: Handlung?
public var fenster: Int?
/// Profit/Verlust an diesem Tisch (Summe der Hand-Nettos, sicht/ansicht._netto_je_raum): Chips,
/// BB und die Zahl der gewerteten Hände. Nil, solange keine Hand gewertet ist.
public var netto: Double?
public var nettoBB: Double?
public var nettoHaende: Int?
/// Die laufende Hand aus dem Client-Log (sicht/ansicht._haende_im_log) - auch ohne Läufer.
public var hand: LogHand?
/// Alle Plätze mit Namen, Stack, Rolle, Aktion und Gegnerwerten (sicht/ansicht._tisch_ansicht).
public var tisch: TischAnsicht?
public var id: String { raum }
public struct LogHand: Decodable, Equatable, Sendable {
public var hand: String?
public var karten: [String] = []
public var board: [String] = []
public var topf: Double?
enum CodingKeys: String, CodingKey { case hand, karten, board, topf }
public init(from d: Decoder) throws {
let c = try d.container(keyedBy: CodingKeys.self)
hand = c.text(.hand); karten = c.liste(.karten); board = c.liste(.board); topf = c.zahl(.topf)
}
}
enum CodingKeys: String, CodingKey {
case raum, titel, zustand, platz, stack, groesse, bb, modus, handlung, fenster, hand, tisch
case netto, nettoBB = "netto_bb", nettoHaende = "netto_haende"
}
public init(from d: Decoder) throws {
let c = try d.container(keyedBy: CodingKeys.self)
raum = c.text(.raum) ?? "?"; titel = c.text(.titel); zustand = c.text(.zustand); platz = c.text(.platz); stack = c.zahl(.stack)
groesse = c.zahl(.groesse).map { Int($0) }; bb = c.text(.bb); modus = c.text(.modus)
handlung = try? c.decodeIfPresent(Handlung.self, forKey: .handlung); fenster = c.zahl(.fenster).map { Int($0) }
netto = c.zahl(.netto); nettoBB = c.zahl(.nettoBB); nettoHaende = c.zahl(.nettoHaende).map { Int($0) }
hand = (try? c.decodeIfPresent(LogHand.self, forKey: .hand)) ?? nil
tisch = (try? c.decodeIfPresent(TischAnsicht.self, forKey: .tisch)) ?? nil
}
}
public struct Sitzen: Decodable, Equatable, Sendable {
public struct Fenster: Decodable, Equatable, Sendable {
public var zahl: Int?
public var ueberzaehlig: [String] = []
enum CodingKeys: String, CodingKey { case zahl, ueberzaehlig }
public init(from d: Decoder) throws {
let c = try d.container(keyedBy: CodingKeys.self)
zahl = c.zahl(.zahl).map { Int($0) }; ueberzaehlig = c.liste(.ueberzaehlig)
}
}
public var leer: String?
public var raeume: [Raum] = []
public var fenster: Fenster?
/// Fertig gerechnet (sicht/abgeleitet.live): Chips, Kacheln, Bereit, Suche.
public var live: LiveTische?
enum CodingKeys: String, CodingKey { case leer, raeume, fenster, live }
public init(from d: Decoder) throws {
let c = try d.container(keyedBy: CodingKeys.self)
leer = c.text(.leer); raeume = c.objekte(.raeume); fenster = try? c.decodeIfPresent(Fenster.self, forKey: .fenster)
live = try? c.decodeIfPresent(LiveTische.self, forKey: .live)
}
}
public struct Anteile: Decodable, Equatable, Sendable {
public var t: Double?
public var fold = 0.0, check = 0.0, call = 0.0, raise = 0.0, allin = 0.0
public var n: Int?
enum CodingKeys: String, CodingKey { case t, fold, check, call, raise, allin, n }
public init(from d: Decoder) throws {
let c = try d.container(keyedBy: CodingKeys.self)
t = c.zahl(.t); fold = c.zahl(.fold) ?? 0; check = c.zahl(.check) ?? 0; call = c.zahl(.call) ?? 0
raise = c.zahl(.raise) ?? 0; allin = c.zahl(.allin) ?? 0; n = c.zahl(.n).map { Int($0) }
}
}
public struct Stil: Decodable, Equatable, Sendable {
public struct Groesse: Decodable, Equatable, Sendable {
public var betragBB: Double?
public var topfAnteil: Double?
enum CodingKeys: String, CodingKey { case betragBB = "betrag_bb", topfAnteil = "topf_anteil" }
public init(from d: Decoder) throws {
let c = try d.container(keyedBy: CodingKeys.self)
betragBB = c.zahl(.betragBB); topfAnteil = c.zahl(.topfAnteil)
}
}
public struct Denkzeit: Decodable, Equatable, Sendable {
public var median: Double?
public var streuung: Double?
public var vk: Double?
public var n: Int?
enum CodingKeys: String, CodingKey { case median, streuung, vk, n }
public init(from d: Decoder) throws {
let c = try d.container(keyedBy: CodingKeys.self)
median = c.zahl(.median); streuung = c.zahl(.streuung); vk = c.zahl(.vk); n = c.zahl(.n).map { Int($0) }
}
}
public var leer: String?
public var verlauf: [Anteile] = []
public var groessen: [Groesse] = []
public var denkzeiten: [Double] = []
public var denkzeit: Denkzeit?
public var anteile: Anteile?
enum CodingKeys: String, CodingKey { case leer, verlauf, groessen, denkzeiten, denkzeit, anteile }
private struct S: Decodable { var s: Double? }
public init(from d: Decoder) throws {
let c = try d.container(keyedBy: CodingKeys.self)
leer = c.text(.leer); verlauf = c.objekte(.verlauf); groessen = c.objekte(.groessen)
denkzeiten = (c.objekte(.denkzeiten) as [S]).compactMap(\.s)
denkzeit = try? c.decodeIfPresent(Denkzeit.self, forKey: .denkzeit)
anteile = try? c.decodeIfPresent(Anteile.self, forKey: .anteile)
}
}
public struct TickerZeile: Decodable, Equatable, Sendable, Identifiable {
public var zeit: Double?
public var art: String?
public var raum: String?
public var text: String?
public var id: String { "\(zeit ?? 0)|\(art ?? "")|\(raum ?? "")|\(text ?? "")" }
enum CodingKeys: String, CodingKey { case zeit, art, raum, text }
public init(from d: Decoder) throws {
let c = try d.container(keyedBy: CodingKeys.self)
zeit = c.zahl(.zeit); art = c.text(.art); raum = c.text(.raum); text = c.text(.text)
}
}
public struct Ticker: Decodable, Equatable, Sendable {
public var leer: String?
public var zeilen: [TickerZeile] = []
public var gedanken: [String] = []
enum CodingKeys: String, CodingKey { case leer, zeilen, gedanken }
public init(from d: Decoder) throws {
let c = try d.container(keyedBy: CodingKeys.self)
leer = c.text(.leer); zeilen = c.objekte(.zeilen); gedanken = c.liste(.gedanken)
}
}