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,54 @@
//
// DieHorizontal.swift
// Bunch O' Dice
//
// Created by Rory Hinnen on 22/6/12.
//
import SwiftUI
struct DieHorizontal: View {
@EnvironmentObject var current: Roll
@State var whichDie: Dice.DiceType
var body: some View {
HStack {
Text(String(current.dice.value(which: whichDie)))
.offset(x: 0.0, y: 2.0)
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)
}
}
.font(.system(size: 40))
}
.font(.system(size: 25))
.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 DieHorizontal_Previews: PreviewProvider {
static var previews: some View {
VStack {
DieHorizontal(whichDie: .four).environmentObject(Roll())
DieHorizontal(whichDie: .three).environmentObject(Roll())
}
}
//.environmentObject(Roll())
}
@@ -0,0 +1,26 @@
//
// ShowPoolHorizontal.swift
// Bunch O' Dice
//
// Created by Rory Hinnen on 22/6/12.
//
import SwiftUI
struct ShowPoolHorizontal: View {
@EnvironmentObject var current: Roll
var body: some View {
VStack(alignment: .trailing) {
ForEach(Dice.DiceType.allCases.reversed(), id: \.rawValue) { i in
DieHorizontal(whichDie: i)
}
}
}
}
struct ShowPoolHorizontal_Previews: PreviewProvider {
static var previews: some View {
ShowPoolHorizontal().environmentObject(Roll())
}
}