class BCDice::GameSystem::StarryDolls

Constants

FUMBLE
HELP_MESSAGE

ダイスボットの使い方

HOR_TABLE_A
HOR_TABLE_B
ID

ゲームシステムの識別子

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

  @d66_sort_type = D66SortType::ASC
end

Public Instance Methods

eval_game_system_specific_command(command) click to toggle source
# File lib/bcdice/game_system/StarryDolls.rb, line 53
def eval_game_system_specific_command(command)
  action_roll(command) ||
    roll_tables(command, TABLES) ||
    RTT.roll_command(@randomizer, command)
end

Private Instance Methods

action_roll(command) click to toggle source
# File lib/bcdice/game_system/StarryDolls.rb, line 75
def action_roll(command)
  parser = Command::Parser.new("D6", round_type: round_type)
                          .has_prefix_number
                          .restrict_cmp_op_to(:>=)
                          .enable_critical
                          .enable_question_target
  cmd = parser.parse(command)
  return nil unless cmd

  times = cmd.prefix_number
  return nil if times < 1

  fumble = 2
  special = cmd.critical || 12

  if special <= fumble
    special = fumble + 1 # p.180
    cmd.critical = special
  end

  dice_list = @randomizer.roll_barabara(times, 6)
  dice_total = dice_list.sum()
  total = dice_total + cmd.modify_number

  result =
    if dice_total <= fumble
      Result.fumble(FUMBLE)
    elsif dice_total >= special
      Result.critical(SPECIAL)
    elsif cmd.question_target?
      Result.new
    elsif total >= cmd.target_number
      Result.success("成功")
    else
      Result.failure("失敗")
    end

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

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