bcdice 3.1.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +78 -1
  3. data/README.md +1 -1
  4. data/i18n/MagicaLogia/zh_hans.yml +564 -0
  5. data/i18n/StellarKnights/ja_jp.yml +498 -0
  6. data/i18n/StellarKnights/ko_kr.yml +498 -0
  7. data/i18n/zh_hans.yml +7 -0
  8. data/lib/bcdice/command/parsed.rb +11 -3
  9. data/lib/bcdice/command/parser.rb +179 -100
  10. data/lib/bcdice/common_command/add_dice.rb +1 -1
  11. data/lib/bcdice/common_command/barabara_dice/node.rb +2 -2
  12. data/lib/bcdice/common_command/barabara_dice/result.rb +6 -0
  13. data/lib/bcdice/common_command/calc.rb +1 -1
  14. data/lib/bcdice/dice_table.rb +2 -0
  15. data/lib/bcdice/dice_table/d66_half_grid_table.rb +33 -0
  16. data/lib/bcdice/dice_table/d66_one_third_table.rb +34 -0
  17. data/lib/bcdice/dice_table/sai_fic_skill_table.rb +1 -1
  18. data/lib/bcdice/game_system.rb +6 -0
  19. data/lib/bcdice/game_system/AceKillerGene.rb +1 -1
  20. data/lib/bcdice/game_system/Ainecadette.rb +68 -0
  21. data/lib/bcdice/game_system/Airgetlamh.rb +1 -1
  22. data/lib/bcdice/game_system/Alsetto.rb +1 -1
  23. data/lib/bcdice/game_system/AlterRaise.rb +2 -2
  24. data/lib/bcdice/game_system/Amadeus.rb +110 -93
  25. data/lib/bcdice/game_system/AngelGear.rb +2 -2
  26. data/lib/bcdice/game_system/AnimaAnimus.rb +16 -9
  27. data/lib/bcdice/game_system/Arianrhod.rb +6 -8
  28. data/lib/bcdice/game_system/Avandner.rb +1 -1
  29. data/lib/bcdice/game_system/BarnaKronika.rb +1 -1
  30. data/lib/bcdice/game_system/BattleTech.rb +109 -28
  31. data/lib/bcdice/game_system/BeastBindTrinity.rb +28 -12
  32. data/lib/bcdice/game_system/BeginningIdol.rb +5 -5
  33. data/lib/bcdice/game_system/BeginningIdol_Korean.rb +5 -5
  34. data/lib/bcdice/game_system/BladeOfArcana.rb +1 -1
  35. data/lib/bcdice/game_system/BlindMythos.rb +39 -38
  36. data/lib/bcdice/game_system/BloodCrusade.rb +6 -7
  37. data/lib/bcdice/game_system/BloodMoon.rb +9 -8
  38. data/lib/bcdice/game_system/CardRanker.rb +8 -7
  39. data/lib/bcdice/game_system/ChaosFlare.rb +21 -15
  40. data/lib/bcdice/game_system/Chill.rb +10 -10
  41. data/lib/bcdice/game_system/Chill3.rb +9 -9
  42. data/lib/bcdice/game_system/CodeLayerd.rb +39 -39
  43. data/lib/bcdice/game_system/ColossalHunter.rb +34 -47
  44. data/lib/bcdice/game_system/CrashWorld.rb +1 -1
  45. data/lib/bcdice/game_system/Cthulhu.rb +1 -1
  46. data/lib/bcdice/game_system/Cthulhu7th.rb +48 -10
  47. data/lib/bcdice/game_system/Cthulhu7th_ChineseTraditional.rb +2 -2
  48. data/lib/bcdice/game_system/Cthulhu7th_Korean.rb +2 -2
  49. data/lib/bcdice/game_system/Cthulhu_ChineseTraditional.rb +1 -1
  50. data/lib/bcdice/game_system/Cthulhu_Korean.rb +1 -1
  51. data/lib/bcdice/game_system/DarkBlaze.rb +0 -11
  52. data/lib/bcdice/game_system/DarkDaysDrive.rb +8 -7
  53. data/lib/bcdice/game_system/DeadlineHeroes.rb +11 -10
  54. data/lib/bcdice/game_system/DemonParasite.rb +5 -13
  55. data/lib/bcdice/game_system/DesperateRun.rb +1 -1
  56. data/lib/bcdice/game_system/DoubleCross.rb +3 -1
  57. data/lib/bcdice/game_system/Dracurouge.rb +1 -1
  58. data/lib/bcdice/game_system/EclipsePhase.rb +14 -14
  59. data/lib/bcdice/game_system/Elric.rb +18 -14
  60. data/lib/bcdice/game_system/Elysion.rb +1 -1
  61. data/lib/bcdice/game_system/EmbryoMachine.rb +9 -8
  62. data/lib/bcdice/game_system/Emoklore.rb +25 -20
  63. data/lib/bcdice/game_system/Fiasco.rb +1 -1
  64. data/lib/bcdice/game_system/FilledWith.rb +205 -1272
  65. data/lib/bcdice/game_system/FutariSousa.rb +12 -10
  66. data/lib/bcdice/game_system/GURPS.rb +17 -28
  67. data/lib/bcdice/game_system/Garako.rb +1 -1
  68. data/lib/bcdice/game_system/GardenOrder.rb +12 -7
  69. data/lib/bcdice/game_system/GeishaGirlwithKatana.rb +1 -1
  70. data/lib/bcdice/game_system/GoblinSlayer.rb +1 -1
  71. data/lib/bcdice/game_system/Gorilla.rb +2 -8
  72. data/lib/bcdice/game_system/GranCrest.rb +18 -11
  73. data/lib/bcdice/game_system/Gundog.rb +9 -8
  74. data/lib/bcdice/game_system/GundogRevised.rb +10 -9
  75. data/lib/bcdice/game_system/GundogZero.rb +1 -1
  76. data/lib/bcdice/game_system/GurpsFW.rb +16 -16
  77. data/lib/bcdice/game_system/HarnMaster.rb +19 -26
  78. data/lib/bcdice/game_system/HatsuneMiku.rb +1 -1
  79. data/lib/bcdice/game_system/Hieizan.rb +12 -21
  80. data/lib/bcdice/game_system/HouraiGakuen.rb +1 -1
  81. data/lib/bcdice/game_system/HuntersMoon.rb +5 -10
  82. data/lib/bcdice/game_system/InfiniteFantasia.rb +19 -17
  83. data/lib/bcdice/game_system/Insane.rb +13 -20
  84. data/lib/bcdice/game_system/IthaWenUa.rb +8 -15
  85. data/lib/bcdice/game_system/JamesBond.rb +10 -10
  86. data/lib/bcdice/game_system/JekyllAndHyde.rb +1 -1
  87. data/lib/bcdice/game_system/Kamigakari.rb +1 -1
  88. data/lib/bcdice/game_system/KanColle.rb +4 -9
  89. data/lib/bcdice/game_system/KemonoNoMori.rb +26 -39
  90. data/lib/bcdice/game_system/KillDeathBusiness.rb +7 -15
  91. data/lib/bcdice/game_system/KurayamiCrying.rb +141 -2
  92. data/lib/bcdice/game_system/LiveraDoll.rb +254 -304
  93. data/lib/bcdice/game_system/LogHorizon.rb +13 -10
  94. data/lib/bcdice/game_system/MagicaLogia_SimplifiedChinese.rb +66 -0
  95. data/lib/bcdice/game_system/MeikyuDays.rb +10 -8
  96. data/lib/bcdice/game_system/MeikyuKingdom.rb +26 -26
  97. data/lib/bcdice/game_system/MeikyuKingdomBasic.rb +5 -4
  98. data/lib/bcdice/game_system/MetalHead.rb +12 -22
  99. data/lib/bcdice/game_system/MetalHeadExtream.rb +5 -5
  100. data/lib/bcdice/game_system/MonotoneMuseum.rb +8 -6
  101. data/lib/bcdice/game_system/Nechronica.rb +63 -90
  102. data/lib/bcdice/game_system/NinjaSlayer.rb +6 -7
  103. data/lib/bcdice/game_system/NjslyrBattle.rb +8 -11
  104. data/lib/bcdice/game_system/OneWayHeroics.rb +1 -1
  105. data/lib/bcdice/game_system/Paradiso.rb +3 -3
  106. data/lib/bcdice/game_system/ParasiteBlood.rb +1 -1
  107. data/lib/bcdice/game_system/Peekaboo.rb +4 -9
  108. data/lib/bcdice/game_system/Pendragon.rb +7 -7
  109. data/lib/bcdice/game_system/PhantasmAdventure.rb +8 -8
  110. data/lib/bcdice/game_system/Postman.rb +1 -1
  111. data/lib/bcdice/game_system/PulpCthulhu.rb +1 -1
  112. data/lib/bcdice/game_system/Raisondetre.rb +2 -2
  113. data/lib/bcdice/game_system/Revulture.rb +123 -0
  114. data/lib/bcdice/game_system/RuneQuest.rb +8 -8
  115. data/lib/bcdice/game_system/Ryutama.rb +1 -1
  116. data/lib/bcdice/game_system/SRS.rb +17 -16
  117. data/lib/bcdice/game_system/SamsaraBallad.rb +38 -11
  118. data/lib/bcdice/game_system/Satasupe.rb +32 -32
  119. data/lib/bcdice/game_system/ScreamHighSchool.rb +5 -5
  120. data/lib/bcdice/game_system/SharedFantasia.rb +19 -23
  121. data/lib/bcdice/game_system/ShinobiGami.rb +14 -6
  122. data/lib/bcdice/game_system/Skynauts.rb +103 -142
  123. data/lib/bcdice/game_system/SkynautsBouken.rb +228 -0
  124. data/lib/bcdice/game_system/StarryDolls.rb +318 -0
  125. data/lib/bcdice/game_system/SteamPunkers.rb +11 -6
  126. data/lib/bcdice/game_system/StellarKnights.rb +85 -706
  127. data/lib/bcdice/game_system/StellarKnights_Korean.rb +79 -0
  128. data/lib/bcdice/game_system/SterileLife.rb +2 -3
  129. data/lib/bcdice/game_system/StrangerOfSwordCity.rb +1 -1
  130. data/lib/bcdice/game_system/StratoShout.rb +8 -16
  131. data/lib/bcdice/game_system/Strave.rb +1 -1
  132. data/lib/bcdice/game_system/SwordWorld.rb +16 -7
  133. data/lib/bcdice/game_system/SwordWorld2_0.rb +2 -2
  134. data/lib/bcdice/game_system/SwordWorld2_5.rb +2 -2
  135. data/lib/bcdice/game_system/TherapieSein.rb +1 -1
  136. data/lib/bcdice/game_system/TokumeiTenkousei.rb +4 -3
  137. data/lib/bcdice/game_system/TokyoGhostResearch.rb +1 -1
  138. data/lib/bcdice/game_system/TrinitySeven.rb +279 -280
  139. data/lib/bcdice/game_system/TunnelsAndTrolls.rb +1 -1
  140. data/lib/bcdice/game_system/Utakaze.rb +53 -48
  141. data/lib/bcdice/game_system/Villaciel.rb +1 -1
  142. data/lib/bcdice/game_system/WARPS.rb +11 -9
  143. data/lib/bcdice/game_system/WaresBlade.rb +4 -9
  144. data/lib/bcdice/game_system/Warhammer.rb +15 -6
  145. data/lib/bcdice/game_system/Warhammer4.rb +15 -11
  146. data/lib/bcdice/game_system/WitchQuest.rb +1 -1
  147. data/lib/bcdice/game_system/YankeeYogSothoth.rb +4 -9
  148. data/lib/bcdice/game_system/Yggdrasill.rb +1 -1
  149. data/lib/bcdice/game_system/ZettaiReido.rb +20 -25
  150. data/lib/bcdice/game_system/filled_with/enemy_data_tables.rb +322 -0
  151. data/lib/bcdice/game_system/filled_with/event_tables.rb +392 -0
  152. data/lib/bcdice/game_system/filled_with/tresure_tables.rb +179 -0
  153. data/lib/bcdice/game_system/meikyu_kingdom_basic/kingdom_table.rb +1 -1
  154. data/lib/bcdice/game_system/sword_world/rating_parsed.rb +4 -4
  155. data/lib/bcdice/game_system/sword_world/rating_parser.rb +1 -1
  156. data/lib/bcdice/game_system/sword_world/transcendent_test.rb +26 -8
  157. data/lib/bcdice/repl.rb +1 -1
  158. data/lib/bcdice/result.rb +26 -0
  159. data/lib/bcdice/version.rb +1 -1
  160. metadata +18 -4
