Chances
public struct Chances
extension Chances: Equatable
extension Chances: Hashable
extension Chances: Describable
A struct that represents the chances of different Rolls happening.
Since
0.16.0-
Creates a new
Chancesobject with no data.Declaration
Swift
public init() -
The rolls and the chances of them occurring.
This is the property one should use in order to iterate through the possibilities, like so:
let chances: Chances = getChancesFromSomewhereElse() let arr = chances.chances.sorted(by: { first, second in first.key < second.key }) for (roll, chance) in arr { print("The chance of rolling a \(roll) is \(chance.n) out of \(chance.d)") }Since
0.21.0 -
A normalized version of this
Chancesinstance. The sum of theChances will be 1Since
0.17.0Declaration
Swift
public var normalized: Chances { get } -
Declaration
Swift
public static func == (lhs: Chances, rhs: Chances) -> Bool -
Declaration
Swift
public func hash(into hasher: inout Hasher) -
Declaration
Swift
public var description: String { get } -
Declaration
Swift
public var debugDescription: String { get }
View on GitHub
Chances Structure Reference