Class: BCDice::GameSystem::Cthulhu7th_ChineseTraditional
- Inherits:
-
Base
- Object
- Base
- BCDice::GameSystem::Cthulhu7th_ChineseTraditional
show all
- Defined in:
- lib/bcdice/game_system/Cthulhu7th_ChineseTraditional.rb
Constant Summary
collapse
- ID =
'Cthulhu7th:ChineseTraditional'
- NAME =
'克蘇魯神話第7版'
- SORT_KEY =
'国際化:Chinese Traditional:克蘇魯神話第7版'
- HELP_MESSAGE =
<<~INFO_MESSAGE_TEXT
・判定 CC(x)<=(目標値)
x:獎勵骰/懲罰骰:Bonus/Penalty Dice (2~-2)。沒有的話可以省略。
致命的失敗:Fumble/失敗:Failure/通常成功:Regular success/
困難成功:Hard success/極限成功:Extreme success/
決定性的成功:Critical success 自動判定。
例)CC<=30 CC(2)<=50 CC(-1)<=75
・組合判定 (CBR(x,y))
進行目標値 x 和 y 的判定。
例)CBR(50,20)
・連射(Full Auto)判定 FAR(w,x,y,z)
w:彈數(1~100)、x:技能値(1~100)、y:故障率
z:獎勵、懲罰骰(-2~2)。可省略。
只計算命中數、貫穿數及剩餘彈藥,不計算傷害。
例)FAR(25,70,98) FAR(50,80,98,-1)
・瘋狂表
・實時型 Short/總結型 Longer
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
-
#eval_game_system_specific_command(command) ⇒ Object
-
#getBulletResults(bullet_count, hit_type, diff) ⇒ Object
-
#getCheckResult(command) ⇒ Object
-
#getCheckResultText(total, diff, fumbleable = false) ⇒ Object
-
#getCombineRoll(command) ⇒ Object
-
#getFullAutoResult(command) ⇒ Object
-
#getFumbleable(more_difficlty) ⇒ Object
-
#getHitBulletCountBase(diff, bullet_set_count) ⇒ Object
-
#getHitResultInfos(dice_num, diff, more_difficlty) ⇒ Object
-
#getHitResultText(output, counts) ⇒ Object
-
#getHitType(more_difficlty, hit_result) ⇒ Object
-
#getLastHitBulletCount(bullet_count) ⇒ Object
-
#getNextDifficltyMessage(more_difficlty) ⇒ Object
-
#getSetOfBullet(diff) ⇒ Object
-
#getSuccessListImpaleBulletList(more_difficlty) ⇒ Object
-
#getTotal(total_list, bonus_dice_count) ⇒ Object
-
#getTotalLists(bonus_dice_count, units_digit) ⇒ Object
-
#initialize(command) ⇒ Cthulhu7th_ChineseTraditional
constructor
A new instance of Cthulhu7th_ChineseTraditional.
-
#isLastBulletTurn(bullet_count, bullet_set_count) ⇒ Object
-
#rollFullAuto(bullet_count, diff, broken_number, dice_num) ⇒ Object
-
#rollPercentD10 ⇒ Object
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
Returns a new instance of Cthulhu7th_ChineseTraditional.
40
41
42
43
44
|
# File 'lib/bcdice/game_system/Cthulhu7th_ChineseTraditional.rb', line 40
def initialize(command)
super(command)
@bonus_dice_range = (-2..2)
end
|
Instance Method Details
#eval_game_system_specific_command(command) ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/bcdice/game_system/Cthulhu7th_ChineseTraditional.rb', line 46
def eval_game_system_specific_command(command)
case command
when /CC/i
return getCheckResult(command)
when /CBR/i
return getCombineRoll(command)
when /FAR/i
return getFullAutoResult(command)
end
return nil
end
|
#getBulletResults(bullet_count, hit_type, diff) ⇒ Object
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
|
# File 'lib/bcdice/game_system/Cthulhu7th_ChineseTraditional.rb', line 270
def getBulletResults(bullet_count, hit_type, diff)
bullet_set_count = getSetOfBullet(diff)
hit_bullet_count_base = getHitBulletCountBase(diff, bullet_set_count)
impale_bullet_count_base = (bullet_set_count / 2.to_f)
lost_bullet_count = 0
hit_bullet_count = 0
impale_bullet_count = 0
if !isLastBulletTurn(bullet_count, bullet_set_count)
case hit_type
when :hit
hit_bullet_count = hit_bullet_count_base
when :impale
hit_bullet_count = impale_bullet_count_base.floor
impale_bullet_count = impale_bullet_count_base.ceil end
lost_bullet_count = bullet_set_count
else
case hit_type
when :hit
hit_bullet_count = getLastHitBulletCount(bullet_count)
when :impale
halfbull = bullet_count / 2.to_f
hit_bullet_count = halfbull.floor
impale_bullet_count = halfbull.ceil
end
lost_bullet_count = bullet_count
end
return hit_bullet_count, impale_bullet_count, lost_bullet_count
end
|
#getCheckResult(command) ⇒ Object
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/bcdice/game_system/Cthulhu7th_ChineseTraditional.rb', line 59
def getCheckResult(command)
nil unless /^CC([-\d]+)?<=(\d+)/i =~ command
bonus_dice_count = Regexp.last_match(1).to_i diff = Regexp.last_match(2).to_i
return "錯誤。目標值需為1以上。" if diff <= 0
unless @bonus_dice_range.include?(bonus_dice_count)
return "錯誤。獎勵、懲罰骰値為#{@bonus_dice_range.min}~#{@bonus_dice_range.max}。"
end
output = ""
output += "(1D100<=#{diff})"
output += " 獎勵、懲罰骰値[#{bonus_dice_count}]"
units_digit = rollPercentD10
total_list = getTotalLists(bonus_dice_count, units_digit)
total = getTotal(total_list, bonus_dice_count)
result_text = getCheckResultText(total, diff)
output += " > #{total_list.join(', ')} > #{total} > #{result_text}"
return output
end
|
#getCheckResultText(total, diff, fumbleable = false) ⇒ Object
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
# File 'lib/bcdice/game_system/Cthulhu7th_ChineseTraditional.rb', line 113
def getCheckResultText(total, diff, fumbleable = false)
if total <= diff
return "決定性的成功" if total == 1
return "極限的成功" if total <= (diff / 5)
return "困難的成功" if total <= (diff / 2)
return "通常成功"
end
fumble_text = "致命的失敗"
return fumble_text if total == 100
if total >= 96
if diff < 50
return fumble_text
else
return fumble_text if fumbleable
end
end
return "失敗"
end
|
#getCombineRoll(command) ⇒ Object
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
162
163
164
165
|
# File 'lib/bcdice/game_system/Cthulhu7th_ChineseTraditional.rb', line 137
def getCombineRoll(command)
return nil unless /CBR\((\d+),(\d+)\)/i =~ command
diff_1 = Regexp.last_match(1).to_i
diff_2 = Regexp.last_match(2).to_i
total = @randomizer.roll_once(100)
result_1 = getCheckResultText(total, diff_1)
result_2 = getCheckResultText(total, diff_2)
successList = ["決定性的成功", "極限的成功", "困難的成功", "通常成功"]
succesCount = 0
succesCount += 1 if successList.include?(result_1)
succesCount += 1 if successList.include?(result_2)
debug("succesCount", succesCount)
rank =
if succesCount >= 2
"成功"
elsif succesCount == 1
"部分的成功"
else
"失敗"
end
return "(1d100<=#{diff_1},#{diff_2}) > #{total}[#{result_1},#{result_2}] > #{rank}"
end
|
#getFullAutoResult(command) ⇒ Object
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
196
197
198
199
200
|
# File 'lib/bcdice/game_system/Cthulhu7th_ChineseTraditional.rb', line 167
def getFullAutoResult(command)
return nil unless /^FAR\((-?\d+)(,(-?\d+))(,(-?\d+))(,(-?\d+))?\)/i =~ command
bullet_count = Regexp.last_match(1).to_i
diff = Regexp.last_match(3).to_i
broken_number = Regexp.last_match(5).to_i
bonus_dice_count = (Regexp.last_match(7) || 0).to_i
output = ""
bullet_count_limit = 100
if bullet_count > bullet_count_limit
output += "\n彈藥太多。請改裝填#{bullet_count_limit}發。\n"
bullet_count = bullet_count_limit
end
return "正確裝填數。" if bullet_count <= 0
return "正確目標值。" if diff <= 0
if broken_number < 0
output += "\n正確故障值。排除獎勵記號。\n"
broken_number = broken_number.abs
end
unless @bonus_dice_range.include?(bonus_dice_count)
return "\n錯誤。獎勵、懲罰骰値為#{@bonus_dice_range.min}~#{@bonus_dice_range.max}です。"
end
output += "獎勵、懲罰骰値[#{bonus_dice_count}]"
output += rollFullAuto(bullet_count, diff, broken_number, bonus_dice_count)
return output
end
|
#getFumbleable(more_difficlty) ⇒ Object
380
381
382
383
|
# File 'lib/bcdice/game_system/Cthulhu7th_ChineseTraditional.rb', line 380
def getFumbleable(more_difficlty)
return (more_difficlty >= 1)
end
|
#getHitBulletCountBase(diff, bullet_set_count) ⇒ Object
356
357
358
359
360
361
362
363
364
|
# File 'lib/bcdice/game_system/Cthulhu7th_ChineseTraditional.rb', line 356
def getHitBulletCountBase(diff, bullet_set_count)
hit_bullet_count_base = (bullet_set_count / 2)
if (diff >= 1) && (diff < 10)
hit_bullet_count_base = 1 end
return hit_bullet_count_base
end
|
#getHitResultInfos(dice_num, diff, more_difficlty) ⇒ Object
246
247
248
249
250
251
252
253
254
255
|
# File 'lib/bcdice/game_system/Cthulhu7th_ChineseTraditional.rb', line 246
def getHitResultInfos(dice_num, diff, more_difficlty)
units_digit = rollPercentD10
total_list = getTotalLists(dice_num, units_digit)
total = getTotal(total_list, dice_num)
fumbleable = getFumbleable(more_difficlty)
hit_result = getCheckResultText(total, diff, fumbleable)
return hit_result, total, total_list
end
|
#getHitResultText(output, counts) ⇒ Object
257
258
259
|
# File 'lib/bcdice/game_system/Cthulhu7th_ChineseTraditional.rb', line 257
def getHitResultText(output, counts)
return "#{output}\n> #{counts[:hit_bullet]}發射擊命中、#{counts[:impale_bullet]}射擊貫穿、剩餘彈藥#{counts[:bullet]}發"
end
|
#getHitType(more_difficlty, hit_result) ⇒ Object
261
262
263
264
265
266
267
268
|
# File 'lib/bcdice/game_system/Cthulhu7th_ChineseTraditional.rb', line 261
def getHitType(more_difficlty, hit_result)
successList, impaleBulletList = getSuccessListImpaleBulletList(more_difficlty)
return :hit if successList.include?(hit_result)
return :impale if impaleBulletList.include?(hit_result)
return ""
end
|
#getLastHitBulletCount(bullet_count) ⇒ Object
370
371
372
373
374
375
376
377
378
|
# File 'lib/bcdice/game_system/Cthulhu7th_ChineseTraditional.rb', line 370
def getLastHitBulletCount(bullet_count)
if bullet_count == 1
return 1
end
count = (bullet_count / 2.to_f).floor
return count
end
|
#getNextDifficltyMessage(more_difficlty) ⇒ Object
333
334
335
336
337
338
339
340
341
342
343
344
|
# File 'lib/bcdice/game_system/Cthulhu7th_ChineseTraditional.rb', line 333
def getNextDifficltyMessage(more_difficlty)
case more_difficlty
when 1
return "\n 變更難度為困難的成功"
when 2
return "\n 變更難度為極限的成功"
when 3
return "\n 變更難度為決定性的成功"
end
return ""
end
|
#getSetOfBullet(diff) ⇒ Object
346
347
348
349
350
351
352
353
354
|
# File 'lib/bcdice/game_system/Cthulhu7th_ChineseTraditional.rb', line 346
def getSetOfBullet(diff)
bullet_set_count = diff / 10
if (diff >= 1) && (diff < 10)
bullet_set_count = 1 end
return bullet_set_count
end
|
#getSuccessListImpaleBulletList(more_difficlty) ⇒ Object
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
|
# File 'lib/bcdice/game_system/Cthulhu7th_ChineseTraditional.rb', line 311
def getSuccessListImpaleBulletList(more_difficlty)
successList = []
impaleBulletList = []
case more_difficlty
when 0
successList = ["困難的成功", "通常成功"]
impaleBulletList = ["決定性的成功", "極限的成功"]
when 1
successList = ["困難的成功"]
impaleBulletList = ["決定性的成功", "極限的成功"]
when 2
successList = []
impaleBulletList = ["決定性的成功", "極限的成功"]
when 3
successList = ["決定性的成功"]
impaleBulletList = []
end
return successList, impaleBulletList
end
|
#getTotal(total_list, bonus_dice_count) ⇒ Object
107
108
109
110
111
|
# File 'lib/bcdice/game_system/Cthulhu7th_ChineseTraditional.rb', line 107
def getTotal(total_list, bonus_dice_count)
return total_list.min if bonus_dice_count >= 0
return total_list.max
end
|
#getTotalLists(bonus_dice_count, units_digit) ⇒ Object
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
# File 'lib/bcdice/game_system/Cthulhu7th_ChineseTraditional.rb', line 92
def getTotalLists(bonus_dice_count, units_digit)
total_list = []
tens_digit_count = 1 + bonus_dice_count.abs
tens_digit_count.times do
bonus = rollPercentD10
total = (bonus * 10) + units_digit
total = 100 if total == 0
total_list.push(total)
end
return total_list
end
|
#isLastBulletTurn(bullet_count, bullet_set_count) ⇒ Object
366
367
368
|
# File 'lib/bcdice/game_system/Cthulhu7th_ChineseTraditional.rb', line 366
def isLastBulletTurn(bullet_count, bullet_set_count)
((bullet_count - bullet_set_count) < 0)
end
|
#rollFullAuto(bullet_count, diff, broken_number, dice_num) ⇒ Object
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
|
# File 'lib/bcdice/game_system/Cthulhu7th_ChineseTraditional.rb', line 202
def rollFullAuto(bullet_count, diff, broken_number, dice_num)
output = ""
loopCount = 0
counts = {
hit_bullet: 0,
impale_bullet: 0,
bullet: bullet_count,
}
4.times do |more_difficlty|
output += getNextDifficltyMessage(more_difficlty)
while dice_num >= @bonus_dice_range.min
loopCount += 1
hit_result, total, total_list = getHitResultInfos(dice_num, diff, more_difficlty)
output += "\n#{loopCount}次: > #{total_list.join(', ')} > #{hit_result}"
if total >= broken_number
output += "卡彈"
return getHitResultText(output, counts)
end
hit_type = getHitType(more_difficlty, hit_result)
hit_bullet, impale_bullet, lost_bullet = getBulletResults(counts[:bullet], hit_type, diff)
counts[:hit_bullet] += hit_bullet
counts[:impale_bullet] += impale_bullet
counts[:bullet] -= lost_bullet
return getHitResultText(output, counts) if counts[:bullet] <= 0
dice_num -= 1
end
dice_num += 1
end
return getHitResultText(output, counts)
end
|
#rollPercentD10 ⇒ Object
85
86
87
88
89
90
|
# File 'lib/bcdice/game_system/Cthulhu7th_ChineseTraditional.rb', line 85
def rollPercentD10
dice = @randomizer.roll_once(10)
dice = 0 if dice == 10
return dice
end
|