Skip to content

Instantly share code, notes, and snippets.

@cipolleschi
Created March 22, 2020 13:54
Show Gist options
  • Select an option

  • Save cipolleschi/132c8f7c2a4715195252138ae4feece3 to your computer and use it in GitHub Desktop.

Select an option

Save cipolleschi/132c8f7c2a4715195252138ae4feece3 to your computer and use it in GitHub Desktop.
DiceRoller App State
import Katana
/// The definition state of the app
struct AppState: State {
/// Slice of the state for the Dice
var diceState = DiceState()
}
extension AppState {
/// Definition of the state of our dice rolls
struct DiceState {
/// Definition of the possible dice
enum Die: Int {
case d4 = 4
case d6 = 6
case d8 = 8
case d10 = 10
case d12 = 12
case d100 = 100
}
/// Map with the last roll of our dice
var currentResults: [Die: Int] = [:]
/// Map with the history of the rolls for every die
var rollHistory: [Die: [Int]] = [:]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment