From a4d1634df7dd2c47663b2cb797c6e643f4fcecb9 Mon Sep 17 00:00:00 2001 From: Rory Hinnen Date: Mon, 7 Sep 2026 10:07:07 -0500 Subject: [PATCH] added modal reroll --- Bunch-O--Dice/MainView.swift | 58 +++++++++++++++------ Bunch-O--Dice/Model/Dice.swift | 20 ++++++- Bunch-O--Dice/Model/RollState.swift | 81 +++++++++++++++++++++++++++++ DieHammer.xcodeproj/project.pbxproj | 2 + Goals.md | 10 ++++ 5 files changed, 153 insertions(+), 18 deletions(-) create mode 100644 Goals.md diff --git a/Bunch-O--Dice/MainView.swift b/Bunch-O--Dice/MainView.swift index 9101999..9c325f8 100644 --- a/Bunch-O--Dice/MainView.swift +++ b/Bunch-O--Dice/MainView.swift @@ -104,11 +104,19 @@ struct MainView: View { .padding() } Spacer() - VStack{ + VStack { Text("Reroll") - Button("🎲", action: { - current.dice.roll(howMany: current.total) - }) + Picker("", selection: $current.saveRerollMode) { + ForEach(RerollMode.allCases, id: \.self) { mode in + Text(mode.label).tag(mode) + } + } + .pickerStyle(.segmented) + .frame(width: 180) + Button("🎲") { + current.applyReroll() + } + .disabled(current.saveRerollMode == .none || current.saveHasRerolled) .padding() .font(.system(size: controlSize)) } @@ -173,13 +181,21 @@ struct MainView: View { Text("Modifier") } Spacer() - VStack{ + VStack { Text("Reroll") - Button("🎲", action: { - current.dice.roll(howMany: current.total) - }) - .padding() - .font(.system(size: controlSize)) + Picker("", selection: $current.woundRerollMode) { + ForEach(RerollMode.allCases, id: \.self) { mode in + Text(mode.label).tag(mode) + } + } + .pickerStyle(.segmented) + .frame(width: 180) + Button("🎲") { + current.applyReroll() + } + .disabled(current.woundRerollMode == .none || current.woundHasRerolled) + .padding() + .font(.system(size: controlSize)) } Spacer() }.padding() @@ -223,13 +239,21 @@ struct MainView: View { .font(.system(size: controlSize)) } - VStack{ + VStack { Text("Reroll") - Button("🎲", action: { - current.dice.roll(howMany: current.total) - }) - .padding() - .font(.system(size: controlSize)) + Picker("", selection: $current.hitRerollMode) { + ForEach(RerollMode.allCases, id: \.self) { mode in + Text(mode.label).tag(mode) + } + } + .pickerStyle(.segmented) + .frame(width: 180) + Button("🎲") { + current.applyReroll() + } + .disabled(current.hitRerollMode == .none || current.hitHasRerolled) + .padding() + .font(.system(size: controlSize)) } } }.padding() @@ -304,7 +328,7 @@ struct MainView: View { buttons(color: blue, label: "Pool", value: current.total) } .sheet(isPresented: $showFillView, - onDismiss: {current.dice.roll(howMany: current.total)}) { + onDismiss: { current.resetPool() }) { VStack { AddToPool() Button("Accept", action: {showFillView.toggle()}) diff --git a/Bunch-O--Dice/Model/Dice.swift b/Bunch-O--Dice/Model/Dice.swift index 00a7cab..d6055dd 100644 --- a/Bunch-O--Dice/Model/Dice.swift +++ b/Bunch-O--Dice/Model/Dice.swift @@ -278,6 +278,25 @@ struct Dice { self.add(pool: rerolls) } } + + mutating func rerollBelow(cutoff: Int) { + var count = 0 + for faceValue in 1..