Rollables

  • An object that is rollable. It must have a roll() method that returns a Roll object.

    Implemented By

    Author

    Samasaur

    See more

    Declaration

    Swift

    public protocol Rollable
  • Die

    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.

    Author

    Samasaur
    See more

    Declaration

    Swift

    public struct Die
    extension Die: Rollable
    extension Die: Equatable
    extension Die: Comparable
    extension Die: Hashable
    extension Die: Describable
  • A collection of Die objects and/or a modifier that can be rolled using the roll() method.

    The properties of Dice objects are immutable; use the addition operators to combine them with other Die objects or modifiers. You can use compound assignment operators if you want, so long as you declare the Dice object as a var instead of a let constant.

    Author

    Samasaur
    See more

    Declaration

    Swift

    public struct Dice : Caching
    extension Dice: Rollable
    extension Dice: Equatable
    extension Dice: Hashable
    extension Dice: Describable
  • A representation of a weighted die; i.e. a die whose sides do not necessarily have the same chance of being rolled.

    The chances of specific rolls are passed using a Chances object. It is recommended to create the object separately, because it is easier to manipulate the Chances that way.

    Since

    0.16.0

    Author

    Samasaur
    See more

    Declaration

    Swift

    public struct WeightedDie
    extension WeightedDie: Rollable
    extension WeightedDie: Equatable
    extension WeightedDie: Hashable
    extension WeightedDie: Describable