bcdice 3.1.2 → 3.4.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 (161) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +154 -75
  3. data/README.md +3 -2
  4. data/i18n/Cthulhu/zh_hans.yml +11 -0
  5. data/i18n/MagicaLogia/zh_hans.yml +564 -0
  6. data/i18n/StellarKnights/ja_jp.yml +498 -0
  7. data/i18n/StellarKnights/ko_kr.yml +498 -0
  8. data/i18n/zh_hans.yml +7 -0
  9. data/lib/bcdice/command/parsed.rb +11 -3
  10. data/lib/bcdice/command/parser.rb +179 -100
  11. data/lib/bcdice/common_command/add_dice.rb +1 -1
  12. data/lib/bcdice/common_command/barabara_dice/node.rb +2 -2
  13. data/lib/bcdice/common_command/barabara_dice/result.rb +6 -0
  14. data/lib/bcdice/common_command/calc.rb +1 -1
  15. data/lib/bcdice/common_command/choice.rb +78 -7
  16. data/lib/bcdice/dice_table.rb +3 -0
  17. data/lib/bcdice/dice_table/d66_half_grid_table.rb +33 -0
  18. data/lib/bcdice/dice_table/d66_left_range_table.rb +29 -0
  19. data/lib/bcdice/dice_table/d66_one_third_table.rb +34 -0
  20. data/lib/bcdice/game_system.rb +10 -0
  21. data/lib/bcdice/game_system/AceKillerGene.rb +1 -1
  22. data/lib/bcdice/game_system/Ainecadette.rb +68 -0
  23. data/lib/bcdice/game_system/Airgetlamh.rb +1 -1
  24. data/lib/bcdice/game_system/Alsetto.rb +1 -1
  25. data/lib/bcdice/game_system/AlterRaise.rb +2 -2
  26. data/lib/bcdice/game_system/Amadeus.rb +110 -93
  27. data/lib/bcdice/game_system/AngelGear.rb +10 -5
  28. data/lib/bcdice/game_system/AnimaAnimus.rb +16 -9
  29. data/lib/bcdice/game_system/Arianrhod.rb +6 -8
  30. data/lib/bcdice/game_system/Avandner.rb +1 -1
  31. data/lib/bcdice/game_system/BarnaKronika.rb +1 -1
  32. data/lib/bcdice/game_system/BattleTech.rb +109 -28
  33. data/lib/bcdice/game_system/BeastBindTrinity.rb +28 -12
  34. data/lib/bcdice/game_system/BeginningIdol.rb +5 -5
  35. data/lib/bcdice/game_system/BeginningIdol_Korean.rb +5 -5
  36. data/lib/bcdice/game_system/BladeOfArcana.rb +1 -1
  37. data/lib/bcdice/game_system/BlindMythos.rb +39 -38
  38. data/lib/bcdice/game_system/BloodCrusade.rb +6 -7
  39. data/lib/bcdice/game_system/BloodMoon.rb +9 -8
  40. data/lib/bcdice/game_system/CardRanker.rb +8 -7
  41. data/lib/bcdice/game_system/ChaosFlare.rb +21 -15
  42. data/lib/bcdice/game_system/Chill.rb +10 -10
  43. data/lib/bcdice/game_system/Chill3.rb +9 -9
  44. data/lib/bcdice/game_system/CodeLayerd.rb +39 -39
  45. data/lib/bcdice/game_system/ColossalHunter.rb +34 -47
  46. data/lib/bcdice/game_system/CrashWorld.rb +1 -1
  47. data/lib/bcdice/game_system/Cthulhu.rb +1 -1
  48. data/lib/bcdice/game_system/Cthulhu7th.rb +50 -12
  49. data/lib/bcdice/game_system/Cthulhu7th_ChineseTraditional.rb +1 -1
  50. data/lib/bcdice/game_system/Cthulhu7th_Korean.rb +1 -1
  51. data/lib/bcdice/game_system/Cthulhu_SimplifiedChinese.rb +60 -0
  52. data/lib/bcdice/game_system/DarkBlaze.rb +0 -11
  53. data/lib/bcdice/game_system/DarkDaysDrive.rb +8 -7
  54. data/lib/bcdice/game_system/DeadlineHeroes.rb +11 -10
  55. data/lib/bcdice/game_system/DemonParasite.rb +5 -13
  56. data/lib/bcdice/game_system/DesperateRun.rb +1 -1
  57. data/lib/bcdice/game_system/DoubleCross.rb +3 -1
  58. data/lib/bcdice/game_system/Dracurouge.rb +3 -2
  59. data/lib/bcdice/game_system/EclipsePhase.rb +14 -14
  60. data/lib/bcdice/game_system/Elric.rb +18 -14
  61. data/lib/bcdice/game_system/Elysion.rb +1 -1
  62. data/lib/bcdice/game_system/EmbryoMachine.rb +9 -8
  63. data/lib/bcdice/game_system/Emoklore.rb +25 -20
  64. data/lib/bcdice/game_system/Fiasco.rb +1 -1
  65. data/lib/bcdice/game_system/FilledWith.rb +4 -0
  66. data/lib/bcdice/game_system/FutariSousa.rb +12 -10
  67. data/lib/bcdice/game_system/GURPS.rb +17 -28
  68. data/lib/bcdice/game_system/Garako.rb +1 -1
  69. data/lib/bcdice/game_system/GardenOrder.rb +12 -7
  70. data/lib/bcdice/game_system/GeishaGirlwithKatana.rb +1 -1
  71. data/lib/bcdice/game_system/GoblinSlayer.rb +1 -1
  72. data/lib/bcdice/game_system/Gorilla.rb +2 -8
  73. data/lib/bcdice/game_system/GranCrest.rb +189 -417
  74. data/lib/bcdice/game_system/Gundog.rb +9 -8
  75. data/lib/bcdice/game_system/GundogRevised.rb +10 -9
  76. data/lib/bcdice/game_system/GundogZero.rb +1 -1
  77. data/lib/bcdice/game_system/GurpsFW.rb +16 -16
  78. data/lib/bcdice/game_system/HarnMaster.rb +19 -26
  79. data/lib/bcdice/game_system/HatsuneMiku.rb +1 -1
  80. data/lib/bcdice/game_system/Hieizan.rb +12 -21
  81. data/lib/bcdice/game_system/HouraiGakuen.rb +1 -1
  82. data/lib/bcdice/game_system/HuntersMoon.rb +5 -10
  83. data/lib/bcdice/game_system/InfiniteFantasia.rb +19 -17
  84. data/lib/bcdice/game_system/Insane.rb +13 -20
  85. data/lib/bcdice/game_system/Irisbane.rb +154 -0
  86. data/lib/bcdice/game_system/IthaWenUa.rb +8 -15
  87. data/lib/bcdice/game_system/JamesBond.rb +10 -10
  88. data/lib/bcdice/game_system/JekyllAndHyde.rb +1 -1
  89. data/lib/bcdice/game_system/Kamigakari.rb +1 -1
  90. data/lib/bcdice/game_system/KanColle.rb +4 -9
  91. data/lib/bcdice/game_system/KemonoNoMori.rb +26 -39
  92. data/lib/bcdice/game_system/KillDeathBusiness.rb +7 -15
  93. data/lib/bcdice/game_system/KurayamiCrying.rb +141 -2
  94. data/lib/bcdice/game_system/LiveraDoll.rb +254 -304
  95. data/lib/bcdice/game_system/LogHorizon.rb +13 -10
  96. data/lib/bcdice/game_system/MagicaLogia_SimplifiedChinese.rb +66 -0
  97. data/lib/bcdice/game_system/MeikyuDays.rb +10 -8
  98. data/lib/bcdice/game_system/MeikyuKingdom.rb +26 -26
  99. data/lib/bcdice/game_system/MeikyuKingdomBasic.rb +4 -3
  100. data/lib/bcdice/game_system/MetalHead.rb +12 -22
  101. data/lib/bcdice/game_system/MetalHeadExtream.rb +5 -5
  102. data/lib/bcdice/game_system/MonotoneMuseum.rb +8 -6
  103. data/lib/bcdice/game_system/Nechronica.rb +63 -90
  104. data/lib/bcdice/game_system/NinjaSlayer.rb +6 -7
  105. data/lib/bcdice/game_system/NjslyrBattle.rb +8 -11
  106. data/lib/bcdice/game_system/OneWayHeroics.rb +1 -1
  107. data/lib/bcdice/game_system/Paradiso.rb +3 -3
  108. data/lib/bcdice/game_system/ParasiteBlood.rb +1 -1
  109. data/lib/bcdice/game_system/Peekaboo.rb +4 -9
  110. data/lib/bcdice/game_system/Pendragon.rb +7 -7
  111. data/lib/bcdice/game_system/PersonaO.rb +86 -0
  112. data/lib/bcdice/game_system/PhantasmAdventure.rb +8 -8
  113. data/lib/bcdice/game_system/Postman.rb +1 -1
  114. data/lib/bcdice/game_system/PulpCthulhu.rb +1 -1
  115. data/lib/bcdice/game_system/Raisondetre.rb +2 -2
  116. data/lib/bcdice/game_system/Revulture.rb +123 -0
  117. data/lib/bcdice/game_system/RuneQuest.rb +8 -8
  118. data/lib/bcdice/game_system/Ryutama.rb +1 -1
  119. data/lib/bcdice/game_system/SRS.rb +17 -16
  120. data/lib/bcdice/game_system/SamsaraBallad.rb +38 -11
  121. data/lib/bcdice/game_system/Satasupe.rb +32 -32
  122. data/lib/bcdice/game_system/ScreamHighSchool.rb +5 -5
  123. data/lib/bcdice/game_system/SharedFantasia.rb +19 -23
  124. data/lib/bcdice/game_system/ShinobiGami.rb +14 -6
  125. data/lib/bcdice/game_system/Skynauts.rb +103 -142
  126. data/lib/bcdice/game_system/SkynautsBouken.rb +228 -0
  127. data/lib/bcdice/game_system/StarryDolls.rb +318 -0
  128. data/lib/bcdice/game_system/SteamPunkers.rb +25 -7
  129. data/lib/bcdice/game_system/StellarKnights.rb +85 -706
  130. data/lib/bcdice/game_system/StellarKnights_Korean.rb +79 -0
  131. data/lib/bcdice/game_system/SterileLife.rb +2 -3
  132. data/lib/bcdice/game_system/StratoShout.rb +8 -16
  133. data/lib/bcdice/game_system/Strave.rb +1 -1
  134. data/lib/bcdice/game_system/SwordWorld.rb +16 -7
  135. data/lib/bcdice/game_system/SwordWorld2_0.rb +2 -2
  136. data/lib/bcdice/game_system/SwordWorld2_5.rb +2 -2
  137. data/lib/bcdice/game_system/TherapieSein.rb +1 -1
  138. data/lib/bcdice/game_system/TokumeiTenkousei.rb +4 -3
  139. data/lib/bcdice/game_system/TokyoGhostResearch.rb +1 -1
  140. data/lib/bcdice/game_system/TorgEternity.rb +2 -2
  141. data/lib/bcdice/game_system/ToshiakiHolyGrailWar.rb +92 -0
  142. data/lib/bcdice/game_system/TrinitySeven.rb +279 -280
  143. data/lib/bcdice/game_system/TunnelsAndTrolls.rb +1 -1
  144. data/lib/bcdice/game_system/Utakaze.rb +53 -48
  145. data/lib/bcdice/game_system/Villaciel.rb +1 -1
  146. data/lib/bcdice/game_system/WARPS.rb +11 -9
  147. data/lib/bcdice/game_system/WaresBlade.rb +4 -9
  148. data/lib/bcdice/game_system/Warhammer.rb +15 -6
  149. data/lib/bcdice/game_system/Warhammer4.rb +15 -11
  150. data/lib/bcdice/game_system/WitchQuest.rb +1 -1
  151. data/lib/bcdice/game_system/YankeeYogSothoth.rb +4 -9
  152. data/lib/bcdice/game_system/Yggdrasill.rb +1 -1
  153. data/lib/bcdice/game_system/ZettaiReido.rb +20 -25
  154. data/lib/bcdice/game_system/meikyu_kingdom_basic/kingdom_table.rb +1 -1
  155. data/lib/bcdice/game_system/sword_world/rating_parsed.rb +4 -4
  156. data/lib/bcdice/game_system/sword_world/rating_parser.rb +1 -1
  157. data/lib/bcdice/game_system/sword_world/transcendent_test.rb +26 -8
  158. data/lib/bcdice/repl.rb +1 -1
  159. data/lib/bcdice/result.rb +26 -0
  160. data/lib/bcdice/version.rb +1 -1
  161. metadata +22 -5
