Files
pokerfreak/mac/Sources/CockpitKern/Wachstum.swift
T
mmintelandClaude Opus 5.5 383f125769 Mac cockpit: catch up with WinUI (server-built live views, stakes, limits, sammler, statistik)
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>
2026-11-30 09:55:51 +01:00

178 lines
7.3 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
public struct KurvenPunkt: Decodable, Equatable, Sendable {
public var t: Double?
public var bb: Double?
enum CodingKeys: String, CodingKey { case t, bb }
public init(from d: Decoder) throws {
let c = try d.container(keyedBy: CodingKeys.self)
t = c.zahl(.t); bb = c.zahl(.bb)
}
}
public struct StakeZeile: Decodable, Equatable, Sendable, Identifiable {
public var stake: String
public var haende: Int?
public var bb100: Double?
public var unten: Double?
public var oben: Double?
public var id: String { stake }
enum CodingKeys: String, CodingKey { case stake, haende, bb100, unten, oben }
public init(from d: Decoder) throws {
let c = try d.container(keyedBy: CodingKeys.self)
stake = c.text(.stake) ?? "?"; haende = c.zahl(.haende).map { Int($0) }; bb100 = c.zahl(.bb100)
unten = c.zahl(.unten); oben = c.zahl(.oben)
}
}
public struct Sitzung: Decodable, Equatable, Sendable, Identifiable {
public var raum: String?
public var von: Double?
public var bis: Double?
public var haende: Int?
public var nettoBB: Double?
public var bb100: Double?
public var id: String { "\(raum ?? "")|\(von ?? 0)" }
enum CodingKeys: String, CodingKey { case raum, von, bis, haende, nettoBB = "netto_bb", bb100 }
public init(from d: Decoder) throws {
let c = try d.container(keyedBy: CodingKeys.self)
raum = c.text(.raum); von = c.zahl(.von); bis = c.zahl(.bis); haende = c.zahl(.haende).map { Int($0) }
nettoBB = c.zahl(.nettoBB); bb100 = c.zahl(.bb100)
}
}
public struct Stunde: Decodable, Equatable, Sendable {
public var stunde: Double?
public var haende: Int?
enum CodingKeys: String, CodingKey { case stunde, haende }
public init(from d: Decoder) throws {
let c = try d.container(keyedBy: CodingKeys.self)
stunde = c.zahl(.stunde); haende = c.zahl(.haende).map { Int($0) }
}
}
public struct Klasse: Decodable, Equatable, Sendable {
public var von: Double?
public var bis: Double?
public var anzahl: Int?
enum CodingKeys: String, CodingKey { case von, bis, anzahl }
public init(from d: Decoder) throws {
let c = try d.container(keyedBy: CodingKeys.self)
von = c.zahl(.von); bis = c.zahl(.bis); anzahl = c.zahl(.anzahl).map { Int($0) }
}
/// "< −50", "−50…−20", "≥ 50"
public var beschriftung: String {
switch (von, bis) {
case (nil, let b?): return "< \(Format.auto(b))"
case (let v?, nil): return "≥ \(Format.auto(v))"
case (let v?, let b?): return "\(Format.auto(v))…\(Format.auto(b))"
default: return "?"
}
}
}
public struct Summe: Decodable, Equatable, Sendable {
public var haende: Int?
public var nettoBB: Double?
public var gewonnen: Int?
public var verloren: Int?
enum CodingKeys: String, CodingKey { case haende, nettoBB = "netto_bb", gewonnen, verloren }
public init(from d: Decoder) throws {
let c = try d.container(keyedBy: CodingKeys.self)
haende = c.zahl(.haende).map { Int($0) }; nettoBB = c.zahl(.nettoBB)
gewonnen = c.zahl(.gewonnen).map { Int($0) }; verloren = c.zahl(.verloren).map { Int($0) }
}
}
public struct Stapel: Decodable, Equatable, Sendable, Identifiable {
public struct Punkt: Decodable, Equatable, Sendable {
public var t: Double?
public var stack: Double?
enum CodingKeys: String, CodingKey { case t, stack }
public init(from d: Decoder) throws {
let c = try d.container(keyedBy: CodingKeys.self)
t = c.zahl(.t); stack = c.zahl(.stack)
}
}
public var raum: String
public var punkte: [Punkt]
public var id: String { raum }
enum CodingKeys: String, CodingKey { case raum, punkte }
public init(from d: Decoder) throws {
let c = try d.container(keyedBy: CodingKeys.self)
raum = c.text(.raum) ?? "?"; punkte = c.objekte(.punkte)
}
}
/// Die Kurven einer Grundlage - eigene Haende oder der ganze Bestand.
public struct Kurven: Decodable, Equatable, Sendable {
public var leer: String?
public var ergebnisKurve: [KurvenPunkt] = []
public var bb100: [StakeZeile] = []
public var jeStunde: [Stunde] = []
public var verteilung: [Klasse] = []
public var summe: Summe?
public var grundlage: String?
public var rechnet = false
/// Je Modus: ab wann gezaehlt wird (Statistik zurueckgesetzt), nil = ab Anfang.
public var nullpunkt: Double?
/// Vergleich je Format (Cash, AoF, ...) und ob eines mit 95 % vorn liegt.
public var jeFormat: [FormatZeile] = []
public var bestesFormat: FormatUrteil?
/// Kennzahlen, Kurve und Aufteilungen eines Modus (nur Uebung und Cash, nicht im Bestand).
public var auswertung: Auswertung?
enum CodingKeys: String, CodingKey {
case auswertung
case leer, ergebnisKurve = "ergebnis_kurve", bb100, jeStunde = "je_stunde", verteilung, summe, grundlage, rechnet
case nullpunkt, jeFormat = "je_format", bestesFormat = "bestes_format"
}
public init(from d: Decoder) throws {
let c = try d.container(keyedBy: CodingKeys.self)
leer = c.text(.leer); ergebnisKurve = c.objekte(.ergebnisKurve); bb100 = c.objekte(.bb100)
jeStunde = c.objekte(.jeStunde); verteilung = c.objekte(.verteilung)
summe = try? c.decodeIfPresent(Summe.self, forKey: .summe); grundlage = c.text(.grundlage)
rechnet = c.wahr(.rechnet)
nullpunkt = c.zahl(.nullpunkt)
jeFormat = c.objekte(.jeFormat)
bestesFormat = try? c.decodeIfPresent(FormatUrteil.self, forKey: .bestesFormat)
auswertung = try? c.decodeIfPresent(Auswertung.self, forKey: .auswertung)
}
}
public struct Wachstum: Decodable, Equatable, Sendable {
public var eigene: Kurven
public var bestand: Kurven?
public var stapel: [Stapel] = []
public var sitzungen: [Sitzung] = []
/// Statistik je Modus (ab dem Nullpunkt); `unklar`: Haende ohne bekannten Modus.
public var uebung: Kurven?
public var echt: Kurven?
public var unklar: Int?
/// Wem wir gegenueber sassen, und die beendeten Turniere in $.
public var gegner: Gegnerbild?
public var turniere: Turniere?
public var leer: String? { eigene.leer }
enum CodingKeys: String, CodingKey { case bestand, stapel, sitzungen, jeModus = "je_modus", gegner, turniere }
enum ModusKeys: String, CodingKey { case uebung, cash, unklar, alt = "echt" } // "alt": Plaene vor der Umbenennung
public init(from d: Decoder) throws {
eigene = try Kurven(from: d)
let c = try d.container(keyedBy: CodingKeys.self)
bestand = try? c.decodeIfPresent(Kurven.self, forKey: .bestand)
stapel = c.objekte(.stapel); sitzungen = c.objekte(.sitzungen)
gegner = try? c.decodeIfPresent(Gegnerbild.self, forKey: .gegner)
turniere = try? c.decodeIfPresent(Turniere.self, forKey: .turniere)
if let m = try? c.nestedContainer(keyedBy: ModusKeys.self, forKey: .jeModus) {
uebung = try? m.decodeIfPresent(Kurven.self, forKey: .uebung)
echt = (try? m.decodeIfPresent(Kurven.self, forKey: .cash)) ?? (try? m.decodeIfPresent(Kurven.self, forKey: .alt))
unklar = m.zahl(.unklar).map { Int($0) }
}
}
public func kurven(cash: Bool) -> Kurven? { cash ? echt : uebung }
}