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

74 lines
3.3 KiB
Swift

import CockpitKern
import SwiftUI
/// Was gespielt wird: je Format eine Karte mit Tischzahl. Mehrere Formate gleichzeitig; die Summe
/// ist die Tischzahl. Ein Format, dessen Lobby-Weg nicht gemessen ist, lässt sich wählen - der
/// Läufer öffnet dort aber nichts und sagt es (lesen/formate.py).
struct FormatWahl: View {
@Environment(Cockpit.self) private var cockpit
private let spalten = [GridItem(.flexible(), spacing: 6), GridItem(.flexible(), spacing: 6)]
var body: some View {
let w = cockpit.wahl
let gemessen = cockpit.ansicht.kopf?.spielplan?.gemessen ?? w.gemessen
VStack(alignment: .leading, spacing: 6) {
HStack(alignment: .firstTextBaseline) {
Text("Was spielen").font(.caption2.weight(.medium)).foregroundStyle(.secondary)
Spacer()
Text(zusammen(w)).font(.caption2).foregroundStyle(.secondary).monospacedDigit()
}
LazyVGrid(columns: spalten, spacing: 6) {
ForEach(SpielFormat.allCases) { f in
FormatKarte(format: f, anzahl: w.anzahl(f), gemessen: gemessen.contains(f),
voll: w.tische >= Spielplan.hoechstens) { cockpit.wahl.setzen(f, $0) }
}
}
}
}
private func zusammen(_ w: Spielplan) -> String {
w.tische == 0 ? "nichts gewählt" : "\(w.tische) Tisch\(w.tische == 1 ? "" : "e") zusammen"
}
}
private struct FormatKarte: View {
var format: SpielFormat
var anzahl: Int
var gemessen: Bool
var voll: Bool
var setzen: (Int) -> Void
private var an: Bool { anzahl > 0 }
var body: some View {
HStack(spacing: 6) {
Image(systemName: format.symbol)
.font(.system(size: 13, weight: .semibold))
.foregroundStyle(an ? Color.accentColor : .secondary)
.frame(width: 18)
VStack(alignment: .leading, spacing: 0) {
Text(format.name).font(.caption.weight(.semibold)).lineLimit(1).minimumScaleFactor(0.8)
if !gemessen {
Text("ungemessen").font(.system(size: 9.5)).foregroundStyle(.orange).lineLimit(1)
}
}
Spacer(minLength: 2)
if an {
Button { setzen(anzahl - 1) } label: { Image(systemName: "minus").frame(width: 16, height: 18) }
Text("\(anzahl)").font(.system(.callout, design: .rounded).weight(.semibold)).monospacedDigit()
.frame(minWidth: 12).contentTransition(.numericText())
}
Button { setzen(anzahl + 1) } label: { Image(systemName: "plus").frame(width: 16, height: 18) }
.disabled(voll)
}
.buttonStyle(.borderless)
.padding(.horizontal, 8).frame(height: 38)
.background(an ? Color.accentColor.opacity(0.14) : Color.white.opacity(0.05), in: RoundedRectangle(cornerRadius: 10))
.overlay(RoundedRectangle(cornerRadius: 10)
.strokeBorder(an ? Color.accentColor.opacity(0.5) : .clear, lineWidth: 1))
.animation(.snappy, value: anzahl)
.help(gemessen ? "\(format.name): \(anzahl) Tisch\(anzahl == 1 ? "" : "e")"
: "\(format.name): der Weg in der Lobby ist noch nicht gemessen - der Läufer öffnet hier nichts")
}
}