class BCDice::GameSystem::DeadlineHeroes
Constants
- CRITICAL_STR
- DEATH_CHARTS
- FAILURE_STR
- FUMBLE_STR
- HELP_MESSAGE
ダイスボットの使い方
- HERO_NAME_BASE_CHARTS
- HERO_NAME_ELEMENT_CHARTS
- HERO_NAME_TEMPLATES
- ID
ゲームシステムの識別子
- NAME
ゲームシステム名
- SORT_KEY
ゲームシステム名の読みがな
- SUCCESS_STR
- TABLES
Public Instance Methods
eval_game_system_specific_command(command)
click to toggle source
# File lib/bcdice/game_system/DeadlineHeroes.rb, line 42 def eval_game_system_specific_command(command) case command when /^DLH/i resolute_action(command) when /^DC\w/i roll_death_chart(command) when 'HNC' roll_hero_name_chart() else roll_tables(command, TABLES) end end
Private Instance Methods
action_result(total, tens, ones, success_rate)
click to toggle source
# File lib/bcdice/game_system/DeadlineHeroes.rb, line 86 def action_result(total, tens, ones, success_rate) if total == 100 || success_rate <= 0 Result.fumble(FUMBLE_STR) elsif total <= success_rate - 100 Result.critical(CRITICAL_STR) elsif tens == ones if total <= success_rate Result.critical(CRITICAL_STR) else Result.fumble(FUMBLE_STR) end elsif total <= success_rate Result.success(SUCCESS_STR) else Result.failure(FAILURE_STR) end end
resolute_action(command)
click to toggle source
# File lib/bcdice/game_system/DeadlineHeroes.rb, line 57 def resolute_action(command) m = /^DLH(\d+([+\-]\d+)*)$/.match(command) unless m return nil end success_rate = ArithmeticEvaluator.eval(m[1]) roll_result, dice10, dice01 = roll_d100 roll_result_text = format('%02d', roll_result) result = action_result(roll_result, dice10, dice01, success_rate) sequence = [ "行為判定(成功率:#{success_rate}%)", "1D100[#{dice10},#{dice01}]=#{roll_result_text}", roll_result_text.to_s, result.text ] result.text = sequence.join(" > ") result end
roll_d100()
click to toggle source
# File lib/bcdice/game_system/DeadlineHeroes.rb, line 104 def roll_d100 dice10 = @randomizer.roll_once(10) dice10 = 0 if dice10 == 10 dice01 = @randomizer.roll_once(10) dice01 = 0 if dice01 == 10 roll_result = dice10 * 10 + dice01 roll_result = 100 if roll_result == 0 return roll_result, dice10, dice01 end
roll_death_chart(command)
click to toggle source
# File lib/bcdice/game_system/DeadlineHeroes.rb, line 152 def roll_death_chart(command) m = /^DC([LSC])(\d+)$/i.match(command) unless m return m end chart = DEATH_CHARTS[m[1]] minus_score = m[2].to_i return chart.roll(@randomizer, minus_score) end
roll_hero_name_chart()
click to toggle source
# File lib/bcdice/game_system/DeadlineHeroes.rb, line 283 def roll_hero_name_chart() dice = @randomizer.roll_once(10) template = HERO_NAME_TEMPLATES[dice - 1] template_result = "ヒーローネームチャート(#{dice}) > #{template[:text]}" if template[:text] == "任意" return template_result end results = [template_result] elements = [] template[:elements].each do |type| base_chart = HERO_NAME_BASE_CHARTS[type] unless base_chart elements.push(type) next end result, element = base_chart.roll(@randomizer) results.push(result) elements.push(element) end hero_name = elements.join("").gsub(/・{2,}/, "・").sub(/・$/, "") results.push("ヒーローネーム > #{hero_name}") return results.join("\n") end