class BCDice::GameSystem::RuinBreakers

Constants

HELP_MESSAGE

ダイスボットの使い方

ID

ゲームシステムの識別子

NAME

ゲームシステム名

SORT_KEY

ゲームシステム名の読みがな

TABLES

Public Instance Methods

eval_game_system_specific_command(command) click to toggle source
# File lib/bcdice/game_system/RuinBreakers.rb, line 49
def eval_game_system_specific_command(command)
  case command
  when /^RB/
    check_roll(command)
  when /^FPD/
    roll_fp_damage(command)
  when /^FPR/
    roll_fp_recovery(command)
  else
    roll_tables(command, TABLES)
  end
end

Private Instance Methods

check_roll(command) click to toggle source
# File lib/bcdice/game_system/RuinBreakers.rb, line 64
def check_roll(command)
  m = %r{^RB(-?\d+([+\-*/]\d+)*)(@(\d+))?(#(\d+))?$}.match(command)
  unless m
    return nil
  end

  success_rate = ArithmeticEvaluator.eval(m[1])
  critical_border = m[4]&.to_i || [success_rate / 5, 1].max
  fumble_border = m[6]&.to_i || (success_rate < 100 ? 96 : 99)

  total = @randomizer.roll_once(100)

  result = Result.new

  compare_result =
    if total >= fumble_border
      result.fumble = true
      result.failure = true
      'ファンブル'
    elsif total == 1 || total <= critical_border
      result.critical = true
      result.success = true
      'クリティカル'
    elsif total <= success_rate
      result.success = true
      '成功'
    else
      result.failure = true
      '失敗'
    end

  sequence = [
    "(1D100<=#{success_rate}@#{critical_border}##{fumble_border})",
    total,
    compare_result
  ]

  result.text = sequence.join(" > ")
  result
end
roll_fp_damage(command) click to toggle source
# File lib/bcdice/game_system/RuinBreakers.rb, line 105
def roll_fp_damage(command)
  m = /^FPD(\d+)$/.match(command)
  unless m
    return nil
  end

  ruin_point = m[1].to_i
  ruin_point_tens, ruin_point_ones = ruin_point.divmod(10)

  dice_list = @randomizer.roll_barabara(1 + ruin_point_tens, 10)
  total = dice_list.sum()
  dice_str = dice_list.join(",")

  sequence = [
    "((1+#{ruin_point_tens})D10+#{ruin_point_ones})",
    "#{total}[#{dice_str}]+#{ruin_point_ones}",
    "#{total + ruin_point_ones}ダメージ"
  ]

  return sequence.join(" > ")
end
roll_fp_recovery(command) click to toggle source
# File lib/bcdice/game_system/RuinBreakers.rb, line 127
def roll_fp_recovery(command)
  m = /^FPR(\d+)$/.match(command)
  unless m
    return nil
  end

  ruin_point = m[1].to_i
  dice_count = ruin_point.fdiv(10).ceil

  dice_list = @randomizer.roll_barabara(dice_count, 10)
  total = dice_list.sum()
  dice_str = dice_list.join(",")

  sequence = [
    "(#{dice_count}D10)",
    "#{total}[#{dice_str}]",
    "#{total}回復"
  ]

  return sequence.join(" > ")
end