blowup now locks out subsequent rolls, unit tests added
This commit is contained in:
@@ -226,14 +226,16 @@ struct MainView: View {
|
||||
VStack {
|
||||
Text("Blow Up")
|
||||
VStack {
|
||||
Button(action: {current.dice.blowup(dice: .six)})
|
||||
{Image(systemName: "die.face.6")
|
||||
Button(action: { current.applyBlowup(face: .six) }) {
|
||||
Image(systemName: "die.face.6")
|
||||
.foregroundColor(.primary)
|
||||
}
|
||||
Button(action: {current.dice.blowup(dice: .five)})
|
||||
{Image(systemName: "die.face.5")
|
||||
.disabled(current.blowupUsed)
|
||||
Button(action: { current.applyBlowup(face: .five) }) {
|
||||
Image(systemName: "die.face.5")
|
||||
.foregroundColor(.primary)
|
||||
}
|
||||
.disabled(current.blowupUsed)
|
||||
}
|
||||
.padding()
|
||||
.font(.system(size: controlSize))
|
||||
|
||||
@@ -150,6 +150,8 @@ class Roll: ObservableObject {
|
||||
@Published var hitHasRerolled = false
|
||||
@Published var woundHasRerolled = false
|
||||
@Published var saveHasRerolled = false
|
||||
|
||||
@Published var blowupUsed = false
|
||||
|
||||
// calculated variables
|
||||
var totalDigits: [Int] {
|
||||
@@ -341,6 +343,7 @@ class Roll: ObservableObject {
|
||||
self.total = save
|
||||
self.state = .hit
|
||||
hitHasRerolled = false
|
||||
blowupUsed = false
|
||||
}
|
||||
self.dice.roll(howMany: self.total)
|
||||
}
|
||||
@@ -349,6 +352,20 @@ class Roll: ObservableObject {
|
||||
func resetPool() {
|
||||
dice.roll(howMany: total)
|
||||
hitHasRerolled = false
|
||||
blowupUsed = false
|
||||
}
|
||||
|
||||
func applyBlowup(face: Dice.DiceType) {
|
||||
guard !blowupUsed else { return }
|
||||
switch face {
|
||||
case .six:
|
||||
dice.blowup(dice: .six)
|
||||
case .five:
|
||||
dice.blowup(dice: .five)
|
||||
default:
|
||||
break
|
||||
}
|
||||
blowupUsed = true
|
||||
}
|
||||
|
||||
func applyReroll() {
|
||||
|
||||
@@ -8,14 +8,14 @@
|
||||
import SwiftUI
|
||||
|
||||
struct OnboardingView: View {
|
||||
private var courses = DTCourse.pages
|
||||
private let courses = DTCourse.pages
|
||||
@State private var selection = 0
|
||||
@EnvironmentObject var current: Roll
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
TabView(selection: $selection) {
|
||||
ForEach(courses.indices) { idx in
|
||||
ForEach(courses.indices, id: \.self) { idx in
|
||||
VStack(spacing: 0) {
|
||||
Spacer()
|
||||
Text(courses[idx].title)
|
||||
|
||||
Reference in New Issue
Block a user