@@ -33,7 +33,7 @@ module BCDice
33
33
  INFO_MESSAGE_TEXT
34
34
 
35
35
  register_prefix(
36
- '\d+A\d*[CF]?\d*[CF]?\d*',
36
+ '\d+A',
37
37
  'CT3[\+\-]?',
38
38
  'CTR[\+\-]?',
39
39
  'DJV\-?',
@@ -22,7 +22,7 @@ module BCDice
22
22
   BMSは振り足しを自動では行いません。
23
23
  例)BM>=1 BM@3>=1 BMS2>=1
24
24
 
25
- ・判定振り足し:ReRollx,x,x...@y>=1
25
+ ・判定振り足し:ReRollx,x,x...@y>=z
26
26
   x:振るダイスの個数
27
27
    y:目標難易度(省略可。デフォルト4)
28
28
    z:必要成功度
@@ -40,15 +40,15 @@ module BCDice
40
40
  def eval_game_system_specific_command(command)
41
41
  debug("eval_game_system_specific_command Begin")
42
42
 
43
- text = judgeRoll(command)
44
- return text unless text.nil?
43
+ result = judgeRoll(command)
44
+ return result unless result.nil?
45
45
 
46
46
  isStop = true
47
47
  text, = reRoll(command, isStop)
48
48
  return text unless text.nil?