@@ -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
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "bcdice/format"
4
+
3
5
  module BCDice
4
6
  module GameSystem
5
7
  class ColossalHunter < Base
@@ -14,10 +16,12 @@ module BCDice
14
16
 
15
17
  # ダイスボットの使い方
16
18
  HELP_MESSAGE = <<~MESSAGETEXT
17
- ・判定(CH±x>=y)
18
-  3D6の判定。クリティカル、ファンブルの自動判定を行います。
19
-  x:修正値。省略可能。y:目標値。省略可能。
20
-  例) CH CH+1 CH+2>=10
19
+ ・判定(nCH±x>=y)
20
+  nD6の判定。クリティカル、ファンブルの自動判定を行います。
21
+  n:ダイス数。省略可能。省略した場合3。
22
+  x:修正値。省略可能。
23
+  y:目標値。省略可能。
24
+  例) CH CH+1 CH+2>=10 4CH+1
21
25
  ・BIG-6表(B6T)
22
26
  ・覚醒表(AWT)
23
27
  ・現状表(CST)
@@ -45,65 +49,48 @@ module BCDice
45
49
  def getCheckRollDiceCommandResult(command)
46
50
  debug("getCheckRollDiceCommandResult command", command)
47
51
 
48
- return nil unless command =~ /(\d+)?CH([+\-\d]*)(>=([+\-\d]*))?$/i
52
+ parser = Command::Parser.new(/\d*CH/, round_type: round_type)
53
+ .restrict_cmp_op_to(nil, :>=)
49
54
 
