Kontostatus und Betrugskennzeichen im Cockpit sichtbar

Die Sicht legt die Kennzeichen als fertige Anzeigezeilen in kopf.konto
(felder, warn) - Verdacht, Sperre, Ruhezeit, Rake, Rakeback, Tischregeln,
EV-Chop, Marken, eigene Einstellungen. Das Cockpit zeigt sie als farbige
Leiste unter der Statuszeile und als Karte in der Uebersicht.
This commit is contained in:
2026-10-30 16:57:14 +01:00
parent 67e021e828
commit 4c97e2db53
5 changed files with 144 additions and 4 deletions
+61
View File
@@ -0,0 +1,61 @@
import CockpitKern
import SwiftUI
/// Der Kontostatus des Raums in der Kopfzeile: Betrugsverdacht, Sperre, Ruhezeit, Rake, Vorteile.
/// Die Zeilen kommen fertig vom Server; hier wird nur gefaerbt und umgebrochen.
struct KontoLeiste: View {
var konto: Konto
/// Verdacht, Sperre oder laufende Ruhezeit: alles drei kann uns aussperren oder Geld kosten.
private var ton: Color { konto.warn ? .red : .secondary }
var body: some View {
FlussLayout(abstand: 6) {
ForEach(konto.felder, id: \.self) { zeile in
Text(zeile)
.font(.caption2)
.padding(.horizontal, 6).padding(.vertical, 2)
.foregroundStyle(farbe(zeile))
.background(farbe(zeile).opacity(0.12), in: Capsule())
.help(zeile)
}
}
}
private func farbe(_ zeile: String) -> Color {
if zeile.hasPrefix("Verdacht: ja") || zeile.hasPrefix("Gesperrt: ja") { return .red }
if zeile.contains("(JETZT)") { return .orange }
if zeile.hasPrefix("Verdacht") { return .green }
if zeile.hasPrefix("Rakeback") || zeile.hasPrefix("Power-Up") { return .blue }
return ton
}
}
/// Der volle Kontostatus als Karte - fuer die Uebersicht, wo Platz ist.
struct KontoKarte: View {
var konto: Konto
var body: some View {
VStack(alignment: .leading, spacing: 8) {
HStack(spacing: 6) {
Label("Konto und Raum", systemImage: "shield.lefthalf.filled")
.font(.subheadline.weight(.semibold))
if konto.warn { Abzeichen(text: "Achtung", farbe: .red) }
Spacer(minLength: 0)
}
if konto.felder.isEmpty {
Text("keine Kennzeichen im Log").font(.caption).foregroundStyle(.secondary)
}
ForEach(konto.felder, id: \.self) { zeile in
HStack(alignment: .firstTextBaseline, spacing: 6) {
Statuspunkt(ton: .grau, groesse: 6)
Text(zeile).font(.caption).fixedSize(horizontal: false, vertical: true)
}
}
if konto.schwarzJetzt {
Text("Ruhezeit laeuft: der Laeufer oeffnet jetzt keinen neuen Tisch.")
.font(.caption2).foregroundStyle(.orange)
}
}
}
}
+8
View File
@@ -38,6 +38,9 @@ struct LiveAnsicht: View {
}
Abschnitt(titel: "Geld", hinweis: cockpit.wahl.live ? "Live" : "Übung") { EmptyView() }
GeldUebersicht()
if let konto = cockpit.ansicht.kopf?.konto, !konto.felder.isEmpty {
KontoKarte(konto: konto)
}
Abschnitt(titel: "Gerade eben", hinweis: nil) { EmptyView() }
HandFeed()
}
@@ -187,10 +190,15 @@ struct KachelAnsicht: View {
/// Sitzt der Bot nirgends: was bis zum Spielen fehlt, und wie die letzte Sitzung lief.
struct Bereit: View {
@Environment(Cockpit.self) private var cockpit
var body: some View {
Abschnitt(titel: "Bis zum Spielen", hinweis: nil) { EmptyView() }
Schrittleiste()
SitzungsKarte()
if let konto = cockpit.ansicht.kopf?.konto, !konto.felder.isEmpty {
KontoKarte(konto: konto)
}
}
}
+3
View File
@@ -222,6 +222,9 @@ struct Kopfzeile: View {
Spacer(minLength: 0)
}
}
if let konto = k?.konto, !konto.felder.isEmpty {
KontoLeiste(konto: konto) // Verdacht, Sperre, Ruhezeit, Rake: was uns aussperrt
}
if cockpit.notAus {
NotAusBand().transition(.scale(scale: 0.95).combined(with: .opacity))
} else {
+33 -1
View File
@@ -48,11 +48,13 @@ public struct Kopf: Decodable, Equatable, Sendable {
/// Der Spielplan, den der Laeufer liest (nil: keiner gesetzt).
public var spielplan: Spielplan?
public var phase: Phase?
/// Kontostatus des Raums: Betrugsverdacht, Sperre, Ruhezeit, Rake - was uns gefaehrlich wird.
public var konto: Konto?
enum CodingKeys: String, CodingKey {
case leer, laeuft, text, seit, zuletzt, laufzeitS = "laufzeit_s", tische, tischeOffen = "tische_offen"
case tischeText = "tische_text", modus, modusQuelle = "modus_quelle", klon, notAus = "not_aus"
case guthaben, pid, status, client, ende, spielplan, phase, clientPort = "client_port"
case guthaben, pid, status, client, ende, spielplan, phase, clientPort = "client_port", konto
}
public init(from d: Decoder) throws {
@@ -78,6 +80,36 @@ public struct Kopf: Decodable, Equatable, Sendable {
ende = try? c.decodeIfPresent(Ende.self, forKey: .ende)
spielplan = (try? c.decodeIfPresent(Spielplan.self, forKey: .spielplan)) ?? nil
phase = (try? c.decodeIfPresent(Phase.self, forKey: .phase)) ?? nil
konto = (try? c.decodeIfPresent(Konto.self, forKey: .konto)) ?? nil
}
}
/// Konto- und Raumstatus (hand/fraud.py, lesen/vorteile.py, lesen/rake.py). Die Zeilen kommen
/// fertig vom Server - die GUI rechnet nichts nach, sie zeigt nur.
public struct Konto: Decodable, Equatable, Sendable {
public var status: String?
public var felder: [String] = []
public var warn = false
public var verdacht: Bool?
public var gesperrt: Bool?
/// Diese Tische laufen gerade in der Ruhezeit des Raums - kein neuer Tisch.
public var schwarzJetzt = false
public var schwarzeStunden: [Int] = []
enum CodingKeys: String, CodingKey {
case status, felder, warn, verdacht, gesperrt
case schwarzJetzt = "schwarz_jetzt", schwarzeStunden = "schwarze_stunden"
}
public init(from d: Decoder) throws {
let c = try d.container(keyedBy: CodingKeys.self)
status = c.text(.status)
felder = c.liste(.felder)
warn = c.wahr(.warn)
verdacht = (try? c.decodeIfPresent(Bool.self, forKey: .verdacht)) ?? nil
gesperrt = (try? c.decodeIfPresent(Bool.self, forKey: .gesperrt)) ?? nil
schwarzJetzt = c.wahr(.schwarzJetzt)
schwarzeStunden = c.liste(.schwarzeStunden).compactMap(Int.init)
}
}