Class: Tablescript::RollContext
- Inherits:
-
Object
- Object
- Tablescript::RollContext
- Defined in:
- lib/tablescript/roll_context.rb
Instance Attribute Summary collapse
-
#roll ⇒ Object
readonly
Returns the value of attribute roll.
Instance Method Summary collapse
- #dice_rolled ⇒ Object
-
#initialize(roll, table, entry) ⇒ RollContext
constructor
A new instance of RollContext.
- #reroll ⇒ Object
- #reroll_and_ignore(*args) ⇒ Object
- #reroll_and_ignore_duplicates(times) ⇒ Object
- #table_name ⇒ Object
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
#roll ⇒ Object (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_rolled ⇒ Object
35 36 37 |
# File 'lib/tablescript/roll_context.rb', line 35 def dice_rolled @table.dice_to_roll end |
#reroll ⇒ Object
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_name ⇒ Object
31 32 33 |
# File 'lib/tablescript/roll_context.rb', line 31 def table_name @table.name end |