bcdice 3.0.0.pre.alpha.1

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 (258) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +21 -0
  3. data/.github/.codecov.yaml +10 -0
  4. data/.github/workflows/coverage.yaml +21 -0
  5. data/.github/workflows/lint.yaml +13 -0
  6. data/.github/workflows/test.yml +20 -0
  7. data/.gitignore +14 -0
  8. data/.rubocop.yml +96 -0
  9. data/.rubocop_todo.yml +113 -0
  10. data/CHANGELOG.md +868 -0
  11. data/Gemfile +11 -0
  12. data/LICENSE +29 -0
  13. data/README.md +38 -0
  14. data/ROADMAP.md +30 -0
  15. data/Rakefile +118 -0
  16. data/bcdice.gemspec +27 -0
  17. data/bin/repl.rb +21 -0
  18. data/docs/README.txt +2028 -0
  19. data/docs/dicebot_sort_key.md +72 -0
  20. data/docs/how_to_make_dicebot.md +453 -0
  21. data/lib/bcdice.rb +8 -0
  22. data/lib/bcdice/arithmetic_evaluator.rb +167 -0
  23. data/lib/bcdice/base.rb +423 -0
  24. data/lib/bcdice/command_parser.rb +242 -0
  25. data/lib/bcdice/common_command.rb +23 -0
  26. data/lib/bcdice/common_command/add_dice.rb +54 -0
  27. data/lib/bcdice/common_command/add_dice/node.rb +488 -0
  28. data/lib/bcdice/common_command/add_dice/parser.rb +282 -0
  29. data/lib/bcdice/common_command/add_dice/randomizer.rb +48 -0
  30. data/lib/bcdice/common_command/barabara_dice.rb +57 -0
  31. data/lib/bcdice/common_command/calc.rb +39 -0
  32. data/lib/bcdice/common_command/choice.rb +35 -0
  33. data/lib/bcdice/common_command/d66_dice.rb +63 -0
  34. data/lib/bcdice/common_command/reroll_dice.rb +190 -0
  35. data/lib/bcdice/common_command/upper_dice.rb +165 -0
  36. data/lib/bcdice/common_command/version.rb +26 -0
  37. data/lib/bcdice/dice_table.rb +8 -0
  38. data/lib/bcdice/dice_table/chain_table.rb +33 -0
  39. data/lib/bcdice/dice_table/d66_grid_table.rb +26 -0
  40. data/lib/bcdice/dice_table/d66_range_table.rb +26 -0
  41. data/lib/bcdice/dice_table/d66_table.rb +34 -0
  42. data/lib/bcdice/dice_table/range_table.rb +267 -0
  43. data/lib/bcdice/dice_table/roll_result.rb +43 -0
  44. data/lib/bcdice/dice_table/sai_fic_skill_table.rb +32 -0
  45. data/lib/bcdice/dice_table/table.rb +35 -0
  46. data/lib/bcdice/enum.rb +15 -0
  47. data/lib/bcdice/format.rb +36 -0
  48. data/lib/bcdice/game_system.rb +187 -0
  49. data/lib/bcdice/game_system/AFF2e.rb +141 -0
  50. data/lib/bcdice/game_system/AceKillerGene.rb +55 -0
  51. data/lib/bcdice/game_system/Airgetlamh.rb +117 -0
  52. data/lib/bcdice/game_system/Alsetto.rb +124 -0
  53. data/lib/bcdice/game_system/Alshard.rb +27 -0
  54. data/lib/bcdice/game_system/AlterRaise.rb +282 -0
  55. data/lib/bcdice/game_system/Amadeus.rb +622 -0
  56. data/lib/bcdice/game_system/Amadeus_Korean.rb +501 -0
  57. data/lib/bcdice/game_system/AnimaAnimus.rb +96 -0
  58. data/lib/bcdice/game_system/Arianrhod.rb +50 -0
  59. data/lib/bcdice/game_system/ArsMagica.rb +149 -0
  60. data/lib/bcdice/game_system/Avandner.rb +101 -0
  61. data/lib/bcdice/game_system/BBN.rb +143 -0
  62. data/lib/bcdice/game_system/BadLife.rb +435 -0
  63. data/lib/bcdice/game_system/BarnaKronika.rb +188 -0
  64. data/lib/bcdice/game_system/BattleTech.rb +530 -0
  65. data/lib/bcdice/game_system/BeastBindTrinity.rb +348 -0
  66. data/lib/bcdice/game_system/BeginningIdol.rb +2527 -0
  67. data/lib/bcdice/game_system/BeginningIdol_Korean.rb +2378 -0
  68. data/lib/bcdice/game_system/BladeOfArcana.rb +252 -0
  69. data/lib/bcdice/game_system/BlindMythos.rb +460 -0
  70. data/lib/bcdice/game_system/BloodCrusade.rb +423 -0
  71. data/lib/bcdice/game_system/BloodMoon.rb +213 -0
  72. data/lib/bcdice/game_system/CardRanker.rb +249 -0
  73. data/lib/bcdice/game_system/ChaosFlare.rb +181 -0
  74. data/lib/bcdice/game_system/Chill.rb +163 -0
  75. data/lib/bcdice/game_system/Chill3.rb +52 -0
  76. data/lib/bcdice/game_system/CodeLayerd.rb +132 -0
  77. data/lib/bcdice/game_system/ColossalHunter.rb +569 -0
  78. data/lib/bcdice/game_system/CrashWorld.rb +81 -0
  79. data/lib/bcdice/game_system/Cthulhu.rb +252 -0
  80. data/lib/bcdice/game_system/Cthulhu7th.rb +767 -0
  81. data/lib/bcdice/game_system/Cthulhu7th_ChineseTraditional.rb +386 -0
  82. data/lib/bcdice/game_system/Cthulhu7th_Korean.rb +383 -0
  83. data/lib/bcdice/game_system/CthulhuTech.rb +263 -0
  84. data/lib/bcdice/game_system/Cthulhu_ChineseTraditional.rb +243 -0
  85. data/lib/bcdice/game_system/Cthulhu_Korean.rb +240 -0
  86. data/lib/bcdice/game_system/DarkBlaze.rb +207 -0
  87. data/lib/bcdice/game_system/DarkDaysDrive.rb +425 -0
  88. data/lib/bcdice/game_system/DarkSouls.rb +91 -0
  89. data/lib/bcdice/game_system/DeadlineHeroes.rb +583 -0
  90. data/lib/bcdice/game_system/DemonParasite.rb +524 -0
  91. data/lib/bcdice/game_system/DetatokoSaga.rb +310 -0
  92. data/lib/bcdice/game_system/DetatokoSaga_Korean.rb +310 -0
  93. data/lib/bcdice/game_system/DiceBot.rb +17 -0
  94. data/lib/bcdice/game_system/DiceOfTheDead.rb +111 -0
  95. data/lib/bcdice/game_system/DoubleCross.rb +373 -0
  96. data/lib/bcdice/game_system/DoubleCross_Korean.rb +371 -0
  97. data/lib/bcdice/game_system/Dracurouge.rb +1856 -0
  98. data/lib/bcdice/game_system/Dracurouge_Korean.rb +310 -0
  99. data/lib/bcdice/game_system/DungeonsAndDragons.rb +19 -0
  100. data/lib/bcdice/game_system/EarthDawn.rb +225 -0
  101. data/lib/bcdice/game_system/EarthDawn3.rb +275 -0
  102. data/lib/bcdice/game_system/EarthDawn4.rb +272 -0
  103. data/lib/bcdice/game_system/EclipsePhase.rb +51 -0
  104. data/lib/bcdice/game_system/Elric.rb +36 -0
  105. data/lib/bcdice/game_system/Elysion.rb +1213 -0
  106. data/lib/bcdice/game_system/EmbryoMachine.rb +227 -0
  107. data/lib/bcdice/game_system/EndBreaker.rb +132 -0
  108. data/lib/bcdice/game_system/EtrianOdysseySRS.rb +27 -0
  109. data/lib/bcdice/game_system/Fiasco.rb +123 -0
  110. data/lib/bcdice/game_system/Fiasco_Korean.rb +122 -0
  111. data/lib/bcdice/game_system/FilledWith.rb +1543 -0
  112. data/lib/bcdice/game_system/FullMetalPanic.rb +27 -0
  113. data/lib/bcdice/game_system/FutariSousa.rb +994 -0
  114. data/lib/bcdice/game_system/FutariSousa_Korean.rb +994 -0
  115. data/lib/bcdice/game_system/Garako.rb +559 -0
  116. data/lib/bcdice/game_system/GardenOrder.rb +451 -0
  117. data/lib/bcdice/game_system/GehennaAn.rb +136 -0
  118. data/lib/bcdice/game_system/GeishaGirlwithKatana.rb +120 -0
  119. data/lib/bcdice/game_system/GoblinSlayer.rb +168 -0
  120. data/lib/bcdice/game_system/GoldenSkyStories.rb +77 -0
  121. data/lib/bcdice/game_system/Gorilla.rb +44 -0
  122. data/lib/bcdice/game_system/GranCrest.rb +518 -0
  123. data/lib/bcdice/game_system/Gundog.rb +52 -0
  124. data/lib/bcdice/game_system/GundogRevised.rb +294 -0
  125. data/lib/bcdice/game_system/GundogZero.rb +261 -0
  126. data/lib/bcdice/game_system/Gurps.rb +403 -0
  127. data/lib/bcdice/game_system/GurpsFW.rb +2330 -0
  128. data/lib/bcdice/game_system/HarnMaster.rb +208 -0
  129. data/lib/bcdice/game_system/HatsuneMiku.rb +706 -0
  130. data/lib/bcdice/game_system/Hieizan.rb +48 -0
  131. data/lib/bcdice/game_system/HouraiGakuen.rb +270 -0
  132. data/lib/bcdice/game_system/HuntersMoon.rb +503 -0
  133. data/lib/bcdice/game_system/Illusio.rb +89 -0
  134. data/lib/bcdice/game_system/InfiniteFantasia.rb +51 -0
  135. data/lib/bcdice/game_system/Insane.rb +822 -0
  136. data/lib/bcdice/game_system/Insane_Korean.rb +773 -0
  137. data/lib/bcdice/game_system/IthaWenUa.rb +38 -0
  138. data/lib/bcdice/game_system/JamesBond.rb +45 -0
  139. data/lib/bcdice/game_system/Kamigakari.rb +394 -0
  140. data/lib/bcdice/game_system/Kamigakari_Korean.rb +428 -0
  141. data/lib/bcdice/game_system/KanColle.rb +938 -0
  142. data/lib/bcdice/game_system/KemonoNoMori.rb +258 -0
  143. data/lib/bcdice/game_system/KillDeathBusiness.rb +1420 -0
  144. data/lib/bcdice/game_system/KillDeathBusiness_Korean.rb +1510 -0
  145. data/lib/bcdice/game_system/KurayamiCrying.rb +49 -0
  146. data/lib/bcdice/game_system/LiveraDoll.rb +375 -0
  147. data/lib/bcdice/game_system/LogHorizon.rb +3567 -0
  148. data/lib/bcdice/game_system/LogHorizon_Korean.rb +1407 -0
  149. data/lib/bcdice/game_system/LostRecord.rb +30 -0
  150. data/lib/bcdice/game_system/LostRoyal.rb +242 -0
  151. data/lib/bcdice/game_system/MagicaLogia.rb +1148 -0
  152. data/lib/bcdice/game_system/MeikyuDays.rb +415 -0
  153. data/lib/bcdice/game_system/MeikyuKingdom.rb +466 -0
  154. data/lib/bcdice/game_system/MeikyuKingdomBasic.rb +269 -0
  155. data/lib/bcdice/game_system/MetalHead.rb +249 -0
  156. data/lib/bcdice/game_system/MetalHeadExtream.rb +917 -0
  157. data/lib/bcdice/game_system/MetallicGuardian.rb +31 -0
  158. data/lib/bcdice/game_system/MonotoneMuseum.rb +354 -0
  159. data/lib/bcdice/game_system/MonotoneMuseum_Korean.rb +304 -0
  160. data/lib/bcdice/game_system/Nechronica.rb +211 -0
  161. data/lib/bcdice/game_system/Nechronica_Korean.rb +160 -0
  162. data/lib/bcdice/game_system/NeverCloud.rb +74 -0
  163. data/lib/bcdice/game_system/NightWizard.rb +231 -0
  164. data/lib/bcdice/game_system/NightWizard3rd.rb +24 -0
  165. data/lib/bcdice/game_system/NightmareHunterDeep.rb +117 -0
  166. data/lib/bcdice/game_system/NinjaSlayer.rb +274 -0
  167. data/lib/bcdice/game_system/NjslyrBattle.rb +54 -0
  168. data/lib/bcdice/game_system/Nuekagami.rb +293 -0
  169. data/lib/bcdice/game_system/OneWayHeroics.rb +134 -0
  170. data/lib/bcdice/game_system/OracleEngine.rb +265 -0
  171. data/lib/bcdice/game_system/OrgaRain.rb +77 -0
  172. data/lib/bcdice/game_system/Oukahoushin3rd.rb +162 -0
  173. data/lib/bcdice/game_system/Paradiso.rb +323 -0
  174. data/lib/bcdice/game_system/Paranoia.rb +64 -0
  175. data/lib/bcdice/game_system/ParanoiaRebooted.rb +109 -0
  176. data/lib/bcdice/game_system/ParasiteBlood.rb +231 -0
  177. data/lib/bcdice/game_system/Pathfinder.rb +21 -0
  178. data/lib/bcdice/game_system/Peekaboo.rb +324 -0
  179. data/lib/bcdice/game_system/Pendragon.rb +39 -0
  180. data/lib/bcdice/game_system/PhantasmAdventure.rb +73 -0
  181. data/lib/bcdice/game_system/Postman.rb +185 -0
  182. data/lib/bcdice/game_system/PulpCthulhu.rb +184 -0
  183. data/lib/bcdice/game_system/Raisondetre.rb +171 -0
  184. data/lib/bcdice/game_system/RecordOfLodossWar.rb +58 -0
  185. data/lib/bcdice/game_system/RecordOfSteam.rb +149 -0
  186. data/lib/bcdice/game_system/RokumonSekai2.rb +110 -0
  187. data/lib/bcdice/game_system/RoleMaster.rb +24 -0
  188. data/lib/bcdice/game_system/RuneQuest.rb +47 -0
  189. data/lib/bcdice/game_system/RyuTuber.rb +266 -0
  190. data/lib/bcdice/game_system/Ryutama.rb +199 -0
  191. data/lib/bcdice/game_system/SRS.rb +348 -0
  192. data/lib/bcdice/game_system/SamsaraBallad.rb +111 -0
  193. data/lib/bcdice/game_system/Satasupe.rb +1173 -0
  194. data/lib/bcdice/game_system/ScreamHighSchool.rb +128 -0
  195. data/lib/bcdice/game_system/SevenFortressMobius.rb +34 -0
  196. data/lib/bcdice/game_system/ShadowRun.rb +26 -0
  197. data/lib/bcdice/game_system/ShadowRun4.rb +49 -0
  198. data/lib/bcdice/game_system/ShadowRun5.rb +80 -0
  199. data/lib/bcdice/game_system/SharedFantasia.rb +69 -0
  200. data/lib/bcdice/game_system/ShinMegamiTenseiKakuseihen.rb +85 -0
  201. data/lib/bcdice/game_system/ShinkuuGakuen.rb +506 -0
  202. data/lib/bcdice/game_system/ShinobiGami.rb +680 -0
  203. data/lib/bcdice/game_system/ShoujoTenrankai.rb +677 -0
  204. data/lib/bcdice/game_system/Skynauts.rb +324 -0
  205. data/lib/bcdice/game_system/SteamPunkers.rb +485 -0
  206. data/lib/bcdice/game_system/StellarKnights.rb +856 -0
  207. data/lib/bcdice/game_system/SterileLife.rb +452 -0
  208. data/lib/bcdice/game_system/StrangerOfSwordCity.rb +103 -0
  209. data/lib/bcdice/game_system/StratoShout.rb +316 -0
  210. data/lib/bcdice/game_system/StratoShout_Korean.rb +314 -0
  211. data/lib/bcdice/game_system/Strave.rb +223 -0
  212. data/lib/bcdice/game_system/SwordWorld.rb +491 -0
  213. data/lib/bcdice/game_system/SwordWorld2_0.rb +295 -0
  214. data/lib/bcdice/game_system/SwordWorld2_5.rb +121 -0
  215. data/lib/bcdice/game_system/TherapieSein.rb +93 -0
  216. data/lib/bcdice/game_system/TokumeiTenkousei.rb +96 -0
  217. data/lib/bcdice/game_system/TokyoGhostResearch.rb +122 -0
  218. data/lib/bcdice/game_system/TokyoNova.rb +19 -0
  219. data/lib/bcdice/game_system/Torg.rb +364 -0
  220. data/lib/bcdice/game_system/Torg1_5.rb +139 -0
  221. data/lib/bcdice/game_system/TorgEternity.rb +414 -0
  222. data/lib/bcdice/game_system/TrinitySeven.rb +364 -0
  223. data/lib/bcdice/game_system/TunnelsAndTrolls.rb +287 -0
  224. data/lib/bcdice/game_system/TwilightGunsmoke.rb +527 -0
  225. data/lib/bcdice/game_system/Utakaze.rb +153 -0
  226. data/lib/bcdice/game_system/VampireTheMasquerade5th.rb +132 -0
  227. data/lib/bcdice/game_system/Villaciel.rb +555 -0
  228. data/lib/bcdice/game_system/WARPS.rb +33 -0
  229. data/lib/bcdice/game_system/WaresBlade.rb +34 -0
  230. data/lib/bcdice/game_system/Warhammer.rb +336 -0
  231. data/lib/bcdice/game_system/WitchQuest.rb +275 -0
  232. data/lib/bcdice/game_system/WorldOfDarkness.rb +135 -0
  233. data/lib/bcdice/game_system/YankeeYogSothoth.rb +440 -0
  234. data/lib/bcdice/game_system/YearZeroEngine.rb +134 -0
  235. data/lib/bcdice/game_system/ZettaiReido.rb +142 -0
  236. data/lib/bcdice/game_system/meikyu_kingdom/item_table.rb +383 -0
  237. data/lib/bcdice/game_system/meikyu_kingdom/kingdom_name_table.rb +89 -0
  238. data/lib/bcdice/game_system/meikyu_kingdom/landscape_table.rb +196 -0
  239. data/lib/bcdice/game_system/meikyu_kingdom/name_tables.rb +223 -0
  240. data/lib/bcdice/game_system/meikyu_kingdom/placename_table.rb +214 -0
  241. data/lib/bcdice/game_system/meikyu_kingdom/tables.rb +610 -0
  242. data/lib/bcdice/game_system/meikyu_kingdom/word_table.rb +117 -0
  243. data/lib/bcdice/game_system/meikyu_kingdom_basic/item_table.rb +380 -0
  244. data/lib/bcdice/game_system/meikyu_kingdom_basic/kingdom_table.rb +184 -0
  245. data/lib/bcdice/game_system/meikyu_kingdom_basic/name_table.rb +417 -0
  246. data/lib/bcdice/game_system/meikyu_kingdom_basic/table.rb +912 -0
  247. data/lib/bcdice/game_system/meikyu_kingdom_basic/word_table.rb +121 -0
  248. data/lib/bcdice/game_system/one_way_heroics/dungeon_table.rb +67 -0
  249. data/lib/bcdice/game_system/one_way_heroics/random_event_table.rb +166 -0
  250. data/lib/bcdice/game_system/one_way_heroics/tables.rb +668 -0
  251. data/lib/bcdice/loader.rb +37 -0
  252. data/lib/bcdice/normalize.rb +38 -0
  253. data/lib/bcdice/preprocessor.rb +87 -0
  254. data/lib/bcdice/randomizer.rb +137 -0
  255. data/lib/bcdice/repl.rb +155 -0
  256. data/lib/bcdice/user_defined_dice_table.rb +153 -0
  257. data/lib/bcdice/version.rb +3 -0
  258. metadata +304 -0