49
49
 
50
- text = getRulingPlanetDiceCommandResult(command)
51
- return text unless text.nil?
50
+ result = getRulingPlanetDiceCommandResult(command)
51
+ return result unless result.nil?
52
52
 
53
53
  text = getDurtyTableCommandReuslt(command)
54
54
  return text unless text.nil?
@@ -72,9 +72,10 @@ module BCDice
72
72
  getRollResult([diceCount], judgeNumberText, judgeNumber, targetNumber, isReRoll, isStop)
73
73
 
74
74
  message += text
75
- message += getTotalResultMessageText(bitList, successList, countOneList, targetNumber, isStop, canReRoll)
75
+ result = getTotalResult(bitList, successList, countOneList, targetNumber, isStop, canReRoll)
76
+ result.text = message + result.text
76
77
 
77
- return message
78
+ return result
78
79
  end
79
80
 
80
81
  def reRoll(command, isStop)
@@ -181,7 +182,7 @@ module BCDice
181
182
  return message, bitList, successList, countOneList, canReRoll
182
183
  end
183
184
 
184
- def getTotalResultMessageText(bitList, successList, countOneList, targetNumber, isStop, canReRoll)
185
+ def getTotalResult(bitList, successList, countOneList, targetNumber, isStop, canReRoll)
185
186
  success = successList.inject { |sum, i| sum + i }
