next step

This commit is contained in:
Rory Hinnen
2026-09-13 18:08:11 -05:00
parent 2034dbab40
commit e4e7c9fa0d
9 changed files with 56 additions and 68 deletions
@@ -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())