class BCDice::GameSystem::TwilightGunsmoke

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/TwilightGunsmoke.rb, line 43
def initialize(command)
  super(command)

  @d66_sort_type = D66SortType::NO_SORT
  @sort_add_dice = true
end

Public Instance Methods

eval_game_system_specific_command(command) click to toggle source
# File lib/bcdice/game_system/TwilightGunsmoke.rb, line 50
def eval_game_system_specific_command(command)
  if (ret = check_roll(command))
    return ret
  end

  return roll_tables(command, TABLES)
end

Private Instance Methods

check_roll(command) click to toggle source
# File lib/bcdice/game_system/TwilightGunsmoke.rb, line 60
def check_roll(command)
  m = /^2D6([+\-\d]*)>=(\d+)(\[(\d+)?(,(\d+))?\])?$/i.match(command)
  unless m
    return nil
  end

  modify_number = m[1] ? ArithmeticEvaluator.eval(m[1]) : 0
  target = m[2].to_i
  critical = (m[4] || 12).to_i
  fumble = (m[6] || 2).to_i

  dice_list = @randomizer.roll_barabara(2, 6).sort
  dice_value = dice_list.sum()
  dice_str = dice_list.join(",")

  total = dice_value + modify_number

  result =
    if dice_value >= critical
      "自動成功"
    elsif dice_value <= fumble
      "自動失敗"
    elsif total >= target
      "成功"
    else
      "失敗"
    end

  sequence = [
    "(#{command})",
    "#{dice_value}[#{dice_str}]#{Format.modifier(modify_number)}",
    total.to_s,
    result,
  ]

  return sequence.join(" > ")
end