50
- diceCount = (Regexp.last_match(1) || 3).to_i
51
- modifyText = (Regexp.last_match(2) || '')
52
- difficultyText = Regexp.last_match(4)
55
+ parsed = parser.parse(command)
56
+ unless parsed
57
+ return nil
58
+ end
53
59
 
54
- # 修正値の計算
55
- modify = getValue(modifyText, 0)
60
+ parsed.command = "3CH" unless parsed.command.start_with?(/\d/)
56
61
 
57
- # 目標値の計算
58
- difficulty = getValue(difficultyText, nil)
62
+ dice_count = parsed.command.to_i
63
+ modify = parsed.modify_number
59
64
 
60
65
  # ダイスロール
61
- dice_list = @randomizer.roll_barabara(diceCount, 6)
66
+ dice_list = @randomizer.roll_barabara(dice_count, 6)
62
67
  dice = dice_list.sum()
63
68
  dice_str = dice_list.join(",")
64
69
 
65
70
  total = dice + modify
66
71
 
67
- # 出力用ダイスコマンドを生成
68
- command = "#{diceCount}CH#{modifyText}"
69
- command += ">=#{difficulty}" unless difficulty.nil?
70
-
71
72
  # 出力文の生成
72
- result = "(#{command}) > #{dice}[#{dice_str}]#{modifyText} > #{total}"
73
+ text = "(#{parsed}) > #{dice}[#{dice_str}]#{Format.modifier(modify)} > #{total}"
73
74
 
