- Humanisierung: die Cockpit-Regler (Denkzeit/Raten/Sizing) wirken jetzt zur Laufzeit (humanisierung.uebernehmen beim Laeufer-Start; vorher las der Bot nur die Vorgaben) - Lehrer spricht menschliche Gegner-Reads aus HUD + Gedaechtnis (Strom-Ereignis art=gegner, Regie am Fokustisch); runner streut gedrosselt je Raum - Turnierwahl deckt Daily/Satellite/PGT/Freeroll/VIP ab (Kategorie-Filter, Cockpit-Tab) bei erhaltener Semantik (hoechstes Preisgeld, Freeroll ohne Band, nur-Uebung)
87 lines
4.6 KiB
Swift
87 lines
4.6 KiB
Swift
import Foundation
|
||
import CockpitKern
|
||
import SwiftUI
|
||
|
||
/// Eigener Steuerbereich für Turniere (Owner 7.11.: "eigener UI-Bereich, mehr Buy-in-Kontrolle").
|
||
/// Erscheint, sobald ein Turnierformat (Turnier/Freerolls/VIP) im Plan Tische hat. Setzt das
|
||
/// Buy-in-Band, den Typ-Filter (die CoinPoker-Kategorie Daily/Satellite/PGT/Freeroll/VIP) und
|
||
/// Late-Reg - gebunden an cockpit.wahl.turnier (CockpitKern.Turnierplan), gelesen vom Selektor
|
||
/// lesen/turnier_anmeldung.waehle (Kategorie über ist_kategorie). EHRLICH: der Live-Anmelde-
|
||
/// Transport ist noch nicht bestätigt.
|
||
struct TurnierBereich: View {
|
||
@Environment(Cockpit.self) private var cockpit
|
||
|
||
/// Turnierformate: nur wenn eines davon gewählt ist, ist der Bereich sinnvoll.
|
||
private static let turnierFormate: [SpielFormat] = [.turnier, .freeroll, .vip]
|
||
/// Typ-Filter: die CoinPoker-Kategorien (nil = alle). Der Selektor erkennt sie über
|
||
/// lesen/turnier_anmeldung.ist_kategorie - zuverlässiger als ein roher Namensteil.
|
||
private static let typen: [(String, String?)] =
|
||
[("Alle", nil), ("Daily", "Daily"), ("Satellite", "Satellite"), ("Freeroll", "Freeroll"),
|
||
("PGT", "PGT"), ("VIP", "VIP")]
|
||
|
||
var body: some View {
|
||
let aktiv = Self.turnierFormate.contains { cockpit.wahl.anzahl($0) > 0 }
|
||
return Group {
|
||
if aktiv {
|
||
VStack(alignment: .leading, spacing: 8) {
|
||
HStack(alignment: .firstTextBaseline) {
|
||
Label("Turniere", systemImage: "trophy").font(.caption.weight(.semibold))
|
||
Spacer()
|
||
Text("höchstes Preisgeld zuerst").font(.caption2).foregroundStyle(.secondary)
|
||
}
|
||
HStack(spacing: 8) {
|
||
Text("Buy-in").font(.caption.weight(.medium))
|
||
feld("ab", wert: bindung(\.buyinMin))
|
||
Text("–").foregroundStyle(.secondary)
|
||
feld("bis", wert: bindung(\.buyinMax))
|
||
Spacer(minLength: 0)
|
||
}
|
||
.font(.caption)
|
||
Text("Das Buy-in-Band gilt nur für bezahlte Turniere – Freerolls sind frei und immer dabei.")
|
||
.font(.caption2).foregroundStyle(.secondary).fixedSize(horizontal: false, vertical: true)
|
||
HStack(spacing: 8) {
|
||
Text("Typ").font(.caption.weight(.medium))
|
||
Picker("", selection: typWahl) {
|
||
ForEach(Self.typen, id: \.0) { Text($0.0).tag($0.1 as String?) }
|
||
}
|
||
.pickerStyle(.menu).labelsHidden().fixedSize()
|
||
Spacer(minLength: 0)
|
||
Toggle(isOn: Binding(get: { cockpit.wahl.turnier.nurLaufend },
|
||
set: { cockpit.wahl.turnier.nurLaufend = $0 })) {
|
||
Text("nur laufende").font(.caption)
|
||
}
|
||
.toggleStyle(.switch).controlSize(.mini).fixedSize()
|
||
.help("Nur Late-Reg/laufende Turniere wählen - dann sitzt der Läufer sofort, statt auf den Start zu warten.")
|
||
}
|
||
Label("Anmeldung wird noch gemessen - Auswahl & Band greifen, der Live-Beitritt ist in Erprobung.",
|
||
systemImage: "info.circle")
|
||
.font(.caption2).foregroundStyle(.secondary).fixedSize(horizontal: false, vertical: true)
|
||
}
|
||
.padding(10)
|
||
.background(.white.opacity(0.06), in: RoundedRectangle(cornerRadius: 14))
|
||
}
|
||
}
|
||
}
|
||
|
||
/// Binding auf ein Double?-Feld des Turnierplans (ab/bis).
|
||
private func bindung(_ pfad: WritableKeyPath<Turnierplan, Double?>) -> Binding<Double?> {
|
||
Binding(get: { cockpit.wahl.turnier[keyPath: pfad] },
|
||
set: { cockpit.wahl.turnier[keyPath: pfad] = $0 })
|
||
}
|
||
|
||
private var typWahl: Binding<String?> {
|
||
Binding(get: { cockpit.wahl.turnier.kategorie }, set: { cockpit.wahl.turnier.kategorie = $0 })
|
||
}
|
||
|
||
/// Schmales Zahlenfeld; leer = offenes Ende (nil).
|
||
private func feld(_ platzhalter: String, wert: Binding<Double?>) -> some View {
|
||
TextField(platzhalter, text: Binding(
|
||
get: { wert.wrappedValue.map { Format.zahl($0, stellen: 2) } ?? "" },
|
||
set: { roh in
|
||
let s = roh.replacingOccurrences(of: ",", with: ".").trimmingCharacters(in: .whitespaces)
|
||
wert.wrappedValue = Double(s).flatMap { $0 > 0 ? $0 : nil }
|
||
}))
|
||
.textFieldStyle(.roundedBorder).frame(width: 64).monospacedDigit()
|
||
}
|
||
}
|