Chances
public struct Chances
extension Chances: Equatable
extension Chances: Hashable
extension Chances: Describable
A struct that represents the chances of different Roll
s happening.
Since
0.16.0-
Creates a new
Chances
object 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
Chances
instance. The sum of theChance
s 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 }