186
187
  countOne = countOneList.inject { |sum, i| sum + i }
187
188
 
@@ -196,27 +197,35 @@ module BCDice
196
197
 
197
198
  if success >= targetNumber
198
199
  result += " > 現状で成功。コマンド実行で追加リロールも可能"
200
+ return Result.success(result)
199
201
  else
200
202
  result += " > 現状のままでは失敗"
201
- result += "。汚染ポイント+#{countOne}" if countOne >= 1
203
+ if countOne >= 1
204
+ result += "。汚染ポイント+#{countOne}"
205
+ return Result.fumble(result)
206
+ else
207
+ return Result.failure(result)
208
+ end
202
209
  end
203
-
204
- return result
205
210
  end
206
211
 
207
212
  if success >= targetNumber
208
213
  result += " > 成功"
209
-
210
214
  if bitList.size >= 1
211
215
  result += "、禁書ビット発生[#{bitList.join(',')}]"
216
+ return Result.critical(result)
217
+ else
218
+ return Result.success(result)
212
219
  end
213
-
214
220
  else
215
221
  result += " > 失敗"
216
- result += "。汚染ポイント+#{countOne}" if countOne >= 1
222
+ if countOne >= 1
223
+ result += "。汚染ポイント+#{countOne}"
224
+ return Result.fumble(result)
225
+ else
226
+ return Result.failure(result)
227
+ end
217
228
  end