74
- # クリティカル・ファンブルチェック
75
- if isFamble(dice)
76
- result += " > ファンブル"
77
- elsif isCritical(total)
78
- result += " > クリティカル"
79
- else
80
- result += getJudgeResultString(difficulty, total)
81
- end
75
+ result = get_judge_result(dice, total, parsed)
82
76
 
77
+ result.text = text + result.text
83
78
  return result
84
79
  end
85
80
 
86
81
  # 成否判定
87
- def getJudgeResultString(difficulty, total)
88
- return '' if difficulty.nil?
89
-
90
- return " > 成功" if total >= difficulty
91
-
92
- return " > 失敗"
93
- end
94
-
95
- def getValue(text, defaultValue)
96
- return defaultValue if text.nil? || text.empty?
97
-
98
- ArithmeticEvaluator.eval(text)
99
- end
100
-
101
- def isCritical(total)
102
- (total >= 16)
103
- end
104
-
105
- def isFamble(total)
106
- (total <= 5)
82
+ def get_judge_result(dice, total, parsed)
83
+ if dice <= 5
84
+ Result.fumble(" > ファンブル")
85
+ elsif total >= 16
86
+ Result.critical(" > クリティカル")
87
+ elsif parsed.cmp_op.nil?
88
+ Result.new("")
89
+ elsif total >= parsed.target_number
90
+ Result.success(" > 成功")
91
+ else
92
+ Result.failure(" > 失敗")
93
+ end
107
94
  end
