CustomDie
public struct CustomDie<Output> where Output : Hashable
extension CustomDie: Equatable
extension CustomDie: Hashable
extension CustomDie: Describable
A class that allows for dice with custom sides instead of numbers.
This class wraps a Die instance, and when roll() is called on this, it calls the Die’s roll() method and maps the output to one of the DieSides passed to the initializer.
Since
0.16.0-
Creates a new
CustomDie, replacing one side with a new one.Declaration
Parameters
sideThe side to replace.
newSideThe side to replace it with.
Return Value
A new
CustomDie, after the first side has been replaced with the second. -
Creates a new
CustomDiewith the given sides.Throws
AnError.IllegalNumberOfSideserror when the number of sides is less than or equal to 0Declaration
Swift
public init(_ sides: DieSide<Output>...) throwsParameters
sidesThe sides of the die.
-
Creates a new
CustomDiethat is a copy of the givenCustomDie.Declaration
Swift
@available(*, deprecated, message: "CustomDie is now a struct; copying is not necessary") public init(copyOf other: CustomDie)Parameters
otherThe other
CustomDieto copy. -
Declaration
Swift
public static func == (lhs: CustomDie, rhs: CustomDie) -> 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
CustomDiewith separate memory.Declaration
Swift
@available(*, deprecated, message: "CustomDie is now a struct; copying is not necessary") func copy() -> CustomDieReturn Value
A copy of the given
CustomDie, with the same number of sides andDieSides, at a different memory location.
View on GitHub
CustomDie Structure Reference