Created
March 22, 2020 13:54
-
-
Save cipolleschi/132c8f7c2a4715195252138ae4feece3 to your computer and use it in GitHub Desktop.
DiceRoller App State
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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