Skip to content

Instantly share code, notes, and snippets.

@worchyld
Last active October 28, 2022 18:49
Show Gist options
  • Save worchyld/6cfdfa1ca059858c48dcc8c71349ad5f to your computer and use it in GitHub Desktop.
Save worchyld/6cfdfa1ca059858c48dcc8c71349ad5f to your computer and use it in GitHub Desktop.
Die, D6 random number creator using Gameplaykit
import GameplayKit
struct Die: Equatable {
public static var roll: Int {
if #available(iOS 9, *) {
let d6 = GKRandomDistribution.d6()
return (d6.nextInt())
}
else {
let d6 = 6
return Int.random(in: 1..<7)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment