Class: Ludy::Dices

Inherits:
Object
  • Object
show all
Defined in:
lib/ludy/dices.rb

Overview

dices, e.g., 4d6, 2d20, etc.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#amountsObject (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

#facesObject (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

#maxObject

the possible max value these dices would roll out.



20
# File 'lib/ludy/dices.rb', line 20

def max; @amounts*@faces; end

#minObject

the possible min value these dices would roll out.



18
# File 'lib/ludy/dices.rb', line 18

def min; @amounts; end

#rollObject

roll the dices



14
15
16
# File 'lib/ludy/dices.rb', line 14

def roll
  @amounts.roll @faces
end