Files
pokerfreak/mac/Sources/Cockpit/StatistikSpielbild.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

122 lines
5.8 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 CockpitKern
import SwiftUI
// Spielbild (eigene Werte), Gegnerbild und Turniere der Statistik-Seite.
private func ganzzahl(_ x: Int?) -> String { Format.zahl(x.map(Double.init), stellen: 0) }
struct SpielbildKarte: View {
var aw: Auswertung
var body: some View {
let k = aw.kennzahlen
let sd = k?.showdownBB ?? 0
let nsd = k?.ohneShowdownBB ?? 0
StatistikKarte("Spielbild", hinweis: "eigene Werte aus den fertigen Händen") {
VStack(alignment: .leading, spacing: 10) {
balken("VPIP", k?.vpip, 0.6, .blue)
balken("PFR", k?.pfr, 0.6, .orange)
balken("WTSD", k?.wtsd, 0.6, .teal)
balken("W$SD", k?.wsd, 1.0, .green)
Divider()
zeile("Aggressionsfaktor nach dem Flop", Format.zahl(k?.af, stellen: 2))
zeile("Gewonnen mit Showdown", Format.vorzeichen(sd, stellen: 0) + " bb", Farben.ergebnis(sd))
zeile("Gewonnen ohne Showdown", Format.vorzeichen(nsd, stellen: 0) + " bb", Farben.ergebnis(nsd))
zeile("Größter Gewinn / Verlust",
"\(Format.vorzeichen(k?.groessterGewinnBB, stellen: 0)) / \(Format.vorzeichen(k?.groessterVerlustBB, stellen: 0)) bb")
zeile("Tiefster Einbruch vom Hoch", Format.vorzeichen(k?.tiefstandBB, stellen: 0) + " bb", .red)
zeile("Gewonnene / verlorene Hände", "\(ganzzahl(k?.gewonnen)) / \(ganzzahl(k?.verloren))")
}
}
}
private func balken(_ name: String, _ wert: Double?, _ max: Double, _ farbe: Color) -> some View {
HStack(spacing: 8) {
Text(name).font(.caption).frame(width: 48, alignment: .leading)
Balken(anteil: (wert ?? 0) / max, farbe: farbe)
Text(Format.prozent(wert)).font(.caption.monospacedDigit()).frame(width: 50, alignment: .trailing)
}
}
private func zeile(_ titel: String, _ wert: String, _ farbe: Color = .primary) -> some View {
HStack {
Text(titel).font(.caption).foregroundStyle(.secondary)
Spacer(minLength: 8)
Text(wert).font(.caption.monospacedDigit()).foregroundStyle(farbe)
}
}
}
struct GegnerbildKarte: View {
var gegner: Gegnerbild?
var eigen: Kennzahlen?
var body: some View {
if let g = gegner, g.anzahl > 0 {
StatistikKarte("Gegnerbild", hinweis: "Ø VPIP \(Format.prozent(g.vpip)) · PFR \(Format.prozent(g.pfr))") {
VStack(alignment: .leading, spacing: 10) {
AnteilsBalken(teile: g.typen.filter { $0.anzahl > 0 }.map {
.init(name: $0.typ, anteil: Double($0.anzahl), ton: Gegnerbild.ton($0.typ), zusatz: "\($0.anzahl) Gegner")
})
StreuDiagramm(punkte: g.streupunkte, marken: marken(g), maximum: g.achsenMaximum, hoehe: 230)
legende(g)
Fussnote("\(g.anzahl) Gegner, je das jüngste Profil des Clients · Größe = Hände · Schublade aus VPIP/PFR ab 20 Händen")
}
}
} else {
StatistikKarte("Gegnerbild") {
Text("Noch keine Gegnerprofile in den Anfragen.").font(.caption).foregroundStyle(.secondary)
}
}
}
private func marken(_ g: Gegnerbild) -> [StreuDiagramm.Marke] {
var m: [StreuDiagramm.Marke] = []
if let v = g.vpip, let p = g.pfr { m.append(.init(vpip: v, pfr: p, ton: "grau")) }
if let v = eigen?.vpip, let p = eigen?.pfr { m.append(.init(vpip: v, pfr: p, ton: "gruen")) }
return m
}
private func legende(_ g: Gegnerbild) -> some View {
HStack(spacing: 14) {
if let v = g.vpip, let p = g.pfr { raute("grau", "Ø Gegner \(Format.prozent(v)) / \(Format.prozent(p))") }
if let v = eigen?.vpip, let p = eigen?.pfr { raute("gruen", "wir \(Format.prozent(v)) / \(Format.prozent(p))") }
}
}
private func raute(_ ton: String, _ text: String) -> some View {
HStack(spacing: 5) {
Rectangle().fill(StatistikFarbe.ton(ton)).frame(width: 8, height: 8).rotationEffect(.degrees(45))
Text(text).font(.caption2).foregroundStyle(.secondary)
}
}
}
/// Beendete Turniere in $: Anzahl, im Geld, bester Platz, Netto und die letzten Plaetze.
struct TurnierKarte: View {
var turniere: Turniere
var body: some View {
let t = turniere
var hinweis = "Preis + Kopfgeld − Buy-in · Buy-ins \(Format.zahl(t.buyins ?? 0, stellen: 2)) $ · Preise \(Format.zahl(t.preise ?? 0, stellen: 2)) $"
if let o = t.ohneBuyin, o > 0 { hinweis += " · \(o) ohne bekannten Buy-in nicht im Netto" }
return StatistikKarte("Turniere", hinweis: hinweis) {
VStack(alignment: .leading, spacing: 6) {
LazyVGrid(columns: [GridItem(.adaptive(minimum: 120), spacing: 8)], spacing: 8) {
Kennzahl(titel: "Turniere", wert: "\(t.anzahl)")
Kennzahl(titel: "Im Geld", wert: "\(t.imGeld ?? 0)")
Kennzahl(titel: "Bester Platz", wert: t.besterPlatz.map(String.init) ?? "–")
Kennzahl(titel: "Netto", wert: Format.vorzeichen(t.netto, stellen: 2) + " $", farbe: Farben.ergebnis(t.netto))
}
ForEach(Array(t.letzte.enumerated()), id: \.offset) { _, l in
let platz = l.platz.map(String.init) ?? "–"
let von = l.teilnehmer.map { " / \($0)" } ?? ""
let zeit = l.zeit.map { StatistikZeit.tagUhr($0) + " · " } ?? ""
Text("\(zeit)\(l.raum ?? "–") · Platz \(platz)\(von) · \(Format.vorzeichen(l.netto, stellen: 2)) $")
.font(.caption).foregroundStyle(.secondary)
}
}
}
}
}