Files
pokerfreak-shell/mac/Sources/CockpitKern/Wachstum.swift
T
mmintelandClaude Opus 5.5 83a31b3831 Mac-App: "Was spielen" mit Tischen je Format, "Formate im Vergleich"
A card per format with its table count under the plan tiles (unmeasured
formats are marked), the table tile shows the sum. Results show bb/100
per format with its 95 % span on a shared axis and the verdict, Practice
and Live separately.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 10:43:23 +01:00

169 lines
6.7 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?
enum CodingKeys: String, CodingKey {
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)
}
}
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?
public var leer: String? { eigene.leer }
enum CodingKeys: String, CodingKey { case bestand, stapel, sitzungen, jeModus = "je_modus" }
enum ModusKeys: String, CodingKey { case uebung, echt, unklar }
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)
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: .echt)
unklar = m.zahl(.unklar).map { Int($0) }
}
}
public func kurven(live: Bool) -> Kurven? { live ? echt : uebung }
}