class BCDice::GameSystem::CrashWorld

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/CrashWorld.rb, line 24
def eval_game_system_specific_command(command)
  result = nil

  case command
  when /CW(\d+)/i
    result = getCrashWorldRoll(Regexp.last_match(1).to_i)
  end

  return result
end
getCrashWorldRoll(target) click to toggle source
# File lib/bcdice/game_system/CrashWorld.rb, line 35
def getCrashWorldRoll(target)
  debug("target", target)

  output = "("
  isEnd = false
  successness = 0
  num = 0

  while !isEnd
    num = @randomizer.roll_once(12)

    # 振った数字を出力へ書き足す
    if output == "("
      output = "(#{num}"
    else
      output = "#{output}, #{num}"
    end

    if num <= target || num == 11
      # 成功/クリティカル(11)。 次回の目標値を変更して継続
      target = num
      successness += 1
    elsif num == 12
      # ファンブルなら終了。
      isEnd = true
    else
      # target < num < 11で終了
      isEnd = true
    end
  end

  if num == 12
    # ファンブルの時、成功度は0
    successness = 0
  end

  output = "#{output})  成功度 : #{successness}"

  if num == 12
    output = "#{output} ファンブル"
  end

  return output
end