Class: Tablescript::RollContext

Inherits:
Object
  • Object
show all
Defined in:
lib/tablescript/roll_context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(roll, table, entry) ⇒ RollContext

Returns a new instance of RollContext.



25
26
27
28
29
# File 'lib/tablescript/roll_context.rb', line 25

def initialize(roll, table, entry)
  @roll = roll
  @table = table
  @entry = entry
end

Instance Attribute Details

#rollObject (readonly)

Returns the value of attribute roll.



23
24
25
# File 'lib/tablescript/roll_context.rb', line 23

def roll
  @roll
end

Instance Method Details

#dice_rolledObject



35
36
37
# File 'lib/tablescript/roll_context.rb', line 35

def dice_rolled
  @table.dice_to_roll
end

#rerollObject



39
40
41
# File 'lib/tablescript/roll_context.rb', line 39

def reroll
  RollStrategy.new(@table).value
end

#reroll_and_ignore(*args) ⇒ Object



43
44
45
# File 'lib/tablescript/roll_context.rb', line 43

def reroll_and_ignore(*args)
  RollAndIgnoreStrategy.new(@table, RpgLib::RollSet.new(*args)).value
end

#reroll_and_ignore_duplicates(times) ⇒ Object



47
48
49
# File 'lib/tablescript/roll_context.rb', line 47

def reroll_and_ignore_duplicates(times)
  RollAndIgnoreDuplicatesStrategy.new(@table, times, RpgLib::RollSet.new(@entry.roll)).values
end

#table_nameObject



31
32
33
# File 'lib/tablescript/roll_context.rb', line 31

def table_name
  @table.name
end