class BCDice::GameSystem::LogHorizon
Constants
- HELP_MESSAGE
ダイスボットの使い方
- ID
ゲームシステムの識別子
- NAME
ゲームシステム名
- SORT_KEY
ゲームシステム名の読みがな
- TABLES
Public Class Methods
new(command)
click to toggle source
Calls superclass method
BCDice::Base::new
# File lib/bcdice/game_system/LogHorizon.rb, line 94 def initialize(command) super(command) @d66_sort_type = D66SortType::NO_SORT end
Private Class Methods
translate_tables(locale)
click to toggle source
# File lib/bcdice/game_system/LogHorizon.rb, line 523 def translate_tables(locale) { "PTAG" => DiceTable::D66Table.from_i18n("LogHorizon.table.PTAG", locale), "KOYU" => DiceTable::D66Table.from_i18n("LogHorizon.table.KOYU", locale), "MGR1" => DiceTable::D66Table.from_i18n("LogHorizon.table.MGR1", locale), "MGR2" => DiceTable::D66Table.from_i18n("LogHorizon.table.MGR2", locale), "MGR3" => DiceTable::D66Table.from_i18n("LogHorizon.table.MGR3", locale), "HLOC" => DiceTable::D66Table.from_i18n("LogHorizon.table.HLOC", locale), "PCNM" => DiceTable::D66Table.from_i18n("LogHorizon.table.PCNM", locale), } end
Public Instance Methods
eval_game_system_specific_command(command)
click to toggle source
# File lib/bcdice/game_system/LogHorizon.rb, line 99 def eval_game_system_specific_command(command) getCheckRollDiceCommandResult(command) || roll_consumption(command) || roll_consumption_table(command) || roll_treasure(command) || roll_treasure_table(command) || roll_treasure_table_b2(command) || getInventionAttributeTextDiceCommandResult(command) || getTroubleInAkibaStreetDiceCommandResult(command) || getAbandonedChildDiceCommandResult(command) || getMusicalInstrumentTypeDiceCommandResult(command) || roll_eastal_exploration_table(command) || roll_tables(command, self.class::TABLES) end
Private Instance Methods
construct_consumption_table(type)
click to toggle source
# File lib/bcdice/game_system/LogHorizon.rb, line 197 def construct_consumption_table(type) table = case type when "P" translate("LogHorizon.CT.PCT") when "E" translate("LogHorizon.CT.ECT") when "G" translate("LogHorizon.CT.GCT") when "C" translate("LogHorizon.CT.CCT") when "ES" translate("LogHorizon.CT.ESCT") when "CS" translate("LogHorizon.CT.CSCT") end ConsumptionTable.new(table[:name], table[:items]) end
construct_treasure_table(type)
click to toggle source
# File lib/bcdice/game_system/LogHorizon.rb, line 282 def construct_treasure_table(type) if type == "HTRS" HeroineTreasureTable.from_i18n("LogHorizon.TRS.HTRS", @locale) else TreasureTable.from_i18n("LogHorizon.TRS.#{type}", @locale) end end
getAbandonedChildDiceCommandResult(command)
click to toggle source
廃棄児ランダム決定表
# File lib/bcdice/game_system/LogHorizon.rb, line 457 def getAbandonedChildDiceCommandResult(command) return nil unless command == "ABDC" roll_random_table("LogHorizon.ABDC") end
getCheckRollDiceCommandResult(command)
click to toggle source
# File lib/bcdice/game_system/LogHorizon.rb, line 116 def getCheckRollDiceCommandResult(command) parser = Command::Parser.new(/\d+LH/, round_type: round_type) .restrict_cmp_op_to(nil, :>=) parsed = parser.parse(command) unless parsed return nil end dice_count = parsed.command.to_i dice_list = @randomizer.roll_barabara(dice_count, 6) dice_total = dice_list.sum() total = dice_total + parsed.modify_number result = result_text(dice_count, dice_list, total, parsed) sequence = [ "(#{parsed})", "#{dice_total}[#{dice_list.join(',')}]#{Format.modifier(parsed.modify_number)}", total, result.text, ].compact result.text = sequence.join(" > ") result end
getInventionAttributeTextDiceCommandResult(command)
click to toggle source
ロデ研の新発明ランダム決定表
# File lib/bcdice/game_system/LogHorizon.rb, line 414 def getInventionAttributeTextDiceCommandResult(command) return nil unless command =~ /IAT([ABMDLT]*)/ tableName = translate("LogHorizon.IAT.name") table_indicate_string = Regexp.last_match(1) && Regexp.last_match(1) != '' ? Regexp.last_match(1) : 'MDLT' is_single = (table_indicate_string.length == 1) result = [] number = [] table_indicate_string.split(//).each do |char| dice_result = @randomizer.roll_once(6) number << dice_result.to_s table = case char when 'A', 'M' translate("LogHorizon.IAT.A") when 'B', 'D' translate("LogHorizon.IAT.B") when 'L' translate("LogHorizon.IAT.L") when 'T' translate("LogHorizon.IAT.T") end chosen = table[:items][dice_result - 1] if is_single chosen = "#{table[:name]}:#{chosen}" end result.push(chosen) end return "#{tableName}([#{number.join(',')}]) > #{result.join(' ')}" end
getMusicalInstrumentTypeDiceCommandResult(command)
click to toggle source
楽器種別表
# File lib/bcdice/game_system/LogHorizon.rb, line 474 def getMusicalInstrumentTypeDiceCommandResult(command) return nil unless command =~ /MII(\d?)/ is_roll = !(Regexp.last_match(1) && Regexp.last_match(1) != '') type = is_roll ? @randomizer.roll_once(6) : Regexp.last_match(1).to_i return nil if type < 1 || 6 < type tableName = translate("LogHorizon.MII.name") type_name = translate("LogHorizon.MII.type_list")[type - 1] dice = @randomizer.roll_once(6) result = translate("LogHorizon.MII.items")[type - 1][dice - 1] return tableName.to_s + (is_roll ? "(#{type})" : '') + " > #{type_name}(#{dice}) > #{result}" end
getTroubleInAkibaStreetDiceCommandResult(command)
click to toggle source
アキバの街で遭遇するトラブルランダム決定表
# File lib/bcdice/game_system/LogHorizon.rb, line 450 def getTroubleInAkibaStreetDiceCommandResult(command) return nil unless command == "TIAS" roll_random_table("LogHorizon.TIAS") end
getValue(text, defaultValue)
click to toggle source
# File lib/bcdice/game_system/LogHorizon.rb, line 158 def getValue(text, defaultValue) return defaultValue if text.nil? || text.empty? ArithmeticEvaluator.eval(text) end
result_text(dice_count, dice_list, total, parsed)
click to toggle source
# File lib/bcdice/game_system/LogHorizon.rb, line 144 def result_text(dice_count, dice_list, total, parsed) if dice_list.count(6) >= 2 Result.critical(translate("LogHorizon.LH.critical")) elsif dice_list.count(1) >= dice_count Result.fumble(translate("LogHorizon.LH.fumble")) elsif parsed.cmp_op.nil? Result.new elsif total >= parsed.target_number Result.success(translate("success")) else Result.failure(translate("failure")) end end
roll_consumption(command)
click to toggle source
消耗表ロール
# File lib/bcdice/game_system/LogHorizon.rb, line 165 def roll_consumption(command) m = /^CT\d*([+\-\d]+)?$/.match(command) return nil unless m modifier = ArithmeticEvaluator.eval(m[1]) formated_modifier = Format.modifier(modifier) dice = @randomizer.roll_once(6) interim_expr = dice.to_s + formated_modifier unless formated_modifier.empty? sequence = [ "(1D6#{formated_modifier})", interim_expr, dice + modifier, ].compact return sequence.join(" > ") end
roll_consumption_table(command)
click to toggle source
消耗表 ###
# File lib/bcdice/game_system/LogHorizon.rb, line 185 def roll_consumption_table(command) m = /(P|E|G|C|ES|CS)CT(\d+)?([+\-\d]+)?(?:\$(\d+))?/.match(command) return nil unless m table = construct_consumption_table(m[1]) cr = m[2].to_i modifier = ArithmeticEvaluator.eval(m[3]) table.fix_dice_value(m[4].to_i) if m[4] return table.roll(cr, modifier, @randomizer) end
roll_eastal_exploration_table(command)
click to toggle source
イースタル探索表
# File lib/bcdice/game_system/LogHorizon.rb, line 492 def roll_eastal_exploration_table(command) m = /ESTL(\d+)?([+\-\d]+)?(?:\$(\d+))?/.match(command) return nil unless m return nil if m[1].nil? && m[2].nil? && m[3].nil? character_rank = m[1].to_i modifier = ArithmeticEvaluator.eval(m[2]) fixed_dice_value = m[3]&.to_i dice_list = if fixed_dice_value [fixed_dice_value] elsif character_rank == 0 [] else @randomizer.roll_barabara(2, 6) end dice_str = "[#{dice_list.join(',')}]" unless dice_list.empty? total = (dice_list.sum() + character_rank * 5 + modifier).clamp(7, 162) table_name = translate("LogHorizon.ESTL.name") table = translate("LogHorizon.ESTL.items") chosen = table[total].chomp return "#{table_name}(#{total}#{dice_str})\n#{chosen}" end
roll_random_table(key)
click to toggle source
# File lib/bcdice/game_system/LogHorizon.rb, line 463 def roll_random_table(key) table = translate(key) tables = table[:tables] dice_list = @randomizer.roll_barabara(tables.size, 6) result = dice_list.map.with_index { |n, index| tables[index][n - 1] } return "#{table[:name]}([#{dice_list.join(',')}]) > #{result.join(' ')}" end
roll_treasure(command)
click to toggle source
財宝表ロール
# File lib/bcdice/game_system/LogHorizon.rb, line 249 def roll_treasure(command) m = /^TRS(\d+)?([+\-\d]+)?$/.match(command) return nil unless m character_rank = m[1].to_i modifier = ArithmeticEvaluator.eval(m[2]) dice_list = @randomizer.roll_barabara(2, 6) dice_total = dice_list.sum total = dice_total + character_rank * 5 + modifier return "(2D6+#{character_rank}*5#{Format.modifier(modifier)}) > "\ "#{dice_total}[#{dice_list.join(',')}]#{Format.modifier(character_rank * 5 + modifier)} > "\ "#{total}" end
roll_treasure_table(command)
click to toggle source
財宝表 ###
# File lib/bcdice/game_system/LogHorizon.rb, line 266 def roll_treasure_table(command) m = /^([CMIHG]TRS)(\d+)?([+\-\d]+)?(\$)?$/.match(command) return nil unless m type = m[1] table = construct_treasure_table(type) character_rank = m[2].to_i modifier = ArithmeticEvaluator.eval(m[3]) return translate("LogHorizon.TRS.need_cr", command: command) if character_rank == 0 && modifier == 0 table.fix_dice_value(7) if m[4] return table.roll(character_rank, modifier, @randomizer) end
roll_treasure_table_b2(command)
click to toggle source
拡張ルール財宝表
# File lib/bcdice/game_system/LogHorizon.rb, line 291 def roll_treasure_table_b2(command) m = /^([CMIO]TRSE)(\d+)?([+\-\d]+)?(\$)?$/.match(command) return nil unless m type = m[1] table = ExpansionTreasureTable.from_i18n("LogHorizon.TRSE.#{type}", @locale) character_rank = m[2].to_i modifier = ArithmeticEvaluator.eval(m[3]) return translate("LogHorizon.TRS.need_cr", command: command) if character_rank == 0 && modifier == 0 table.fix_dice_value(7) if m[4] return table.roll(character_rank, modifier, @randomizer) end