Class: BCDice::GameSystem::HarnMaster

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

Constant Summary collapse

ID =

ゲームシステムの識別子

'HarnMaster'
NAME =

ゲームシステム名

'ハーンマスター'
SORT_KEY =

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

'はあんますたあ'
HELP_MESSAGE =

ダイスボットの使い方

<<~MESSAGETEXT
  ・判定
   1D100<=XX の判定時に致命的失敗・決定的成功を判定
  ・ショック判定(SHKx)
   例)SHK13,3
  ・人型用 中段命中部位表 (SLH)/上段命中部位 (SLHU)/上段命中部位 (SLHD)
MESSAGETEXT

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, #initialize, prefixes_pattern, register_prefix, register_prefix_from_super_class, #sort_add_dice?, #sort_barabara_dice?

Methods included from Translate

#translate

Constructor Details

This class inherits a constructor from BCDice::Base

Instance Method Details

#eval_game_system_specific_command(command) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/bcdice/game_system/HarnMaster.rb', line 45

def eval_game_system_specific_command(command)
  result = nil

  case command
  when /^SHK(\d*),(\d+)/i
    toughness = Regexp.last_match(1).to_i
    damage = Regexp.last_match(2).to_i
    result = getCheckShockResult(damage, toughness)
  when /SLH(U|D)?/i
    type = Regexp.last_match(1)
    result = getStrikeLocationHuman(type)
  else
    result = nil
  end

  return result
rescue StandardError => e
  return e.message
end

#getCheckShockResult(damage, toughness) ⇒ Object



65
66
67
68
69
70
71
72
73
74
# File 'lib/bcdice/game_system/HarnMaster.rb', line 65

def getCheckShockResult(damage, toughness)
  dice_list = @randomizer.roll_barabara(damage, 6)
  dice = dice_list.sum()
  diceText = dice_list.join(",")

  result = (dice <= toughness ? '成功' : '失敗')

  text = "ショック判定(ダメージ:#{damage}, 耐久力:#{toughness}) > (#{dice}[#{diceText}]) > #{result}"
  return text
end

#getFaceLocation(part) ⇒ Object



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/bcdice/game_system/HarnMaster.rb', line 117

def getFaceLocation(part)
  debug("getFaceLocation part", part)

  unless part =~ /\+$/
    debug("is NOT Face")
    return part
  end

  debug("is Face")

  table = [
    [15, ""],
    [30, "*目"],
    [64, "*頬"],
    [80, ""],
    [90, "*耳"],
    [100, ""],
  ]

  number = @randomizer.roll_once(100)
  faceLocation = get_table_by_number(number, table)
  debug("faceLocation", faceLocation)
  debug("number", number)
  faceLocation = getLocationSide(faceLocation, number)

  result = part.sub(/\+$/, " > (#{number})#{faceLocation}")
  return result
end

#getLocationSide(part, number) ⇒ Object



104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/bcdice/game_system/HarnMaster.rb', line 104

def getLocationSide(part, number)
  unless part =~ /^\*/
    debug("part has NO side", part)
    return part
  end

  debug("part has side", part)

  side = (number.odd? ? "" : "")

  part.sub(/\*/, side)
end

#getStrikeLocationHuman(type) ⇒ Object



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/bcdice/game_system/HarnMaster.rb', line 76

def getStrikeLocationHuman(type)
  typeName = ''
  table = nil

  case type
  when 'U'
    typeName = "命中部位(人型 上段)"
    table = getStrikeLocationHumanUpperTable()
  when 'D'
    typeName = "命中部位(人型 下段)"
    table = getStrikeLocationHumanDownTable()
  when nil
    typeName = "命中部位(人型 中段)"
    table = getStrikeLocationHumanNormalTable()
  else
    raise "unknow atak type #{type}"
  end

  number = @randomizer.roll_once(100)
  part = get_table_by_number(number, table)
  part = getLocationSide(part, number)
  part = getFaceLocation(part)

  result = "#{typeName} > (#{number})#{part}"

  return result
end

#getStrikeLocationHumanDownTableObject



184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/bcdice/game_system/HarnMaster.rb', line 184

def getStrikeLocationHumanDownTable()
  table = [
    [6, "*前腕"],
    [12, "*手"],
    [19, "胸部"],
    [29, "腹部"],
    [35, "股間"],
    [49, "*臀部"],
    [70, "*腿"],
    [78, "*膝"],
    [92, "*脛"],
    [100, "*足"],
  ]
  return table
end

#getStrikeLocationHumanNormalTableObject



162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/bcdice/game_system/HarnMaster.rb', line 162

def getStrikeLocationHumanNormalTable()
  table = [
    [5, "頭部"],
    [10, "顔+"],
    [15, ""],
    [27, "*肩"],
    [33, "*上腕"],
    [35, "*肘"],
    [39, "*前腕"],
    [43, "*手"],
    [60, "胸部"],
    [70, "腹部"],
    [74, "股間"],
    [80, "*臀部"],
    [88, "*腿"],
    [90, "*膝"],
    [96, "*脛"],
    [100, "*足"],
  ]
  return table
end

#getStrikeLocationHumanUpperTableObject



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/bcdice/game_system/HarnMaster.rb', line 146

def getStrikeLocationHumanUpperTable()
  table = [
    [15, "頭部"],
    [30, "顔+"],
    [45, ""],
    [57, "*肩"],
    [69, "*上腕"],
    [73, "*肘"],
    [81, "*前腕"],
    [85, "*手"],
    [95, "胸部"],
    [100, "腹部"],
  ]
  return table
end

#result_1d100(total, _dice_total, cmp_op, target) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/bcdice/game_system/HarnMaster.rb', line 26

def result_1d100(total, _dice_total, cmp_op, target)
  return Result.nothing if target == '?'
  return nil unless cmp_op == :<=

  if total <= target
    if total % 5 == 0
      Result.critical("決定的成功")
    else
      Result.success("成功")
    end
  else
    if total % 5 == 0
      Result.fumble("致命的失敗")
    else
      Result.failure("失敗")
    end
  end
end