108
95
 
109
96
  def getSourceSceneDiceCommandResult(command)
@@ -562,7 +549,7 @@ module BCDice
562
549
 
563
550
  }.freeze
564
551
 
565
- register_prefix("CH.*", "B6T", "CNP", TABLES.keys)
552
+ register_prefix('\d*CH', "B6T", "CNP", TABLES.keys)
566
553
  end
567
554
  end
568
555
  end
@@ -19,7 +19,7 @@ module BCDice
19
19
  例・CW8
20
20
  INFO_MESSAGE_TEXT
21
21
 
22
- register_prefix('CW\d+')
22
+ register_prefix('CW')
23
23
 
24
24
  def eval_game_system_specific_command(command)
25
25
  result = nil
@@ -48,7 +48,7 @@ module BCDice
48
48
 
49
49
  INFO_MESSAGE_TEXT
50
50
 
51
- register_prefix('CC(B)?\(\d+\)', 'CC(B)?', 'RES(B)?', 'CBR(B)?\(\d+,\d+\)')
51
+ register_prefix('CCB?', 'RESB?', 'CBRB?')
52
52
 
53
53
  def initialize(command)
54
54
  super(command)
@@ -17,13 +17,19 @@ module BCDice
17
17
 
18
18
  # ダイスボットの使い方
19
19
  HELP_MESSAGE = <<~INFO_MESSAGE_TEXT
20
- ※コマンドは入力内容の前方一致で検出しています。
21
20
  ・判定 CC(x)<=(目標値)
22
-  x:ボーナス・ペナルティダイス (2~-2)。省略可。
21
+  x:ボーナス・ペナルティダイス。省略可。
23
22
   目標値が無くても1D100は表示される。
24
23
   ファンブル/失敗/ レギュラー成功/ハード成功/
25
24
   イクストリーム成功/クリティカル を自動判定。
26
- 例)CC<=30 CC(2)<=50 CC(+2)<=50 CC(-1)<=75 CC-1<=50 CC1<=65 CC+1<=65 CC
25
+  例)CC<=30 CC(2)<=50 CC(+2)<=50 CC(-1)<=75 CC-1<=50 CC1<=65 CC+1<=65 CC
26
+
27
+ ・技能ロールの難易度指定 CC(x)<=(目標値)(難易度)
28
+  目標値の後に難易度を指定することで
29
+  成功/失敗/クリティカル/ファンブル を自動判定する。
30
+  難易度の指定:
31
+   r:レギュラー h:ハード e:イクストリーム c:クリティカル
32
+  例)CC<=70r CC1<=60h CC-2<=50e CC2<=99c
27
33
 
28
34
  ・組み合わせ判定 (CBR(x,y))
29
35
   目標値 x と y で%ロールを行い、成否を判定。
@@ -48,7 +54,7 @@ module BCDice
48
54
    強力でない呪文の場合 FCL/強力な呪文の場合 FCM
49
55
  INFO_MESSAGE_TEXT
50
56
 
51
- register_prefix('CC', 'CBR\(\d+,\d+\)', 'FAR', 'BMR', 'BMS', 'FCL', 'FCM', 'PH', 'MA')
57
+ register_prefix('CC', 'CBR', 'FAR', 'BMR', 'BMS', 'FCL', 'FCM', 'PH', 'MA')
52
58
 
53
59
  def eval_game_system_specific_command(command)
