bcdice 3.0.0.pre.alpha.2 → 3.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (235) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +42 -1
  3. data/README.md +34 -7
  4. data/i18n/DetatokoSaga/ja_jp.yml +3 -2
  5. data/i18n/DetatokoSaga/ko_kr.yml +1 -0
  6. data/i18n/KillDeathBusiness/ja_jp.yml +4 -4
  7. data/i18n/KillDeathBusiness/ko_kr.yml +5 -4
  8. data/i18n/MagicaLogia/ko_kr.yml +564 -0
  9. data/i18n/MonotoneMuseum/ja_jp.yml +40 -4
  10. data/i18n/StratoShout/ja_jp.yml +4 -4
  11. data/i18n/StratoShout/ko_kr.yml +4 -4
  12. data/lib/bcdice.rb +4 -1
  13. data/lib/bcdice/arithmetic.rb +22 -0
  14. data/lib/bcdice/arithmetic/node.rb +112 -43
  15. data/lib/bcdice/arithmetic/parser.rb +240 -0
  16. data/lib/bcdice/arithmetic_evaluator.rb +7 -156
  17. data/lib/bcdice/base.rb +8 -1
  18. data/lib/bcdice/command/lexer.rb +57 -0
  19. data/lib/bcdice/command/parsed.rb +65 -0
  20. data/lib/bcdice/command/parser.rb +489 -0
  21. data/lib/bcdice/common_command.rb +2 -0
  22. data/lib/bcdice/common_command/add_dice.rb +3 -1
  23. data/lib/bcdice/common_command/add_dice/node.rb +142 -69
  24. data/lib/bcdice/common_command/add_dice/parser.rb +100 -83
  25. data/lib/bcdice/common_command/add_dice/randomizer.rb +2 -0
  26. data/lib/bcdice/common_command/barabara_dice.rb +2 -0
  27. data/lib/bcdice/common_command/barabara_dice/node.rb +9 -1
  28. data/lib/bcdice/common_command/barabara_dice/result.rb +22 -0
  29. data/lib/bcdice/common_command/calc.rb +2 -0
  30. data/lib/bcdice/common_command/calc/node.rb +10 -1
  31. data/lib/bcdice/common_command/calc/parser.rb +1 -1
  32. data/lib/bcdice/common_command/d66_dice.rb +5 -1
  33. data/lib/bcdice/common_command/lexer.rb +2 -1
  34. data/lib/bcdice/common_command/upper_dice.rb +2 -0
  35. data/lib/bcdice/common_command/upper_dice/parser.rb +118 -97
  36. data/lib/bcdice/common_command/version.rb +3 -1
  37. data/lib/bcdice/deprecated/checker.rb +6 -6
  38. data/lib/bcdice/dice_table.rb +3 -0
  39. data/lib/bcdice/dice_table/chain_table.rb +2 -0
  40. data/lib/bcdice/dice_table/d66_grid_table.rb +2 -0
  41. data/lib/bcdice/dice_table/d66_parity_table.rb +36 -0
  42. data/lib/bcdice/dice_table/d66_range_table.rb +2 -0
  43. data/lib/bcdice/dice_table/d66_table.rb +2 -0
  44. data/lib/bcdice/dice_table/roll_result.rb +2 -0
  45. data/lib/bcdice/dice_table/table.rb +2 -0
  46. data/lib/bcdice/enum.rb +2 -0
  47. data/lib/bcdice/format.rb +2 -0
  48. data/lib/bcdice/game_system.rb +10 -0
  49. data/lib/bcdice/game_system/AceKillerGene.rb +1 -1
  50. data/lib/bcdice/game_system/AlchemiaStruggle.rb +346 -0
  51. data/lib/bcdice/game_system/Alshard.rb +1 -2
  52. data/lib/bcdice/game_system/Amadeus.rb +1 -1
  53. data/lib/bcdice/game_system/AngelGear.rb +123 -0
  54. data/lib/bcdice/game_system/AnimaAnimus.rb +1 -5
  55. data/lib/bcdice/game_system/ArsMagica.rb +1 -1
  56. data/lib/bcdice/game_system/BBN.rb +7 -5
  57. data/lib/bcdice/game_system/BadLife.rb +2 -2
  58. data/lib/bcdice/game_system/BarnaKronika.rb +1 -1
  59. data/lib/bcdice/game_system/BeastBindTrinity.rb +3 -12
  60. data/lib/bcdice/game_system/BeginningIdol.rb +4 -4
  61. data/lib/bcdice/game_system/BeginningIdol_Korean.rb +4 -4
  62. data/lib/bcdice/game_system/BladeOfArcana.rb +4 -4
  63. data/lib/bcdice/game_system/BlindMythos.rb +12 -10
  64. data/lib/bcdice/game_system/BloodCrusade.rb +54 -80
  65. data/lib/bcdice/game_system/BloodMoon.rb +43 -2
  66. data/lib/bcdice/game_system/CardRanker.rb +24 -64
  67. data/lib/bcdice/game_system/ChaosFlare.rb +4 -4
  68. data/lib/bcdice/game_system/Chill.rb +1 -1
  69. data/lib/bcdice/game_system/CodeLayerd.rb +37 -67
  70. data/lib/bcdice/game_system/ColossalHunter.rb +2 -2
  71. data/lib/bcdice/game_system/Cthulhu.rb +8 -4
  72. data/lib/bcdice/game_system/Cthulhu7th.rb +42 -336
  73. data/lib/bcdice/game_system/Cthulhu7th_ChineseTraditional.rb +1 -1
  74. data/lib/bcdice/game_system/Cthulhu7th_Korean.rb +1 -1
  75. data/lib/bcdice/game_system/CthulhuTech.rb +1 -2
  76. data/lib/bcdice/game_system/DarkBlaze.rb +5 -5
  77. data/lib/bcdice/game_system/DeadlineHeroes.rb +1 -1
  78. data/lib/bcdice/game_system/DesperateRun.rb +163 -0
  79. data/lib/bcdice/game_system/DetatokoSaga.rb +25 -7
  80. data/lib/bcdice/game_system/DetatokoSaga_Korean.rb +3 -3
  81. data/lib/bcdice/game_system/DiceBot.rb +22 -4
  82. data/lib/bcdice/game_system/DiceOfTheDead.rb +1 -1
  83. data/lib/bcdice/game_system/DoubleCross.rb +61 -94
  84. data/lib/bcdice/game_system/EarthDawn.rb +1 -1
  85. data/lib/bcdice/game_system/EarthDawn3.rb +1 -1
  86. data/lib/bcdice/game_system/EarthDawn4.rb +1 -1
  87. data/lib/bcdice/game_system/Elysion.rb +2 -2
  88. data/lib/bcdice/game_system/EmbryoMachine.rb +6 -6
  89. data/lib/bcdice/game_system/EtrianOdysseySRS.rb +1 -2
  90. data/lib/bcdice/game_system/FilledWith.rb +3 -3
  91. data/lib/bcdice/game_system/FullMetalPanic.rb +1 -2
  92. data/lib/bcdice/game_system/GURPS.rb +1 -1
  93. data/lib/bcdice/game_system/Garako.rb +14 -5
  94. data/lib/bcdice/game_system/GardenOrder.rb +1 -1
  95. data/lib/bcdice/game_system/GehennaAn.rb +4 -4
  96. data/lib/bcdice/game_system/GoblinSlayer.rb +1 -1
  97. data/lib/bcdice/game_system/Gorilla.rb +1 -1
  98. data/lib/bcdice/game_system/Gundog.rb +1 -1
  99. data/lib/bcdice/game_system/GundogRevised.rb +3 -3
  100. data/lib/bcdice/game_system/GundogZero.rb +2 -2
  101. data/lib/bcdice/game_system/GurpsFW.rb +2 -5
  102. data/lib/bcdice/game_system/HarnMaster.rb +1 -1
  103. data/lib/bcdice/game_system/HatsuneMiku.rb +2 -2
  104. data/lib/bcdice/game_system/HouraiGakuen.rb +1 -1
  105. data/lib/bcdice/game_system/HuntersMoon.rb +17 -110
  106. data/lib/bcdice/game_system/Illusio.rb +25 -34
  107. data/lib/bcdice/game_system/InfiniteBabeL.rb +518 -0
  108. data/lib/bcdice/game_system/JekyllAndHyde.rb +42 -0
  109. data/lib/bcdice/game_system/JuinKansen.rb +251 -0
  110. data/lib/bcdice/game_system/KanColle.rb +17 -166
  111. data/lib/bcdice/game_system/KillDeathBusiness.rb +35 -44
  112. data/lib/bcdice/game_system/KillDeathBusiness_Korean.rb +2 -1
  113. data/lib/bcdice/game_system/LogHorizon.rb +8 -8
  114. data/lib/bcdice/game_system/LostRoyal.rb +2 -4
  115. data/lib/bcdice/game_system/MagicaLogia.rb +3 -3
  116. data/lib/bcdice/game_system/MagicaLogia_Korean.rb +66 -0
  117. data/lib/bcdice/game_system/MeikyuDays.rb +2 -2
  118. data/lib/bcdice/game_system/MeikyuKingdom.rb +3 -3
  119. data/lib/bcdice/game_system/MeikyuKingdomBasic.rb +3 -3
  120. data/lib/bcdice/game_system/MetalHeadExtream.rb +5 -5
  121. data/lib/bcdice/game_system/MetallicGuardian.rb +1 -2
  122. data/lib/bcdice/game_system/MonotoneMuseum.rb +4 -3
  123. data/lib/bcdice/game_system/MonotoneMuseum_Korean.rb +1 -1
  124. data/lib/bcdice/game_system/NSSQ.rb +2 -2
  125. data/lib/bcdice/game_system/Nechronica.rb +3 -3
  126. data/lib/bcdice/game_system/NeverCloud.rb +540 -5
  127. data/lib/bcdice/game_system/NightWizard.rb +2 -2
  128. data/lib/bcdice/game_system/NightWizard3rd.rb +1 -1
  129. data/lib/bcdice/game_system/NightmareHunterDeep.rb +3 -4
  130. data/lib/bcdice/game_system/NinjaSlayer.rb +30 -41
  131. data/lib/bcdice/game_system/OneWayHeroics.rb +1 -1
  132. data/lib/bcdice/game_system/OracleEngine.rb +14 -18
  133. data/lib/bcdice/game_system/OrgaRain.rb +17 -25
  134. data/lib/bcdice/game_system/Paradiso.rb +3 -3
  135. data/lib/bcdice/game_system/ParanoiaRebooted.rb +1 -1
  136. data/lib/bcdice/game_system/Peekaboo.rb +1 -1
  137. data/lib/bcdice/game_system/PhantasmAdventure.rb +0 -4
  138. data/lib/bcdice/game_system/Postman.rb +1 -1
  139. data/lib/bcdice/game_system/PulpCthulhu.rb +1 -1
  140. data/lib/bcdice/game_system/Raisondetre.rb +1 -1
  141. data/lib/bcdice/game_system/RecordOfLodossWar.rb +8 -7
  142. data/lib/bcdice/game_system/RecordOfSteam.rb +1 -1
  143. data/lib/bcdice/game_system/RokumonSekai2.rb +3 -3
  144. data/lib/bcdice/game_system/RuinBreakers.rb +1 -1
  145. data/lib/bcdice/game_system/RyuTuber.rb +6 -4
  146. data/lib/bcdice/game_system/Ryutama.rb +2 -2
  147. data/lib/bcdice/game_system/SRS.rb +1 -6
  148. data/lib/bcdice/game_system/SamsaraBallad.rb +5 -4
  149. data/lib/bcdice/game_system/Satasupe.rb +90 -865
  150. data/lib/bcdice/game_system/ScreamHighSchool.rb +2 -2
  151. data/lib/bcdice/game_system/SevenFortressMobius.rb +1 -1
  152. data/lib/bcdice/game_system/SharedFantasia.rb +1 -1
  153. data/lib/bcdice/game_system/ShinkuuGakuen.rb +3 -3
  154. data/lib/bcdice/game_system/ShinobiGami.rb +75 -39
  155. data/lib/bcdice/game_system/ShoujoTenrankai.rb +1 -1
  156. data/lib/bcdice/game_system/Skynauts.rb +2 -2
  157. data/lib/bcdice/game_system/SteamPunkers.rb +7 -5
  158. data/lib/bcdice/game_system/StellarKnights.rb +1 -3
  159. data/lib/bcdice/game_system/SterileLife.rb +1 -1
  160. data/lib/bcdice/game_system/StrangerOfSwordCity.rb +2 -2
  161. data/lib/bcdice/game_system/StratoShout.rb +10 -36
  162. data/lib/bcdice/game_system/StratoShout_Korean.rb +2 -1
  163. data/lib/bcdice/game_system/SwordWorld.rb +46 -182
  164. data/lib/bcdice/game_system/SwordWorld2_0.rb +21 -149
  165. data/lib/bcdice/game_system/SwordWorld2_5.rb +126 -40
  166. data/lib/bcdice/game_system/TherapieSein.rb +2 -2
  167. data/lib/bcdice/game_system/TokumeiTenkousei.rb +2 -2
  168. data/lib/bcdice/game_system/Torg.rb +2 -2
  169. data/lib/bcdice/game_system/TorgEternity.rb +5 -8
  170. data/lib/bcdice/game_system/TrinitySeven.rb +2 -2
  171. data/lib/bcdice/game_system/TunnelsAndTrolls.rb +7 -7
  172. data/lib/bcdice/game_system/TwilightGunsmoke.rb +2 -2
  173. data/lib/bcdice/game_system/UnsungDuet.rb +1 -1
  174. data/lib/bcdice/game_system/Utakaze.rb +2 -2
  175. data/lib/bcdice/game_system/VampireTheMasquerade5th.rb +1 -1
  176. data/lib/bcdice/game_system/Warhammer.rb +7 -7
  177. data/lib/bcdice/game_system/Warhammer4.rb +10 -13
  178. data/lib/bcdice/game_system/WorldOfDarkness.rb +1 -1
  179. data/lib/bcdice/game_system/YearZeroEngine.rb +1 -1
  180. data/lib/bcdice/game_system/Yggdrasill.rb +605 -0
  181. data/lib/bcdice/game_system/ZettaiReido.rb +2 -2
  182. data/lib/bcdice/game_system/cthulhu7th/full_auto.rb +294 -0
  183. data/lib/bcdice/game_system/cthulhu7th/rollable.rb +41 -0
  184. data/lib/bcdice/game_system/meikyu_kingdom/item_table.rb +2 -0
  185. data/lib/bcdice/game_system/meikyu_kingdom/kingdom_name_table.rb +2 -0
  186. data/lib/bcdice/game_system/meikyu_kingdom/landscape_table.rb +2 -0
  187. data/lib/bcdice/game_system/meikyu_kingdom/name_tables.rb +2 -0
  188. data/lib/bcdice/game_system/meikyu_kingdom/placename_table.rb +2 -0
  189. data/lib/bcdice/game_system/meikyu_kingdom/tables.rb +2 -0
  190. data/lib/bcdice/game_system/meikyu_kingdom/word_table.rb +2 -0
  191. data/lib/bcdice/game_system/meikyu_kingdom_basic/item_table.rb +2 -0
  192. data/lib/bcdice/game_system/meikyu_kingdom_basic/kingdom_table.rb +2 -0
  193. data/lib/bcdice/game_system/meikyu_kingdom_basic/name_table.rb +2 -0
  194. data/lib/bcdice/game_system/meikyu_kingdom_basic/table.rb +2 -0
  195. data/lib/bcdice/game_system/meikyu_kingdom_basic/word_table.rb +2 -0
  196. data/lib/bcdice/game_system/one_way_heroics/dungeon_table.rb +2 -0
  197. data/lib/bcdice/game_system/one_way_heroics/random_event_table.rb +2 -0
  198. data/lib/bcdice/game_system/one_way_heroics/tables.rb +2 -0
  199. data/lib/bcdice/game_system/satasupe/tables.rb +723 -0
  200. data/lib/bcdice/game_system/sword_world/rating_lexer.rb +47 -0
  201. data/lib/bcdice/game_system/sword_world/rating_parsed.rb +99 -0
  202. data/lib/bcdice/game_system/sword_world/rating_parser.rb +457 -0
  203. data/lib/bcdice/game_system/sword_world/transcendent_test.rb +104 -0
  204. data/lib/bcdice/loader.rb +11 -4
  205. data/lib/bcdice/normalize.rb +3 -1
  206. data/lib/bcdice/preprocessor.rb +12 -8
  207. data/lib/bcdice/randomizer.rb +14 -0
  208. data/lib/bcdice/repl.rb +3 -1
  209. data/lib/bcdice/result.rb +4 -0
  210. data/lib/bcdice/translate.rb +2 -0
  211. data/lib/bcdice/user_defined_dice_table.rb +28 -15
  212. data/lib/bcdice/version.rb +3 -1
  213. metadata +28 -27
  214. data/.editorconfig +0 -21
  215. data/.github/.codecov.yaml +0 -10
  216. data/.github/workflows/coverage.yaml +0 -21
  217. data/.github/workflows/lint.yaml +0 -13
  218. data/.github/workflows/test.yml +0 -20
  219. data/.gitignore +0 -14
  220. data/.rubocop.yml +0 -108
  221. data/.rubocop_todo.yml +0 -114
  222. data/Gemfile +0 -14
  223. data/ROADMAP.md +0 -30
  224. data/Rakefile +0 -152
  225. data/bcdice.gemspec +0 -29
  226. data/bin/repl.rb +0 -21
  227. data/docs/README.txt +0 -2028
  228. data/docs/dicebot_sort_key.md +0 -72
  229. data/docs/how_to_make_dicebot.md +0 -453
  230. data/lib/bcdice/command_parser.rb +0 -242
  231. data/lib/bcdice/common_command/add_dice/parser.y +0 -153
  232. data/lib/bcdice/common_command/barabara_dice/parser.y +0 -107
  233. data/lib/bcdice/common_command/calc/parser.y +0 -79
  234. data/lib/bcdice/common_command/reroll_dice/parser.y +0 -158
  235. data/lib/bcdice/common_command/upper_dice/parser.y +0 -143
