Owner: 'man muesste eine time range angeben, z.B. nur innerhalb der naechsten Stunde.' Es gibt jeden
Volltag Level-Up-Freerolls; ohne Fenster nimmt der Selektor das hoechste Preisgeld egal wann. Neu:
turnierplan.fenster_min (Minuten, None=alle) -> waehle/_passende filtern auf Turniere, die binnen N
Minuten starten (_im_fenster, jetzt_ms durch naechste_anmeldung/runner gereicht; ohne Startzeit
konservativ raus). gesetzt/aus_dict/als_dict/waehle_argumente + Swift Turnierplan.fensterMin + Cockpit-
Feld 'Startet in <N> Min oder weniger'. Specs: turnierplan +Fenster-Roundtrip, turnier_anmeldung
+Fenster-Auswahl (naeher schlaegt hoeheres Preisgeld); 137 gruen, Mac-Build gruen.
LIVE GEMESSEN (archiv/mitschrieb/TURNIER-ANMELDUNG-LIVE.md): Owner-Register-Klick aufgezeichnet -
Client sendet 'send_to_tournament_lobby' {room_name, request_id tournamentlobby.registration,
request_params chipName/isReEntry/toRegister/isLateRegistration/visibleBuyIn/password}, Antwort
'receive_from_tournament_lobby isSuccess:true'. Damit ist der Anmelde-Rahmen BESTAETIGT (nicht mehr
ANNAHME); naechster Schritt = diesen Rahmen ueber die Lobby-Pipe senden.
134 lines
7.2 KiB
Swift
134 lines
7.2 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
|
||
|
||
/// Es gibt EINE Turnier-Kachel; Freerolls/VIP sind Typen darunter (Owner 9.11.), keine eigenen
|
||
/// Kacheln mehr. Der Bereich erscheint, sobald die Turnier-Kachel Tische hat.
|
||
private static let turnierFormate: [SpielFormat] = [.turnier]
|
||
/// 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"), ("PGT", "PGT"),
|
||
("Freerolls", "Freeroll"), ("VIP", "VIP")]
|
||
|
||
var body: some View {
|
||
let aktiv = Self.turnierFormate.contains { cockpit.wahl.anzahl($0) > 0 }
|
||
let anmeldungen = cockpit.ansicht.kopf?.turnierAnmeldungen ?? []
|
||
return VStack(alignment: .leading, spacing: 8) {
|
||
if aktiv { planEditor }
|
||
if !anmeldungen.isEmpty { anmeldungenListe(anmeldungen) }
|
||
}
|
||
}
|
||
|
||
/// Die eigenen Anmeldungen (lesen/turnier_verwaltung.uebersicht) mit Abmelden-Knopf je Zeile.
|
||
/// Abmelden sendet die Steuer-Aktion turnier_abmelden -> ta.anmelden_connector(raum, to_register=False).
|
||
private func anmeldungenListe(_ liste: [TurnierAnmeldung]) -> some View {
|
||
VStack(alignment: .leading, spacing: 6) {
|
||
Label("Angemeldet (\(liste.count))", systemImage: "checkmark.seal")
|
||
.font(.caption.weight(.semibold))
|
||
ForEach(liste) { a in
|
||
HStack(spacing: 8) {
|
||
VStack(alignment: .leading, spacing: 1) {
|
||
Text(a.name ?? a.raum).font(.caption.weight(.medium)).lineLimit(1)
|
||
if let s = a.status, !s.isEmpty {
|
||
Text(s).font(.caption2).foregroundStyle(.secondary)
|
||
}
|
||
}
|
||
Spacer(minLength: 0)
|
||
Button("Abmelden") { cockpit.steuern("turnier_abmelden", raum: a.raum) }
|
||
.buttonStyle(.bordered).controlSize(.small)
|
||
}
|
||
}
|
||
}
|
||
.padding(10)
|
||
.background(.white.opacity(0.06), in: RoundedRectangle(cornerRadius: 14))
|
||
}
|
||
|
||
/// Der Plan-Editor (Buy-in-Band, Typ, Late-Reg) - sichtbar, sobald ein Turnierformat Tische hat.
|
||
private var planEditor: some View {
|
||
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.")
|
||
}
|
||
HStack(spacing: 8) {
|
||
Text("Startet in").font(.caption.weight(.medium))
|
||
TextField("alle", text: fensterBindung)
|
||
.textFieldStyle(.roundedBorder).frame(width: 52).monospacedDigit()
|
||
Text("Min oder weniger").font(.caption).foregroundStyle(.secondary)
|
||
Spacer(minLength: 0)
|
||
}
|
||
.help("Nur Turniere anmelden, die in den nächsten N Minuten starten (leer = alle; z. B. 60 für die nächste Stunde).")
|
||
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 })
|
||
}
|
||
|
||
/// Zeitfenster in Minuten (leer = kein Fenster): nur Turniere, die in den nächsten N Minuten starten.
|
||
private var fensterBindung: Binding<String> {
|
||
Binding(get: { cockpit.wahl.turnier.fensterMin.map(String.init) ?? "" },
|
||
set: { roh in
|
||
let n = Int(roh.trimmingCharacters(in: .whitespaces))
|
||
cockpit.wahl.turnier.fensterMin = (n ?? 0) > 0 ? n : nil
|
||
})
|
||
}
|
||
|
||
/// 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()
|
||
}
|
||
}
|