Class: BCDice::GameSystem::LogHorizon::TreasureTable
- Inherits:
-
Object
- Object
- BCDice::GameSystem::LogHorizon::TreasureTable
- Includes:
- Translate
- Defined in:
- lib/bcdice/game_system/LogHorizon.rb
Overview
財宝表
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
-
#fix_dice_value(dice) ⇒ void
プライズ取得用にダイスの値を固定する.
-
#initialize(name, items, locale) ⇒ TreasureTable
constructor
A new instance of TreasureTable.
- #roll(cr, modifier, randomizer) ⇒ String?
Methods included from Translate
Constructor Details
#initialize(name, items, locale) ⇒ TreasureTable
Returns a new instance of TreasureTable.
320 321 322 323 324 325 326 |
# File 'lib/bcdice/game_system/LogHorizon.rb', line 320 def initialize(name, items, locale) @name = name @items = items @locale = locale @dice_list = nil end |
Class Method Details
.from_i18n(key, locale) ⇒ Object
312 313 314 315 |
# File 'lib/bcdice/game_system/LogHorizon.rb', line 312 def from_i18n(key, locale) table = I18n.translate(key, raise: true, locale: locale) new(table[:name], table[:items], locale) end |
Instance Method Details
#fix_dice_value(dice) ⇒ void
This method returns an undefined value.
プライズ取得用にダイスの値を固定する
331 332 333 |
# File 'lib/bcdice/game_system/LogHorizon.rb', line 331 def fix_dice_value(dice) @dice_list = [dice] end |
#roll(cr, modifier, randomizer) ⇒ String?
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 |
# File 'lib/bcdice/game_system/LogHorizon.rb', line 339 def roll(cr, modifier, randomizer) return nil if cr == 0 && modifier == 0 index = if cr == 0 && modifier != 0 modifier # modifierの値のみ設定されている場合には、その値の項目をダイスロールせずに参照する else @dice_list ||= randomizer.(2, 6) @dice_list.sum() + 5 * cr + modifier end chosen = pick_item(index) dice_str = "[#{@dice_list&.join(',')}]" if @dice_list "#{@name}(#{index}#{dice_str}) > #{chosen}" end |