@@ -59,10 +59,51 @@ module BCDice
59
59
  end
60
60
 
61
61
  def eval_game_system_specific_command(command)
62
- return roll_tables(command, TABLES)
62
+ return roll_tables(command, TABLES) || BloodCrusade::RTT.roll_command(randomizer, command)
63
63
  end
64
64
 
65
65
  TABLES = {
66
+ "ST" => DiceTable::Table.new(
67
+ "シーン表",
68
+ "2D6",
69
+ [
70
+ "どこまでも広がる荒野。風が吹き抜けていく。",
71
+ "血まみれの惨劇の跡。いったい誰がこんなことを?",
72
+ "都市の地下。かぼそい明かりがコンクリートを照らす。",
73
+ "豪華な調度が揃えられた室内。くつろぎの空間を演出。",
74
+ "普通の道端。様々な人が道を行き交う。",
75
+ "明るく浮かぶ月の下。暴力の気配が満ちていく。",
76
+ "打ち捨てられた廃墟。荒れ果てた景色に心も荒む。",
77
+ "生活の様子が色濃く残る部屋の中。誰の部屋だろう?",
78
+ "にぎやかな飲食店。騒ぐ人々に紛れつつ事態は進行する。",
79
+ "ざわめく木立。踊る影。",
80
+ "高い塔の上。都市を一望できる。"
81
+ ]
82
+ ),
83
+ "MIT" => DiceTable::Table.new(
84
+ "軽度狂気表",
85
+ "1D6",
86
+ [
87
+ "【誇大妄想】(判定に失敗するたびに【テンション】が1増加する。)",
88
+ "【記憶喪失】(【幸福】の修復判定にマイナス2の修正。)",
89
+ "【こだわり】(戦闘中の行動を「パス」以外で一つ選択し、その行動をすると【テンション】が6増加する。)",
90
+ "【お守り中毒】(「幸運のお守り」を装備していない場合、全ての2d6判定にマイナス1の修正。)",
91
+ "【不死幻想】(自分が受けるダメージが全て1増加する。)",
92
+ "【血の飢え】(戦闘中、ラウンドごとに他のキャラクターにダメージを与えないと、ラウンド終了時に【テンション】4増加。)"
93
+ ]
94
+ ),
95
+ "SIT" => DiceTable::Table.new(
96
+ "重度狂気表",
97
+ "1D6",
98
+ [
99
+ "【幸福依存】(【幸福】を一つ選択し、その【幸福】が結果フェイズに失われたとき、死亡する。)",
100
+ "【見えない友達】(交流判定にマイナス3の修正がつく。)",
101
+ "【臆病】(自分の行う妨害判定にマイナス2の修正がつく。)",
102
+ "【陰謀論】(休息判定にマイナス3の修正がつく。)",
103
+ "【指令受信】(メインフェイズの3サイクル目の自分のシーンでは、可能な範囲でGMが行動を決定する。)",
104
+ "【猜疑心】(自分が「連携攻撃」を行うとき、関係の【深度】をダメージに加えられない。)"
105
+ ]
106
+ ),
66
107
  "CHT" => DiceTable::Table.new(
67
108
  "自信幸福表",
68
109
  "1D6",
@@ -206,7 +247,7 @@ module BCDice
206
247
  ),
207
248
  }.merge(BloodCrusade::TABLES_WITH_BLOOD_MOON).freeze