218
-
219
- return result
220
229
  end
221
230
 
222
231
  def getSameDieList(diceList)
@@ -252,44 +261,36 @@ module BCDice
252
261
  end
253
262
 
254
263
  def getRulingPlanetDiceCommandResult(command)
255
- return nil unless command =~ /^RP(\d+)/i
264
+ m = /^RP(\d+)$/i.match(command)
265
+ return nil unless m
256
266
 
257
- targetNumbers = Regexp.last_match(1).split(//).map(&:to_i)
267
+ targetNumbers = m[1].each_char.map(&:to_i)
258
268
  diceList = getRulingPlanetDice
259
269
 
260
- matchResult = "失敗"
261
- targetNumbers.each do |i|
262
- if diceList.include?(i)
263
- matchResult = "発動"
264
- break
265
- end
266
- end
270
+ condition = diceList.any? { |dice| targetNumbers.include?(dice) }
267
271
 
268
- text = "守護星表チェック(#{targetNumbers.join(',')}) #{diceList.count}D10[#{diceList.join(',')}] #{matchResult}"
272
+ result = condition ? "発動" : "失敗"
273
+ text = "守護星表チェック(#{targetNumbers.join(',')}) > #{diceList.count}D10[#{diceList.join(',')}] > #{result}"
269
274
 
270
- return text
275
+ Result.new.tap do |r|
276
+ r.text = text
277
+ r.condition = condition
278
+ end
271
279
  end
272
280
 
273
281
  def getRulingPlanetDice
274
- dice1 = @randomizer.roll_once(10)
275
- dice2 = dice1
282
+ dice1, dice2 = @randomizer.roll_barabara(2, 10)
276
283
 
277
284
  while dice1 == dice2
278
285
  dice2 = @randomizer.roll_once(10)
279
286
  end
280
287
 
281
- dice1 = changeRulingPlanetDice(dice1)
282
- dice2 = changeRulingPlanetDice(dice2)
288
+ dice1 = 0 if dice1 == 10
289
+ dice2 = 0 if dice2 == 10
283
290
 
284
291
  return dice1, dice2
285
292
  end
286
293
 
287
- def changeRulingPlanetDice(dice)
288
- return 0 if dice == 10
289
-
290
- return dice
291
- end
292
-
293
294
  def getDurtyTableCommandReuslt(command)
294
295
  return nil unless /^DT$/i =~ command
295
296
 
@@ -456,7 +457,7 @@ module BCDice
456
457
  ),
457
458
  }.freeze
458
459
 
459
- register_prefix('BM', 'ReRoll\d+', 'RP\d+', 'DT', TABLES.keys)
460
+ register_prefix('BM', 'ReRoll', 'RP', 'DT', TABLES.keys)
460
461
  end
461
462
  end
462
463
  end
@@ -44,18 +44,17 @@ module BCDice
44
44
  @round_type = RoundType::CEIL # 端数切り上げに設定
45
45
  end
46
46
 
47
- def check_2D6(total, dice_total, _dice_list, cmp_op, target)
48
- return '' if target == '?'
49
- return '' unless cmp_op == :>=
47
+ def result_2d6(total, dice_total, _dice_list, cmp_op, target)
48
+ return nil if target == '?' || cmp_op != :>=
50
49
 
51
50
  if dice_total <= 2
52
- "ファンブル(【モラル】-3。追跡フェイズなら吸血シーンを追加。戦闘フェイズなら吸血鬼は追加行動を一回得る)"
51
+ Result.fumble("ファンブル(【モラル】-3。追跡フェイズなら吸血シーンを追加。戦闘フェイズなら吸血鬼は追加行動を一回得る)")
53
52
  elsif dice_total >= 12
