class BCDice::GameSystem::NightmareHunterDeep

Constants

HELP_MESSAGE

ダイスボットの使い方

ID

ゲームシステムの識別子

NAME

ゲームシステム名

SORT_KEY

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

Public Class Methods

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

  @sort_add_dice = true
end

Public Instance Methods

dice_revision(dice_list) click to toggle source
# File lib/bcdice/game_system/NightmareHunterDeep.rb, line 106
def dice_revision(dice_list)
  count6 = dice_list.count(6)
  if count6 > 0
    return "+#{count6}*4", count6 * 4
  else
    return nil, 0
  end
end
eval_game_system_specific_command(command) click to toggle source
# File lib/bcdice/game_system/NightmareHunterDeep.rb, line 40
def eval_game_system_specific_command(command)
  command = command
            .sub(/Lv(\d+)/i) { (Regexp.last_match(1).to_i * 5 - 1).to_s }
            .sub(/NL(\d+)/i) { (Regexp.last_match(1).to_i * 5 + 5).to_s }

  parser = Command::Parser.new(/\d+D6/, round_type: round_type)
                          .restrict_cmp_op_to(nil, :>=)
                          .enable_question_target()
  cmd = parser.parse(command)
  unless cmd
    return nil
  end

  times = cmd.command.to_i

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

  suffix, revision = dice_revision(dice_list)
  total += revision

  target = cmd.question_target? ? "?" : cmd.target_number
  result = result_text(total, cmd.cmp_op, target)

  sequence = [
    "(#{cmd})",
    interim_expr(cmd, dice_total, dice_list),
    expr_with_revision(dice_total + cmd.modify_number, suffix),
    total,
    result,
    fate(dice_list),
  ].compact

  return sequence.join(" > ")
end
expr_with_revision(total, suffix) click to toggle source
# File lib/bcdice/game_system/NightmareHunterDeep.rb, line 102
def expr_with_revision(total, suffix)
  suffix ? "#{total}#{suffix}" : nil
end
fate(dice_list) click to toggle source

ナイトメアハンターディープ用宿命表示

# File lib/bcdice/game_system/NightmareHunterDeep.rb, line 91
def fate(dice_list)
  dice_list.count(1) > 0 ? "宿命獲得" : nil
end
interim_expr(cmd, dice_total, dice_list) click to toggle source
# File lib/bcdice/game_system/NightmareHunterDeep.rb, line 95
def interim_expr(cmd, dice_total, dice_list)
  if dice_list.size > 1 || cmd.modify_number != 0
    modifier = Format.modifier(cmd.modify_number)
    "#{dice_total}[#{dice_list.join(',')}]#{modifier}"
  end
end
result_text(total, cmp_op, target) click to toggle source
# File lib/bcdice/game_system/NightmareHunterDeep.rb, line 77
def result_text(total, cmp_op, target)
  return nil unless cmp_op == :>=

  if target != "?"
    return total >= target ? "成功" : "失敗"
  end

  success_lv = (total + 1) / 5
  success_nl = (total - 5) / 5

  return success_lv > 0 ? "Lv#{success_lv}/NL#{success_nl}成功" : "失敗"
end