208
249
 
209
- register_prefix(TABLES.keys)
250
+ register_prefix(BloodCrusade::RTT.prefixes, TABLES.keys)
210
251
  end
211
252
  end
212
253
  end
@@ -14,10 +14,11 @@ module BCDice
14
14
 
15
15
  # ダイスボットの使い方
16
16
  HELP_MESSAGE = <<~INFO_MESSAGE_TEXT
17
- ランダムでモンスターカードを選ぶ (RM)
17
+ ランダムでモンスターカードを選ぶ (RM) (RTTn n:色番号、省略可能)
18
+ ランダム分野表 RCT
18
19
  特定のモンスターカードを選ぶ (CMxy x:色、y:番号)
19
20
   白:W、青:U、緑:V、金:G、赤:R、黒:B
20
-  例)CMW1→白の2:白竜 CMG12→金の12:土精霊
21
+  例)CMW2→白の2:白竜 CMG12→金の12:土精霊
21
22
  場所表 (ST)
22
23
  街中場所表 (CST)
23
24
  郊外場所表 (OST)
@@ -43,7 +44,7 @@ module BCDice
43
44
  if dice_total <= 2
44
45
  return " > ファンブル"
45
46
  elsif dice_total >= 12
46
- return " > スペシャル > " + getRandumMonster()
47
+ return " > スペシャル > " + RTT.roll_command(@randomizer, "RM")
47
48
  elsif total >= target
