all features implemented

This commit is contained in:
Rory Hinnen
2026-09-07 15:27:33 -05:00
parent ac4d4a670a
commit 2a6130ba8e
64 changed files with 691 additions and 340 deletions
@@ -0,0 +1,50 @@
//
// Die.swift
// Bunch O' Dice
//
// Created by Rory Hinnen on 22/2/20.
//
import SwiftUI
struct SingleDie: View {
@EnvironmentObject var current: Roll
@State var whichDie: Dice.DiceType
var body: some View {
VStack {
Text(String(current.dice.value(which: whichDie)))
Group {
if (current.state != .armour) && (whichDie.rawValue >= current.cutoff.rawValue) {
Text(whichDie.print())
.foregroundColor(Color.red)
} else if (current.state == .armour) && (whichDie.rawValue < current.cutoff.rawValue) {
Text(whichDie.print())
.foregroundColor(Color.red)
} else {
Text(whichDie.print())
.foregroundColor(Color.black)
.background(Color.white)
}
}
.font(.system(size: 45))
}
.font(/*@START_MENU_TOKEN@*/.title/*@END_MENU_TOKEN@*/)
.padding(.horizontal, 5.0)
.gesture(TapGesture().onEnded {
if current.state == .hit {
current.hitCutoff = whichDie
}
else if current.state == .armour {
current.armourSave = Int(whichDie.rawValue)
}
})
}
}
struct Die_Previews: PreviewProvider {
static var previews: some View {
Die(whichDie: .one)
.environmentObject(Roll())
}
}