Class: SavageWorlds::SWDie

Inherits:
DiceBag::Roll show all
Defined in:
lib/dicebag/systems/savage_worlds.rb

Overview

Models a single Savage World die, with attributes for max and half values.

Since all Savage Worlds Trait (Attributes + Skills) dice can explode, that option is included automatically.

Instance Attribute Summary collapse

Attributes inherited from DiceBag::Roll

#dstr, #tree

Instance Method Summary collapse

Methods inherited from DiceBag::Roll

#average, #minimum, #notes, #notes_to_s, #result, #roll

Methods included from RollString

#inspect, #to_s

Constructor Details

#initialize(sides, mod = 0) ⇒ SWDie

Returns a new instance of SWDie.



13
14
15
16
17
18
19
20
# File 'lib/dicebag/systems/savage_worlds.rb', line 13

def initialize(sides, mod = 0)
  @maximum = sides
  @half    = (sides / 2) + (mod / 2)

  dstr = mod.zero? ? "1d#{sides}e" : "1d#{sides}e #{mod}"

  super(dstr)
end

Instance Attribute Details

#halfObject (readonly)

Returns the value of attribute half.



11
12
13
# File 'lib/dicebag/systems/savage_worlds.rb', line 11

def half
  @half
end

#maximumObject (readonly)

Returns the value of attribute maximum.



10
11
12
# File 'lib/dicebag/systems/savage_worlds.rb', line 10

def maximum
  @maximum
end