48
49
  return " > 成功"
49
50
  else
@@ -52,72 +53,31 @@ module BCDice
52
53
  end
53
54
 
54
55
  def eval_game_system_specific_command(command)
55
- command = command.upcase
56
-
57
- case command
58
- when /^RM$/i
59
- return getRandumMonster
60
- when /^CM(\w)(\d+)$/i
61
- color = Regexp.last_match(1).upcase
62
- index = Regexp.last_match(2).to_i
63
- return getMonster(color, index)
64
- else
65
- return roll_tables(command, TABLES)
66
- end
67
- end
68
-
69
- def getRandumMonster
70
- type = "ランダムモンスター選択"
71
- colorTable = getColorTable
72
- color, colorIndex = get_table_by_1d6(colorTable)
73
-
74
- monsters = getMonsterTables(colorIndex - 1)
75
- monsterName, monsterIndex = get_table_by_2d6(monsters)
76
-
77
- output = "#{type}(#{colorIndex},#{monsterIndex}) > #{color}の#{monsterIndex}:#{monsterName}"
78
- return output
56
+ roll_tables(command, TABLES) || get_monster(command) || RTT.roll_command(randomizer, command)
79
57
  end
80
58
 
81
- def getColorTable
82
- ['白', '青', '緑', '金', '赤', '黒']
83
- end
84
-
85
- def getMonsterTables(colorIndex)
86
- tables = [
87
- ['白竜', '僧侶', '格闘家', '斧使い', '剣士', '槍士', '歩兵', '弓兵', '砲兵', '天使', '軍神'],
88
- ['水竜', '魚', '魚人', 'イカ', '蟹', '探偵', '海賊', '魔術師', '使い魔', '雲', '水精霊'],
89
- ['緑竜', 'ワーム', '鳥人', '鳥', '獣', '獣人', 'エルフ', '妖精', '昆虫', '植物', '森精霊'],
90
- ['金竜', '宝石', '岩石', '鋼', '錬金術師', '魔法生物', 'ドワーフ', '機械', '運命', '女神', '土精霊'],
91
- ['火竜', '竜人', '恐竜', '戦車', '蛮族', '小鬼', '大鬼', '巨人', '雷', '炎', '火精霊'],
92
- ['黒竜', '闇騎士', '怪物', '忍者', '妖怪', '蝙蝠', '吸血鬼', '不死者', '幽霊', '悪魔', '邪神'],
93
- ]
94
-
95
- return tables[colorIndex]
96
- end
97
-
98
- def getMonster(color, monsterIndex)
99
- return nil if monsterIndex < 2
100
-
101
- type = "モンスター選択"
102
-
103
- colorWords = ['W', 'U', 'V', 'G', 'R', 'B']
104
- colorIndex = colorWords.index(color)
105
- debug("colorIndex")
106
-
107
- return nil if colorIndex.nil?
59
+ COLOR_TABLE = ['W', 'U', 'V', 'G', 'R', 'B'].freeze
108
60
 
109
- colorTable = getColorTable
110
- color = colorTable[colorIndex]
61
+ RTT = DiceTable::SaiFicSkillTable.new([
62
+ ['白', ['白竜', '僧侶', '格闘家', '斧使い', '剣士', '槍士', '歩兵', '弓兵', '砲兵', '天使', '軍神']],
63
+ ['青', ['水竜', '魚', '魚人', 'イカ', '蟹', '探偵', '海賊', '魔術師', '使い魔', '雲', '水精霊']],
64
+ ['緑', ['緑竜', 'ワーム', '鳥人', '鳥', '獣', '獣人', 'エルフ', '妖精', '昆虫', '植物', '森精霊']],
65
+ ['金', ['金竜', '宝石', '岩石', '鋼', '錬金術師', '魔法生物', 'ドワーフ', '機械', '運命', '女神', '土精霊']],
66
+ ['赤', ['火竜', '竜人', '恐竜', '戦車', '蛮族', '小鬼', '大鬼', '巨人', '雷', '炎', '火精霊']],
67
+ ['黒', ['黒竜', '闇騎士', '怪物', '忍者', '妖怪', '蝙蝠', '吸血鬼', '不死者', '幽霊', '悪魔', '邪神']],
68
+ ], rtt: "RM", rtt_format: "ランダムモンスター選択(%<category_dice>d,%<row_dice>d) > %<text>s", s_format: "%<category_name>sの%<row_dice>d:%<skill_name>s")
111
69
 
112
- monsters = getMonsterTables(colorIndex)
113
- debug("monsters", monsters)
114
- debug("monsterIndex", monsterIndex)
115
- monsterName = monsters[monsterIndex - 2]
70
+ def get_monster(command)
71
+ m = command.match(/^CM(\w)(\d+)$/i)
72
+ return nil unless m
116
73
 
117
- return nil if monsterName.nil?
74
+ cat = COLOR_TABLE.index(m[1])
75
+ row_dice = m[2].to_i
76
+ return nil unless cat
77
+ return nil unless row_dice.between?(2, 12)
118
78
 
119
- output = "#{type} #{color}の#{monsterIndex}:#{monsterName}"
120
- return output
79
+ skill = RTT.categories[cat].skills[row_dice - 2]
80
+ return "モンスター選択 > #{skill}"
121
81
  end
122
82
 
123
83
  TABLES = {
@@ -242,7 +202,7 @@ module BCDice
242
202
  ]
243
203
  ),
244
204
  }.freeze
