class Tablescript::RollAndIgnoreStrategy

RollAndIgnoreStrategy

Public Class Methods

new(table, rollset, roller = nil) click to toggle source
# File lib/tablescript/roll_and_ignore_strategy.rb, line 23
def initialize(table, rollset, roller = nil)
  @table = table
  @rollset = rollset
  @roller = roller || RpgLib::DiceRoller.instance
  @roll = nil
  @value = nil
end

Public Instance Methods

roll() click to toggle source
# File lib/tablescript/roll_and_ignore_strategy.rb, line 31
def roll
  evaluate
  @roll
end
value() click to toggle source
# File lib/tablescript/roll_and_ignore_strategy.rb, line 36
def value
  evaluate
  @value
end

Private Instance Methods

evaluate() click to toggle source
# File lib/tablescript/roll_and_ignore_strategy.rb, line 43
def evaluate
  return unless @roll.nil?
  @roll = @roller.roll_and_ignore(@table.dice_to_roll, @rollset)
  @value = @table.lookup(@roll)
end