class BCDice::GameSystem::Garako

Constants

DAMAGE_CHARTS
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/Garako.rb, line 42
def initialize(command)
  super(command)

  @sides_implicit_d = 10
end

Public Instance Methods

eval_game_system_specific_command(command) click to toggle source

@param command [String] @return [String, nil]

# File lib/bcdice/game_system/Garako.rb, line 50
def eval_game_system_specific_command(command)
  roll_tables(command, TABLES) ||
    roll_gr(command) ||
    roll_damage_chart(command) ||
    roll_attack_hit(command)
end

Private Instance Methods

roll_attack_hit(command) click to toggle source

ダメージ算出+部位決定チャート

@param command [String] @return [String, nil]

# File lib/bcdice/game_system/Garako.rb, line 108
def roll_attack_hit(command)
  m = /^GHA([-+\d]+)$/i.match(command)
  return nil unless m

  modifier = ArithmeticEvaluator.eval(m[1])
  attack = @randomizer.roll_once(10)
  total = attack + modifier
  hit_text = "#{total}(ダメージを受けない)"
  if total > 0
    hit = TABLES["HIT"].roll(@randomizer)
    hit_dice = ", HIT[#{hit.value}]"
    hit_text = "#{hit.body}に #{total} -【部位装甲】"
  end

  formated_modifier = Format.modifier(modifier)
  sequence = [
    "(1D10#{formated_modifier})",
    "#{attack}[#{attack}]#{formated_modifier}#{hit_dice}",
    hit_text
  ]

  return sequence.join(" > ")
end
roll_damage_chart(command) click to toggle source

部位ダメージチャート

@param command [String] @return [String, nil]

# File lib/bcdice/game_system/Garako.rb, line 136
def roll_damage_chart(command)
  m = /^([CEFAL]D[CT])([-+\d]+)$/i.match(command)
  return nil unless m

  chart = DAMAGE_CHARTS[m[1]]
  damage = ArithmeticEvaluator.eval(m[2]).clamp(0, 10)
  return "ダメージを受けない" if damage <= 0

  result = chart[:table][damage - 1]
  return "#{chart[:name]}(#{damage}) > #{result}"
end
roll_gr(command) click to toggle source

判定

@param command [String] @return [String, nil]

# File lib/bcdice/game_system/Garako.rb, line 63
def roll_gr(command)
  parser = Command::Parser.new("GR", round_type: round_type)
                          .enable_fumble
                          .restrict_cmp_op_to(nil, :>=)
  cmd = parser.parse(command)
  return nil unless cmd

  modify_number = cmd.modify_number || 0
  auto_failure_number = cmd.fumble || 1
  target_number = cmd.target_number

  dice = @randomizer.roll_once(10)
  total = dice + modify_number

  result =
    if dice == 1
      "ファンブル"
    elsif dice <= auto_failure_number # 公式FAQより、ファンブルと自動失敗を区別する可能性があるので分岐
      "自動失敗"
    elsif dice == 10
      "クリティカル"
    elsif target_number && total >= target_number
      "成功"
    elsif target_number
      "失敗"
    end

  formated_modifier = Format.modifier(modify_number)
  formated_auto_failure = "##{auto_failure_number}" if auto_failure_number >= 2
  format_target = ">=#{target_number}" if target_number

  sequence = [
    "(1D10#{formated_modifier}#{formated_auto_failure}#{format_target})",
    "#{dice}[#{dice}]#{formated_modifier}",
    total.to_s,
    result
  ]

  return sequence.compact.join(" > ")
end