WinUI is ahead; the Swift app now draws what sicht/ precomputes instead of computing its own views: - Spielen page: live tables from sitzen.live (raster, kacheln, bereit, search, close question), "Gerade eben" from entscheidungen.feed, money from geld.anzeige - Stakes priority with tables per stake (spielplan.stufen/stufen_tische); micro_only is gone - Loss limits (deckel_einstellen), sammler in Zuschauer mode (main button becomes Sammeln starten/stoppen), "Nur offene Tische spielen", queue - Statistik: full auswertung (key figures, EV/SD curve, bb/100 by ..., history, best times, play/opponent picture, tournaments) - Small items: Spickzettel, streamer toggle, sendung_lesen, daily limits editor Intentional deviations: "highest first" compares instead of 1e15 + bb (WinUI cannot separate NL2 and NL5 there), a single table shows its tile, narrow segment pickers fall back to menus. Plan: plans/2026-11-30_swift-winui-abgleich.md Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
197 lines
8.7 KiB
Swift
197 lines
8.7 KiB
Swift
import Foundation
|
|
|
|
/// Der Bereich `zuschauer` (sicht/ANSICHT.md): was der Laeufer sieht und täte, ohne Klick.
|
|
public struct Zuschauer: Decodable, Equatable, Sendable {
|
|
public var laeuft: Bool
|
|
public var leer: String?
|
|
public var tische: [ZuschauerPlatz] = []
|
|
public var abgleich: [ZuschauerAbgleich] = []
|
|
/// Der Sammler (betrieb/sammler.py): fremden Tischen der gewaehlten Stufen zusehen, Haende sammeln.
|
|
public var sammler: Sammler?
|
|
|
|
enum CodingKeys: String, CodingKey { case laeuft, leer, tische, abgleich, sammler }
|
|
public init(from d: Decoder) throws {
|
|
let c = try d.container(keyedBy: CodingKeys.self)
|
|
laeuft = c.wahr(.laeuft); leer = c.text(.leer); tische = c.objekte(.tische); abgleich = c.objekte(.abgleich)
|
|
sammler = try? c.decodeIfPresent(Sammler.self, forKey: .sammler)
|
|
}
|
|
}
|
|
|
|
/// `zuschauer.sammler`: laeuft er, sein Satz, die Gesamtzahl der Tische, die Stufen mit Vorrang (`an`, `rang`).
|
|
public struct Sammler: Decodable, Equatable, Sendable {
|
|
public static let tischeVorgabe = 12
|
|
public static let tischeHoechstens = 48
|
|
|
|
public var laeuft = false
|
|
public var gesperrt = false
|
|
public var text = ""
|
|
public var hinweis: String?
|
|
public var tische = Sammler.tischeVorgabe
|
|
public var stufen: [StufeInfo] = []
|
|
|
|
enum CodingKeys: String, CodingKey { case laeuft, gesperrt, text, hinweis, tische, stufen }
|
|
|
|
public init(from d: Decoder) throws {
|
|
let c = try d.container(keyedBy: CodingKeys.self)
|
|
laeuft = c.wahr(.laeuft); gesperrt = c.wahr(.gesperrt); text = c.text(.text) ?? ""
|
|
hinweis = c.text(.hinweis).flatMap { $0.isEmpty ? nil : $0 }
|
|
tische = c.zahl(.tische).map { Int($0) } ?? Sammler.tischeVorgabe; stufen = c.objekte(.stufen)
|
|
}
|
|
|
|
/// Die gewaehlten Stufen nach Vorrang (rang, dann hoechster Big Blind zuerst).
|
|
public var reihe: [Double] {
|
|
stufen.filter(\.an).sorted { (max(1, $0.rang), -$0.bb) < (max(1, $1.rang), -$1.bb) }.map(\.bb)
|
|
}
|
|
}
|
|
|
|
/// Ein offener Tisch: sein Stand und, solange die Hand läuft, der eigene Zug daran.
|
|
public struct ZuschauerPlatz: Decodable, Equatable, Sendable, Identifiable {
|
|
public var raum: String
|
|
public var tisch: ZuschauerTisch?
|
|
public var zug: ZuschauerZug?
|
|
public var id: String { raum }
|
|
|
|
enum CodingKeys: String, CodingKey { case raum, tisch, zug }
|
|
public init(from d: Decoder) throws {
|
|
let c = try d.container(keyedBy: CodingKeys.self)
|
|
raum = c.text(.raum) ?? "?"
|
|
tisch = (try? c.decodeIfPresent(ZuschauerTisch.self, forKey: .tisch)) ?? nil
|
|
zug = (try? c.decodeIfPresent(ZuschauerZug.self, forKey: .zug)) ?? nil
|
|
}
|
|
}
|
|
|
|
public struct ZuschauerZug: Decodable, Equatable, Sendable {
|
|
public struct Empfehlung: Decodable, Equatable, Sendable {
|
|
public var aktion: String?
|
|
public var betragBB: Double?
|
|
public var grund: String?
|
|
public var klartext: String?
|
|
public var confidence: Double?
|
|
enum CodingKeys: String, CodingKey { case aktion, grund, klartext, confidence, betragBB = "betrag_bb" }
|
|
public init(from d: Decoder) throws {
|
|
let c = try d.container(keyedBy: CodingKeys.self)
|
|
aktion = c.text(.aktion); betragBB = c.zahl(.betragBB); grund = c.text(.grund)
|
|
klartext = c.text(.klartext); confidence = c.zahl(.confidence)
|
|
}
|
|
}
|
|
|
|
public struct Linie: Decodable, Equatable, Sendable, Identifiable {
|
|
public var aktion: String?
|
|
public var betragBB: Double?
|
|
public var evBB: Double?
|
|
public var id: String { "\(aktion ?? "?")|\(betragBB ?? -1)" }
|
|
enum CodingKeys: String, CodingKey { case aktion, betragBB = "betrag_bb", evBB = "ev_bb" }
|
|
public init(from d: Decoder) throws {
|
|
let c = try d.container(keyedBy: CodingKeys.self)
|
|
aktion = c.text(.aktion); betragBB = c.zahl(.betragBB); evBB = c.zahl(.evBB)
|
|
}
|
|
}
|
|
|
|
public struct Read: Decodable, Equatable, Sendable, Identifiable {
|
|
public var sitz: Int
|
|
public var einschaetzung: Spieler.Einschaetzung
|
|
public var id: Int { sitz }
|
|
enum CodingKeys: String, CodingKey { case sitz }
|
|
public init(from d: Decoder) throws {
|
|
let c = try d.container(keyedBy: CodingKeys.self)
|
|
sitz = c.zahl(.sitz).map { Int($0) } ?? 0
|
|
einschaetzung = try Spieler.Einschaetzung(from: d)
|
|
}
|
|
}
|
|
|
|
public var raum: String?
|
|
public var hand: String?
|
|
public var modus: String?
|
|
public var strasse: String?
|
|
public var karten: [String] = []
|
|
public var board: [String] = []
|
|
public var topfBB: Double?
|
|
public var zuZahlenBB: Double?
|
|
public var stackBB: Double?
|
|
public var taktS: Double?
|
|
public var hinweis: String?
|
|
public var empfehlung: Empfehlung?
|
|
public var equity: Double?
|
|
public var linien: [Linie] = []
|
|
public var reads: [Read] = []
|
|
|
|
enum CodingKeys: String, CodingKey {
|
|
case raum, hand, modus, strasse, karten, board, hinweis, empfehlung, equity, reads
|
|
case topfBB = "topf_bb", zuZahlenBB = "zu_zahlen_bb", stackBB = "stack_bb", taktS = "takt_s", linien = "evs_bb"
|
|
}
|
|
public init(from d: Decoder) throws {
|
|
let c = try d.container(keyedBy: CodingKeys.self)
|
|
raum = c.text(.raum); hand = c.text(.hand); modus = c.text(.modus); strasse = c.text(.strasse)
|
|
karten = c.liste(.karten); board = c.liste(.board); topfBB = c.zahl(.topfBB); zuZahlenBB = c.zahl(.zuZahlenBB)
|
|
stackBB = c.zahl(.stackBB); taktS = c.zahl(.taktS); hinweis = c.text(.hinweis)
|
|
empfehlung = (try? c.decodeIfPresent(Empfehlung.self, forKey: .empfehlung)) ?? nil
|
|
equity = c.zahl(.equity); linien = c.objekte(.linien); reads = c.objekte(.reads)
|
|
}
|
|
}
|
|
|
|
/// Der Tisch, auch ohne eigenen Platz: dieselben Felder wie sitzen.tisch, dazu wer dran ist.
|
|
public struct ZuschauerTisch: Decodable, Equatable, Sendable {
|
|
public struct AmZug: Decodable, Equatable, Sendable {
|
|
public var name: String?
|
|
public var fristS: Double?
|
|
enum CodingKeys: String, CodingKey { case name, fristS = "frist_s" }
|
|
public init(from d: Decoder) throws {
|
|
let c = try d.container(keyedBy: CodingKeys.self)
|
|
name = c.text(.name); fristS = c.zahl(.fristS)
|
|
}
|
|
}
|
|
|
|
public var raum: String?
|
|
public var modus: String?
|
|
public var board: [String] = []
|
|
/// In Chips, wie der Tisch ihn zeigt (game.potInfo); fehlt, solange die Hand keinen meldet.
|
|
public var topf: Double?
|
|
public var amZug: AmZug?
|
|
public var hinweis: String?
|
|
public var tisch: TischAnsicht
|
|
|
|
enum CodingKeys: String, CodingKey { case raum, modus, board, topf, hinweis, amZug = "am_zug" }
|
|
public init(from d: Decoder) throws {
|
|
let c = try d.container(keyedBy: CodingKeys.self)
|
|
raum = c.text(.raum); modus = c.text(.modus); board = c.liste(.board); topf = c.zahl(.topf); hinweis = c.text(.hinweis)
|
|
amZug = (try? c.decodeIfPresent(AmZug.self, forKey: .amZug)) ?? nil
|
|
tisch = try TischAnsicht(from: d)
|
|
}
|
|
}
|
|
|
|
public struct ZuschauerAbgleich: Decodable, Equatable, Sendable, Identifiable {
|
|
public struct Zug: Decodable, Equatable, Sendable, Identifiable {
|
|
public var strasse: String?
|
|
public var bediener: String?
|
|
public var kern: String?
|
|
public var abweichung: Bool
|
|
public var kostenBB: Double?
|
|
public var warum: String?
|
|
public var id: String { "\(strasse ?? "")|\(bediener ?? "")|\(kern ?? "")" }
|
|
|
|
private struct Linie: Decodable { var aktion: String? }
|
|
enum CodingKeys: String, CodingKey { case strasse, bediener, kern, abweichung, warum, kostenBB = "kosten_bb" }
|
|
public init(from d: Decoder) throws {
|
|
let c = try d.container(keyedBy: CodingKeys.self)
|
|
strasse = c.text(.strasse); abweichung = c.wahr(.abweichung); kostenBB = c.zahl(.kostenBB); warum = c.text(.warum)
|
|
bediener = ((try? c.decodeIfPresent(Linie.self, forKey: .bediener)) ?? nil)?.aktion
|
|
kern = ((try? c.decodeIfPresent(Linie.self, forKey: .kern)) ?? nil)?.aktion
|
|
}
|
|
}
|
|
|
|
public var raum: String?
|
|
public var hand: String?
|
|
public var abweichungen: Int
|
|
public var kostenBB: Double?
|
|
public var unbewertet: Int
|
|
public var zuege: [Zug] = []
|
|
public var id: String { "\(raum ?? "")|\(hand ?? "")|\(zuege.count)|\(zuege.first?.id ?? "")" }
|
|
|
|
enum CodingKeys: String, CodingKey { case raum, hand, abweichungen, unbewertet, zuege, kostenBB = "kosten_bb" }
|
|
public init(from d: Decoder) throws {
|
|
let c = try d.container(keyedBy: CodingKeys.self)
|
|
raum = c.text(.raum); hand = c.text(.hand); abweichungen = c.zahl(.abweichungen).map { Int($0) } ?? 0
|
|
kostenBB = c.zahl(.kostenBB); unbewertet = c.zahl(.unbewertet).map { Int($0) } ?? 0; zuege = c.objekte(.zuege)
|
|
}
|
|
}
|