From 1fd69b1887fa1c5cae18ba5fed5f37a95ccd9959 Mon Sep 17 00:00:00 2001 From: Marc Mintel Date: Fri, 6 Nov 2026 17:42:52 +0100 Subject: [PATCH] Cockpit: Geld vom Zeitplan getrennt, Profit/Verlust je Tisch sichtbar - Geld-Kachel oeffnet jetzt einen eigenen Geld-Editor (Stakes, Einkauf, Stopps, Tisch-Regeln); die Plan-Kachel nur noch den Zeitplan. Immer nur einer offen. Vorher steckte beides in einem Panel (Eigentuemer 6.11.: dumm). - Jede Live-Tischkarte zeigt Profit/Verlust als Pille (gruen/rot, Pfeil), Chips und gewertete Haende im Tooltip - die Python-Seite liefert netto schon je Raum, das Swift-Modell liest es jetzt (netto_bb -> nettoBB). 154 Swift-Tests gruen, tisch_netto_spec gruen. --- mac/Sources/Cockpit/Cockpit.swift | 4 +- mac/Sources/Cockpit/PlanEditor.swift | 184 +++++++++++++++----------- mac/Sources/Cockpit/Spielplan.swift | 40 ++++-- mac/Sources/Cockpit/Tische.swift | 31 +++++ mac/Sources/Cockpit/Wurzel.swift | 4 +- mac/Sources/CockpitKern/Modelle.swift | 11 +- mac/Tests/Pruefung/SpielerSpec.swift | 19 +++ 7 files changed, 204 insertions(+), 89 deletions(-) diff --git a/mac/Sources/Cockpit/Cockpit.swift b/mac/Sources/Cockpit/Cockpit.swift index 0ca098f0..40998180 100644 --- a/mac/Sources/Cockpit/Cockpit.swift +++ b/mac/Sources/Cockpit/Cockpit.swift @@ -109,8 +109,10 @@ final class Cockpit { planWeitergeben() } } - /// Der Plan-Editor (Zeitplan, Geldmodell) ist aufgeklappt. + /// Der Zeitplan-Editor (Sitzungen, Pausen, Uhrzeiten) ist aufgeklappt. var planOffen = false + /// Der Geld-Editor (Stakes, Einkauf, Stopps) ist aufgeklappt - getrennt vom Zeitplan. + var geldOffen = false /// Der Editor "Stimme & KI" (Anbieter) ist aufgeklappt. var stimmeOffen = false diff --git a/mac/Sources/Cockpit/PlanEditor.swift b/mac/Sources/Cockpit/PlanEditor.swift index cd47f758..c9b7888e 100644 --- a/mac/Sources/Cockpit/PlanEditor.swift +++ b/mac/Sources/Cockpit/PlanEditor.swift @@ -29,14 +29,14 @@ struct PhaseBand: View { } } -/// Zeitplan und Geldmodell auf einen Blick - antippen klappt den Plan auf. +/// Der Zeitplan auf einen Blick - antippen klappt ihn auf. Geld ist eine eigene Kachel. struct PlanKachel: View { @Environment(Cockpit.self) private var cockpit var body: some View { let w = cockpit.wahl let vorlage = PlanVorlage.erkennen(w) - Button { cockpit.planOffen.toggle() } label: { + Button { cockpit.geldOffen = false; cockpit.planOffen.toggle() } label: { Kachel(titel: "Plan") { Label(vorlage?.titel ?? "Eigener", systemImage: vorlage?.symbol ?? "slider.horizontal.3") .font(.callout.weight(.semibold)).lineLimit(1) @@ -50,13 +50,14 @@ struct PlanKachel: View { } } .buttonStyle(.plain) - .help("Wie lange, wie oft, mit welchen Stops") + .help("Wie lange, wie oft, zu welchen Uhrzeiten") } } -/// Der Plan: drei Vorlagen als Knöpfe, darunter in einem Satz, was der Läufer damit tut. Die -/// Feineinstellung bleibt eingeklappt. Jede Änderung geht gleich an den Läufer. -struct PlanEditor: View { +/// Der Zeitplan: drei Vorlagen als Knöpfe, darunter in einem Satz, was der Läufer damit tut. Die +/// Feineinstellung der Sitzungen bleibt eingeklappt. Geld ist ein eigener Editor (Geld-Kachel). +/// Jede Änderung geht gleich an den Läufer. +struct ZeitenEditor: View { @Environment(Cockpit.self) private var cockpit @State private var fein = false @@ -72,8 +73,10 @@ struct PlanEditor: View { Text(c.wahl.ablauf) .font(.caption).foregroundStyle(.secondary) .fixedSize(horizontal: false, vertical: true) + Text("Die Vorlagen stellen auch die Geld-Stopps mit ein; feiner regelst du Geld in der Geld-Kachel.") + .font(.caption2).foregroundStyle(.tertiary).fixedSize(horizontal: false, vertical: true) DisclosureGroup(isExpanded: $fein) { - Feineinstellung().padding(.top, 8) + SitzungsEinstellung().padding(.top, 8) } label: { Text(aktiv == nil ? "Feineinstellung · eigener Plan" : "Feineinstellung") .font(.caption.weight(.medium)) @@ -89,6 +92,26 @@ struct PlanEditor: View { } } +/// Alles ums Geld an einem Ort: Stakes, Einkauf, Stopps und die Regeln am einzelnen Tisch - vom +/// Zeitplan getrennt (Eigentümer 6.11.: Geld anfassen, ohne den ganzen Sitzungsplan zu sehen). +struct GeldEditor: View { + @Environment(Cockpit.self) private var cockpit + + var body: some View { + @Bindable var c = cockpit + VStack(alignment: .leading, spacing: 10) { + GeldEinstellung() + HStack { + Spacer() + Button("Fertig") { c.geldOffen = false }.buttonStyle(.borderedProminent) + } + } + .controlSize(.small) + .padding(10) + .background(.white.opacity(0.05), in: RoundedRectangle(cornerRadius: 14)) + } +} + private struct VorlageKnopf: View { var vorlage: PlanVorlage var an: Bool @@ -114,91 +137,53 @@ private struct VorlageKnopf: View { } } -/// Alles einzeln, als Sätze: jede Zeile sagt, was der Läufer tut. -private struct Feineinstellung: View { +/// Die Sitzungen als Sätze: wie viele Tische, wie lange, Pause danach, wie oft, nur zu Uhrzeiten. +private struct SitzungsEinstellung: View { @Environment(Cockpit.self) private var cockpit - @State private var stakesText = "" var body: some View { @Bindable var c = cockpit - VStack(alignment: .leading, spacing: 12) { - PlanAbschnitt(titel: "Sitzungen", symbol: "calendar.badge.clock") { - Frage("Wie viele Tische je Sitzung?") { - Wahl(an: c.wahl.tischeBis != nil, aus: "immer \(c.wahl.tische)", an_: "ausgelost") { - c.wahl.tischeBis = $0 ? min(c.wahl.tische + 2, Spielplan.hoechstens) : nil - } - if let bis = c.wahl.tischeBis { - Stepper("\(c.wahl.tische) bis \(bis)", value: Binding(get: { bis }, set: { c.wahl.tischeBis = $0 }), - in: (c.wahl.tische + 1)...Spielplan.hoechstens) - } + PlanAbschnitt(titel: "Sitzungen", symbol: "calendar.badge.clock") { + Frage("Wie viele Tische je Sitzung?") { + Wahl(an: c.wahl.tischeBis != nil, aus: "immer \(c.wahl.tische)", an_: "ausgelost") { + c.wahl.tischeBis = $0 ? min(c.wahl.tische + 2, Spielplan.hoechstens) : nil } - Frage("Wie lange dauert eine Sitzung?") { - Wahl(an: c.wahl.zeitplan.sitzung != nil, aus: "ohne Ende", an_: "begrenzt") { - c.wahl.zeitplan.sitzung = $0 ? Spanne(45, 90) : nil - } - if c.wahl.zeitplan.sitzung != nil { - MinutenSpanne(wert: Binding(get: { c.wahl.zeitplan.sitzung ?? Spanne(45, 90) }, - set: { c.wahl.zeitplan.sitzung = $0 }), unten: 5) - } + if let bis = c.wahl.tischeBis { + Stepper("\(c.wahl.tische) bis \(bis)", value: Binding(get: { bis }, set: { c.wahl.tischeBis = $0 }), + in: (c.wahl.tische + 1)...Spielplan.hoechstens) + } + } + Frage("Wie lange dauert eine Sitzung?") { + Wahl(an: c.wahl.zeitplan.sitzung != nil, aus: "ohne Ende", an_: "begrenzt") { + c.wahl.zeitplan.sitzung = $0 ? Spanne(45, 90) : nil } if c.wahl.zeitplan.sitzung != nil { - Frage("Und danach?") { - Wahl(an: c.wahl.zeitplan.pause.bis > 0, aus: "Schluss", an_: "Pause, dann weiter") { - c.wahl.zeitplan.pause = $0 ? Spanne(10, 20) : Spanne(0, 0) - } - if c.wahl.zeitplan.pause.bis > 0 { - MinutenSpanne(wert: $c.wahl.zeitplan.pause, unten: 1) - } + MinutenSpanne(wert: Binding(get: { c.wahl.zeitplan.sitzung ?? Spanne(45, 90) }, + set: { c.wahl.zeitplan.sitzung = $0 }), unten: 5) + } + } + if c.wahl.zeitplan.sitzung != nil { + Frage("Und danach?") { + Wahl(an: c.wahl.zeitplan.pause.bis > 0, aus: "Schluss", an_: "Pause, dann weiter") { + c.wahl.zeitplan.pause = $0 ? Spanne(10, 20) : Spanne(0, 0) } if c.wahl.zeitplan.pause.bis > 0 { - Frage("Wie oft?") { - Stepper(c.wahl.zeitplan.sitzungen.map { "\($0) Sitzungen, dann Schluss" } ?? "immer wieder", - value: Binding(get: { c.wahl.zeitplan.sitzungen ?? 1 }, - set: { c.wahl.zeitplan.sitzungen = $0 > 1 ? $0 : nil }), - in: 1...24) - } + MinutenSpanne(wert: $c.wahl.zeitplan.pause, unten: 1) } } - Frage("Nur zu bestimmten Uhrzeiten?") { uhrzeiten } - Text("Zufall: Dauer, Pause und Tischzahl werden je Sitzung neu ausgelost - kein starres Muster.") - .font(.caption2).foregroundStyle(.tertiary).fixedSize(horizontal: false, vertical: true) - } - PlanAbschnitt(titel: "Geld", symbol: "banknote") { - Frage("Welche Stakes?") { stakes } - Frage("Wie viel kaufen?") { - Picker("", selection: $c.wahl.geld.kauf) { - Text("Max (tief)").tag(Geldplan.Kauf.max) - Text("Min").tag(Geldplan.Kauf.min) + if c.wahl.zeitplan.pause.bis > 0 { + Frage("Wie oft?") { + Stepper(c.wahl.zeitplan.sitzungen.map { "\($0) Sitzungen, dann Schluss" } ?? "immer wieder", + value: Binding(get: { c.wahl.zeitplan.sitzungen ?? 1 }, + set: { c.wahl.zeitplan.sitzungen = $0 > 1 ? $0 : nil }), + in: 1...24) } - .pickerStyle(.segmented).labelsHidden() } - Frage("Wann ist eine Sitzung vorbei?") { - VStack(alignment: .leading, spacing: 4) { - GrenzeZeile(titel: "Verlust", grenze: $c.wahl.geld.sitzungVerlust, vorgabe: Grenze(250)) - GrenzeZeile(titel: "Gewinn", grenze: $c.wahl.geld.sitzungGewinn, vorgabe: Grenze(150)) - } - } - Frage("Wann ist der Tag vorbei?") { - VStack(alignment: .leading, spacing: 4) { - GrenzeZeile(titel: "Verlust", grenze: $c.wahl.geld.tagVerlust, vorgabe: Grenze(500)) - GrenzeZeile(titel: "Gewinn", grenze: $c.wahl.geld.tagGewinn, vorgabe: Grenze(300)) - } - } - Frage("Am einzelnen Tisch") { - VStack(alignment: .leading, spacing: 2) { - Stepper("aufstehen nach \(Format.zahl(c.wahl.geld.tischVerlustBB, stellen: 0)) BB Verlust", - value: $c.wahl.geld.tischVerlustBB, in: 10...1000, step: 10) - Stepper("nachkaufen unter \(Format.zahl(c.wahl.geld.nachkaufUnterBB, stellen: 0)) BB", - value: $c.wahl.geld.nachkaufUnterBB, in: 10...100, step: 5) - Stepper("aufstehen unter \(Format.zahl(c.wahl.geld.aufstehenUnterBB, stellen: 0)) BB Stack", - value: $c.wahl.geld.aufstehenUnterBB, in: 5...max(5, c.wahl.geld.nachkaufUnterBB - 5), step: 5) - } - } - Text("% heißt: Anteil der Bankroll beim Sitzungsstart (nur Cash).") - .font(.caption2).foregroundStyle(.tertiary) } + Frage("Nur zu bestimmten Uhrzeiten?") { uhrzeiten } + Text("Zufall: Dauer, Pause und Tischzahl werden je Sitzung neu ausgelost - kein starres Muster.") + .font(.caption2).foregroundStyle(.tertiary).fixedSize(horizontal: false, vertical: true) } - .onAppear { stakesText = c.wahl.geld.stakesBB.map { Format.zahl($0, stellen: 2) } ?? "" } } private var uhrzeiten: some View { @@ -224,6 +209,51 @@ private struct Feineinstellung: View { } } } +} + +/// Geld als Sätze: Stakes, Einkauf, Stopps je Sitzung und Tag, Regeln am einzelnen Tisch. +private struct GeldEinstellung: View { + @Environment(Cockpit.self) private var cockpit + @State private var stakesText = "" + + var body: some View { + @Bindable var c = cockpit + PlanAbschnitt(titel: "Geld", symbol: "banknote") { + Frage("Welche Stakes?") { stakes } + Frage("Wie viel kaufen?") { + Picker("", selection: $c.wahl.geld.kauf) { + Text("Max (tief)").tag(Geldplan.Kauf.max) + Text("Min").tag(Geldplan.Kauf.min) + } + .pickerStyle(.segmented).labelsHidden() + } + Frage("Wann ist eine Sitzung vorbei?") { + VStack(alignment: .leading, spacing: 4) { + GrenzeZeile(titel: "Verlust", grenze: $c.wahl.geld.sitzungVerlust, vorgabe: Grenze(250)) + GrenzeZeile(titel: "Gewinn", grenze: $c.wahl.geld.sitzungGewinn, vorgabe: Grenze(150)) + } + } + Frage("Wann ist der Tag vorbei?") { + VStack(alignment: .leading, spacing: 4) { + GrenzeZeile(titel: "Verlust", grenze: $c.wahl.geld.tagVerlust, vorgabe: Grenze(500)) + GrenzeZeile(titel: "Gewinn", grenze: $c.wahl.geld.tagGewinn, vorgabe: Grenze(300)) + } + } + Frage("Am einzelnen Tisch") { + VStack(alignment: .leading, spacing: 2) { + Stepper("aufstehen nach \(Format.zahl(c.wahl.geld.tischVerlustBB, stellen: 0)) BB Verlust", + value: $c.wahl.geld.tischVerlustBB, in: 10...1000, step: 10) + Stepper("nachkaufen unter \(Format.zahl(c.wahl.geld.nachkaufUnterBB, stellen: 0)) BB", + value: $c.wahl.geld.nachkaufUnterBB, in: 10...100, step: 5) + Stepper("aufstehen unter \(Format.zahl(c.wahl.geld.aufstehenUnterBB, stellen: 0)) BB Stack", + value: $c.wahl.geld.aufstehenUnterBB, in: 5...max(5, c.wahl.geld.nachkaufUnterBB - 5), step: 5) + } + } + Text("% heißt: Anteil der Bankroll beim Sitzungsstart (nur Cash).") + .font(.caption2).foregroundStyle(.tertiary) + } + .onAppear { stakesText = c.wahl.geld.stakesBB.map { Format.zahl($0, stellen: 2) } ?? "" } + } private var stakes: some View { @Bindable var c = cockpit diff --git a/mac/Sources/Cockpit/Spielplan.swift b/mac/Sources/Cockpit/Spielplan.swift index 47ca83da..59be83a1 100644 --- a/mac/Sources/Cockpit/Spielplan.swift +++ b/mac/Sources/Cockpit/Spielplan.swift @@ -74,27 +74,49 @@ struct PlanKacheln: View { } fuss: { Text(cockpit.laeuft == true ? "\(cockpit.ansicht.kopf?.tischeOffen ?? 0) von \(w.tische) offen" : "füllt der Läufer auf") } - Kachel(titel: w.cash ? "Budget" : "Geld") { - if w.cash { + if w.cash { + // In Cash bleibt das Budget direkt eintippbar; der Pfeil oben rechts öffnet den Geld-Editor. + Kachel(titel: "Budget") { TextField("ohne", text: $budgetText) .font(.system(size: 22, weight: .semibold, design: .rounded)) .textFieldStyle(.plain) .onSubmit { budgetUebernehmen() } .onAppear { budgetText = w.budget.map { Format.zahl($0, stellen: 0) } ?? "" } - } else { - Text("Chips").font(.system(size: 20, weight: .semibold, design: .rounded)).foregroundStyle(.secondary) - } - } fuss: { - if w.cash { + } fuss: { Text(cockpit.ansicht.kopf?.guthaben.map { "von \(Format.zahl($0, stellen: 0)) Guthaben" } ?? "Guthaben noch unbekannt") - } else { - Text("Buy-in \(w.geld.kauf == .max ? "Max" : "Min")") } + .overlay(alignment: .topTrailing) { geldPfeil } + } else { + Button { oeffneGeld() } label: { + Kachel(titel: "Geld") { + Text("Chips").font(.system(size: 20, weight: .semibold, design: .rounded)).foregroundStyle(.secondary) + } fuss: { + Text("Buy-in \(w.geld.kauf == .max ? "Max" : "Min")") + } + .overlay(alignment: .topTrailing) { geldPfeil } + } + .buttonStyle(.plain) + .help("Stakes, Einkauf und Stopps") } PlanKachel() } } + private var geldPfeil: some View { + Button { oeffneGeld() } label: { + Image(systemName: cockpit.geldOffen ? "chevron.up" : "chevron.down") + .font(.caption2).foregroundStyle(.secondary).padding(8) + } + .buttonStyle(.plain) + .help("Stakes, Einkauf und Stopps") + } + + /// Geld-Editor auf/zu - und den Zeitplan dabei zu (immer nur einer offen). + private func oeffneGeld() { + cockpit.planOffen = false + cockpit.geldOffen.toggle() + } + private func budgetUebernehmen() { let roh = budgetText.replacingOccurrences(of: ".", with: "").replacingOccurrences(of: ",", with: ".") cockpit.wahl.budget = Double(roh.trimmingCharacters(in: .whitespaces)).flatMap { $0 > 0 ? $0 : nil } diff --git a/mac/Sources/Cockpit/Tische.swift b/mac/Sources/Cockpit/Tische.swift index a505a40a..bf56c803 100644 --- a/mac/Sources/Cockpit/Tische.swift +++ b/mac/Sources/Cockpit/Tische.swift @@ -128,6 +128,9 @@ struct KachelAnsicht: View { Text(k.raumInfo?.titel ?? k.raum).font(.subheadline.weight(.semibold)).lineLimit(1) if let z = k.raumInfo?.zustand { Abzeichen(text: z, farbe: Farben.zustand(z)) } Spacer(minLength: 0) + if let nbb = k.raumInfo?.nettoBB { + TischNetto(nettoBB: nbb, netto: k.raumInfo?.netto, haende: k.raumInfo?.nettoHaende) + } symbolKnopf("camera", "Foto") { cockpit.steuern("foto", raum: k.raum) } symbolKnopf("xmark", "Tisch schließen") { cockpit.steuern("tische_schliessen", raum: k.raum) } } @@ -189,6 +192,34 @@ struct KachelAnsicht: View { } } +/// Profit/Verlust an diesem Tisch als Pille: grün im Plus, rot im Minus, Pfeil in die Richtung. +/// Chips und Zahl der gewerteten Hände im Tooltip - genau sehen, ob er vorne oder hinten liegt. +struct TischNetto: View { + var nettoBB: Double + var netto: Double? + var haende: Int? + + var body: some View { + let farbe = Farben.ergebnis(nettoBB) + Label { + Text(Format.vorzeichen(nettoBB, stellen: 1) + " bb").font(.caption.monospacedDigit().weight(.semibold)) + } icon: { + Image(systemName: nettoBB >= 0 ? "arrow.up.right" : "arrow.down.right").font(.system(size: 9, weight: .bold)) + } + .foregroundStyle(farbe) + .padding(.horizontal, 7).padding(.vertical, 2) + .background(farbe.opacity(0.15), in: Capsule()) + .help(hilfe) + } + + private var hilfe: String { + var t = "Profit/Verlust an diesem Tisch: \(Format.vorzeichen(nettoBB, stellen: 1)) bb" + if let netto { t += " · \(Format.vorzeichen(netto, stellen: 0)) Chips" } + if let haende { t += " · \(haende) \(haende == 1 ? "Hand" : "Hände") gewertet" } + return t + } +} + /// Sitzt der Laeufer nirgends: was bis zum Spielen fehlt, und wie die letzte Sitzung lief. struct Bereit: View { @Environment(Cockpit.self) private var cockpit diff --git a/mac/Sources/Cockpit/Wurzel.swift b/mac/Sources/Cockpit/Wurzel.swift index f9163ba7..a01bd1a6 100644 --- a/mac/Sources/Cockpit/Wurzel.swift +++ b/mac/Sources/Cockpit/Wurzel.swift @@ -215,7 +215,8 @@ struct Kopfzeile: View { if !cockpit.zuschauen { // der Spielplan gilt nur für den Läufer PlanKacheln() FormatWahl() - if cockpit.planOffen { PlanEditor().transition(.move(edge: .top).combined(with: .opacity)) } + if cockpit.planOffen { ZeitenEditor().transition(.move(edge: .top).combined(with: .opacity)) } + if cockpit.geldOffen { GeldEditor().transition(.move(edge: .top).combined(with: .opacity)) } } PhaseBand() if !notAusSagtAlles { @@ -246,6 +247,7 @@ struct Kopfzeile: View { .padding(.horizontal, 12).padding(.top, 10).padding(.bottom, 10) .animation(.snappy, value: cockpit.cashFragen) .animation(.snappy, value: cockpit.planOffen) + .animation(.snappy, value: cockpit.geldOffen) .animation(.snappy, value: cockpit.stimmeOffen) .animation(.snappy, value: cockpit.sendungOffen) .animation(.spring(duration: 0.35), value: cockpit.notAus) diff --git a/mac/Sources/CockpitKern/Modelle.swift b/mac/Sources/CockpitKern/Modelle.swift index 565f4855..48348264 100644 --- a/mac/Sources/CockpitKern/Modelle.swift +++ b/mac/Sources/CockpitKern/Modelle.swift @@ -377,6 +377,11 @@ public struct Raum: Decodable, Equatable, Sendable, Identifiable { public var modus: String? public var handlung: Handlung? public var fenster: Int? + /// Profit/Verlust an diesem Tisch (Summe der Hand-Nettos, sicht/ansicht._netto_je_raum): Chips, + /// BB und die Zahl der gewerteten Hände. Nil, solange keine Hand gewertet ist. + public var netto: Double? + public var nettoBB: Double? + public var nettoHaende: Int? /// Die laufende Hand aus dem Client-Log (sicht/ansicht._haende_im_log) - auch ohne Läufer. public var hand: LogHand? /// Alle Plätze mit Namen, Stack, Rolle, Aktion und Gegnerwerten (sicht/ansicht._tisch_ansicht). @@ -395,13 +400,17 @@ public struct Raum: Decodable, Equatable, Sendable, Identifiable { } } - enum CodingKeys: String, CodingKey { case raum, titel, zustand, platz, stack, groesse, bb, modus, handlung, fenster, hand, tisch } + enum CodingKeys: String, CodingKey { + case raum, titel, zustand, platz, stack, groesse, bb, modus, handlung, fenster, hand, tisch + case netto, nettoBB = "netto_bb", nettoHaende = "netto_haende" + } public init(from d: Decoder) throws { let c = try d.container(keyedBy: CodingKeys.self) raum = c.text(.raum) ?? "?"; titel = c.text(.titel); zustand = c.text(.zustand); platz = c.text(.platz); stack = c.zahl(.stack) groesse = c.zahl(.groesse).map { Int($0) }; bb = c.text(.bb); modus = c.text(.modus) handlung = try? c.decodeIfPresent(Handlung.self, forKey: .handlung); fenster = c.zahl(.fenster).map { Int($0) } + netto = c.zahl(.netto); nettoBB = c.zahl(.nettoBB); nettoHaende = c.zahl(.nettoHaende).map { Int($0) } hand = (try? c.decodeIfPresent(LogHand.self, forKey: .hand)) ?? nil tisch = (try? c.decodeIfPresent(TischAnsicht.self, forKey: .tisch)) ?? nil } diff --git a/mac/Tests/Pruefung/SpielerSpec.swift b/mac/Tests/Pruefung/SpielerSpec.swift index b4b01341..a2d30637 100644 --- a/mac/Tests/Pruefung/SpielerSpec.swift +++ b/mac/Tests/Pruefung/SpielerSpec.swift @@ -31,6 +31,25 @@ struct SpielerSpec { #expect(t?.spieler.last?.draussen == true) } + @Test("Profit/Verlust je Tisch aus sitzen.raeume[] gelesen (netto_bb -> nettoBB)") + func nettoJeTisch() { + let a = ansicht(#""" + {"sitzen":{"raeume":[{"raum":"A","zustand":"gesessen","platz":3, + "netto":-2320.0,"netto_bb":-1.16,"netto_haende":14}]}} + """#) + let r = a.sitzen?.raeume.first + #expect(r?.nettoBB == -1.16) + #expect(r?.netto == -2320.0) + #expect(r?.nettoHaende == 14) + } + + @Test("ohne gewertete Hand bleibt das Netto leer") + func nettoLeer() { + let a = ansicht(#"{"sitzen":{"raeume":[{"raum":"A","zustand":"frei"}]}}"#) + #expect(a.sitzen?.raeume.first?.nettoBB == nil) + #expect(a.sitzen?.raeume.first?.nettoHaende == nil) + } + @Test("dein Platz liegt unten, die anderen im Uhrzeigersinn") func lage() { #expect(Sitzlage.stelle(sitz: 3, ich: 3, plaetze: 6) == 0)