Class: BCDice::GameSystem::Skynauts
- Inherits:
-
Base
- Object
- Base
- BCDice::GameSystem::Skynauts
show all
- Defined in:
- lib/bcdice/game_system/Skynauts.rb
Constant Summary
collapse
- ID =
'Skynauts'
- NAME =
'歯車の塔の探空士'
- SORT_KEY =
'すかいのおつ'
- HELP_MESSAGE =
<<~MESSAGETEXT
◆判定 (SNn)、(2D6<=n) n:目標値(省略時:7)
例)SN5 SN5 SN(3+2)
◆航行チェック (NV+n) n:修正値(省略時:0)
例)NV NV+1
◆ダメージチェック (Dx/y@m) x:ダメージ左側の値、y:ダメージ右側の値
m:《弾道学》(省略可)上:8、下:2、左:4、右:6
飛空艇シート外の座標は()が付きます。
例) D/4 D19/2 D/3@8 D[大揺れ]/2
◆砲撃判定+ダメージチェック (BOMn/Dx/y@m) n:目標値(省略時:7)
x:ダメージ左側の値、y:ダメージ右側の値
m:《弾道学》(省略可)上:8、下:2、左:4、右:6
例) BOM/D/4 BOM9/D19/2@4
◆《回避運動》 (AVOn@mXX) n:目標値(省略時:7)
m:回避方向。上:8、下:2、左:4、右:6、XX:ダメージチェック結果
例)
AVO9@8[縦1,横4],[縦2,横6],[縦3,横8] AVO@2[縦6,横4],[縦2,横6]
MESSAGETEXT
- DIRECTION_INFOS =
{
1 => {name: "左下", position_diff: {x: -1, y: +1}},
2 => {name: "下", position_diff: {x: 0, y: +1}},
3 => {name: "右下", position_diff: {x: +1, y: +1}},
4 => {name: "左", position_diff: {x: -1, y: 0}},
6 => {name: "右", position_diff: {x: +1, y: 0}},
7 => {name: "左上", position_diff: {x: -1, y: -1}},
8 => {name: "上", position_diff: {x: 0, y: -1}},
9 => {name: "右上", position_diff: {x: +1, y: -1}},
}.freeze
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) ⇒ Skynauts
Returns a new instance of Skynauts.
37
38
39
40
|
# File 'lib/bcdice/game_system/Skynauts.rb', line 37
def initialize(command)
super(command)
@round_type = RoundType::FLOOR end
|
Instance Method Details
#eval_game_system_specific_command(command) ⇒ Object
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
|
# File 'lib/bcdice/game_system/Skynauts.rb', line 42
def eval_game_system_specific_command(command)
debug("\n=======================================\n")
debug("eval_game_system_specific_command command", command)
result = getJudgeResult(command)
return result unless result.nil?
result = navigationResult(command)
return result unless result.nil?
result = getFireResult(command)
return result unless result.nil?
result = getBomberResult(command)
return result unless result.nil?
result = getAvoidResult(command)
return result unless result.nil?
debug("rollCommand result")
return nil
end
|
#getAvoidResult(command) ⇒ Object
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
|
# File 'lib/bcdice/game_system/Skynauts.rb', line 262
def getAvoidResult(command)
return nil unless (m = /^AVO(\d*)?(@([2468]))(\(?\[縦\d+,横\d+\]\)?,?)+$/.match(command))
debug("====getAvoidResult====", command)
direction = m[3].to_i
debug("回避方向", direction)
judgeCommand = command.slice(/^AVO(\d*)?(@([2468]))/) text = "#{judgeCommand} > 《回避運動》"
text += getJudgeResult("SN" + Regexp.last_match(1).to_s)
return text unless text =~ /成功/
pointCommand = command.slice(/(\(?\[縦\d+,横\d+\]\)?,?)+/)
firePoint = scanFirePoints(pointCommand)
fireCount = firePoint.size
text += "\n > #{pointCommand}"
text += " > 《回避運動》:"
text += getDirectionInfo(direction, :name, "")
text += "\n > "
text += getFirePointText(firePoint, fireCount, direction)
return text
end
|
#getBomberResult(command) ⇒ Object
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
|
# File 'lib/bcdice/game_system/Skynauts.rb', line 240
def getBomberResult(command)
return nil unless (m = %r{^BOM(\d*)?/D([12346789]*)(\[.+\])*/(\d+)(@([2468]))?$}i.match(command))
debug("====getBomberResult====", command)
target = m[1].to_s
direction = m[6].to_i
debug("弾道学方向", direction)
text = "#{command} > "
text += getJudgeResult("SN" + target)
return text unless text =~ /成功/
fireCommand = command.slice(%r{D([12346789]*)(\[.+\])*/(\d+)(@([2468]))?})
text += "\n > #{getFireResult(fireCommand)}"
return text
end
|
#getDirectionInfo(direction, key, defaultValue = nil) ⇒ Object
126
127
128
129
130
131
|
# File 'lib/bcdice/game_system/Skynauts.rb', line 126
def getDirectionInfo(direction, key, defaultValue = nil)
info = DIRECTION_INFOS[direction.to_i]
return defaultValue if info.nil?
return info[key]
end
|
#getFirePoint(fireRange, fireCount) ⇒ Object
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
# File 'lib/bcdice/game_system/Skynauts.rb', line 163
def getFirePoint(fireRange, fireCount)
debug("====getFirePoint====")
firePoint = []
fireCount.times do |count|
debug("\n砲撃回数", count + 1)
firePoint << []
yPos = @randomizer.roll_once(6) xPos = @randomizer.roll_sum(2, 6) position = [xPos, yPos]
firePoint[-1] << position
debug("着弾点", firePoint)
fireRange.split(//).each do |rangeText|
debug("範囲", rangeText)
position_diff = getDirectionInfo(rangeText, :position_diff, {})
position = [xPos + position_diff[:x].to_i, yPos + position_diff[:y].to_i]
firePoint[-1] << position
debug("着弾点:範囲", firePoint)
end
end
debug("\n最終着弾点", firePoint)
return firePoint
end
|
#getFirePointText(firePoint, _fireCount, direction = 0) ⇒ Object
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
|
# File 'lib/bcdice/game_system/Skynauts.rb', line 197
def getFirePointText(firePoint, _fireCount, direction = 0)
debug("====getFirePointText====")
fireTextList = []
firePoint.each do |point|
text = ""
point.each do |x, y|
x, y = getMovePoint(x, y, direction)
text += (isInMapPosition(x, y) ? "[縦#{y},横#{x}]" : "([縦#{y},横#{x}])")
debug("着弾点テキスト", text)
end
fireTextList << text
end
fireText = fireTextList.join(",")
debug("\n最終着弾点テキスト", fireText)
return fireText
end
|
#getFireResult(command) ⇒ Object
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
# File 'lib/bcdice/game_system/Skynauts.rb', line 133
def getFireResult(command)
return nil unless (m = %r{^D([12346789]*)(\[.+\])*/(\d+)(@([2468]))?$}.match(command))
debug("====getFireResult====")
fireCount = m[3].to_i fireRange = m[1].to_s ballistics = m[5].to_i debug("fireCount", fireCount)
debug("fireRange", fireRange)
debug("ballistics", ballistics)
fireCountMax = 25
fireCount = [fireCount, fireCountMax].min
firePoint = getFirePoint(fireRange, fireCount) fireText = getFirePointText(firePoint, fireCount)
if ballistics != 0 fireText += " > 《弾道学》:"
fireText += getDirectionInfo(ballistics, :name, "")
fireText += "\n > "
fireText += getFirePointText(firePoint, fireCount, ballistics)
end
text = "#{command} > #{fireText}"
return text
end
|
#getJudgeResult(command) ⇒ Object
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/bcdice/game_system/Skynauts.rb', line 70
def getJudgeResult(command)
return nil unless (m = (/^2D6<=(\d)$/i.match(command) || /^SN(\d*)$/i.match(command)))
debug("====getJudgeResult====")
target = m[1].empty? ? 7 : m[1].to_i debug("目標値", target)
dice_list = @randomizer.roll_barabara(2, 6)
total = dice_list.sum()
diceText = dice_list.join(",")
if total <= 2
result = "ファンブル"
elsif total <= target
result = "成功"
else
result = "失敗"
end
text = "(2D6<=#{target}) > #{total}[#{diceText}] > #{total} > #{result}"
return text
end
|
#getMovePoint(x, y, direction) ⇒ Object
225
226
227
228
229
230
231
232
233
234
235
236
237
238
|
# File 'lib/bcdice/game_system/Skynauts.rb', line 225
def getMovePoint(x, y, direction)
debug("====getMovePoint====")
debug("方向", direction)
debug("座標移動前x", x)
debug("座標移動前y", y)
position_diff = getDirectionInfo(direction, :position_diff, {})
x += position_diff[:x].to_i
y += position_diff[:y].to_i
debug("\n座標移動後x", x)
debug("座標移動後y", y)
return x, y
end
|
#isInMapPosition(x, y) ⇒ Object
221
222
223
|
# File 'lib/bcdice/game_system/Skynauts.rb', line 221
def isInMapPosition(x, y)
((1 <= y) && (y <= 6)) && ((2 <= x) && (x <= 12))
end
|
#navigationResult(command) ⇒ Object
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
# File 'lib/bcdice/game_system/Skynauts.rb', line 95
def navigationResult(command)
return nil unless (m = /^NV(\+(\d+))?$/.match(command))
debug("====navigationResult====")
bonus = m[2].to_i debug("移動修正", bonus)
total = @randomizer.roll_once(6)
movePointBase = (total / 2) <= 0 ? 1 : (total / 2)
movePoint = movePointBase + bonus
debug("移動エリア数", movePoint)
text = "航行チェック(最低1) (1D6/2+#{bonus}) > #{total} /2+#{bonus} > "
text += "#{movePointBase}+#{bonus} > #{movePoint}エリア進む"
return text
end
|
#scanFirePoints(command) ⇒ Object
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
|
# File 'lib/bcdice/game_system/Skynauts.rb', line 290
def scanFirePoints(command)
debug("====scanFirePoints====", command)
command = command.gsub(/\(|\)/, "")
firePoint = []
command.split(/\],/).each do |pointText|
debug("pointText", pointText)
firePoint << []
pointText.split(/\]/).each do |point|
debug("point", point)
firePoint[-1] << []
next unless point =~ /[^\d]*(\d+),[^\d]*(\d+)/
y = Regexp.last_match(1).to_i
x = Regexp.last_match(2).to_i
firePoint[-1][-1] = [x, y]
debug("着弾点", firePoint)
end
end
return firePoint
end
|