Files
mmintel 9c79d8236b Acceptance 5.11.: channel play without AFK, quiet focus, working Cockpit, stronger play
- Practice tables: 20-min session 54/54 turns at the server, control session 28 turns,
  0 timeouts; stage: 3 tables, two rounds each, clean teardown.
- Never let the clock run: an engine abstention becomes check or fold (nie_verstreichen).
- Mittler join in a fixed order (kill the duplicate, then announce), a mittler ends with its
  game, the laufwache opens no tables, stop waits for the runner to stand up.
- Focus: no lobby connections from HUD, probes or layout; "Focus Window on Turn" off.
- Tables: disconnected or sitting-out opponents do not count; a table without channel is
  closed and avoided after 45 s; the join event keeps the writer's pid (strict invariants).
- Geldwache: same room list as the runner, the table's own report, stand up before closing.
- Engine: the small blind completes the top 65 % against limpers (price per fair share);
  the calling range of a bet is as wide as the villain calls - value bets into stations.
- Cockpit: the source tree never comes from SHELL; one operating set for laufwache and
  Cockpit (sicht/start.py --client, ServerStart).
- Project lives in ~/Projects/pokerfreak (kern was a detour).
2026-11-05 16:10:43 +01:00

86 lines
3.9 KiB
Swift

import Foundation
import CockpitKern
import SwiftUI
/// Welches Format läuft am besten: bb/100 je Format mit 95-%-Spanne als Balken auf einer
/// gemeinsamen Achse, darüber das Urteil - nur wenn die Spannen es tragen.
struct FormatVergleich: View {
var kurven: Kurven?
var body: some View {
let zeilen = kurven?.jeFormat ?? []
if !zeilen.isEmpty {
VStack(alignment: .leading, spacing: 8) {
HStack(alignment: .firstTextBaseline) {
Text("Formate im Vergleich").font(.caption.weight(.semibold)).foregroundStyle(.secondary)
Spacer()
Text("bb/100 · 95 %").font(.caption2).foregroundStyle(.tertiary)
}
if let u = kurven?.bestesFormat { urteil(u) }
let achse = Self.achse(zeilen)
ForEach(zeilen) { z in
FormatBalken(zeile: z, achse: achse)
}
}
.padding(10)
.background(.white.opacity(0.05), in: RoundedRectangle(cornerRadius: 14))
}
}
private func urteil(_ u: FormatUrteil) -> some View {
let sieger = u.format.flatMap(SpielFormat.init(rawValue:))
return VStack(alignment: .leading, spacing: 1) {
Label(sieger.map { "\($0.name) liegt vorn" } ?? "Noch kein Urteil",
systemImage: sieger == nil ? "hourglass" : "rosette")
.font(.callout.weight(.semibold))
.foregroundStyle(sieger == nil ? Color.secondary : .green)
Text(u.grund).font(.caption2).foregroundStyle(.tertiary).fixedSize(horizontal: false, vertical: true)
}
}
/// Gemeinsame Achse über alle Spannen und Werte, mit der Null darin.
static func achse(_ z: [FormatZeile]) -> ClosedRange<Double> {
let werte: [Double] = z.flatMap { [$0.unten, $0.oben, $0.bb100].compactMap { $0 } } + [0.0]
let lo = werte.min() ?? -1, hi = werte.max() ?? 1
return lo == hi ? (lo - 1)...(hi + 1) : lo...hi
}
}
private struct FormatBalken: View {
var zeile: FormatZeile
var achse: ClosedRange<Double>
private var format: SpielFormat? { SpielFormat(rawValue: zeile.format) }
var body: some View {
VStack(alignment: .leading, spacing: 3) {
HStack(spacing: 6) {
Image(systemName: format?.symbol ?? "questionmark.circle").font(.caption).foregroundStyle(.secondary).frame(width: 16)
Text(zeile.name).font(.caption.weight(.semibold))
Text("\(zeile.haende) Hände").font(.caption2).foregroundStyle(.tertiary)
Spacer()
Text(Format.vorzeichen(zeile.bb100, stellen: 1)).font(.caption.weight(.semibold).monospacedDigit())
.foregroundStyle(Farben.ergebnis(zeile.bb100))
}
GeometryReader { g in
let x = { (v: Double) in g.size.width * (v - achse.lowerBound) / (achse.upperBound - achse.lowerBound) }
ZStack(alignment: .leading) {
Capsule().fill(.quaternary).frame(height: 4)
Rectangle().fill(.secondary.opacity(0.6)).frame(width: 1, height: 12).offset(x: x(0))
if let u = zeile.unten, let o = zeile.oben {
Capsule().fill(Farben.ergebnis(zeile.bb100).opacity(0.35))
.frame(width: max(2, x(o) - x(u)), height: 8).offset(x: x(u))
}
if let b = zeile.bb100 {
Circle().fill(Farben.ergebnis(b)).frame(width: 8, height: 8).offset(x: x(b) - 4)
}
}
.frame(maxHeight: .infinity)
}
.frame(height: 12)
.help(zeile.unten.map { u in "95 %: \(Format.zahl(u, stellen: 0)) bis \(Format.zahl(zeile.oben, stellen: 0)) bb/100" }
?? "zu wenig Hände für eine Spanne")
}
}
}