Class: BCDice::GameSystem::NightmareHunterDeep

Inherits:
Base
  • Object
show all
Defined in:
lib/bcdice/game_system/NightmareHunterDeep.rb

Constant Summary collapse

ID =

ゲームシステムの識別子

'NightmareHunterDeep'
NAME =

ゲームシステム名

'ナイトメアハンター=ディープ'
SORT_KEY =

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

'ないとめあはんたあていいふ'
HELP_MESSAGE =

ダイスボットの使い方

<<~INFO_MESSAGE_TEXT
  判定(xD6+y>=a, xD6+y, xD6)
    出目6の個数をカウントして、その4倍を合計値に加算します。
    また、宿命を獲得したか表示します。

    Lv目標値 (xD6+y>=LVn, xD6+y>=NLn)
      レベルで目標値を指定することができます。
      LVn -> n*5+1, NLn -> n*5+5 に変換されます。
    目標値'?' (xD6+y>=?)
      目標値を '?' にすると何Lv成功か、何NL成功かを表示します。

  ※判定コマンドは xD6 から始まる必要があります。また xD6 が複数あると反応しません。
INFO_MESSAGE_TEXT

Instance Attribute Summary

Attributes inherited from Base

#d66_sort_type, #default_cmp_op, #default_target_number, #randomizer, #reroll_dice_reroll_threshold, #round_type, #sides_implicit_d, #upper_dice_reroll_threshold

Instance Method Summary collapse

Methods inherited from Base

#change_text, #check_result, command_pattern, #enable_debug, #enabled_d9?, #eval, eval, #grich_text, prefixes_pattern, register_prefix, register_prefix_from_super_class, #sort_add_dice?, #sort_barabara_dice?

Methods included from Translate

#translate

Constructor Details

#initialize(command) ⇒ NightmareHunterDeep

Returns a new instance of NightmareHunterDeep.



34
35
36
37
38
# File 'lib/bcdice/game_system/NightmareHunterDeep.rb', line 34

def initialize(command)
  super(command)

  @sort_add_dice = true
end

Instance Method Details

#dice_revision(dice_list) ⇒ Object



106
107
108
109
110
111
112
113
# 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) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# 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) ⇒ Object



102
103
104
# File 'lib/bcdice/game_system/NightmareHunterDeep.rb', line 102

def expr_with_revision(total, suffix)
  suffix ? "#{total}#{suffix}" : nil
end

#fate(dice_list) ⇒ Object

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



91
92
93
# 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) ⇒ Object



95
96
97
98
99
100
# 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) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
# 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