// // HitCalculatorView.swift // Bunch O' Dice // import SwiftUI struct HitCalculatorView: View { @EnvironmentObject var current: Roll private let controlSize = 30.0 var body: some View { VStack { RerollPickerView(mode: $current.hitRerollMode) .disabledWithOpacity(current.torrent) HStack(alignment: .top) { Spacer() StatStepper( top: "Hit Modifier", value: (current.modifier.rawValue > 0 ? "+" : "") + String(current.modifier.rawValue), bottom: "", increment: { current.modifier = current.modifier.add() }, decrement: { current.modifier = current.modifier.remove() } ) .disabledWithOpacity(current.torrent || current.psychic) Spacer() VStack { Text("Blow Up") VStack { Button(action: { current.applyBlowup(face: .six) }) { Image(systemName: "die.face.6") .foregroundColor(.primary) } Button(action: { current.applyBlowup(face: .five) }) { Image(systemName: "die.face.5") .foregroundColor(.primary) } } .padding() .font(.system(size: controlSize)) } .disabledWithOpacity(current.blowupUsed || current.torrent) Spacer() } HStack(spacing: 6) { ToggleChip(label: "Torrent", isOn: $current.torrent) Spacer() ToggleChip(label: "Psychic", isOn: $current.psychic) .disabledWithOpacity(current.torrent) Spacer() ToggleChip(label: "Lethal", isOn: $current.lethalHits) } .padding(.horizontal) VStack(spacing: 8) { HStack { ToggleChip(label: "Sustained Hits", isOn: $current.sustainedHits) Spacer() if current.sustainedHits { Text("X:") Text("▲") .gesture(TapGesture().onEnded { if current.sustainedHitsX < 6 { current.sustainedHitsX += 1 } }) Text(String(current.sustainedHitsX)) .frame(minWidth: 30, alignment: .center) Text("▼") .gesture(TapGesture().onEnded { if current.sustainedHitsX > 1 { current.sustainedHitsX -= 1 } }) } } HStack { ToggleChip(label: "Anti-X", isOn: $current.antiX) Spacer() if current.antiX { Text("▲") .gesture(TapGesture().onEnded { if current.antiXThreshold < 6 { current.antiXThreshold += 1 } }) Text("\(current.antiXThreshold)+") .frame(minWidth: 34, alignment: .center) Text("▼") .gesture(TapGesture().onEnded { if current.antiXThreshold > 2 { current.antiXThreshold -= 1 } }) } } } .font(.system(size: 18)) .padding(.horizontal) } .padding() } } #Preview { HitCalculatorView() .environmentObject(Roll()) }