class FifthedSim::Stat

Attributes

mod_bonus[R]
save_mod_bonus[R]
value[R]

Public Class Methods

define(&block) click to toggle source
# File lib/fifthed_sim/stat.rb, line 21
def self.define(&block)
  h = DefinitionProxy.new(&block).hash
  self.new(h)
end
from_value(h) click to toggle source
# File lib/fifthed_sim/stat.rb, line 26
def self.from_value(h)
  raise ArgumentError, "#{h} not fixnum" unless h.is_a?(Fixnum)
  self.new({value: h, save_mod: 0, mod_bonus: 0})
end
new(hash) click to toggle source
# File lib/fifthed_sim/stat.rb, line 31
def initialize(hash)
  @value = hash[:value]
  @mod_bonus = (hash[:mod_bonus] || 0)
  @save_mod_bonus = (hash[:save_mod_bonus] || 0)
end

Public Instance Methods

mod() click to toggle source
# File lib/fifthed_sim/stat.rb, line 41
def mod
  ((@value - 10) / 2) + @mod_bonus
end
saving_throw() click to toggle source
# File lib/fifthed_sim/stat.rb, line 45
def saving_throw
  1.d(20) + mod + save_mod_bonus
end