54
- "スペシャル(【モラル】+3。追跡フェイズならあなたに関係を持つPCの【モラル】+2。攻撃判定ならダメージ+1D6)"
53
+ Result.critical("スペシャル(【モラル】+3。追跡フェイズならあなたに関係を持つPCの【モラル】+2。攻撃判定ならダメージ+1D6)")
55
54
  elsif total >= target
56
- "成功"
55
+ Result.success("成功")
57
56
  else
58
- "失敗"
57
+ Result.failure("失敗")
59
58
  end
60
59
  end
61
60
 
@@ -9,7 +9,7 @@ module BCDice
9
9
  ID = 'BloodMoon'
10
10
 
11
11
  # ゲームシステム名
12
- NAME = 'ブラッド・ムーン'
12
+ NAME = 'ブラッドムーン'
13
13
 
14
14
  # ゲームシステム名の読みがな
15
15
  SORT_KEY = 'ふらつとむうん'
@@ -43,18 +43,19 @@ module BCDice
43
43
  end
44
44
 
45
45
  # ゲーム別成功度判定(2D6)
46
- def check_2D6(total, dice_total, _dice_list, cmp_op, target)
47
- return '' if target == '?'
48
- return '' unless cmp_op == :>=
46
+ def result_2d6(total, dice_total, _dice_list, cmp_op, target)
47
+ return nil unless cmp_op == :>=
49
48
 
50
49
  if dice_total <= 2
51
- return "ファンブル(【余裕】が 0 に)"
50
+ Result.fumble("ファンブル(【余裕】が 0 に)")
52
51
  elsif dice_total >= 12
53
- return "スペシャル(【余裕】+3)"
52
+ Result.critical("スペシャル(【余裕】+3)")
53
+ elsif target == '?'
54
+ Result.nothing
54
55
  elsif total >= target
55
- return "成功"
56
+ Result.success("成功")
56
57
  else
57
- return "失敗"
58
+ Result.failure("失敗")
58
59
  end
59
60
  end
60
61
 
@@ -37,18 +37,19 @@ module BCDice
37
37
  end
38
38
 
39
39
  # ゲーム別成功度判定(2D6)
40
- def check_2D6(total, dice_total, _dice_list, cmp_op, target)
41
- return '' if target == '?'
42
- return '' unless cmp_op == :>=
40
+ def result_2d6(total, dice_total, _dice_list, cmp_op, target)
41
+ return nil unless cmp_op == :>=
43
42
 
44
43
  if dice_total <= 2
45
- return "ファンブル"
44
+ Result.fumble("ファンブル")
46
45
  elsif dice_total >= 12
47
- return "スペシャル > " + RTT.roll_command(@randomizer, "RM")
46
+ Result.critical("スペシャル > " + RTT.roll_command(@randomizer, "RM"))
47
+ elsif target == "?"
48
+ Result.nothing
48
49
  elsif total >= target
49
- return "成功"
50
+ Result.success("成功")
50
51
  else
51
- return "失敗"
52
+ Result.failure("失敗")
52
53
  end
53
54
  end
54
55
 
@@ -39,33 +39,39 @@ module BCDice
39
39
  - FT7
40
40
  INFO_MESSAGE_TEXT
41
41
 
42
- register_prefix('\d*CF', 'FT\d*')
42
+ register_prefix('\d*CF', 'FT')
43
43
 
44
44
  # ゲーム別成功度判定(2D6)。以前の処理をそのまま残しています。
45
- def check_2D6(total, dice_total, _dice_list, cmp_op, target)
46
- return '' if target == '?'
45
+ def result_2d6(total, dice_total, _dice_list, cmp_op, target)
46
+ return nil unless cmp_op == :>=
47
47
 
48
- output = ''
48
+ sequence = []
49
+ result = Result.new
49
50
 
50
51
  if dice_total <= 2
51
52
  total -= 20
52
- output = "ファンブル(-20)"
53
+ sequence.push("ファンブル(-20)")
54
+ result.fumble = true
53
55
  end
