Class: Ludy::Dices
- Inherits:
-
Object
- Object
- Ludy::Dices
- Defined in:
- lib/ludy/dices.rb
Overview
dices, e.g., 4d6, 2d20, etc.
Instance Attribute Summary collapse
-
#amounts ⇒ Object
readonly
dices amounts of this dices; faces of this kind of dice.
-
#faces ⇒ Object
readonly
dices amounts of this dices; faces of this kind of dice.
Instance Method Summary collapse
-
#initialize(amounts = 1, faces = 20) ⇒ Dices
constructor
the default dice is 1d20.
-
#max ⇒ Object
the possible max value these dices would roll out.
-
#min ⇒ Object
the possible min value these dices would roll out.
-
#roll ⇒ Object
roll the dices.
Constructor Details
#initialize(amounts = 1, faces = 20) ⇒ Dices
the default dice is 1d20
9 10 11 12 |
# File 'lib/ludy/dices.rb', line 9 def initialize amounts = 1, faces = 20 @amounts = amounts @faces = faces end |
Instance Attribute Details
#amounts ⇒ Object (readonly)
dices amounts of this dices; faces of this kind of dice
7 8 9 |
# File 'lib/ludy/dices.rb', line 7 def amounts @amounts end |
#faces ⇒ Object (readonly)
dices amounts of this dices; faces of this kind of dice
7 8 9 |
# File 'lib/ludy/dices.rb', line 7 def faces @faces end |
Instance Method Details
#max ⇒ Object
the possible max value these dices would roll out.
20 |
# File 'lib/ludy/dices.rb', line 20 def max; @amounts*@faces; end |
#min ⇒ Object
the possible min value these dices would roll out.
18 |
# File 'lib/ludy/dices.rb', line 18 def min; @amounts; end |
#roll ⇒ Object
roll the dices
14 15 16 |
# File 'lib/ludy/dices.rb', line 14 def roll @amounts.roll @faces end |