class BCDice::GameSystem::LogHorizon::TreasureTable
財宝表
Public Class Methods
from_i18n(key, locale)
click to toggle source
# 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
new(name, items, locale)
click to toggle source
@param name [String] @param items [Hash{Integer => String}]
# File lib/bcdice/game_system/LogHorizon.rb, line 320 def initialize(name, items, locale) @name = name @items = items @locale = locale @dice_list = nil end
Public Instance Methods
fix_dice_value(dice)
click to toggle source
プライズ取得用にダイスの値を固定する @param dice [Integer] @return [void]
# File lib/bcdice/game_system/LogHorizon.rb, line 331 def fix_dice_value(dice) @dice_list = [dice] end
roll(cr, modifier, randomizer)
click to toggle source
@param cr [Integer] @param modifier [Integer] @param randomizer [Randomizer] @return [String, nil]
# 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.roll_barabara(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
Private Instance Methods
pick_item(index)
click to toggle source
@param index [Integer] @return [String]
# File lib/bcdice/game_system/LogHorizon.rb, line 360 def pick_item(index) if index <= 6 translate("LogHorizon.TRS.below_lower_limit", value: 6) # 6以下の出目は未定義です elsif index <= 62 @items[index] elsif index <= 72 "#{@items[index - 10]}&80G" elsif index <= 82 "#{@items[index - 20]}&160G" elsif index <= 87 "#{@items[index - 30]}&260G" else translate("LogHorizon.TRS.exceed_upper_limit", value: 88) # 88以上の出目は未定義です end end