class BCDice::GameSystem::MonotoneMuseum

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

  # 式、出目ともに送信する

  # D66ダイスあり(出目をソートしない)
  @d66_sort_type = D66SortType::NO_SORT
  # バラバラロール(Bコマンド)でソートする
  @sort_add_dice = true
end

Private Class Methods

translate_tables(locale) click to toggle source
# File lib/bcdice/game_system/MonotoneMuseum.rb, line 132
def translate_tables(locale)
  {
    "ET" => DiceTable::D66GridTable.from_i18n("MonotoneMuseum.table.ET", locale),
    "ET2" => DiceTable::D66GridTable.from_i18n("MonotoneMuseum.table.ET2", locale),
    "OT" => DiceTable::Table.from_i18n("MonotoneMuseum.table.OT", locale),
    "DT" => DiceTable::Table.from_i18n("MonotoneMuseum.table.DT", locale),
    "DT2" => MMTable.from_i18n("MonotoneMuseum.table.DT2", locale),
    "WDT" => DiceTable::Table.from_i18n("MonotoneMuseum.table.WDT", locale),
    "WDT2" => MMTable.from_i18n("MonotoneMuseum.table.WDT2", locale),
    "OT2" => MMTable.from_i18n("MonotoneMuseum.table.OT2", locale),
    "DTO" => MMTable.from_i18n("MonotoneMuseum.table.DTO", locale),
    "DTS" => MMTable.from_i18n("MonotoneMuseum.table.DTS", locale),
    "EDT" => DiceTable::Table.from_i18n("MonotoneMuseum.table.EDT", locale),
    "DTM" => MMTable.from_i18n("MonotoneMuseum.table.DTM", locale),
    "OT3" => DiceTable::Table.from_i18n("MonotoneMuseum.table.OT3", locale),
  }
end

Public Instance Methods

eval_game_system_specific_command(command) click to toggle source

固有のダイスロールコマンドを実行する @param [String] command 入力されたコマンド @return [String, nil] ダイスロールコマンドの実行結果

# File lib/bcdice/game_system/MonotoneMuseum.rb, line 51
def eval_game_system_specific_command(command)
  if (ret = check_roll(command))
    return ret
  end

  return roll_tables(command, self.class::TABLES)
end

Private Instance Methods

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

  dice_count = m[1].to_i
  modify_number = m[2] ? ArithmeticEvaluator.eval(m[2]) : 0
  target = m[3].to_i
  critical = m[5]&.to_i || 12
  fumble = m[7]&.to_i || 2

  dice_list = @randomizer.roll_barabara(dice_count, 6).sort
  dice_value = dice_list.sum()
  dice_str = dice_list.join(",")
  total = dice_value + modify_number

  result =
    if dice_value <= fumble
      Result.fumble(translate("MonotoneMuseum.automatic_failure"))
    elsif dice_value >= critical
      Result.critical(translate("MonotoneMuseum.automatic_success"))
    elsif total >= target
      Result.success(translate("success"))
    else
      Result.failure(translate("failure"))
    end

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

  result.text = sequence.join(" > ")

  result
end