Files
mmintelandClaude Opus 5.5 f40ae277c0 Mac-App: Modus je Tisch - Turnier mit Spur zum Geld, K-Poker mit Tasten und Uhr
The data layer already sends `modus` on jetzt and on each decision row.
The app now decodes it (TischModus, lenient like the other models) and
shows it on every live tile and in the opened decision: tournament level,
blinds, a pulsing Bubble / green "im Geld" capsule and one tick per
remaining player (filled = paid place, a bar above 40 players); K-Poker
as key caps with sizes and the move clock; Cash as a quiet chip.

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

166 lines
5.9 KiB
Swift
Raw Permalink 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
/// Der Modus eines Tisches auf einen Blick: Cash, Turnier (Level, Blinds, Spur zum Geld) oder
/// K-Poker (Menue als Tasten, Uhr). Quelle ist die Anfrage, mit der der Kern entschied.
struct ModusLeiste: View {
var modus: TischModus
var body: some View {
switch modus {
case .cash(let stake): cash(stake)
case .turnier(let t): TurnierLeiste(t: t)
case .kpoker(let k): kpoker(k)
}
}
private func cash(_ stake: String?) -> some View {
HStack(spacing: 6) {
ModusChip(symbol: "circle.circle", text: "Cash", farbe: .secondary)
if let stake { Text(stake).font(.caption).foregroundStyle(.secondary) }
Spacer(minLength: 0)
}
}
private func kpoker(_ k: TischModus.KPoker) -> some View {
HStack(spacing: 6) {
ModusChip(symbol: "keyboard", text: "K-Poker", farbe: .teal)
if k.menue.isEmpty {
Taste(text: "Menü unbekannt", leer: true)
} else {
ForEach(Array(k.menue.enumerated()), id: \.offset) { _, p in
Taste(text: Aktionskuerzel.kurz(p.aktion, nil), groessen: p.groessen)
}
}
Spacer(minLength: 0)
Label(k.uhrS.map { "\(Format.zahl($0, stellen: 0)) s" } ?? "–", systemImage: "timer")
.font(.caption.weight(.semibold).monospacedDigit()).foregroundStyle(.secondary)
.help("Zeit für einen Zug an diesem Tisch")
}
}
}
private struct TurnierLeiste: View {
var t: TischModus.Turnier
var body: some View {
VStack(alignment: .leading, spacing: 5) {
HStack(spacing: 6) {
ModusChip(symbol: "trophy.fill", text: "Level \(t.level.map(String.init) ?? "–")", farbe: .indigo)
Text(blinds).font(.caption.monospacedDigit()).foregroundStyle(.secondary).lineLimit(1)
Spacer(minLength: 0)
LageKapsel(lage: t.lage)
}
if let spur = t.spur {
HStack(spacing: 8) {
Geldspur(spur: spur, lage: t.lage)
Text(t.spurText).font(.caption2.monospacedDigit()).foregroundStyle(.secondary)
.fixedSize()
}
.help("\(t.feld) Spieler übrig, \(t.bezahlt) Plätze werden bezahlt")
}
}
}
private var blinds: String {
"BB \(Format.zahl(t.bb, stellen: 0))" + (t.ante.map { $0 > 0 ? " · Ante \(Format.zahl($0, stellen: 0))" : "" } ?? "")
}
}
/// Bubble pulsiert orange, im Geld ist gruen, davor ruhig mit der Zahl bis zum Geld.
private struct LageKapsel: View {
var lage: TischModus.Geldlage
@State private var puls = false
private var farbe: Color {
switch lage {
case .bubble: .orange
case .imGeld: .green
case .vorDemGeld: .secondary
}
}
var body: some View {
HStack(spacing: 5) {
Circle().fill(farbe).frame(width: 6, height: 6).opacity(lage == .bubble && puls ? 0.3 : 1)
Text(lage.text).font(.caption2.weight(.semibold))
}
.padding(.horizontal, 8).frame(height: 20)
.foregroundStyle(farbe)
.background(farbe.opacity(0.14), in: Capsule())
.animation(lage == .bubble ? .easeInOut(duration: 0.8).repeatForever(autoreverses: true) : .default, value: puls)
.onAppear { puls = lage == .bubble }
.onChange(of: lage) { _, l in puls = l == .bubble }
}
}
/// Ein Strich je verbleibendem Spieler, gefuellt = bezahlter Platz; grosse Felder als Balken.
private struct Geldspur: View {
var spur: TischModus.Spur
var lage: TischModus.Geldlage
private var farbe: Color { lage == .imGeld ? .green : .indigo }
var body: some View {
switch spur {
case .striche(let gefuellt, let gesamt):
HStack(spacing: 2) {
ForEach(0..<gesamt, id: \.self) { i in
if i < gefuellt {
Capsule().fill(farbe.opacity(0.75))
} else {
Capsule().strokeBorder(lage == .bubble ? Color.orange : .secondary, lineWidth: 1)
}
}
}
.frame(height: 6)
case .anteil(let a):
GeometryReader { g in
ZStack(alignment: .leading) {
Capsule().fill(.quaternary)
Capsule().fill(farbe.opacity(0.75)).frame(width: g.size.width * a)
}
}
.frame(height: 6)
}
}
}
struct ModusChip: View {
var symbol: String
var text: String
var farbe: Color
var body: some View {
Label(text, systemImage: symbol)
.font(.caption2.weight(.semibold))
.labelStyle(.titleAndIcon)
.padding(.horizontal, 8).frame(height: 20)
.foregroundStyle(farbe)
.background(farbe.opacity(0.14), in: Capsule())
}
}
/// Eine K-Poker-Aktion als Taste; Raise nennt seine Groessen klein daneben.
private struct Taste: View {
var text: String
var groessen: [Double] = []
var leer = false
var body: some View {
HStack(spacing: 3) {
Text(text).font(.caption2.weight(.semibold))
if !groessen.isEmpty {
Text(groessen.map { Format.zahl($0) }.joined(separator: " · ")).font(.system(size: 9.5)).foregroundStyle(.secondary)
}
}
.padding(.horizontal, 6).frame(height: 20)
.foregroundStyle(leer ? .secondary : .primary)
.background(leer ? Color.clear : Color.white.opacity(0.08), in: RoundedRectangle(cornerRadius: 5))
.overlay(RoundedRectangle(cornerRadius: 5).strokeBorder(.separator, style: StrokeStyle(lineWidth: 1, dash: leer ? [3] : [])))
.overlay(alignment: .bottom) {
if !leer { RoundedRectangle(cornerRadius: 1).fill(.separator).frame(height: 1.5).padding(.horizontal, 2) }
}
}
}