class BCDice::GameSystem::RecordOfLodossWar

Constants

HELP_MESSAGE
ID
NAME
SORT_KEY

Public Instance Methods

eval_game_system_specific_command(command) click to toggle source
# File lib/bcdice/game_system/RecordOfLodossWar.rb, line 24
def eval_game_system_specific_command(command)
  parser = Command::Parser.new("LWD", "LW", round_type: round_type)
                          .restrict_cmp_op_to(nil, :<=)
  cmd = parser.parse(command)

  if cmd.nil? || ![nil, :<=].include?(cmd.cmp_op)
    return nil
  end

  auto_failure = cmd.command == "LWD" ? 51 : 91
  critical = (cmd.target_number.to_f / 10).ceil

  dice_value = @randomizer.roll_once(100)

  result =
    if dice_value >= auto_failure
      "自動失敗(#{auto_failure})"
    elsif dice_value <= critical
      "大成功(#{critical})"
    elsif dice_value <= 10
      "自動成功"
    elsif cmd.cmp_op
      dice_value <= cmd.target_number ? "成功" : "失敗"
    end

  sequence = [
    "(1D100#{cmd.cmp_op}#{cmd.target_number})",
    dice_value.to_s,
    result
  ].compact

  return sequence.join(" > ")
end