class Rollable::Roll
- Rollable::Roll
- Rollable::IsRollable
- Reference
- Object
Overview
It is rollable, making the sum of each Dice
values.
It is also possible to get the details of a roll, using the methods
.min_details
, .max_details
, .average_details
, .test_details
Example:
r = Rollable.parse "1d6+2" # note: it also support "1d6 + 2"
r.min # => 3
r.max # => 9
r.average # => 5.5
r.test # => the sum of a random value in 1..6 and 2
Defined in:
rollable/roll.crrollable/roll/parse_wrap.cr
Constructors
- .new(dice : Array(Rollable::Dice))
-
.parse(str : String) : Roll
Parse the string "str" and returns a new
Roll
object
Class Method Summary
-
.parse(str : String, &) : Roll | Nil
Parse the string "str" and returns a new
Roll
object, and execute the "block" if an error occured
Instance Method Summary
- #<(right : Roll)
- #<=(right : Roll)
- #<=>(right : Roll) : Int32
- #==(right : Roll)
- #>(right : Roll)
- #>=(right : Roll)
- #average : Float64
- #average_details : Array(Float64)
- #clone
- #compact
-
#compact!
let a [1d6, 1d4, 1d6, 2, 2d6] first, we copy it for 1d6 we check evey d6 in the copy, fetch and delete them
- #dice : Array(Rollable::Dice)
- #max : Int32
- #max_details : Array(Int32)
- #min : Int32
- #min_details : Array(Int32)
- #order
- #order!
-
#reverse : Roll
Return a reversed copy of the
Roll
's values. -
#reverse! : Roll
Reverse the values of the
Roll
. - #size(*args, **options)
- #size(*args, **options, &)
- #test : Int32
- #test_details : Array(Int32)
-
#to_s : String
Returns a nicely readable and concise string representation of this object, typically intended for users.
Instance methods inherited from class Rollable::IsRollable
average : Float64
average,
max : Int32
max,
min : Int32
min,
test : Int32
test
Constructor Detail
Parse the string "str" and returns a new Roll
object
see #parse_str
Class Method Detail
Parse the string "str" and returns a new Roll
object,
and execute the "block" if an error occured
Instance Method Detail
let a [1d6, 1d4, 1d6, 2, 2d6] first, we copy it for 1d6 we check evey d6 in the copy, fetch and delete them
Returns a nicely readable and concise string representation of this object, typically intended for users.
This method should usually not be overridden. It delegates to
#to_s(IO)
which can be overridden for custom implementations.
Also see #inspect
.