245
- register_prefix('RM', 'CM.*', TABLES.keys)
205
+ register_prefix(RTT.prefixes, 'CM', TABLES.keys)
246
206
  end
247
207
  end
248
208
  end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bcdice/command_parser'
4
-
5
3
  module BCDice
6
4
  module GameSystem
7
5
  class ChaosFlare < Base
@@ -41,7 +39,7 @@ module BCDice
41
39
  - FT7
42
40
  INFO_MESSAGE_TEXT
43
41
 
44
- register_prefix('\d*CF.*', 'FT\d*')
42
+ register_prefix('\d*CF', 'FT\d*')
45
43
 
46
44
  # ゲーム別成功度判定(2D6)。以前の処理をそのまま残しています。
47
45
  def check_2D6(total, dice_total, _dice_list, cmp_op, target)
@@ -108,7 +106,9 @@ module BCDice
108
106
  # @param command [String]
109
107
  # @return [String, nil]
110
108
  def cf_roll(command)
111
- parser = CommandParser.new(/\d*CF/)
109
+ parser = Command::Parser.new(/\d*CF/, round_type: round_type)
110
+ .enable_critical
111
+ .enable_fumble
112
112
 
113
113
  @cmd = parser.parse(command)
114
114
  unless @cmd
@@ -22,7 +22,7 @@ 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\d+')
26
26
 
27
27
  def check_1D100(total, _dice_total, cmp_op, target)
28
28
  return '' if target == '?'
@@ -26,9 +26,17 @@ module BCDice
26
26
  4CL+2@7 または 4CL@7+2 :サイコロ4個で判定値7のロールを行い達成値を出し、修正値2を足す。
27
27
  4CL[2] :サイコロ4個でクリティカル値2のロールを行う。
28
28
  0CL : 1CL[0]と同じ判定
29
+
30
+ デフォルトダイス:10面
29
31
  MESSAGETEXT
30
32
 
31
- register_prefix('[+-]?\d*CL([+-]\d+)?[@\d]*.*')
33
+ register_prefix('[+-]?\d*CL([+-]\d+)?[@\d]*')
34
+
35
+ def initialize(command)
36
+ super(command)
37
+
38
+ @sides_implicit_d = 10
39
+ end
32
40
 
33
41
  def eval_game_system_specific_command(command)
34
42
  debug('eval_game_system_specific_command command', command)
@@ -36,15 +44,15 @@ module BCDice
36
44
  result = ''
37
45
 
38
46
  case command
39
- when /([+-]?\d+)?CL([+-]\d+)?(\@(\d))?(\[(\d+)\])?([+-]\d+)?(>=(\d+))?/i
47
+ when /([+-]?\d+)?CL([+-]\d+)?(@(\d))?(\[(\d+)\])?([+-]\d+)?(>=(\d+))?/i
40
48
  m = Regexp.last_match
41
49
  base = (m[1] || 1).to_i
42
50
  modifier1 = m[2].to_i
43
51
  target = (m[4] || 6).to_i
44
- criticalTarget = (m[6] || 1).to_i
52
+ critical_target = (m[6] || 1).to_i
45
53
  modifier2 = m[7].to_i
46
54
  diff = m[9].to_i
47
- result = checkRoll(base, target, criticalTarget, diff, modifier1 + modifier2)
55
+ result = check_roll(base, target, critical_target, diff, modifier1 + modifier2)
48
56
  end
49
57
 
50
58
  return nil if result.empty?
@@ -52,80 +60,42 @@ module BCDice
52
60
  return "#{command} > #{result}"
53
61
  end
54
62
 
55
- def checkRoll(base, target, criticalTarget, diff, modifier)
56
- result = ""
57
-
58
- base = getValue(base)
59
- target = getValue(target)
60
- criticalTarget = getValue(criticalTarget)
61
- if base <= 0
62
- criticalTarget = 0
63
+ def check_roll(base, target, critical_target, diff, modifier)
64
+ if base <= 0 # クリティカルしない1D
65
+ critical_target = 0
63
66
  base = 1
64
67
  end
65
68
 
66
69
  target = 10 if target > 10
70
+ dice_list = @randomizer.roll_barabara(base, 10).sort
71
+ success_count = dice_list.count { |x| x <= target }
72
+ critical_count = dice_list.count { |x| x <= critical_target }
73
+ success_total = success_count + critical_count + modifier
67
74
 
68
- result += "(#{base}d10#{Format.modifier(modifier)})"
69
-
70
- diceList = @randomizer.roll_barabara(base, 10).sort
71
-
72
- result += " > [#{diceList.join(',')}]#{Format.modifier(modifier)} > "
73
- result += getRollResultString(diceList, target, criticalTarget, diff, modifier)
74
-
75
- return result
76
- end
77
-
78
- def getRollResultString(diceList, target, criticalTarget, diff, modifier)
79
- successCount, criticalCount = getSuccessInfo(diceList, target, criticalTarget)
80
-
81
- successTotal = successCount + criticalCount + modifier
82
- result = ""
75
+ mod_text = Format.modifier(modifier)
83
76
 
77
+ # (10d10+5)
78
+ result = "(#{base}d10#{mod_text}) > [#{dice_list.join(',')}]#{mod_text} > "
84
79
  result += "判定値[#{target}] " unless target == 6
85
- result += "クリティカル値[#{criticalTarget}] " unless criticalTarget == 1
86
- result += "達成値[#{successCount}]"
87
-
88
- # 出目がすべて判定値より大きければ固定値に関わらずファンブル
89
- if successCount <= 0
90
- result += " > ファンブル!"
91
- return result
92
- end
93
-
94
- result += "+クリティカル[#{criticalCount}]" if criticalCount > 0
95
- result += Format.modifier(modifier)
96
- result += "=[#{successTotal}]" if criticalCount > 0 || modifier != 0
97
-
98
- successText = getSuccessResultText(successTotal, diff)
99
- result += " > #{successText}"
100
-
101
- return result
102
- end
103
-
104
- def getSuccessResultText(successTotal, diff)
105
- return successTotal.to_s if diff == 0
106
- return "成功" if successTotal >= diff
80
+ result += "クリティカル値[#{critical_target}] " unless critical_target == 1
81
+ result += "達成値[#{success_count}]"
107
82
 
108
- return "失敗"
109
- end
110
-
111
- def getSuccessInfo(diceList, target, criticalTarget)
112
- debug("checkSuccess diceList, target, criticalTarget", diceList, target, criticalTarget)
113
-
114
- successCount = 0
115
- criticalCount = 0
83
+ return "#{result} > ファンブル!" if success_count <= 0
116
84
 
117
- diceList.each do |dice|
118
- successCount += 1 if dice <= target
119
- criticalCount += 1 if dice <= criticalTarget
120
- end
121
-
122
- return successCount, criticalCount
123
- end
85
+ result += "+クリティカル[#{critical_count}]" if critical_count > 0
86
+ result += mod_text
87
+ result += "=[#{success_total}]" if critical_count > 0 || modifier != 0
124
88
 
125
- def getValue(number)
126
- return 0 if number > 100
89
+ success_text =
90
+ if diff == 0
91
+ success_total.to_s
92
+ elsif success_total >= diff
93
+ "成功"
94
+ else
95
+ "失敗"
96
+ end
127
97
 
