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 DieSide
s passed to the initializer.
Since
0.16.0-
Creates a new
CustomDie
, replacing one side with a new one.Declaration
Parameters
side
The side to replace.
newSide
The side to replace it with.
Return Value
A new
CustomDie
, after the first side has been replaced with the second. -
Creates a new
CustomDie
with the given sides.Throws
AnError.IllegalNumberOfSides
error when the number of sides is less than or equal to 0Declaration
Swift
public init(_ sides: DieSide<Output>...) throws
Parameters
sides
The sides of the die.
-
Creates a new
CustomDie
that 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
other
The other
CustomDie
to 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
CustomDie
with separate memory.Declaration
Swift
@available(*, deprecated, message: "CustomDie is now a struct; copying is not necessary") func copy() -> CustomDie
Return Value
A copy of the given
CustomDie
, with the same number of sides andDieSide
s, at a different memory location.