54
60
  case command
@@ -77,6 +83,7 @@ module BCDice
77
83
  LEVEL = [
78
84
  :fumble,
79
85
  :failure,
86
+ :success,
80
87
  :regular_success,
81
88
  :hard_success,
82
89
  :extreme_success,
@@ -88,23 +95,38 @@ module BCDice
88
95
  extreme_success: "イクストリーム成功",
89
96
  hard_success: "ハード成功",
90
97
  regular_success: "レギュラー成功",
98
+ success: "成功",
91
99
  fumble: "ファンブル",
92
100
  failure: "失敗",
93
101
  }.freeze
94
102
 
103
+ def self.with_difficulty_level(total, difficulty)
104
+ fumble = difficulty < 50 ? 96 : 100
105
+
106
+ if total == 1
107
+ ResultLevel.new(:critical)
108
+ elsif total >= fumble
109
+ ResultLevel.new(:fumble)
110
+ elsif total <= difficulty
111
+ ResultLevel.new(:success)
112
+ else
113
+ ResultLevel.new(:failure)
114
+ end
115
+ end
116
+
95
117
  def self.from_values(total, difficulty, fumbleable = false)
96
118
  fumble = difficulty < 50 || fumbleable ? 96 : 100
97
119
 
98
120
  if total == 1
99
121
  ResultLevel.new(:critical)
122
+ elsif total >= fumble
123
+ ResultLevel.new(:fumble)
100
124
  elsif total <= (difficulty / 5)
101
125
  ResultLevel.new(:extreme_success)
102
126
  elsif total <= (difficulty / 2)
103
127
  ResultLevel.new(:hard_success)
104
128
  elsif total <= difficulty
105
129
  ResultLevel.new(:regular_success)
106
- elsif total >= fumble
107
- ResultLevel.new(:fumble)
108
130
  else
109
131
  ResultLevel.new(:failure)
110
132
  end
@@ -117,7 +139,7 @@ module BCDice
117
139
  end
118
140
 
119
141
  def success?
120
- @level_index >= LEVEL.index(:regular_success)
142
+ @level_index >= LEVEL.index(:success)
121
143
  end
122
144
 
123
145
  def failure?
@@ -160,15 +182,26 @@ module BCDice
160
182
  end
161
183
 
162
184
  def skill_roll(command)
163
- m = /^CC([-+]?\d+)?(?:<=(\d+))?$/.match(command)
185
+ m = /^CC([-+]?\d+)?(?:<=(\d+)([RHEC])?)?$/.match(command)
164
186
  unless m
165
187
  return nil
166
188
  end
167
189
 
168
190
  bonus_dice = m[1].to_i
169
- difficulty = m[2].to_i
191
+ difficulty = m[2]&.to_i
192
+ difficulty_level = m[3]
193
+
194
+ if difficulty == 0
195
+ difficulty = nil
196
+ elsif difficulty_level == "H"
197
+ difficulty /= 2
198
+ elsif difficulty_level == "E"
199
+ difficulty /= 5
200
+ elsif difficulty_level == "C"
201
+ difficulty = 0
202
+ end
170
203
 
171
- if bonus_dice == 0 && difficulty == 0
204
+ if bonus_dice == 0 && difficulty.nil?
172
205
  dice = @randomizer.roll_once(100)
173
206
  return "1D100 > #{dice}"
174
207
  end
@@ -179,8 +212,13 @@ module BCDice
179
212
 
180
213
  total, total_list = roll_with_bonus(bonus_dice)
181
214
 
182
- expr = difficulty.zero? ? "1D100" : "1D100<=#{difficulty}"
183
- result = ResultLevel.from_values(total, difficulty) unless difficulty.zero?
215
+ expr = difficulty.nil? ? "1D100" : "1D100<=#{difficulty}"
216
+ result =
217
+ if difficulty_level
218
+ ResultLevel.with_difficulty_level(total, difficulty)
219
+ elsif difficulty
220
+ ResultLevel.from_values(total, difficulty)
221
+ end
184
222
 
185
223
  sequence = [
186
224
  "(#{expr}) ボーナス・ペナルティダイス[#{bonus_dice}]",