Die
public struct Die
extension Die: Rollable
extension Die: Equatable
extension Die: Comparable
extension Die: Hashable
extension Die: Describable
                A representation of a single die.
It can be rolled using the roll() method, which will give a Roll result.
A Die object cannot change. Use the addition operators and the Dice class to represent more complex dice expressions.
- 
                  
                  
The number of sides on this
Die. This value does not need to be possible (for example, it can be 13), but it does need to be larger than 0.Declaration
Swift
public let sides: Int - 
                  
                  
Creates a new
Diewith the given number of sides.This initializer will fail if the number of sides is
<= 0.Throws
AnError.IllegalNumberOfSideserror when the number of sides is less than or equal to 0Declaration
Swift
public init(sides: Int) throwsParameters
sidesThe number of sides for this die.
 - 
                  
                  
Creates a new
Diefrom the given string in dice notation.You cannot have a negative die (
-d6), a die with negative sides (d-6), or a die with 0 sides (d0). Because this is aDieinitializer, you can only have one die (no2d6).Throws
Numerous errors if the string is malformed or empty.Declaration
Swift
public init(_ str: String) throwsParameters
strThe string to convert from.
 - 
                  
                  
Creates a new
Diethat is a copy of the givenDie.Declaration
Swift
@available(*, deprecated, message: "CustomDie is now a struct; copying is not necessary") public init(copyOf other: Die)Parameters
otherThe other
Dieto copy. - 
                  
                  
The probabilities of all possible rolls.
Since
0.17.0Declaration
Swift
public var probabilities: Chances { get } - 
                  
                  
The exact (double) average result from using the
roll()method. This is used in the Dice method to avoid rounding errors.Since
0.15.0Declaration
Swift
public var doubleAverageResult: Double { get } - 
                  
                  
Determines whether this
Diecan reach the targetRollusing the given comparison type.Since
0.15.0
Declaration
Swift
public func canReach(_ target: Roll, _ comparisonType: RollComparison) -> BoolParameters
targetThe target to check reachibility for.
comparisonTypeThe comparison to use when checking reachibility.
Return Value
Whether or not this die can reach the target, using the given comparison.
 - 
                  
                  
Declaration
Swift
public static func == (lhs: Die, rhs: Die) -> Bool - 
                  
                  
Declaration
Swift
public static func < (lhs: Die, rhs: Die) -> Bool - 
                  
                  
Declaration
Swift
public func hash(into hasher: inout Hasher) - 
                  
                  
Declaration
Swift
public var description: String { get } - 
                  
                  
Declaration
Swift
public var debugDescription: String { get } - 
                  
                  
Returns a copy of the given
Diewith separate memory.Declaration
Swift
@available(*, deprecated, message: "Die is now a struct; copying is not necessary") func copy() -> DieReturn Value
A copy of the given
Die, with the same number of sides, at a different memory location. - 
                  
                  
A four-sided die (
d4).Declaration
Swift
static var d4: Die { get } - 
                  
                  
A six-sided die (
d6).Declaration
Swift
static var d6: Die { get } - 
                  
                  
An eight-sided die (
d8).Declaration
Swift
static var d8: Die { get } - 
                  
                  
A ten-sided die (
d10).Declaration
Swift
static var d10: Die { get } - 
                  
                  
A twelve-sided die (
d12).Declaration
Swift
static var d12: Die { get } - 
                  
                  
A twenty-sided die (
d20).Declaration
Swift
static var d20: Die { get } - 
                  
                  
A one hundred-sided die (
d100).Declaration
Swift
static var d100: Die { get } 
View on GitHub
        Die Structure Reference