next step
This commit is contained in:
@@ -15,6 +15,39 @@ struct DiePoolView: View {
|
||||
}
|
||||
}
|
||||
|
||||
private struct DieView: View {
|
||||
let whichDie: Dice.DiceType
|
||||
@EnvironmentObject var current: Roll
|
||||
@Environment(\.dieColorSelected) var colorSelected
|
||||
@Environment(\.dieColorPrimary) var colorPrimary
|
||||
var body: some View {
|
||||
let size = 42.0
|
||||
let displayColorHit = (whichDie.rawValue >= current.cutoff.rawValue) ? colorSelected : colorPrimary
|
||||
let displayColorArmor = (whichDie.rawValue <= current.cutoff.rawValue) ? colorSelected : colorPrimary
|
||||
let displayColorArmorText = (whichDie.rawValue < current.cutoff.rawValue) ? colorSelected : colorPrimary
|
||||
|
||||
VStack(spacing: 2) {
|
||||
Text(String(current.dice.value(which: whichDie)))
|
||||
.foregroundColor(current.state == .armour ? displayColorArmorText : displayColorHit)
|
||||
.frame(minWidth: 30, alignment: .center)
|
||||
Image(systemName: "die.face." + String(whichDie.rawValue) + ".fill")
|
||||
.foregroundColor(current.state == .armour ? displayColorArmor : displayColorHit)
|
||||
}
|
||||
.font(.system(size: size))
|
||||
.padding(4)
|
||||
.frame(maxWidth: .infinity)
|
||||
.gesture(TapGesture().onEnded {
|
||||
if current.state == .hit {
|
||||
if whichDie.rawValue != 1 {
|
||||
current.hitCutoff = whichDie
|
||||
}
|
||||
} else if current.state == .armour {
|
||||
current.armourSave = Int(whichDie.rawValue)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
DiePoolView()
|
||||
.environmentObject(Roll())
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
//
|
||||
// DieView.swift
|
||||
// Bunch O' Dice
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct DieView: View {
|
||||
let whichDie: Dice.DiceType
|
||||
@EnvironmentObject var current: Roll
|
||||
var colorSelected: Color = Color.green.opacity(0.75)
|
||||
var colorPrimary: Color = Color.yellow
|
||||
|
||||
var body: some View {
|
||||
let size = 42.0
|
||||
let displayColorHit = (whichDie.rawValue >= current.cutoff.rawValue) ? colorSelected : colorPrimary
|
||||
let displayColorArmor = (whichDie.rawValue <= current.cutoff.rawValue) ? colorSelected : colorPrimary
|
||||
let displayColorArmorText = (whichDie.rawValue < current.cutoff.rawValue) ? colorSelected : colorPrimary
|
||||
|
||||
VStack(spacing: 2) {
|
||||
Text(String(current.dice.value(which: whichDie)))
|
||||
.foregroundColor(current.state == .armour ? displayColorArmorText : displayColorHit)
|
||||
.frame(minWidth: 30, alignment: .center)
|
||||
Image(systemName: "die.face." + String(whichDie.rawValue) + ".fill")
|
||||
.foregroundColor(current.state == .armour ? displayColorArmor : displayColorHit)
|
||||
}
|
||||
.font(.system(size: size))
|
||||
.padding(4)
|
||||
.frame(maxWidth: .infinity)
|
||||
.gesture(TapGesture().onEnded {
|
||||
if current.state == .hit {
|
||||
if whichDie.rawValue != 1 {
|
||||
current.hitCutoff = whichDie
|
||||
}
|
||||
} else if current.state == .armour {
|
||||
current.armourSave = Int(whichDie.rawValue)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
DieView(whichDie: .four)
|
||||
.environmentObject(Roll())
|
||||
}
|
||||
@@ -16,9 +16,9 @@ struct HitCalculatorView: View {
|
||||
HStack(alignment: .top) {
|
||||
Spacer()
|
||||
StatStepper(
|
||||
top: "Hit",
|
||||
top: "Hit Modifier",
|
||||
value: (current.modifier.rawValue > 0 ? "+" : "") + String(current.modifier.rawValue),
|
||||
bottom: "Modifier",
|
||||
bottom: "",
|
||||
increment: { current.modifier = current.modifier.add() },
|
||||
decrement: { current.modifier = current.modifier.remove() }
|
||||
)
|
||||
|
||||
@@ -9,29 +9,29 @@ struct InfoAreaView: View {
|
||||
@EnvironmentObject var current: Roll
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 6) {
|
||||
HStack() {
|
||||
switch current.state {
|
||||
case .hit:
|
||||
if current.lethalHits || current.sustainedHits {
|
||||
Text("Crits (6s): \(current.critHitCount)")
|
||||
.fontWeight(.semibold)
|
||||
.foregroundColor(.orange)
|
||||
.foregroundColor(.red)
|
||||
}
|
||||
if current.antiX {
|
||||
Text("Anti-X (\(current.antiXThreshold)+): \(current.antiXCount)")
|
||||
.fontWeight(.semibold)
|
||||
.foregroundColor(.orange)
|
||||
.foregroundColor(.red)
|
||||
}
|
||||
case .wound:
|
||||
if current.autoWoundsCarried > 0 {
|
||||
Text("Auto-wounds carried: \(current.autoWoundsCarried) (skip wound roll)")
|
||||
.fontWeight(.semibold)
|
||||
.foregroundColor(.orange)
|
||||
.foregroundColor(.red)
|
||||
}
|
||||
if current.devastatingWounds {
|
||||
Text("Mortals (6s): \(current.critWoundCount)")
|
||||
Text("Mortal wounds: \(current.critWoundCount)")
|
||||
.fontWeight(.semibold)
|
||||
.foregroundColor(.orange)
|
||||
.foregroundColor(.red)
|
||||
}
|
||||
case .armour:
|
||||
EmptyView()
|
||||
|
||||
@@ -8,6 +8,9 @@ import SwiftUI
|
||||
struct RollSummaryView: View {
|
||||
@EnvironmentObject var current: Roll
|
||||
@State private var showFillView = false
|
||||
@Environment(\.dieColorSelected) var colorSelected
|
||||
@Environment(\.dieColorPrimary) var colorPrimary
|
||||
|
||||
|
||||
var body: some View {
|
||||
VStack{
|
||||
@@ -24,7 +27,7 @@ struct RollSummaryView: View {
|
||||
.padding(.vertical, 12)
|
||||
.clipShape(Circle())
|
||||
.foregroundColor(.black)
|
||||
.glassEffect(.clear.tint(Color.blue.opacity(0.7)))
|
||||
.glassEffect(.clear.tint(colorPrimary))
|
||||
}
|
||||
}
|
||||
.sheet(isPresented: $showFillView,
|
||||
@@ -51,7 +54,7 @@ struct RollSummaryView: View {
|
||||
.padding(.vertical, 12)
|
||||
.clipShape(Circle())
|
||||
.foregroundColor(.black)
|
||||
.glassEffect(.clear.tint(Color.red.opacity(0.7)))
|
||||
.glassEffect(.clear.tint(colorSelected))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,22 +16,19 @@ struct StatePickerView: View {
|
||||
if current.state == .hit { circle() }
|
||||
Text(RollState.hit.print())
|
||||
}
|
||||
}
|
||||
.glassEffect()
|
||||
}.padding(10)
|
||||
Button(action: { current.state = .wound }) {
|
||||
ZStack {
|
||||
if current.state == .wound { circle() }
|
||||
Text(RollState.wound.print())
|
||||
}
|
||||
}
|
||||
.glassEffect()
|
||||
}.padding(10)
|
||||
Button(action: { current.state = .armour }) {
|
||||
ZStack {
|
||||
if current.state == .armour { circle() }
|
||||
Text(RollState.armour.print())
|
||||
}
|
||||
}
|
||||
.glassEffect()
|
||||
}.padding(10)
|
||||
}
|
||||
.font(.system(size: 60))
|
||||
}
|
||||
|
||||
@@ -29,9 +29,8 @@ struct MainView: View {
|
||||
var body: some View {
|
||||
VStack {
|
||||
StatePickerView()
|
||||
VStack(spacing: 12) {
|
||||
VStack(spacing: 8) {
|
||||
RollSummaryView()
|
||||
// DiePoolView()
|
||||
switch current.state {
|
||||
case .wound: WoundCalculatorView()
|
||||
case .armour: ArmourCalculatorView()
|
||||
@@ -39,7 +38,7 @@ struct MainView: View {
|
||||
}
|
||||
InfoAreaView()
|
||||
Spacer()
|
||||
}.padding()
|
||||
}
|
||||
}
|
||||
.toolbar {
|
||||
ToolbarItemGroup(placement: .bottomBar) {
|
||||
|
||||
Reference in New Issue
Block a user