Class: BCDice::GameSystem::LogHorizon::ConsumptionTable
- Inherits:
-
Object
- Object
- BCDice::GameSystem::LogHorizon::ConsumptionTable
- Defined in:
- lib/bcdice/game_system/LogHorizon.rb
Overview
消耗表
Instance Method Summary collapse
-
#fix_dice_value(dice) ⇒ void
ダイスの値を固定する.
-
#initialize(name, tables) ⇒ ConsumptionTable
constructor
A new instance of ConsumptionTable.
- #roll(cr, modifier, randomizer) ⇒ Object
Constructor Details
#initialize(name, tables) ⇒ ConsumptionTable
Returns a new instance of ConsumptionTable.
221 222 223 224 225 226 |
# File 'lib/bcdice/game_system/LogHorizon.rb', line 221 def initialize(name, tables) @name = name @tables = tables @dice_value = nil end |
Instance Method Details
#fix_dice_value(dice) ⇒ void
This method returns an undefined value.
ダイスの値を固定する
231 232 233 |
# File 'lib/bcdice/game_system/LogHorizon.rb', line 231 def fix_dice_value(dice) @dice_value = dice end |
#roll(cr, modifier, randomizer) ⇒ Object
235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/bcdice/game_system/LogHorizon.rb', line 235 def roll(cr, modifier, randomizer) table_index = ((cr - 1) / 5).clamp(0, @tables.size - 1) items = @tables[table_index] @dice_value ||= randomizer.roll_once(6) total = @dice_value + modifier chosen = items[total.clamp(0, 7)] "#{@name}(#{total}[#{@dice_value}]) > #{chosen}" end |