128
- return number
98
+ return "#{result} > #{success_text}"
129
99
  end
130
100
  end
131
101
  end
@@ -45,7 +45,7 @@ module BCDice
45
45
  def getCheckRollDiceCommandResult(command)
46
46
  debug("getCheckRollDiceCommandResult command", command)
47
47
 
48
- return nil unless command =~ /(\d+)?CH([\+\-\d]*)(>=([\+\-\d]*))?$/i
48
+ return nil unless command =~ /(\d+)?CH([+\-\d]*)(>=([+\-\d]*))?$/i
49
49
 
50
50
  diceCount = (Regexp.last_match(1) || 3).to_i
51
51
  modifyText = (Regexp.last_match(2) || '')
@@ -134,7 +134,7 @@ module BCDice
134
134
  def getYear(yearText)
135
135
  text = yearText.gsub(/(\d+)D(6+)/) { getD6xResult(Regexp.last_match(1).to_i, Regexp.last_match(2).length) }
136
136
 
137
- unless text.match?(%r{^[\+\-\*/\d]+$})
137
+ unless text.match?(%r{^[+\-*/\d]+$})
138
138
  return nil
139
139
  end
140
140
 
@@ -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('CC(B)?\(\d+\)', 'CC(B)?', 'RES(B)?', 'CBR(B)?\(\d+,\d+\)')
52
52
 
53
53
  def initialize(command)
54
54
  super(command)
@@ -97,7 +97,11 @@ module BCDice
97
97
  private
98
98
 
99
99
  def getCheckResult(command)
