commit 32f03f50c3c9e20ef7b1667e15b2a2ddc31ceaad Author: neon443 <69979447+neon443@users.noreply.github.com> Date: Sun May 26 19:24:17 2024 +0100 Initial Commit diff --git a/.swiftpm/playgrounds/CachedManifest.plist b/.swiftpm/playgrounds/CachedManifest.plist new file mode 100644 index 0000000..596e334 --- /dev/null +++ b/.swiftpm/playgrounds/CachedManifest.plist @@ -0,0 +1,47 @@ + + + + + CachedManifest + + manifestData + + eyJkZXBlbmRlbmNpZXMiOltdLCJkaXNwbGF5TmFtZSI6IlJORyIsInBhY2th + Z2VLaW5kIjp7InJvb3QiOnt9fSwicGxhdGZvcm1zIjpbeyJvcHRpb25zIjpb + XSwicGxhdGZvcm1OYW1lIjoiaW9zIiwidmVyc2lvbiI6IjE2LjAifV0sInBy + b2R1Y3RzIjpbeyJuYW1lIjoiUk5HIiwic2V0dGluZ3MiOlt7ImRpc3BsYXlW + ZXJzaW9uIjpbIjEuMCJdfSx7ImJ1bmRsZVZlcnNpb24iOlsiMSJdfSx7ImlP + U0FwcEluZm8iOlt7ImFjY2VudENvbG9yIjp7InByZXNldENvbG9yIjp7InBy + ZXNldENvbG9yIjp7InJhd1ZhbHVlIjoiYmx1ZSJ9fX0sImFwcENhdGVnb3J5 + Ijp7InJhd1ZhbHVlIjoicHVibGljLmFwcC1jYXRlZ29yeS51dGlsaXRpZXMi + fSwiYXBwSWNvbiI6eyJwbGFjZWhvbGRlciI6eyJpY29uIjp7InJhd1ZhbHVl + IjoiY2FsY3VsYXRvciJ9fX0sImNhcGFiaWxpdGllcyI6W10sInN1cHBvcnRl + ZERldmljZUZhbWlsaWVzIjpbInBhZCIsInBob25lIl0sInN1cHBvcnRlZElu + dGVyZmFjZU9yaWVudGF0aW9ucyI6W3sicG9ydHJhaXQiOnt9fSx7ImxhbmRz + Y2FwZVJpZ2h0Ijp7fX0seyJsYW5kc2NhcGVMZWZ0Ijp7fX0seyJwb3J0cmFp + dFVwc2lkZURvd24iOnsiY29uZGl0aW9uIjp7ImRldmljZUZhbWlsaWVzIjpb + InBhZCJdfX19XX1dfV0sInRhcmdldHMiOlsiQXBwTW9kdWxlIl0sInR5cGUi + OnsiZXhlY3V0YWJsZSI6bnVsbH19XSwidGFyZ2V0TWFwIjp7IkFwcE1vZHVs + ZSI6eyJkZXBlbmRlbmNpZXMiOltdLCJleGNsdWRlIjpbXSwibmFtZSI6IkFw + cE1vZHVsZSIsInBhY2thZ2VBY2Nlc3MiOnRydWUsInBhdGgiOiIuIiwicmVz + b3VyY2VzIjpbXSwic2V0dGluZ3MiOlt7ImtpbmQiOnsiZW5hYmxlVXBjb21p + bmdGZWF0dXJlIjp7Il8wIjoiQmFyZVNsYXNoUmVnZXhMaXRlcmFscyJ9fSwi + dG9vbCI6InN3aWZ0In1dLCJ0eXBlIjoiZXhlY3V0YWJsZSJ9fSwidGFyZ2V0 + cyI6W3siZGVwZW5kZW5jaWVzIjpbXSwiZXhjbHVkZSI6W10sIm5hbWUiOiJB + cHBNb2R1bGUiLCJwYWNrYWdlQWNjZXNzIjp0cnVlLCJwYXRoIjoiLiIsInJl + c291cmNlcyI6W10sInNldHRpbmdzIjpbeyJraW5kIjp7ImVuYWJsZVVwY29t + aW5nRmVhdHVyZSI6eyJfMCI6IkJhcmVTbGFzaFJlZ2V4TGl0ZXJhbHMifX0s + InRvb2wiOiJzd2lmdCJ9XSwidHlwZSI6ImV4ZWN1dGFibGUifV0sInRvb2xz + VmVyc2lvbiI6eyJfdmVyc2lvbiI6IjUuOS4wIn19 + + manifestHash + + ZB/SWxlchPYcczKX1JhFcosGzSflW/fzQhD7DXE27Pk= + + schemaVersion + 4 + swiftPMVersionString + 5.10.0-dev + + + diff --git a/.swiftpm/playgrounds/DocumentThumbnail.plist b/.swiftpm/playgrounds/DocumentThumbnail.plist new file mode 100644 index 0000000..df1ad71 --- /dev/null +++ b/.swiftpm/playgrounds/DocumentThumbnail.plist @@ -0,0 +1,19 @@ + + + + + DocumentThumbnailConfiguration + + accentColorHash + + Fkd2iMDgBpnGz6RJejYS1+g8UyBitkslD+2JCBKO1Ug= + + appIconHash + + 0tSlknALCSBljl1W7VDr+qgrH0o+EF6bz9i8uwgcLoc= + + thumbnailIsPrerendered + + + + diff --git a/.swiftpm/playgrounds/DocumentThumbnail.png b/.swiftpm/playgrounds/DocumentThumbnail.png new file mode 100644 index 0000000..72d68a3 Binary files /dev/null and b/.swiftpm/playgrounds/DocumentThumbnail.png differ diff --git a/.swiftpm/playgrounds/Workspace.plist b/.swiftpm/playgrounds/Workspace.plist new file mode 100644 index 0000000..b871129 --- /dev/null +++ b/.swiftpm/playgrounds/Workspace.plist @@ -0,0 +1,13 @@ + + + + + AppSettings + + appIconPlaceholderGlyphName + calculator + appSettingsVersion + 1 + + + diff --git a/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/.swiftpm/xcode/xcuserdata/neon443.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/.swiftpm/xcode/xcuserdata/neon443.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 0000000..7b501c8 --- /dev/null +++ b/.swiftpm/xcode/xcuserdata/neon443.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,6 @@ + + + diff --git a/.swiftpm/xcode/xcuserdata/neon443.xcuserdatad/xcschemes/xcschememanagement.plist b/.swiftpm/xcode/xcuserdata/neon443.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..deb4913 --- /dev/null +++ b/.swiftpm/xcode/xcuserdata/neon443.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,14 @@ + + + + + SchemeUserState + + RNG.xcscheme_^#shared#^_ + + orderHint + 0 + + + + diff --git a/ContentView.swift b/ContentView.swift new file mode 100644 index 0000000..c27b8f3 --- /dev/null +++ b/ContentView.swift @@ -0,0 +1,26 @@ +import SwiftUI + +struct ContentView: View { + var body: some View { + VStack { + NavigationSplitView { + List { + NavigationLink { + DiceView() + .navigationTitle("Dice") + } label: { + HStack { + Text("Dice") + Spacer() + Image(systemName: "die.face.6.fill") + } + } + } + .navigationTitle("RNG") + .navigationBarTitleDisplayMode(.inline) + } detail: { + Image(systemName: "dice.fill") + } + } + } +} diff --git a/DiceView.swift b/DiceView.swift new file mode 100644 index 0000000..0015831 --- /dev/null +++ b/DiceView.swift @@ -0,0 +1,72 @@ +import SwiftUI + +struct DiceView: View { + @State var generated: [Int] = [] + @State var displayDies: [Int] = [] + @State var history: [Int] = [] + let columns = [GridItem(.adaptive(minimum: 50, maximum: 75))] + @State var dies: Double = 1 + @State var multiDieMode = "plus" + var body: some View { + VStack { + List { + Section("Number of die") { + HStack { + Text(String(Int(dies))) + Slider(value: $dies, in: 1...10, step: 1) + } + } + Section("Multi die mode") { + Picker(selection: $multiDieMode, label: Text("")) { + Image(systemName: "plus").tag("plus") + Image(systemName: "multiply").tag("multiply") + }.pickerStyle(SegmentedPickerStyle()) + } + Section("Visual") { + HStack { + Spacer() + if displayDies.isEmpty { + LazyVGrid(columns: columns, spacing: 10) { + + ForEach(0.. displayDies.count ? Int.random(in: 1...6) : displayDies[index])") + .resizable() + .scaledToFit() + .frame(width: 50, height: 50) + Image(systemName: multiDieMode) + .resizable() + .scaledToFit() + .frame(width: 25) + } + }.padding() + } else { + Text("Results are visualised here when you press the generate button") + } + Spacer() + } + } + Section("Result") { + Button("Generate") { + generated = rngN6DieArr(dies: Int(dies)) + displayDies = generated + } + Text(String(arrCombine(arr: generated, combineMode: multiDieMode))) + .bold() + .font(.largeTitle) + } + Button("Test1") { + generated = [1, 2] + multiDieMode = "plus" + } + Button("Test2") { + generated = [1, 2] + multiDieMode = "multiply" + } + } + } + } +} + +#Preview { + DiceView() +} diff --git a/MyApp.swift b/MyApp.swift new file mode 100644 index 0000000..9c6f92a --- /dev/null +++ b/MyApp.swift @@ -0,0 +1,76 @@ +import SwiftUI + +@main +struct RNGApp: App { + var body: some Scene { + WindowGroup { + ContentView() + } + } +} + +// array combiner, adds up all ints in an array +func totalIntArr(arr: [Int]) -> Int { + var total = 0 + for num in arr { + total += num + } + return total +} + +// array combiner, adds up all doubles in an array +func totalDoubleArr(arr: [Double]) -> Double { + var total: Double = 0 + for num in arr { + total += num + } + return total +} + +// array combiner, adds or multiplies all ints in an array +func arrCombine(arr: [Int], combineMode: String) -> Int { + var output = 0 + if combineMode == "plus" { + for num in arr { + output += num + } + } else if combineMode == "multiply" { + output = 1 + for num in arr { + output *= num + } + } else { + print("invalid combineMode '\(combineMode)'. must be 'plus' or 'multiply', returning 0") + return 0 + } + return output +} + + +func rng(min: Int, max: Int, step: Int) -> Int { + let range = (max - min) / step + 1 + var rng = Int.random(in: 0.. Int { + return Int.random(in: 1...6) +} + +func rngCDie(min: Int, max: Int) -> Int { + return Int.random(in: min...max) +} + +func rngN6DieArr(dies: Int) -> [Int] { + var output: [Int] = [] + for _ in 1...dies { + output.append(rng6Die()) + } + return output +} + +func rngCDie(dies: Int, min: Int, max: Int) -> Int { + + return 0 +} diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..a1bdaef --- /dev/null +++ b/Package.swift @@ -0,0 +1,47 @@ +// swift-tools-version: 5.9 + +// WARNING: +// This file is automatically generated. +// Do not edit it by hand because the contents will be replaced. + +import PackageDescription +import AppleProductTypes + +let package = Package( + name: "RNG", + platforms: [ + .iOS("16.0") + ], + products: [ + .iOSApplication( + name: "RNG", + targets: ["AppModule"], + bundleIdentifier: "com.neon443.RNG", + teamIdentifier: "8626DL2GW3", + displayVersion: "1.0", + bundleVersion: "1", + appIcon: .placeholder(icon: .calculator), + accentColor: .presetColor(.blue), + supportedDeviceFamilies: [ + .pad, + .phone + ], + supportedInterfaceOrientations: [ + .portrait, + .landscapeRight, + .landscapeLeft, + .portraitUpsideDown(.when(deviceFamilies: [.pad])) + ], + appCategory: .utilities + ) + ], + targets: [ + .executableTarget( + name: "AppModule", + path: ".", + swiftSettings: [ + .enableUpcomingFeature("BareSlashRegexLiterals") + ] + ) + ] +) \ No newline at end of file diff --git a/RNGView.swift b/RNGView.swift new file mode 100644 index 0000000..06def65 --- /dev/null +++ b/RNGView.swift @@ -0,0 +1,37 @@ +import SwiftUI + +struct CustomRNGView: View { + @State var rangeL: String = "" + @State var rangeH: String = "" + @State var show = false + var body: some View { + Text("Unimplemented") + Form { + HStack { + TextField("From", text: $rangeL) + .keyboardType(.numberPad) + Divider() + TextField("To", text: $rangeH) + .keyboardType(.numberPad) + } + HStack { + Text("Any number") + Divider() + HStack { + Text("From: ") + Text(rangeL) + Spacer() + } + HStack { + Text("To: ") + Text(rangeH) + Spacer() + } + } + } + } +} + +#Preview { + CustomRNGView() +}