54
56
 
55
- unless cmp_op == :>=
56
- return output
57
- end
57
+ if target != '?'
58
+ if total >= target
59
+ sequence.push("成功")
60
+ result.success = true
61
+ else
62
+ sequence.push("失敗")
63
+ result.failure = true
64
+ end
58
65
 
59
- if total >= target
60
- output += " 成功"
61
- if total > target
62
- output += " > 差分値#{total - target}"
66
+ if total - target != 0
67
+ sequence.push("差分値#{total - target}")
63
68
  end
64
- else
65
- output += " > 失敗 > 差分値#{total - target}"
66
69
  end
67
70
 
68
- return output
71
+ return Result.nothing if sequence.empty?
72
+
73
+ result.text = sequence.join(" > ")
74
+ return result
69
75
  end
70
76
 
71
77
  def eval_game_system_specific_command(command)
@@ -22,24 +22,24 @@ module BCDice
22
22
   例)SR7   sr13   SR(7+4)   Ssr10
23
23
  INFO_MESSAGE_TEXT
24
24
 
25
- register_prefix('SR\d+')
25
+ register_prefix('SR')
26
26
 
27
- def check_1D100(total, _dice_total, cmp_op, target)
28
- return '' if target == '?'
29
- return '' if cmp_op != :<=
27
+ def result_1d100(total, _dice_total, cmp_op, target)
28
+ return nil if target == '?'
29
+ return nil if cmp_op != :<=
30
30
 
31
31
  if total >= 100
32
- "ファンブル"
32
+ Result.fumble("ファンブル")
33
33
  elsif total > target
34
- "失敗"
34
+ Result.failure("失敗")
35
35
  elsif total >= (target * 0.9)
36
- "L成功"
36
+ Result.success("L成功")
37
37
  elsif total >= (target / 2)
38
- "M成功"
38
+ Result.success("M成功")
39
39
  elsif total >= (target / 10)
40
- "H成功"
40
+ Result.success("H成功")
41
41
  else
42
- "C成功"
42
+ Result.critical("C成功")
43
43
  end
44
44
  end
45
45
 
@@ -19,9 +19,9 @@ module BCDice
19
19
     Chill3 : (1D100<=50) > 55 > Botch
20
20
  INFO_MESSAGE_TEXT
21
21
 
22
- def check_1D100(total, dice_total, cmp_op, target)
23
- return '' if target == '?'
24
- return '' unless cmp_op == :<=
22
+ def result_1d100(total, dice_total, cmp_op, target)
23
+ return nil if target == '?'
24
+ return nil unless cmp_op == :<=
25
25
 
26
26
  # ゾロ目ならC-ResultかBotch
27
27
  tens = (dice_total / 10) % 10
@@ -30,21 +30,21 @@ module BCDice
30
30
  if tens == ones
31
31
  if (total > target) || (dice_total == 100) # 00は必ず失敗
32
32
  if target > 100 # 目標値が100を超えている場合は、00を振ってもBotchにならない
33
- return "失敗"
33
+ return Result.failure("失敗")
34
34
  else
35
- return "Botch"
35
+ return Result.fumble("Botch")
36
36
  end
37
37
  else
38
- return "C成功"
38
+ return Result.critical("C成功")
39
39
  end
40
40
  elsif (total <= target) || (dice_total == 1) # 01は必ず成功
41
41
  if total <= (target / 2)
42
- return "H成功"
42
+ return Result.success("H成功")
43
43
  else
44
- return "L成功"
44
+ return Result.success("L成功")
45
45
  end
46
46
  else
47
- return "失敗"
47
+ return Result.failure("失敗")
48
48
  end
49
49
  end
50
50
  end
@@ -30,7 +30,7 @@ module BCDice
30
30
  デフォルトダイス:10面
31
31
  MESSAGETEXT
32
32
 
33
- register_prefix('[+-]?\d*CL([+-]\d+)?[@\d]*')
33
+ register_prefix('[+-]?\d*CL')
34
34
 
35
35
  def initialize(command)
36
36
  super(command)
@@ -41,61 +41,61 @@ module BCDice
41
41
  def eval_game_system_specific_command(command)
