class BCDice::GameSystem::AngelGear

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

  @sort_barabara_dice = true # バラバラロール(Bコマンド)でソート有
end

Public Instance Methods

eval_game_system_specific_command(command) click to toggle source
# File lib/bcdice/game_system/AngelGear.rb, line 38
def eval_game_system_specific_command(command)
  if (m = /^(\d+)AG(\d+)?(([+\-]\d+)*)$/.match(command))
    resolute_action(m[1].to_i, m[2]&.to_i, m[3], command)
  else
    roll_tables(command, TABLES)
  end
end
resolute_action(num_dice, skill_value, modify, command) click to toggle source
# File lib/bcdice/game_system/AngelGear.rb, line 46
def resolute_action(num_dice, skill_value, modify, command)
  dice = @randomizer.roll_barabara(num_dice, 6).sort
  dice_text = dice.join(",")
  modify_n = 0
  success = 0
  if skill_value
    success = dice.count { |val| val <= skill_value }
    modify_n = Arithmetic.eval(modify, RoundType::FLOOR) unless modify.empty?
  end

  gospel = '(福音発生)' if success + modify_n >= 100

  output = "(#{command}) > #{success}[#{dice_text}]#{format('%+d', modify_n)} > 成功数: #{success + modify_n}#{gospel}"

  if success + modify_n >= 100
    Result.critical(output)
  elsif 0 < success + modify_n
    Result.success(output)
  else
    Result.failure(output)
  end
end