Files
mmintel 06f336e730 Bankroll reserve, table shape, Bomb Pot, stakes band, HU fix
- Echtgeld bankroll = conservative N-buy-in reserve per table (configurable,
  default 20), replacing the aggressive 1/5 rule; threaded through table
  selection (auswahl) and the sit gate (sitzen) end to end.
- Table shape selectable (Multiway/Heads-Up/Both); heads-up detected from the
  seat count AND the room name ('NL HU'); an opened wrong-shape table is closed.
- Bomb Pot playable in both modes (PLO5, engine capable); only K-Poker stays
  off (bet menu unmeasured). Drop the 'gambling' framing for an honest
  capability gate (nicht_bespielbar / NICHT_BESPIELBAR).
- Stakes band (min/max BB) added to the money model; 'Echtgeld' mode rename;
  native Preferences window; budget tile shows the reserve, not a percent.
- Fix runner import path so the client auto-config thread finds lobby_adapter.
2026-11-07 23:09:43 +01:00

167 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 Foundation
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: "Echtgeld", 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.auto(t.bb))" + (t.ante.map { $0 > 0 ? " · Ante \(Format.auto($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) }
}
}
}