42
42
  debug('eval_game_system_specific_command command', command)
43
43
 
44
- result = ''
45
-
46
- case command
47
- when /([+-]?\d+)?CL([+-]\d+)?(@(\d))?(\[(\d+)\])?([+-]\d+)?(>=(\d+))?/i
48
- m = Regexp.last_match
49
- base = (m[1] || 1).to_i
50
- modifier1 = m[2].to_i
51
- target = (m[4] || 6).to_i
52
- critical_target = (m[6] || 1).to_i
53
- modifier2 = m[7].to_i
54
- diff = m[9].to_i
55
- result = check_roll(base, target, critical_target, diff, modifier1 + modifier2)
56
- end
57
-
58
- return nil if result.empty?
44
+ m = /([+-]?\d+)?CL([+-]\d+)?(@(\d))?(\[(\d+)\])?([+-]\d+)?(>=(\d+))?/i.match(command)
45
+ return nil unless m
59
46
 
60
- return "#{command} #{result}"
47
+ base = (m[1] || 1).to_i
48
+ modifier1 = m[2].to_i
49
+ target = (m[4] || 6).to_i
50
+ critical_target = (m[6] || 1).to_i
51
+ modifier2 = m[7].to_i
52
+ diff = m[9].to_i if m[9]
53
+ check_roll(command, base, target, critical_target, diff, modifier1 + modifier2)
61
54
  end
62
55
 
63
- def check_roll(base, target, critical_target, diff, modifier)
56
+ def check_roll(command, base, target, critical_target, diff, modifier)
64
57
  if base <= 0 # クリティカルしない1D
65
58
  critical_target = 0
66
59
  base = 1
67
60
  end
61
+ result = Result.new
68
62
 
69
63
  target = 10 if target > 10
70
64
  dice_list = @randomizer.roll_barabara(base, 10).sort
71
65
  success_count = dice_list.count { |x| x <= target }
72
66
  critical_count = dice_list.count { |x| x <= critical_target }
67
+ result.critical = critical_count > 0
73
68
  success_total = success_count + critical_count + modifier
74
69
 
75
70
  mod_text = Format.modifier(modifier)
76
71
 
77
72
  # (10d10+5)
78
- result = "(#{base}d10#{mod_text}) > [#{dice_list.join(',')}]#{mod_text} > "
79
- result += "判定値[#{target}] " unless target == 6
80
- result += "クリティカル値[#{critical_target}] " unless critical_target == 1
81
- result += "達成値[#{success_count}]"
82
-
83
- return "#{result} > ファンブル!" if success_count <= 0
84
-
85
- result += "+クリティカル[#{critical_count}]" if critical_count > 0
86
- result += mod_text
87
- result += "=[#{success_total}]" if critical_count > 0 || modifier != 0
88
-
89
- success_text =
90
- if diff == 0
91
- success_total.to_s
92
- elsif success_total >= diff
93
- "成功"
94
- else
95
- "失敗"
96
- end
97
-
98
- return "#{result} #{success_text}"
73
+ text = "#{command} > (#{base}d10#{mod_text}) > [#{dice_list.join(',')}]#{mod_text} > "
74
+ text += "判定値[#{target}] " unless target == 6
75
+ text += "クリティカル値[#{critical_target}] " unless critical_target == 1
76
+ text += "達成値[#{success_count}]"
77
+
78
+ if success_count <= 0
79
+ result.fumble = true
80
+ result.failure = true
81
+ result.text = "#{text} > ファンブル!"
82
+ return result
83
+ end
84
+
85
+ text += "+クリティカル[#{critical_count}]" if result.critical?
86
+ text += mod_text
87
+ text += "=[#{success_total}]" if result.critical? || modifier != 0
88
+
89
+ if diff.nil?
90
+ result.text = "#{text} > #{success_total}"
91
+ elsif success_total >= diff
92
+ result.text = "#{text} > 成功"
93
+ result.success = true
94
+ else
95
+ result.text = "#{text} > 失敗"
96
+ result.failure = true
97
+ end
98
+ return result
99
99
  end
100
100
  end
101
101
  end