class BCDice::GameSystem::TorgEternity
Constants
- HELP_MESSAGE
ダイスボットの使い方
- ID
ゲームシステムの識別子
- NAME
ゲームシステム名
- SORT_KEY
ゲームシステム名の読みがな
Public Instance Methods
eval_game_system_specific_command(command)
click to toggle source
# File lib/bcdice/game_system/TorgEternity.rb, line 46 def eval_game_system_specific_command(command) torg_check(command) || getRolld20DiceCommandResult(command) || getUpRollDiceCommandResult(command) || getPossibilityRollDiceCommandResult(command) || getBonusDamageDiceCommandResult(command) || getSuccessLevelDiceCommandResult(command) || getDamageResultDiceCommandResult(command) || getRollBonusDiceCommandResult(command) end
getBonusDamageDiceCommandResult(command)
click to toggle source
ダメージボーナスコマンド
# File lib/bcdice/game_system/TorgEternity.rb, line 174 def getBonusDamageDiceCommandResult(command) debug("TorgEternity Bonus Damage Roll Command ? ", command) m = /(\d+)(BD)(([+\-]\d+)*)/i.match(command) unless m return nil end number_bonus_die = m[1].to_i value_modifier, output_modifier = get_torg_eternity_modifier(m[3]) if number_bonus_die <= 0 output = "エラーです。xBD (x≧1) として下さい" else value_roll, output_roll = get_torg_eternity_damage_bonus_dice(number_bonus_die) output_value = value_roll + value_modifier output = "ボーナスダメージロール(#{number_bonus_die}BD#{output_modifier}) > #{value_roll}[#{output_roll}]#{output_modifier} > #{output_value}ダメージ" end return output end
getDamageResultDiceCommandResult(command)
click to toggle source
ダメージ結果表コマンド
# File lib/bcdice/game_system/TorgEternity.rb, line 214 def getDamageResultDiceCommandResult(command) debug("TorgEternity Damage Result Table Command ? ", command) m = /(DT|Damage)(-*\d+([+\-]\d+)*)/i.match(command) unless m return nil end value = ArithmeticEvaluator.eval(m[2]) debug(value) output = get_torg_eternity_damage_result(value) output = "ダメージ結果表[#{value}] > #{output}" debug(output) return output end
getPossibilityRollDiceCommandResult(command)
click to toggle source
ロールコマンド (ポシビリティロール)
# File lib/bcdice/game_system/TorgEternity.rb, line 151 def getPossibilityRollDiceCommandResult(command) debug("Torg Eternity Possibility Roll Command ? ", command) m = /(^|\s)(S)?(POS)((\d+)(\+\d+)?)/i.match(command) unless m return nil end output_modifier = ArithmeticEvaluator.eval(m[4]) skilled, unskilled, dice_str, = torg_eternity_dice(true, false) subtotal_skilled = skilled + output_modifier subtotal_unskilled = unskilled + output_modifier value_skilled = format("%+d", get_torg_eternity_bonus(subtotal_skilled)) if subtotal_skilled != subtotal_unskilled value_unskilled = format("%+d", get_torg_eternity_bonus(subtotal_unskilled)) output = "d20ロール(ポシビリティ) > #{output_modifier}+1d20[#{dice_str}] > #{value_skilled}[#{subtotal_skilled}](技能有) / #{value_unskilled}[#{subtotal_unskilled}](技能無)" else output = "d20ロール(ポシビリティ) > #{output_modifier}+1d20[#{dice_str}] > #{value_skilled}[#{subtotal_skilled}]" end return output end
getRollBonusDiceCommandResult(command)
click to toggle source
ロールボーナス表コマンド
# File lib/bcdice/game_system/TorgEternity.rb, line 230 def getRollBonusDiceCommandResult(command) debug("TorgEternity Roll Bonus Table Command ? ", command) m = /(BT|Bonus|Total)(\d+)(([+\-]\d+)*)/i.match(command) unless m return nil end value_roll = m[2].to_i output_bonus = get_torg_eternity_bonus(value_roll) debug(output_bonus) value_modifier, output_modifier = get_torg_eternity_modifier(m[3]) if value_roll <= 1 output = "ロールボーナス表[#{value_roll}] > Mishap!!" elsif output_modifier.empty? output = "ロールボーナス表[#{value_roll}] > #{output_bonus}" else value_result = output_bonus.to_i + value_modifier debug(value_result) output = "ロールボーナス表[#{value_roll}]#{output_modifier} > #{output_bonus}[#{value_roll}]#{output_modifier} > #{value_result}" end debug(output) return output end
getRolld20DiceCommandResult(command)
click to toggle source
TORG Eternity ########################
ロールコマンド (通常ロール)
# File lib/bcdice/game_system/TorgEternity.rb, line 100 def getRolld20DiceCommandResult(command) debug("Torg Eternity Dice Roll Command ? ", command) m = /(^|\s)(S)?(TE)$/i.match(command) unless m return nil end skilled, unskilled, dice_str, mishap = torg_eternity_dice(false, true) if mishap == 1 output = "d20ロール(通常) > 1d20[#{dice_str}] > Mishap! 絶対失敗!" else value_skilled = format("%+d", get_torg_eternity_bonus(skilled)) if skilled != unskilled value_unskilled = format("%+d", get_torg_eternity_bonus(unskilled)) output = "d20ロール(通常) > 1d20[#{dice_str}] > #{value_skilled}[#{skilled}](技能有) / #{value_unskilled}[#{unskilled}](技能無)" else output = "d20ロール(通常) > 1d20[#{dice_str}] > #{value_skilled}[#{skilled}]" end end return output end
getSuccessLevelDiceCommandResult(command)
click to toggle source
成功レベル表コマンド
# File lib/bcdice/game_system/TorgEternity.rb, line 194 def getSuccessLevelDiceCommandResult(command) debug("TorgEternity Success Level Table Command ? ", command) m = /(RT|Result)(-*\d+([+\-]\d+)*)/i.match(command) unless m return nil end value = ArithmeticEvaluator.eval(m[2]) debug(value) if value < 0 output = "Failure." else output = get_torg_eternity_success_level(value) end output = "成功レベル表[#{value}] > #{output}" debug(output) return output end
getUpRollDiceCommandResult(command)
click to toggle source
ロールコマンド (高揚ロール)
# File lib/bcdice/game_system/TorgEternity.rb, line 124 def getUpRollDiceCommandResult(command) debug("Torg Eternity Dice Roll ( UP ) Command ? ", command) m = /(^|\s)(S)?(UP)$/i.match(command) unless m return nil end skilled1, unskilled1, dice_str1, mishap = torg_eternity_dice(false, true) if mishap == 1 output = "d20ロール(高揚) > 1d20[#{dice_str1}] > Mishap! 絶対失敗!" else skilled2, unskilled2, dice_str2, = torg_eternity_dice(false, false) subtotal_skilled = skilled1 + skilled2 subtotal_unskilled = unskilled1 + unskilled2 value_skilled = format("%+d", get_torg_eternity_bonus(subtotal_skilled)) if subtotal_skilled != subtotal_unskilled value_unskilled = format("%+d", get_torg_eternity_bonus(subtotal_unskilled)) output = "d20ロール(高揚) > 1d20[#{dice_str1}] + 1d20[#{dice_str2}] > #{value_skilled}[#{subtotal_skilled}](技能有) / #{value_unskilled}[#{subtotal_unskilled}](技能無)" else output = "d20ロール(高揚) > 1d20[#{dice_str1}] + 1d20[#{dice_str2}] > #{value_skilled}[#{subtotal_skilled}]" end end return output end
get_torg_eternity_bonus(value)
click to toggle source
# File lib/bcdice/game_system/TorgEternity.rb, line 385 def get_torg_eternity_bonus(value) bonus_table = [ [1, -10], [2, -8], [3, -6], [5, -4], [7, -2], [9, -1], [11, 0], [13, 1], [15, 2], [16, 3], [17, 4], [18, 5], [19, 6], [20, 7] ] bonus = get_torg_eternity_table_result(value, bonus_table) if value > 20 over_value_bonus = ((value - 21) / 5).to_i + 1 bonus += over_value_bonus end return bonus end
get_torg_eternity_damage_bonus_dice(number)
click to toggle source
ボーナスダイスロールサブルーチン
# File lib/bcdice/game_system/TorgEternity.rb, line 323 def get_torg_eternity_damage_bonus_dice(number) debug("bonus dice roll : #{number}") value_roll = 0 output_roll = "" if number > 0 value_roll = 0 output_roll = "" while number > 0 output_roll = "#{output_roll}," unless output_roll.empty? dice_value = @randomizer.roll_once(6) dice_text = dice_value.to_s if dice_value == 6 dice_value = 5 dice_text = "5∞" number += 1 end value_roll += dice_value output_roll = "#{output_roll}#{dice_text}" debug(value_roll) debug(output_roll) number -= 1 end else output_roll = "0" end debug(value_roll) debug(output_roll) return value_roll, output_roll end
get_torg_eternity_damage_result(value)
click to toggle source
ダメージチャート
# File lib/bcdice/game_system/TorgEternity.rb, line 366 def get_torg_eternity_damage_result(value) damage_table = [ [-50, "ノーダメージ"], [-5, "1ショック"], [0, "2ショック"], [5, "1レベル負傷 + 2ショック"], [10, "2レベル負傷 + 4ショック"], [15, "3レベル負傷 + 6ショック"], [20, "4レベル負傷 + 8ショック"], [25, "5レベル負傷 + 10ショック"], [30, "6レベル負傷 + 12ショック"], [35, "7レベル負傷 + 14ショック"], [40, "8レベル負傷 + 16ショック"], [45, "9レベル負傷 + 18ショック"], [50, "10レベル負傷 + 20ショック"] ] return get_torg_eternity_table_result(value, damage_table) end
get_torg_eternity_modifier(string_modifier)
click to toggle source
修正式計算サブルーチン
# File lib/bcdice/game_system/TorgEternity.rb, line 268 def get_torg_eternity_modifier(string_modifier) debug("modifier check : #{string_modifier}") if string_modifier == '' value_modifier = 0 output_modifier = "" else value_modifier = ArithmeticEvaluator.eval(string_modifier) output_modifier = format("%+d", value_modifier) end debug(value_modifier) debug(output_modifier) return value_modifier, output_modifier end
get_torg_eternity_success_level(value)
click to toggle source
成功レベル表
# File lib/bcdice/game_system/TorgEternity.rb, line 356 def get_torg_eternity_success_level(value) success_table = [ [0, "Success - Standard."], [5, "Success - Good!"], [10, "Success - Outstanding!!"] ] return get_torg_eternity_table_result(value, success_table) end
get_torg_eternity_table_result(value, table)
click to toggle source
# File lib/bcdice/game_system/TorgEternity.rb, line 254 def get_torg_eternity_table_result(value, table) output = nil table.each do |item| item_index = item[0] if item_index > value break end output = item[1] end return output end
replace_text(string)
click to toggle source
TORG 1.x ########################
# File lib/bcdice/game_system/TorgEternity.rb, line 58 def replace_text(string) string = string.gsub(/TG(\d+)/i) { "1R20+#{Regexp.last_match(1)}" } string = string.gsub(/TG/i, '1R20') return string end
torg_check(string)
click to toggle source
# File lib/bcdice/game_system/TorgEternity.rb, line 64 def torg_check(string) string = replace_text(string) m = /(^|\s)S?(1R20(([+-]\d+)*))(\s|$)/i.match(string) unless m return nil end string = m[2] mod = m[3] debug(mod) mod = ArithmeticEvaluator.eval(mod) if mod debug(mod) mod = mod.to_i skilled, unskilled, dice_str, = torg_eternity_dice(false, false) sk_bonus = get_torg_eternity_bonus(skilled) if mod if mod > 0 output = "#{sk_bonus}[#{dice_str}]+#{mod}" else output = "#{sk_bonus}[#{dice_str}]#{mod}" end else output = "#{sk_bonus}[#{dice_str}]" end output += " > " + (sk_bonus + mod).to_s if skilled != unskilled output += "(技能無" + (get_torg_eternity_bonus(unskilled) + mod).to_s + ")" end output = "(#{string}) > #{output}" return output end
torg_eternity_dice(check_pos, check_mishap)
click to toggle source
d20ロールサブルーチン
# File lib/bcdice/game_system/TorgEternity.rb, line 283 def torg_eternity_dice(check_pos, check_mishap) isSkilledCritical = true isCritical = true skilled = 0 unskilled = 0 mishap = 0 dice_str = "" while isSkilledCritical dice_str += "," unless dice_str.empty? dice_n = @randomizer.roll_once(20) if check_pos if dice_n < 10 dice_str_now = "#{dice_n}→10" dice_n = 10 isSkilledCritical = false else dice_str_now = dice_n.to_s end dice_str += dice_str_now else dice_str += dice_n.to_s end skilled += dice_n unskilled += dice_n if isCritical if dice_n == 20 isCritical = false elsif dice_n != 10 isSkilledCritical = false isCritical = false if check_mishap & (dice_n == 1) mishap = 1 end end check_pos = false check_mishap = false end return skilled, unskilled, dice_str, mishap end