class BCDice::GameSystem::ShinobiGami

Constants

DEMON_SKILL_TABLES

妖魔忍法表A, B, C

HELP_MESSAGE

ダイスボットの使い方

ID

ゲームシステムの識別子

METAMORPHOSE_TABLE

異形表

NAME

ゲームシステム名

RTT
SORT_KEY

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

SPECIAL
TABLES

Public Class Methods

new(command) click to toggle source
Calls superclass method BCDice::Base::new
# File lib/bcdice/game_system/ShinobiGami.rb, line 47
def initialize(command)
  super(command)

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

Public Instance Methods

eval_game_system_specific_command(command) click to toggle source
# File lib/bcdice/game_system/ShinobiGami.rb, line 74
def eval_game_system_specific_command(command)
  result = action_roll(command) || roll_tables(command, TABLES) || RTT.roll_command(@randomizer, command)
  return result if result
  return sinobigami_metamorphose_table() if command == 'MT'

  nil
end
result_2d6(total, dice_total, _dice_list, cmp_op, target) click to toggle source
# File lib/bcdice/game_system/ShinobiGami.rb, line 56
def result_2d6(total, dice_total, _dice_list, cmp_op, target)
  return nil unless cmp_op == :>=

  if dice_total <= 2
    Result.fumble("ファンブル")
  elsif dice_total >= 12
    Result.critical(SPECIAL)
  elsif target == "?"
    nil
  elsif total >= target
    Result.success("成功")
  else
    Result.failure("失敗")
  end
end

Private Instance Methods

action_roll(command) click to toggle source
# File lib/bcdice/game_system/ShinobiGami.rb, line 97
def action_roll(command)
  parser = Command::Parser.new(/\d*SG/, round_type: round_type)
                          .restrict_cmp_op_to(:>=, nil)
                          .enable_critical
                          .enable_fumble
  cmd = parser.parse(command)
  return nil unless cmd

  times = cmd.command.start_with?(/\d/) ? cmd.command.to_i : 2
  return nil if times <= 1

  cmd.critical ||= 12
  cmd.fumble ||= 2

  dice_list_full = @randomizer.roll_barabara(times, 6).sort
  dice_list_full_str = "[#{dice_list_full.join(',')}]" if times > 2

  dice_list = dice_list_full[-2, 2]
  dice_total = dice_list.sum()
  total = dice_total + cmd.modify_number

  result =
    if dice_total <= cmd.fumble
      Result.fumble("ファンブル")
    elsif dice_total >= cmd.critical
      Result.critical(SPECIAL)
    elsif cmd.cmp_op.nil?
      Result.new
    elsif total >= cmd.target_number
      Result.success("成功")
    else
      Result.failure("失敗")
    end

  sequence = [
    "(#{cmd.to_s(:after_modify_number)})",
    dice_list_full_str,
    "#{dice_total}[#{dice_list.join(',')}]#{Format.modifier(cmd.modify_number)}",
    total,
    result.text
  ].compact

  result.text = sequence.join(" > ")
  result
end
sinobigami_metamorphose_table() click to toggle source

異形表

# File lib/bcdice/game_system/ShinobiGami.rb, line 144
def sinobigami_metamorphose_table()
  text, value = get_table_by_1d6(METAMORPHOSE_TABLE)
  output = "異形表(#{value}) > #{text}"

  if (demon_skill_table = DEMON_SKILL_TABLES[value - 1])
    text, = get_table_by_1d6(demon_skill_table[:table])
    output += " #{demon_skill_table[:name]} > #{text}#{demon_skill_table[:page]}"
  end

  return output
end