100
- m = %r{CCB?(\d+)?(?:<=([+-/*\d]+))?}i.match(command)
100
+ m = %r{^CCB?(\d+)?(?:<=([+-/*\d]+))?$}i.match(command)
101
+ unless m
102
+ return nil
103
+ end
104
+
101
105
  broken_num = m[1].to_i
102
106
  diff = ArithmeticEvaluator.eval(m[2])
103
107
 
@@ -189,7 +193,7 @@ module BCDice
189
193
  end
190
194
 
191
195
  def getRegistResult(command)
192
- m = /RES(B)?([-\d]+)/i.match(command)
196
+ m = /^RES(B)?([-\d]+)$/i.match(command)
193
197
  unless m
194
198
  return nil
195
199
  end
@@ -215,7 +219,7 @@ module BCDice
215
219
  end
216
220
 
217
221
  def getCombineRoll(command)
218
- m = /CBR(B)?\((\d+),(\d+)\)/i.match(command)
222
+ m = /^CBR(B)?\((\d+),(\d+)\)$/i.match(command)
219
223
  unless m
220
224
  return nil
221
225
  end
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "bcdice/game_system/cthulhu7th/rollable"
4
+ require "bcdice/game_system/cthulhu7th/full_auto"
5
+
3
6
  module BCDice
4
7
  module GameSystem
5
8
  class Cthulhu7th < Base
@@ -45,37 +48,31 @@ module BCDice
45
48
    強力でない呪文の場合 FCL/強力な呪文の場合 FCM
46
49
  INFO_MESSAGE_TEXT
47
50
 
48
- register_prefix('CC\(\d+\)', 'CC.*', 'CBR\(\d+,\d+\)', 'FAR.*', 'BMR', 'BMS', 'FCL', 'FCM', 'PH', 'MA')
49
-
50
- BONUS_DICE_RANGE = (-2..2).freeze
51
+ register_prefix('CC', 'CBR\(\d+,\d+\)', 'FAR', 'BMR', 'BMS', 'FCL', 'FCM', 'PH', 'MA')
51
52
 
52
53
  def eval_game_system_specific_command(command)
53
54
  case command
54
55
  when /^CC/i
55
- return skill_roll(command)
56
+ skill_roll(command)
56
57
  when /^CBR/i
57
- return combine_roll(command)
58
+ combine_roll(command)
58
59
  when /^FAR/i
59
- return getFullAutoResult(command)
60
+ getFullAutoResult(command)
60
61
  when /^BMR/i # 狂気の発作(リアルタイム)
61
- return roll_bmr_table()
62
+ roll_bmr_table()
62
63
  when /^BMS/i # 狂気の発作(サマリー)
63
- return roll_bms_table()
64
+ roll_bms_table()
64
65
  when /^FCL/i # キャスティング・ロールのプッシュに失敗した場合(小)
65
- return roll_1d8_table("キャスティング・ロール失敗(小)表", FAILED_CASTING_L_TABLE)
66
+ roll_1d8_table("キャスティング・ロール失敗(小)表", FAILED_CASTING_L_TABLE)
66
67
  when /^FCM/i # キャスティング・ロールのプッシュに失敗した場合(大)
67
- return roll_1d8_table("キャスティング・ロール失敗(大)表", FAILED_CASTING_M_TABLE)
68
+ roll_1d8_table("キャスティング・ロール失敗(大)表", FAILED_CASTING_M_TABLE)
68
69
  when /^PH/i # 恐怖症表
69
- return roll_1d100_table("恐怖症表", PHOBIAS_TABLE)
70
+ roll_1d100_table("恐怖症表", PHOBIAS_TABLE)
70
71
  when /^MA/i # マニア表
71
- return roll_1d100_table("マニア表", MANIAS_TABLE)
72
- else
73
- return nil
72
+ roll_1d100_table("マニア表", MANIAS_TABLE)
74
73
  end
75
74
  end
76
75
 
77
- private
78
-
79
76
  class ResultLevel
80
77
  LEVEL = [
81
78
  :fumble,
@@ -95,6 +92,24 @@ module BCDice
95
92
  failure: "失敗",
96
93
  }.freeze
97
94
 
95
+ def self.from_values(total, difficulty, fumbleable = false)
96
+ fumble = difficulty < 50 || fumbleable ? 96 : 100
97
+
98
+ if total == 1
99
+ ResultLevel.new(:critical)
100
+ elsif total <= (difficulty / 5)
101
+ ResultLevel.new(:extreme_success)
102
+ elsif total <= (difficulty / 2)
103
+ ResultLevel.new(:hard_success)
104
+ elsif total <= difficulty
105
+ ResultLevel.new(:regular_success)
106
+ elsif total >= fumble
107
+ ResultLevel.new(:fumble)
108
+ else
109
+ ResultLevel.new(:failure)
110
+ end
111
+ end
112
+
98
113
  def initialize(level)
99
114
  @level = level
100
115
  @level_index = LEVEL.index(level)
@@ -122,6 +137,10 @@ module BCDice
122
137
  end
123
138
  end
124
139
 
140
+ private
141
+
142
+ include Rollable
143
+
125
144
  def roll_1d8_table(table_name, table)
126
145
  total_n = @randomizer.roll_once(8)
127
146
  index = total_n - 1
@@ -154,14 +173,14 @@ module BCDice
154
173
  return "1D100 > #{dice}"
155
174
  end
156
175
 
157
- unless BONUS_DICE_RANGE.include?(bonus_dice)
158
- return "エラー。ボーナス・ペナルティダイスの値は#{BONUS_DICE_RANGE.min}~#{BONUS_DICE_RANGE.max}です。"
176
+ if bonus_dice.abs > 100
177
+ return "ボーナス・ペナルティダイスの値は-100以上、100以下としてください"
159
178
  end
160
179
 
161
180
  total, total_list = roll_with_bonus(bonus_dice)
162
181
 
163
182
  expr = difficulty.zero? ? "1D100" : "1D100<=#{difficulty}"
164
- result = result_level(total, difficulty) unless difficulty.zero?
183
+ result = ResultLevel.from_values(total, difficulty) unless difficulty.zero?
165
184
 
166
185
  sequence = [
167
186
  "(#{expr}) ボーナス・ペナルティダイス[#{bonus_dice}]",
@@ -180,54 +199,8 @@ module BCDice
180
199
  end
181
200
  end
182
201
 
183
- # 1D100の一の位用のダイスロール
184
- # 0から9までの値を返す
185
- #
186
- # @return [Integer]
187
- def roll_ones_d10
188
- dice = @randomizer.roll_once(10)
189
- return 0 if dice == 10
190
-
191
- return dice
192
- end
193
-
194
- # @param bonus [Integer] ボーナス・ペナルティダイスの数。負の数ならペナルティダイス。
195
- # @return [Array<(Integer, Array<Integer>)>]
196
- def roll_with_bonus(bonus)
197
- tens_list = Array.new(bonus.abs + 1) { @randomizer.roll_tens_d10 }
198
- ones = roll_ones_d10()
199
-
200
- dice_list = tens_list.map do |tens|
201
- dice = tens + ones
202
- dice == 0 ? 100 : dice
203
- end
204
-
205
- dice =
206
- if bonus >= 0
207
- dice_list.min
208
- else
209
- dice_list.max
210
- end
211
-
212
- return dice, dice_list
213
- end
214
-
215
- def result_level(total, difficulty, fumbleable = false)
216
- fumble = difficulty < 50 || fumbleable ? 96 : 100
217
-
218
- if total == 1
219
- ResultLevel.new(:critical)
220
- elsif total <= (difficulty / 5)
221
- ResultLevel.new(:extreme_success)
222
- elsif total <= (difficulty / 2)
223
- ResultLevel.new(:hard_success)
224
- elsif total <= difficulty
225
- ResultLevel.new(:regular_success)
226
- elsif total >= fumble
227
- ResultLevel.new(:fumble)
228
- else
229
- ResultLevel.new(:failure)
230
- end
202
+ def getFullAutoResult(command)
203
+ FullAuto.eval(command, @randomizer)
231
204
  end
232
205
 
233
206
  def combine_roll(command)
@@ -239,8 +212,8 @@ module BCDice
239
212
 
240
213
  total = @randomizer.roll_once(100)
241
214
 
242
- result_1 = result_level(total, difficulty_1)
243
- result_2 = result_level(total, difficulty_2)
215
+ result_1 = ResultLevel.from_values(total, difficulty_1)
216
+ result_2 = ResultLevel.from_values(total, difficulty_2)
244
217
 
245
218
  rank =
246
219
  if result_1.success? && result_2.success?
@@ -258,273 +231,6 @@ module BCDice
258
231
  end
259
232
  end
260
233
 
261
- def getFullAutoResult(command)
262
- return nil unless /^FAR\((-?\d+),(-?\d+),(-?\d+)(?:,(-?\d+)?)?(?:,(-?\w+)?)?(?:,(-?\d+)?)?\)/i =~ command
263
-
264
- bullet_count = Regexp.last_match(1).to_i
265
- diff = Regexp.last_match(2).to_i
266
- broken_number = Regexp.last_match(3).to_i
267
- bonus_dice_count = (Regexp.last_match(4) || 0).to_i
268
- stop_count = (Regexp.last_match(5) || "").to_s.downcase
269
- bullet_set_count_cap = (Regexp.last_match(6) || diff / 10).to_i
270
-
271
- output = ""
272
-
273
- # 最大で(8回*(PC技能値最大値/10))=72発しか撃てないはずなので上限
274
- bullet_count_limit = 100
275
- if bullet_count > bullet_count_limit
276
- output += "弾薬が多すぎます。装填された弾薬を#{bullet_count_limit}発に変更します。\n"
277
- bullet_count = bullet_count_limit
278
- end
279
-
280
- # ボレーの上限の設定がおかしい場合の注意表示
281
- if (bullet_set_count_cap > diff / 10) && (diff > 39) && !Regexp.last_match(6).nil?
282
- bullet_set_count_cap = diff / 10
283
- output += "ボレーの弾丸の数の上限は\[技能値÷10(切り捨て)\]発なので、それより高い数を指定できません。ボレーの弾丸の数を#{bullet_set_count_cap}発に変更します。\n"
284
- elsif (diff <= 39) && (bullet_set_count_cap > 3) && !Regexp.last_match(6).nil?
285
- bullet_set_count_cap = 3
286
- output += "技能値が39以下ではボレーの弾丸の数の上限および下限は3発です。ボレーの弾丸の数を#{bullet_set_count_cap}発に変更します。\n"
287
- end
288
-
289
- # ボレーの下限の設定がおかしい場合の注意表示およびエラー表示
290
- return "ボレーの弾丸の数は正の数です。" if (bullet_set_count_cap <= 0) && !Regexp.last_match(6).nil?
291
-
292
- if (bullet_set_count_cap < 3) && !Regexp.last_match(6).nil?
293
- bullet_set_count_cap = 3
294
- output += "ボレーの弾丸の数の下限は3発です。ボレーの弾丸の数を3発に変更します。\n"
295
- end
296
-
297
- return "弾薬は正の数です。" if bullet_count <= 0
298
- return "目標値は正の数です。" if diff <= 0
299
-
300
- if broken_number < 0
301
- output += "故障ナンバーは正の数です。マイナス記号を外します。\n"
302
- broken_number = broken_number.abs
303
- end
304
-
305
- unless BONUS_DICE_RANGE.include?(bonus_dice_count)
306
- return "エラー。ボーナス・ペナルティダイスの値は#{BONUS_DICE_RANGE.min}~#{BONUS_DICE_RANGE.max}です。"
307
- end
308
-
309
- output += "ボーナス・ペナルティダイス[#{bonus_dice_count}]"
310
- output += rollFullAuto(bullet_count, diff, broken_number, bonus_dice_count, stop_count, bullet_set_count_cap)
311
-
312
- return output
313
- end
314
-
315
- def rollFullAuto(bullet_count, diff, broken_number, dice_num, stop_count, bullet_set_count_cap)
316
- output = ""
317
- loopCount = 0
318
-
319
- counts = {
320
- hit_bullet: 0,
321
- impale_bullet: 0,
322
- bullet: bullet_count,
323
- }
324
-
325
- # 難易度変更用ループ
326
- (0..3).each do |more_difficulty|
327
- output += getNextDifficultyMessage(more_difficulty)
328
-
329
- # ペナルティダイスを減らしながらロール用ループ
330
- while dice_num >= BONUS_DICE_RANGE.min
331
-
332
- loopCount += 1
333
- hit_result, total, total_list = getHitResultInfos(dice_num, diff, more_difficulty)
334
- output += "\n#{loopCount}回目: > #{total_list.join(', ')} > #{hit_result}"
335
-
336
- if total >= broken_number
337
- output += " ジャム"
338
- return getHitResultText(output, counts)
339
- end
340
-
341
- hit_type = getHitType(more_difficulty, hit_result)
342
- hit_bullet, impale_bullet, lost_bullet = getBulletResults(counts[:bullet], hit_type, diff, bullet_set_count_cap)
343
-
344
- output += " (#{hit_bullet}発が命中、#{impale_bullet}発が貫通)"
345
-
346
- counts[:hit_bullet] += hit_bullet
347
- counts[:impale_bullet] += impale_bullet
348
- counts[:bullet] -= lost_bullet
349
-
350
- return getHitResultText(output, counts) if counts[:bullet] <= 0
351
-
352
- dice_num -= 1
353
- end
354
-
355
- # 指定された難易度となった場合、連射処理を途中で止める
356
- if shouldStopRollFullAuto?(stop_count, more_difficulty)
357
- output += "\n【指定の難易度となったので、処理を終了します。】"
358
- break
359
- end
360
-
361
- dice_num += 1
362
- end
363
-
364
- return getHitResultText(output, counts)
365
- end
366
-
367
- # 連射処理を止める条件(難易度の閾値)
368
- # @return [Hash<String, Integer>]
369
- #
370
- # 成功の種類の小文字表記 => 難易度の閾値
371
- ROLL_FULL_AUTO_DIFFICULTY_THRESHOLD = {
372
- # レギュラー
373
- 'r' => 0,
374
- # ハード
375
- 'h' => 1,
376
- # イクストリーム
377
- 'e' => 2
378
- }.freeze
379
-
380
- # 連射処理を止めるべきかどうかを返す
381
- # @param [String] stop_count 成功の種類
382
- # @param [Integer] difficulty 難易度
383
- # @return [Boolean]
384
- def shouldStopRollFullAuto?(stop_count, difficulty)
385
- difficulty_threshold = ROLL_FULL_AUTO_DIFFICULTY_THRESHOLD[stop_count]
386
- return difficulty_threshold && difficulty >= difficulty_threshold
387
- end
388
-
389
- def getHitResultInfos(dice_num, diff, more_difficulty)
390
- total, total_list = roll_with_bonus(dice_num)
391
-
392
- fumbleable = getFumbleable(more_difficulty)
393
- hit_result = result_level(total, diff, fumbleable).to_s
394
-
395
- return hit_result, total, total_list
396
- end
397
-
398
- def getHitResultText(output, counts)
399
- return "#{output}\n> #{counts[:hit_bullet]}発が通常命中、#{counts[:impale_bullet]}発が貫通、残弾#{counts[:bullet]}発"
400
- end
401
-
402
- def getHitType(more_difficulty, hit_result)
403
- successList, impaleBulletList = getSuccessListImpaleBulletList(more_difficulty)
404
-
405
- return :hit if successList.include?(hit_result)
406
- return :impale if impaleBulletList.include?(hit_result)
407
-
408
- return ""
409
- end
410
-
411
- def getBulletResults(bullet_count, hit_type, diff, bullet_set_count_cap)
412
- bullet_set_count = getSetOfBullet(diff, bullet_set_count_cap)
413
- hit_bullet_count_base = getHitBulletCountBase(diff, bullet_set_count)
414
- impale_bullet_count_base = (bullet_set_count / 2.to_f)
415
-
416
- lost_bullet_count = 0
417
- hit_bullet_count = 0
418
- impale_bullet_count = 0
419
-
420
- if !isLastBulletTurn(bullet_count, bullet_set_count)
421
-
422
- case hit_type
423
- when :hit
424
- hit_bullet_count = hit_bullet_count_base # 通常命中した弾数の計算
425
-
426
- when :impale
427
- impale_bullet_count = impale_bullet_count_base.floor # 貫通した弾数の計算
428
- hit_bullet_count = impale_bullet_count_base.ceil
429
- end
430
-
431
- lost_bullet_count = bullet_set_count
432
-
433
- else
434
-
435
- case hit_type
436
- when :hit
437
- hit_bullet_count = getLastHitBulletCount(bullet_count)
438
-
439
- when :impale
440
- impale_bullet_count = getLastHitBulletCount(bullet_count)
441
- hit_bullet_count = bullet_count - impale_bullet_count
442
- end
443
-
444
- lost_bullet_count = bullet_count
445
- end
446
-
447
- return hit_bullet_count, impale_bullet_count, lost_bullet_count
448
- end
449
-
450
- def getSuccessListImpaleBulletList(more_difficulty)
451
- successList = []
452
- impaleBulletList = []
453
-
454
- case more_difficulty
455
- when 0
456
- successList = ["ハード成功", "レギュラー成功"]
457
- impaleBulletList = ["クリティカル", "イクストリーム成功"]
458
- when 1
459
- successList = ["ハード成功"]
460
- impaleBulletList = ["クリティカル", "イクストリーム成功"]
461
- when 2
462
- successList = []
463
- impaleBulletList = ["クリティカル", "イクストリーム成功"]
464
- when 3
465
- successList = ["クリティカル"]
466
- impaleBulletList = []
467
- end
468
-
469
- return successList, impaleBulletList
470
- end
471
-
472
- def getNextDifficultyMessage(more_difficulty)
473
- case more_difficulty
474
- when 1
475
- return "\n【難易度がハードに変更】"
476
- when 2
477
- return "\n【難易度がイクストリームに変更】"
478
- when 3
479
- return "\n【難易度がクリティカルに変更】"
480
- end
481
-
482
- return ""
483
- end
484
-
485
- def getSetOfBullet(diff, bullet_set_count_cap)
486
- bullet_set_count = diff / 10
487
-
488
- if bullet_set_count_cap < bullet_set_count
489
- bullet_set_count = bullet_set_count_cap
490
- end
491
-
492
- if (diff >= 1) && (diff < 30)
493
- bullet_set_count = 3 # 技能値が29以下での最低値保障処理
494
- end
495
-
496
- return bullet_set_count
497
- end
498
-
499
- def getHitBulletCountBase(diff, bullet_set_count)
500
- hit_bullet_count_base = (bullet_set_count / 2)
501
-
502
- if (diff >= 1) && (diff < 30)
503
- hit_bullet_count_base = 1 # 技能値29以下での最低値保障
504
- end
505
-
506
- return hit_bullet_count_base
507
- end
508
-
509
- def isLastBulletTurn(bullet_count, bullet_set_count)
510
- ((bullet_count - bullet_set_count) < 0)
511
- end
512
-
513
- def getLastHitBulletCount(bullet_count)
514
- # 残弾1での最低値保障処理
515
- if bullet_count == 1
516
- return 1
517
- end
518
-
519
- count = (bullet_count / 2.to_f).floor
520
- return count
521
- end
522
-
523
- def getFumbleable(more_difficulty)
524
- # 成功が49以下の出目のみとなるため、ファンブル値は上昇
525
- return (more_difficulty >= 1)
526
- end
527
-
528
234
  # 表一式
529
235
  # 即時の恐怖症表
530
236
  def roll_bmr_table()