@@ -0,0 +1,364 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BCDice
4
+ module GameSystem
5
+ class TrinitySeven < Base
6
+ # ゲームシステムの識別子
7
+ ID = 'TrinitySeven'
8
+
9
+ # ゲームシステム名
10
+ NAME = 'トリニティセブンRPG'
11
+
12
+ # ゲームシステム名の読みがな
13
+ SORT_KEY = 'とりにていせふんRPG'
14
+
15
+ # ダイスボットの使い方
16
+ HELP_MESSAGE = <<~MESSAGETEXT
17
+ クリティカルが変動した命中及び、7の出目がある場合のダメージ計算が行なえます。
18
+ なお、通常の判定としても利用できます。
19
+
20
+ ・発動/命中 [TR(±c*)<=(x)±(y*)又は TR<=(x)など]*は必須ではない項目です。
21
+ "TR(クリティカルの修正値*)<=(発動/命中)±(発動/命中の修正値*)"
22
+ 加算減算のみ修正値も付けられます。 [修正値]は必須ではありません。
23
+ 例)TR<=50 TR<=60+20 TR7<=40 TR-7<=80 TR+10<=80+20
24
+
25
+ ・ダメージ計算 [(x)DM(c*)±(y*)又は(x)DM(c*)又は(x)DM±(y*)]*は必須ではない項目です。
26
+ "(ダイス数)DM(7の出目の数*)+(修正*)"
27
+ 加算減算のみ修正値も付けられます。 [7の出目の数]および[修正値]は必須ではありません。
28
+ 例)6DM2+1 5DM2 4DM 3DM+3
29
+ 後から7の出目に変更する場合はC(7*6+5)のように入力して計算してください。
30
+
31
+ ・名前表 [TRNAME]
32
+ 名字と名前を出します。PCや突然現れたNPCの名付けにどうぞ。
33
+
34
+ MESSAGETEXT
35
+
36
+ register_prefix(['(\d+)DM\d+(\+|\-)?\d*', '(\d+)DM(\+|\-)?\d*', 'TR(\d+)<=(\d+)(\+|\-)?\d*', 'TR<=(\d+)(\+|\-)?\d*', 'TR(\+|\-)?(\d+)<=(\d+)(\+|\-)?\d*', 'TRNAME'])
37
+
38
+ def eval_game_system_specific_command(command) # スパゲッティなコードだけど許して!!! → 絶対に許さない。全力でリファクタリングした。
39
+ debug("eval_game_system_specific_command command", command)
40
+
41
+ if /TRNAME/ =~ command
42
+ firstName, = get_NAME_table
43
+ secondName, = get_NAMEtwo_table
44
+ return "#{firstName} , #{secondName}"
45
+ end
46
+
47
+ if /^TR([\+\-\d]*)<=([\d]*)([\+\-\d]*)/ =~ command
48
+ critical = Regexp.last_match(1).to_i + 7
49
+ target = Regexp.last_match(2).to_i
50
+ modify = Regexp.last_match(3).to_i
51
+ return rollHit(command, critical, target, modify)
52
+ end
53
+
54
+ if /^([\d]*)DM([\d]*)([\+\-\d]*)$/ =~ command
55
+ diceCount = Regexp.last_match(1).to_i
56
+ critical = Regexp.last_match(2).to_i
57
+ modify = Regexp.last_match(3).to_i
58
+ return rollDamage(command, diceCount, critical, modify)
59
+ end
60
+
61
+ return ''
62
+ end
63
+
64
+ def rollHit(command, critical, target, modify)
65
+ target += modify
66
+
67
+ total = @randomizer.roll_once(100)
68
+ result = getHitRollResult(total, target, critical)
69
+
70
+ text = "(#{command}) > #{total}[#{total}] > #{result}"
71
+ debug("eval_game_system_specific_command result text", text)
72
+
73
+ return text
74
+ end
75
+
76
+ def getHitRollResult(total, target, critical)
77
+ return "ファンブル" if total >= 96
78
+ return "クリティカル" if total <= critical
79
+
80
+ return "成功" if total <= target
81
+
82
+ return "失敗"
83
+ end
84
+
85
+ def rollDamage(command, diceCount, critical, modify)
86
+ return "" if diceCount < critical
87
+
88
+ dice_list = @randomizer.roll_barabara(diceCount, 6)
89
+ total = dice_list.sum()
90
+ diceText = dice_list.join(",")
91
+
92
+ additionalListText = ""
93
+ total, additionalList = getRollDamageCritialText(diceCount, critical, total, diceText, modify)
94
+
95
+ additionalListText = "→[#{additionalList.join(',')}]" unless additionalList.empty?
96
+
97
+ modifyText = ""
98
+ modifyText = "+#{modify}" if modify > 0
99
+ modifyText = modify.to_s if modify < 0
100
+
101
+ text = "(#{command}) [#{diceText}]#{additionalListText}#{modifyText} > #{total}"
102
+
103
+ return text
104
+ end
105
+
106
+ def getRollDamageCritialText(diceCount, critical, total, diceText, modify)
107
+ diceList = []
108
+
109
+ if critical == 0
110
+ total += modify
111
+ return total, diceList
112
+ end
113
+
114
+ diceList = diceText.split(/,/).map(&:to_i)
115
+
116
+ diceList.sort!
117
+ restDice = diceList.clone
118
+
119
+ critical = diceCount if critical > diceCount
120
+
121
+ critical.times do
122
+ restDice.shift
123
+ diceList.shift
124
+ diceList.push(7)
125
+ end
126
+
127
+ max = restDice.pop
128
+ max = 1 if max.nil?
129
+
130
+ total = max * (7**critical) + modify
131
+ restDice.each { |i| total += i }
132
+
133
+ return total, diceList
134
+ end
135
+
136
+ def check_1D100(_total, dice_total, _cmp_op, _target)
137
+ if dice_total >= 96
138
+ " > ファンブル"
139
+ elsif dice_total <= 7
140
+ " > クリティカル"
141
+ end
142
+ end
143
+
144
+ # 名前表
145
+ def get_NAME_table
146
+ table = [
147
+ [1, '春日'],
148
+ [2, '浅見'],
149
+ [3, '風間'],
150
+ [4, '神無月'],
151
+ [5, '倉田'],
152
+ [6, '不動'],
153
+ [7, '山奈'],
154
+ [8, 'シャルロック'],
155
+ [9, '霧隠'],
156
+ [10, '果心'],
157
+ [11, '今井'],
158
+ [12, '長瀬'],
159
+ [13, '明智'],
160
+ [14, '風祭'],
161
+ [15, '志貫'],
162
+ [16, '一文字'],
163
+ [17, '月夜野'],
164
+ [18, '桜田門'],
165
+ [19, '果瀬'],
166
+ [20, '九十九'],
167
+ [21, '速水'],
168
+ [22, '片桐'],
169
+ [23, '葉月'],
170
+ [24, 'ウィンザー'],
171
+ [25, '時雨里'],
172
+ [26, '神城'],
173
+ [27, '水際'],
174
+ [28, '一ノ江'],
175
+ [29, '仁藤'],
176
+ [30, '北千住'],
177
+ [31, '西村'],
178
+ [32, '諏訪'],
179
+ [33, '藤宮'],
180
+ [34, '御代'],
181
+ [35, '橘'],
182
+ [36, '霧生'],
183
+ [37, '白石'],
184
+ [38, '椎名'],
185
+ [39, '綾小路'],
186
+ [40, '二条'],
187
+ [41, '光明寺'],
188
+ [42, '春秋'],
189
+ [43, '雪見'],
190
+ [44, '刀条院'],
191
+ [45, 'ランカスター'],
192
+ [46, 'ハクア'],
193
+ [47, 'エルタニア'],
194
+ [48, 'ハーネス'],
195
+ [49, 'アウグストゥス'],
196
+ [50, '椎名町'],
197
+ [51, '鍵守'],
198
+ [52, '茜ヶ崎'],
199
+ [53, '鎮宮'],
200
+ [54, '美柳'],
201
+ [55, '鎖々塚'],
202
+ [56, '櫻ノ杜'],
203
+ [57, '鏡ヶ守'],
204
+ [58, '輝井'],
205
+ [59, '南陽'],
206
+ [60, '雪乃城'],
207
+ [61, '六角屋'],
208
+ [62, '鈴々'],
209
+ [63, '東三条'],
210
+ [64, '朱雀院'],
211
+ [65, '青龍院'],
212
+ [66, '白虎院'],
213
+ [67, '玄武院'],
214
+ [68, '麒麟院'],
215
+ [69, 'リーシュタット'],
216
+ [70, 'サンクチュアリ'],
217
+ [71, '六実'],
218
+ [72, '須藤'],
219
+ [73, 'ミレニアム'],
220
+ [74, '七里'],
221
+ [75, '三枝'],
222
+ [76, '八殿'],
223
+ [77, '藤里'],
224
+ [78, '久宝'],
225
+ [79, '東'],
226
+ [80, '赤西'],
227
+ [81, '神ヶ崎'],
228
+ [82, 'グランシア'],
229
+ [83, 'ダークブーレード'],
230
+ [84, '天光寺'],
231
+ [85, '月見里'],
232
+ [86, '璃宮'],
233
+ [87, '藤見澤'],
234
+ [88, '赤聖'],
235
+ [89, '姫宮'],
236
+ [90, '華ノ宮'],
237
+ [91, '天才'],
238
+ [92, '達人'],
239
+ [93, '賢者'],
240
+ [94, '疾風'],
241
+ [95, '海の'],
242
+ [96, '最強'],
243
+ [97, '凶器'],
244
+ [98, '灼熱'],
245
+ [99, '人間兵器'],
246
+ [100, '魔王'],
247
+ ]
248
+
249
+ dice_now = @randomizer.roll_once(100)
250
+
251
+ return get_table_by_number(dice_now, table)
252
+ end
253
+
254
+ def get_NAMEtwo_table
255
+ table = [
256
+ [1, 'アラタ/聖'],
257
+ [2, 'アビィス/リリス'],
258
+ [3, 'ルーグ/レヴィ'],
259
+ [4, 'ラスト/アリン'],
260
+ [5, 'ソラ/ユイ'],
261
+ [6, 'イーリアス/アキオ'],
262
+ [7, 'アカーシャ/ミラ'],
263
+ [8, 'アリエス/リーゼロッテ'],
264
+ [9, 'ムラサメ/シャルム'],
265
+ [10, '龍貴/竜姫'],
266
+ [11, '英樹/春菜'],
267
+ [12, '準一/湊'],
268
+ [13, '急司郎/光理'],
269
+ [14, '夕也/愛奈'],
270
+ [15, '晴彦/アキ'],
271
+ [16, '疾風/ヤシロ'],
272
+ [17, 'カガリ/灯花'],
273
+ [18, '次郎/優都'],
274
+ [19, '春太郎/静理'],
275
+ [20, 'ジン/時雨'],
276
+ [21, 'イオリ/伊織'],
277
+ [22, 'ユウヒ/優姫'],
278
+ [23, 'サツキ/翠名'],
279
+ [24, 'シュライ/サクラ'],
280
+ [25, 'ミナヅキ/姫乃'],
281
+ [26, 'カエデ/優樹菜'],
282
+ [27, 'ハル/フユ'],
283
+ [28, 'オdール/瑞江'],
284
+ [29, 'ニトゥレスト/キリカ'],
285
+ [30, 'スカー/綾瀬'],
286
+ [31, '真夏/小夏'],
287
+ [32, '光一/ののか'],
288
+ [33, '彩/翠'],
289
+ [34, 'トウカ/柊花'],
290
+ [35, '命/ミコト'],
291
+ [36, '司/つかさ'],
292
+ [37, 'ゆとり/なごみ'],
293
+ [38, '冬彦/観月'],
294
+ [39, 'カレン/華恋'],
295
+ [40, '清次郎/亜矢'],
296
+ [41, 'サード/夢子'],
297
+ [42, 'ボックス/詩子'],
298
+ [43, 'ヘリオス/カエデ'],
299
+ [44, 'ゲート/京香'],
300
+ [45, 'オンリー/パトリシア'],
301
+ [46, 'ザッハーク/アーリ'],
302
+ [47, 'ラスタバン/ラスティ'],
303
+ [48, '桜花/燁澄'],
304
+ [49, '計都/リヴィア'],
305
+ [50, 'カルヴァリオ/香夜'],
306
+ [51, '悠人/夜々子'],
307
+ [52, '太子/羽菜'],
308
+ [53, '夕立/夕凪'],
309
+ [54, 'アルフ/愛美'],
310
+ [55, 'ファロス/灯利'],
311
+ [56, 'スプートニク/詩姫'],
312
+ [57, 'アーネスト/累'],
313
+ [58, 'ナイン/カグヤ'],
314
+ [59, 'クリア/ヒマワリ'],
315
+ [60, 'ウォーカー/オリビア'],
316
+ [61, 'ダーク/クオン'],
317
+ [62, 'ウェイヴ/凛'],
318
+ [63, 'ルーン/マリエ'],
319
+ [64, 'エンギ/セイギ'],
320
+ [65, 'シラヌイ/ミライ'],
321
+ [66, 'ブライン/キズナ'],
322
+ [67, 'クロウ/カナタ'],
323
+ [68, 'スレイヤー/ヒカル'],
324
+ [69, 'レス/ミリアリア'],
325
+ [70, 'ミフユ/サリエル'],
326
+ [71, '鳴央/音央'],
327
+ [72, 'モンジ/理亜'],
328
+ [73, 'パルデモントゥム/スナオ'],
329
+ [74, 'ミシェル/詩穂'],
330
+ [75, 'フレンズ/サン'],
331
+ [76, 'サトリ/識'],
332
+ [77, 'ロード/唯花'],
333
+ [78, 'クロノス/久宝'],
334
+ [79, 'フィラデルフィア/冬海'],
335
+ [80, 'ティンダロス/美星'],
336
+ [81, '勇弥/ユーリス'],
337
+ [82, 'エイト/アンジェラ'],
338
+ [83, 'サタン/ルシエル'],
339
+ [84, 'エース/小波'],
340
+ [85, 'セージ/胡蝶'],
341
+ [86, '忍/千之'],
342
+ [87, '重吾/キリコ'],
343
+ [88, 'マイケル/ミホシ'],
344
+ [89, 'カズマ/鶴香'],
345
+ [90, 'ヤマト/エリシエル'],
346
+ [91, '歴史上の人物の名前(信長、ジャンヌなど)'],
347
+ [92, 'スポーツ選手の名前(ベッカム、沙保里など)'],
348
+ [93, '学者の名前(ソクラテス、エレナなど)'],
349
+ [94, 'アイドルの名前(タクヤ、聖子など)'],
350
+ [95, '土地、国、町の名前(イングランド、ワシントンなど)'],
351
+ [96, 'モンスターの名前(ドラゴン、ラミアなど)'],
352
+ [97, '武器防具の名前(ソード、メイルなど)'],
353
+ [98, '自然現象の名前(カザンハリケーンなど)'],
354
+ [99, '機械の名前(洗濯機、テレビなど)'],
355
+ [100, '目についた物の名前(シャーペン、メガネなど)'],
356
+ ]
357
+
358
+ dice_now = @randomizer.roll_once(100)
359
+
360
+ return get_table_by_number(dice_now, table)
361
+ end
362
+ end
363
+ end
364
+ end
@@ -0,0 +1,287 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BCDice
4
+ module GameSystem
5
+ class TunnelsAndTrolls < Base
6
+ # ゲームシステムの識別子
7
+ ID = 'TunnelsAndTrolls'
8
+
9
+ # ゲームシステム名
10
+ NAME = 'トンネルズ&トロールズ'
11
+
12
+ # ゲームシステム名の読みがな
13
+ SORT_KEY = 'とんねるすあんととろおるす'
14
+
15
+ # ダイスボットの使い方
16
+ HELP_MESSAGE = <<~INFO_MESSAGE_TEXT
17
+ ・行為判定 (nD6+x>=nLV)
18
+ 失敗、成功、自動失敗の自動判定とゾロ目の振り足し経験値の自動計算を行います。
19
+ SAVEの難易度を「レベル」で表記することが出来ます。
20
+ 例えば「2Lv」と書くと「25」に置換されます。
21
+ 判定時以外は悪意ダメージを表示します。
22
+ バーサークとハイパーバーサーク用に専用コマンドが使えます。
23
+ 例)2D6+1>=1Lv
24
+   (2D6+1>=20) > 7[2,5]+1 > 8 > 失敗
25
+  判定時にはゾロ目を自動で振り足します。
26
+
27
+ ・バーサークとハイパーバーサーク (nBS+x or nHBS+x)
28
+  "(ダイス数)BS(修正値)"でバーサーク、"(ダイス数)HBS(修正値)"でハイパーバーサークでロールできます。
29
+  最初のダイスの読替は、個別の出目はそのままで表示。
30
+  下から2番目の出目をずらした分だけ合計にマイナス修正を追加して表示します。
31
+ INFO_MESSAGE_TEXT
32
+
33
+ register_prefix(['\d+H?BS.*', '\d+R6.*', '\d+D\d+.+', '\dD6.*'])
34
+
35
+ def initialize(command)
36
+ super(command)
37
+
38
+ @sort_add_dice = true
39
+ end
40
+
41
+ private
42
+
43
+ def replace_text(string)
44
+ if /BS/i =~ string
45
+ string = string.gsub(/(\d+)HBS([^\d\s][\+\-\d]+)/i) { "#{Regexp.last_match(1)}R6#{Regexp.last_match(2)}[H]" }
46
+ string = string.gsub(/(\d+)HBS/i) { "#{Regexp.last_match(1)}R6[H]" }
47
+ string = string.gsub(/(\d+)BS([^\d\s][\+\-\d]+)/i) { "#{Regexp.last_match(1)}R6#{Regexp.last_match(2)}" }
48
+ string = string.gsub(/(\d+)BS/i) { "#{Regexp.last_match(1)}R6" }
49
+ end
50
+
51
+ return string
52
+ end
53
+
54
+ def eval_game_system_specific_command(string)
55
+ if /^\d+D\d+/i.match?(string)
56
+ return roll_action(string)
57
+ end
58
+
59
+ string = replace_text(string)
60
+ debug('tandt_berserk string', string)
61
+
62
+ output = "1"
63
+
64
+ return output unless (m = /(^|\s)S?((\d+)[rR]6([\+\-\d]*)(\[(\w+)\])?)(\s|$)/i.match(string))
65
+
66
+ debug('tandt_berserk matched')
67
+
68
+ string = m[2]
69
+ dice_c = m[3].to_i
70
+ bonus = 0
71
+ bonus = ArithmeticEvaluator.eval(m[4]) if m[4]
72
+ isHyperBerserk = false
73
+ isHyperBerserk = true if m[5] && (m[6] =~ /[Hh]/)
74
+ dice_arr = []
75
+ dice_now = 0
76
+ dice_str = ""
77
+ isFirstLoop = true
78
+ n_max = 0
79
+ bonus2 = 0
80
+
81
+ debug('isHyperBerserk', isHyperBerserk)
82
+
83
+ # 2回目以降
84
+ dice_arr.push(dice_c)
85
+
86
+ loop do
87
+ debug('loop dice_arr', dice_arr)
88
+ dice_wk = dice_arr.shift
89
+
90
+ debug('roll dice_wk d6', dice_wk)
91
+ dice_list = @randomizer.roll_barabara(dice_wk, 6).sort
92
+ rollTotal = dice_list.sum()
93
+ rollDiceMaxCount = dice_list.count(6)
94
+
95
+ if dice_wk >= 2 # ダイスが二個以上
96
+ dice_num = dice_list
97
+
98
+ diceType = 6
99
+
100
+ dice_face = []
101
+ diceType.times do |_i|
102
+ dice_face.push(0)
103
+ end
104
+
105
+ dice_num.each do |dice_o|
106
+ dice_face[dice_o - 1] += 1
107
+ end
108
+
109
+ dice_face.each do |dice_o|
110
+ if dice_o >= 2
111
+ dice_o += 1 if isHyperBerserk
112
+ dice_arr.push(dice_o)
113
+ end
114
+ end
115
+
116
+ if isFirstLoop && dice_arr.empty?
117
+ min1 = 0
118
+ min2 = 0
119
+
120
+ diceType.times do |i|
121
+ index = diceType - i - 1
122
+ debug('diceType index', index)
123
+ if dice_face[index] > 0
124
+ min2 = min1
125
+ min1 = index
126
+ end
127
+ end
128
+
129
+ debug("min1, min2", min1, min2)
130
+ bonus2 = -(min2 - min1)
131
+ rollDiceMaxCount -= 1 if min2 == 5
132
+
133
+ if isHyperBerserk
134
+ dice_arr.push(3)
135
+ else
136
+ dice_arr.push(2)
137
+ end
138
+ end
139
+ end
140
+
141
+ dice_now += rollTotal
142
+ dice_str += "][" if dice_str != ""
143
+ dice_str += dice_list.join(",")
144
+ n_max += rollDiceMaxCount
145
+ isFirstLoop = false
146
+
147
+ debug('loop last chek dice_arr', dice_arr)
148
+
149
+ break if dice_arr.empty?
150
+ end
151
+
152
+ debug('loop breaked')
153
+
154
+ debug('dice_now, bonus, bonus2', dice_now, bonus, bonus2)
155
+ total_n = dice_now + bonus + bonus2
156
+
157
+ dice_str = "[#{dice_str}]"
158
+ output = "#{dice_now}#{dice_str}"
159
+
160
+ if bonus2 < 0
161
+ debug('bonus2', bonus2)
162
+ output += bonus2.to_s
163
+ end
164
+
165
+ debug('bonus', bonus)
166
+ if bonus > 0
167
+ output += "+#{bonus}"
168
+ elsif bonus < 0
169
+ output += bonus.to_s
170
+ end
171
+
172
+ if output =~ /[^\d\[\]]+/
173
+ output = "(#{string}) > #{output} > #{total_n}"
174
+ else
175
+ output = "(#{string}) > #{total_n}"
176
+ end
177
+
178
+ output += " > 悪意#{n_max}" if n_max > 0
179
+
180
+ return output
181
+ end
182
+
183
+ def roll_action(command)
184
+ command = command
185
+ .sub(/\d+LV$/i) { |level| level.to_i * 5 + 15 }
186
+
187
+ parser = CommandParser.new(/^\d+D6$/)
188
+ .allow_cmp_op(nil, :>=)
189
+ .enable_question_target()
190
+ cmd = parser.parse(command)
191
+ unless cmd
192
+ return nil
193
+ end
194
+
195
+ times = cmd.command.to_i
196
+ roll_action_dice(times)
197
+ total = @dice_total + cmd.modify_number
198
+
199
+ target = cmd.question_target? ? "?" : cmd.target_number
200
+
201
+ sequence = [
202
+ "(#{cmd})",
203
+ interim_expr(cmd, @dice_total),
204
+ total.to_s,
205
+ action_result(total, @dice_total, target),
206
+ additional_result(@count_6)
207
+ ].compact
208
+
209
+ return sequence.join(" > ")
210
+ end
211
+
212
+ def roll_action_dice(times)
213
+ dice_list = @randomizer.roll_barabara(times, 6).sort
214
+ @dice_list = [dice_list]
215
+ while same_all_dice?(dice_list)
216
+ dice_list = @randomizer.roll_barabara(times, 6).sort
217
+ @dice_list.push(dice_list)
218
+ end
219
+
220
+ dice_list_flatten = @dice_list.flatten
221
+ @dice_total = dice_list_flatten.sum()
222
+ @count_6 = dice_list_flatten.count(6)
223
+ end
224
+
225
+ # 出目が全て同じか
226
+ def same_all_dice?(dice_list)
227
+ dice_list.size > 1 && dice_list.uniq.size == 1
228
+ end
229
+
230
+ def interim_expr(cmd, dice_total)
231
+ if @dice_list.flatten.size == 1 && cmd.modify_number == 0
232
+ return nil
233
+ end
234
+
235
+ dice_list = @dice_list.map { |ds| "[#{ds.join(',')}]" }.join("")
236
+ modifier = Format.modifier(cmd.modify_number)
237
+
238
+ return [dice_total.to_s, dice_list, modifier].join("")
239
+ end
240
+
241
+ def action_result(total, dice_total, target_number)
242
+ if dice_total == 3
243
+ "自動失敗"
244
+ elsif target_number.nil?
245
+ nil
246
+ elsif target_number == "?"
247
+ success_level(total, dice_total)
248
+ elsif total >= target_number
249
+ "成功 > 経験値#{experience_point(target_number, dice_total)}"
250
+ else
251
+ "失敗"
252
+ end
253
+ end
254
+
255
+ def success_level(total, dice_total)
256
+ level = (total - 15) / 5
257
+ if level <= 0
258
+ "失敗 > 経験値#{dice_total}"
259
+ else
260
+ "#{level}Lv成功 > 経験値#{dice_total}"
261
+ end
262
+ end
263
+
264
+ def experience_point(target_number, dice_total)
265
+ ep = 1.0 * (target_number - 15) / 5 * dice_total
266
+
267
+ if ep <= 0
268
+ "0"
269
+ elsif int?(ep)
270
+ ep.to_i.to_s
271
+ else
272
+ format("%.1f", ep)
273
+ end
274
+ end
275
+
276
+ def int?(v)
277
+ v == v.to_i
278
+ end
279
+
280
+ def additional_result(count_6)
281
+ if count_6 > 0
282
+ "悪意#{count_6}"
283
+ end
284
+ end
285
+ end
286
+ end
287
+ end