Files
pokerfreak/mac/Sources/CockpitKern/Modelle.swift
T
mmintelandClaude Opus 5.5 064f80de50 Swift/Rust-Cockpit gleichgezogen: Sitzungsleiste, Micro-only-Budget aus, --nur-spiel, Mac-Tischraum (Spaces)
- Rust: cockpit/src/umfang.rs (--nur-spiel / POKERFREAK_NUR_SPIEL): ohne Zuschauer und leere Sonderformate
- Swift: Sitzungsleiste aus dem Server, Budget aus bei Micro-only, Umfang.nurSpiel blendet Zuschauer,
  Sonderformate, Maus, Lehrer und Klon aus
- Mac: Tischraum - Tisch-App und Cockpit per app-bindings auf den letzten Schreibtisch, Panel dockt
  dann nur dort an (Gegenstueck zum Windows-Tisch-Desktop). Auf Windows geschrieben, ungeprueft.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 12:27:52 +01:00

597 lines
25 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
}
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 = ""
enum CodingKeys: String, CodingKey {
case da, laeuft, titel, geld, bb, ton, zellen, stoppAnteil = "stopp_anteil", stoppTon = "stopp_ton"
case stoppText = "stopp_text", ende
}
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) ?? ""
}
}
/// 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?
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?
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?
enum CodingKeys: String, CodingKey {
case leer, laeuft, hoertAuf = "hoert_auf", text, seit, zuletzt, laufzeitS = "laufzeit_s", tische, tischeOffen = "tische_offen"
case tischeText = "tische_text", modus, modusQuelle = "modus_quelle", klon, notAus = "not_aus"
case guthaben, pid, status, client, ende, spielplan, maus, phase, clientPort = "client_port", konto
case turnierAnmeldungen = "turnier_anmeldungen", sitzungsleiste
}
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) }
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
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
}
}
/// 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?
enum CodingKeys: String, CodingKey { case leer, zeilen, facetten, gesamt, angezeigt, gekappt, ausschnitt, hinweis }
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)
}
}
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?
enum CodingKeys: String, CodingKey { case leer, zeilen, uebung, regeln, stand, netto }
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)
}
}
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?
enum CodingKeys: String, CodingKey { case leer, raeume, fenster }
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)
}
}
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)
}
}