bcdice 3.0.0.pre.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
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,139 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bcdice/game_system/Torg'
4
+
5
+ module BCDice
6
+ module GameSystem
7
+ class Torg1_5 < Torg
8
+ # ゲームシステムの識別子
9
+ ID = 'TORG1.5'
10
+
11
+ # ゲームシステム名
12
+ NAME = 'トーグ1.5版'
13
+
14
+ # ゲームシステム名の読みがな
15
+ SORT_KEY = 'とおく1.5'
16
+
17
+ register_prefix(Torg.prefixes)
18
+
19
+ # 一般結果表 成功度
20
+ def get_torg_success_level(value)
21
+ success_table = [
22
+ [0, "ぎりぎり"],
23
+ [1, "ふつう"],
24
+ [3, "まあよい"],
25
+ [7, "かなりよい"],
26
+ [12, "すごい"]
27
+ ]
28
+
29
+ return get_torg_table_result(value, success_table)
30
+ end
31
+
32
+ # 対人行為結果表
33
+ # 威圧/威嚇(intimidate/Test)
34
+ def get_torg_interaction_result_intimidate_test(value)
35
+ interaction_results_table = [
36
+ [0, "萎縮"],
37
+ [5, "技能なし"],
38
+ [10, "逆転負け"],
39
+ [15, "モラル崩壊"],
40
+ [17, "プレイヤーズコール"]
41
+ ]
42
+
43
+ return get_torg_table_result(value, interaction_results_table)
44
+ end
45
+
46
+ # 挑発/トリック(Taunt/Trick)
47
+ def get_torg_interaction_result_taunt_trick(value)
48
+ interaction_results_table = [
49
+ [0, "萎縮"],
50
+ [5, "技能なし"],
51
+ [10, "逆転負け"],
52
+ [15, "高揚/逆転負け"],
53
+ [17, "プレイヤーズコール"]
54
+ ]
55
+
56
+ return get_torg_table_result(value, interaction_results_table)
57
+ end
58
+
59
+ # 間合い(maneuver)
60
+ def get_torg_interaction_result_maneuver(value)
61
+ interaction_results_table = [
62
+ [0, "疲労"],
63
+ [5, "萎縮"],
64
+ [10, "技能なし"],
65
+ [15, "逆転負け/疲労"],
66
+ [17, "プレイヤーズコール"]
67
+ ]
68
+
69
+ return get_torg_table_result(value, interaction_results_table)
70
+ end
71
+
72
+ # オーズダメージチャート
73
+ def get_torg_damage_ords(value)
74
+ damage_table_ords = [
75
+ [0, "1"],
76
+ [1, "O1"],
77
+ [2, "K1"],
78
+ [3, "O2"],
79
+ [4, "K2"],
80
+ [5, "転倒 O3"],
81
+ [6, "転倒 K3"],
82
+ [7, "転倒 K/O4"],
83
+ [8, "1レベル負傷 KO4"],
84
+ [9, "1レベル負傷 K/O5"],
85
+ [10, "1レベル負傷 KO5"],
86
+ [11, "2レベル負傷 K/O6"],
87
+ [12, "2レベル負傷 KO6"],
88
+ [13, "3レベル負傷 K/O7"],
89
+ [14, "3レベル負傷 KO7"],
90
+ [15, "4レベル負傷 KO8"]
91
+ ]
92
+
93
+ return get_torg_damage(value, 4, 8, damage_table_ords)
94
+ end
95
+
96
+ # ポシビリティー能力者ダメージチャート
97
+ def get_torg_damage_posibility(value)
98
+ damage_table_posibility = [
99
+ [0, "1"],
100
+ [1, "1"],
101
+ [2, "O1"],
102
+ [3, "K1"],
103
+ [4, "2"],
104
+ [5, "O2"],
105
+ [6, "転倒 K2"],
106
+ [7, "転倒 O3"],
107
+ [8, "転倒 K3"],
108
+ [9, "転倒 K/O3"],
109
+ [10, "1レベル負傷 K/O4"],
110
+ [11, "1レベル負傷 K/O4"],
111
+ [12, "1レベル負傷 KO4"],
112
+ [13, "2レベル負傷 K/O5"],
113
+ [14, "2レベル負傷 KO5"],
114
+ [15, "3レベル負傷 KO5"]
115
+ ]
116
+
117
+ return get_torg_damage(value, 3, 5, damage_table_posibility)
118
+ end
119
+
120
+ def get_torg_damage(value, max_damage, max_shock, damage_table)
121
+ if value < 0
122
+ return '1'
123
+ end
124
+
125
+ table_max_value = damage_table.length - 1
126
+
127
+ if value <= table_max_value
128
+ return get_torg_table_result(value, damage_table)
129
+ end
130
+
131
+ over_kill_value = ((value - table_max_value) / 2).to_i
132
+ over_kill_damage = max_damage + over_kill_value * 1
133
+ over_kill_shock = max_shock + over_kill_value * 1
134
+
135
+ return "#{over_kill_damage}レベル負傷 KO#{over_kill_shock}"
136
+ end
137
+ end
138
+ end
139
+ end
@@ -0,0 +1,414 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BCDice
4
+ module GameSystem
5
+ class TorgEternity < Base
6
+ # ゲームシステムの識別子
7
+ ID = 'TorgEternity'
8
+ # ゲームシステム名
9
+ NAME = 'TORG Eternity'
10
+ # ゲームシステム名の読みがな
11
+ SORT_KEY = 'とおくえたあにてい'
12
+ # ダイスボットの使い方
13
+ HELP_MESSAGE = <<~INFO_MESSAGE_TEXT
14
+ ・判定
15
+  ・TG
16
+   "TG[m]"で1d20をロールします。[]内は省略可能。
17
+   mは技能基本値を入れて下さい。Rコマンドに読替されます。
18
+   振り足しを自動で行い、20の出目が出たときには技能無し値も並記します。
19
+   (TORGダイスボットと同じ挙動をするコマンドです。ロールボーナスの読み替えのみ、Eternity版となります)
20
+  ・TE
21
+   "TE"で1d20をロールします。
22
+   振り足しを自動で行い、20の出目が出たときには技能無し値も並記します。
23
+   出目1の時には「Mishap! 自動失敗!」と出力されます。
24
+  ・UP
25
+   "UP"で高揚状態のロール(通常の1d20に加え、1d20を追加で振り足し)を行います。
26
+   各ロールでの振り足しを自動で行い、20の出目が出たときには技能無し値も並記します。
27
+   一投目で出目1の時には「Mishap! 自動失敗!」と出力され、二投目は行われません。
28
+  ・POS
29
+   "POSm"で、ポシビリティ使用による1d20のロールを行います。
30
+   mはポシビリティを使用する前のロール結果を入れて下さい。
31
+   出目が10未満の場合は、10への読み替えが行われます。
32
+   また、振り足しを自動で行い、20の出目が出たときには技能無し値も並記します。
33
+ ・ボーナスダメージロール
34
+  "xBD[+y]"でロールします。[]内は省略可能。
35
+  xはダメージダイス数。yはダメージ基本値 or 式を入れて下さい。
36
+  xは1以上が必要です。0だとエラーが出力されます。マイナス値はコマンドとして認識されません。
37
+  振り足し処理は自動で行われます。(振り足し発生時の目は、「5∞」と出力されます)
38
+ ・各種表
39
+  "(表コマンド)(数値)"で振ります。
40
+  ・成功レベル表「RTx or RESULTx」
41
+  ・ダメージ結果表「DTx or DAMAGEx」
42
+  ・ロールボーナス表「BTx+y or BONUSx+y or TOTALx+y」 xは数値, yは技能基本値
43
+ INFO_MESSAGE_TEXT
44
+ register_prefix(['TE.*', 'UP.*', 'POS.*', '\d+BD.*', 'TG.*', 'RT.*', 'Result.*', 'DT.*', 'damage.*', 'BT.*', 'bonus.*', 'total.*', '1R20.*'])
45
+ def initialize(command)
46
+ super(command)
47
+ end
48
+
49
+ def eval_game_system_specific_command(command)
50
+ torg_check(command) ||
51
+ getRolld20DiceCommandResult(command) ||
52
+ getUpRollDiceCommandResult(command) ||
53
+ getPossibilityRollDiceCommandResult(command) ||
54
+ getBonusDamageDiceCommandResult(command) ||
55
+ getSuccessLevelDiceCommandResult(command) ||
56
+ getDamageResultDiceCommandResult(command) ||
57
+ getRollBonusDiceCommandResult(command)
58
+ end
59
+
60
+ #################### TORG 1.x ########################
61
+ def replace_text(string)
62
+ string = string.gsub(/TG(\d+)/i) { "1R20+#{Regexp.last_match(1)}" }
63
+ string = string.gsub(/TG/i, '1R20')
64
+ return string
65
+ end
66
+
67
+ def torg_check(string)
68
+ string = replace_text(string)
69
+
70
+ m = /(^|\s)S?(1R20(([+-]\d+)*))(\s|$)/i.match(string)
71
+ unless m
72
+ return nil
73
+ end
74
+
75
+ string = m[2]
76
+ mod = m[3]
77
+
78
+ debug(mod)
79
+ mod = ArithmeticEvaluator.eval(mod) if mod
80
+ debug(mod)
81
+ mod = mod.to_i
82
+ skilled, unskilled, dice_str, = torg_eternity_dice(false, false)
83
+ sk_bonus = get_torg_eternity_bonus(skilled)
84
+ if mod
85
+ if mod > 0
86
+ output = "#{sk_bonus}[#{dice_str}]+#{mod}"
87
+ else
88
+ output = "#{sk_bonus}[#{dice_str}]#{mod}"
89
+ end
90
+ else
91
+ output = "#{sk_bonus}[#{dice_str}]"
92
+ end
93
+ output += " > " + (sk_bonus + mod).to_s
94
+ if skilled != unskilled
95
+ output += "(技能無" + (get_torg_eternity_bonus(unskilled) + mod).to_s + ")"
96
+ end
97
+ output = "(#{string}) > #{output}"
98
+ return output
99
+ end
100
+
101
+ #################### TORG Eternity ########################
102
+ # ロールコマンド (通常ロール)
103
+ def getRolld20DiceCommandResult(command)
104
+ debug("Torg Eternity Dice Roll Command ? ", command)
105
+ m = /(^|\s)(S)?(TE)$/i.match(command)
106
+ unless m
107
+ return nil
108
+ end
109
+
110
+ skilled, unskilled, dice_str, mishap = torg_eternity_dice(false, true)
111
+ if mishap == 1
112
+ output = "d20ロール(通常) > 1d20[#{dice_str}] > Mishap! 絶対失敗!"
113
+ else
114
+ value_skilled = format("%+d", get_torg_eternity_bonus(skilled))
115
+ if skilled != unskilled
116
+ value_unskilled = format("%+d", get_torg_eternity_bonus(unskilled))
117
+ output = "d20ロール(通常) > 1d20[#{dice_str}] > #{value_skilled}[#{skilled}](技能有) / #{value_unskilled}[#{unskilled}](技能無)"
118
+ else
119
+ output = "d20ロール(通常) > 1d20[#{dice_str}] > #{value_skilled}[#{skilled}]"
120
+ end
121
+ end
122
+
123
+ return output
124
+ end
125
+
126
+ # ロールコマンド (高揚ロール)
127
+ def getUpRollDiceCommandResult(command)
128
+ debug("Torg Eternity Dice Roll ( UP ) Command ? ", command)
129
+ m = /(^|\s)(S)?(UP)$/i.match(command)
130
+ unless m
131
+ return nil
132
+ end
133
+
134
+ skilled1, unskilled1, dice_str1, mishap = torg_eternity_dice(false, true)
135
+ if mishap == 1
136
+ output = "d20ロール(高揚) > 1d20[#{dice_str1}] > Mishap! 絶対失敗!"
137
+ else
138
+ skilled2, unskilled2, dice_str2, = torg_eternity_dice(false, false)
139
+ subtotal_skilled = skilled1 + skilled2
140
+ subtotal_unskilled = unskilled1 + unskilled2
141
+ value_skilled = format("%+d", get_torg_eternity_bonus(subtotal_skilled))
142
+ if subtotal_skilled != subtotal_unskilled
143
+ value_unskilled = format("%+d", get_torg_eternity_bonus(subtotal_unskilled))
144
+ output = "d20ロール(高揚) > 1d20[#{dice_str1}] + 1d20[#{dice_str2}] > #{value_skilled}[#{subtotal_skilled}](技能有) / #{value_unskilled}[#{subtotal_unskilled}](技能無)"
145
+ else
146
+ output = "d20ロール(高揚) > 1d20[#{dice_str1}] + 1d20[#{dice_str2}] > #{value_skilled}[#{subtotal_skilled}]"
147
+ end
148
+ end
149
+
150
+ return output
151
+ end
152
+
153
+ # ロールコマンド (ポシビリティロール)
154
+ def getPossibilityRollDiceCommandResult(command)
155
+ debug("Torg Eternity Possibility Roll Command ? ", command)
156
+ m = /(^|\s)(S)?(POS)((\d+)(\+\d+)?)/i.match(command)
157
+ unless m
158
+ return nil
159
+ end
160
+
161
+ output_modifier = ArithmeticEvaluator.eval(m[4])
162
+ skilled, unskilled, dice_str, = torg_eternity_dice(true, false)
163
+ subtotal_skilled = skilled + output_modifier
164
+ subtotal_unskilled = unskilled + output_modifier
165
+ value_skilled = format("%+d", get_torg_eternity_bonus(subtotal_skilled))
166
+ if subtotal_skilled != subtotal_unskilled
167
+ value_unskilled = format("%+d", get_torg_eternity_bonus(subtotal_unskilled))
168
+ output = "d20ロール(ポシビリティ) > #{output_modifier}+1d20[#{dice_str}] > #{value_skilled}[#{subtotal_skilled}](技能有) / #{value_unskilled}[#{subtotal_unskilled}](技能無)"
169
+ else
170
+ output = "d20ロール(ポシビリティ) > #{output_modifier}+1d20[#{dice_str}] > #{value_skilled}[#{subtotal_skilled}]"
171
+ end
172
+
173
+ return output
174
+ end
175
+
176
+ # ダメージボーナスコマンド
177
+ def getBonusDamageDiceCommandResult(command)
178
+ debug("TorgEternity Bonus Damage Roll Command ? ", command)
179
+ m = /(\d+)(BD)(([\+\-]\d+)*)/i.match(command)
180
+ unless m
181
+ return nil
182
+ end
183
+
184
+ number_bonus_die = m[1].to_i
185
+ value_modifier, output_modifier = get_torg_eternity_modifier(m[3])
186
+ if number_bonus_die <= 0
187
+ output = "エラーです。xBD (x≧1) として下さい"
188
+ else
189
+ value_roll, output_roll = get_torg_eternity_damage_bonus_dice(number_bonus_die)
190
+ output_value = value_roll + value_modifier
191
+ output = "ボーナスダメージロール(#{number_bonus_die}BD#{output_modifier}) > #{value_roll}[#{output_roll}]#{output_modifier} > #{output_value}ダメージ"
192
+ end
193
+ return output
194
+ end
195
+
196
+ # 成功レベル表コマンド
197
+ def getSuccessLevelDiceCommandResult(command)
198
+ debug("TorgEternity Success Level Table Command ? ", command)
199
+ m = /(RT|Result)(\-*\d+([\+\-]\d+)*)/i.match(command)
200
+ unless m
201
+ return nil
202
+ end
203
+
204
+ value = ArithmeticEvaluator.eval(m[2])
205
+ debug(value)
206
+ if value < 0
207
+ output = "Failure."
208
+ else
209
+ output = get_torg_eternity_success_level(value)
210
+ end
211
+ output = "成功レベル表[#{value}] > #{output}"
212
+ debug(output)
213
+ return output
214
+ end
215
+
216
+ # ダメージ結果表コマンド
217
+ def getDamageResultDiceCommandResult(command)
218
+ debug("TorgEternity Damage Result Table Command ? ", command)
219
+ m = /(DT|Damage)(\-*\d+([\+\-]\d+)*)/i.match(command)
220
+ unless m
221
+ return nil
222
+ end
223
+
224
+ value = ArithmeticEvaluator.eval(m[2])
225
+ debug(value)
226
+ output = get_torg_eternity_damage_result(value)
227
+ output = "ダメージ結果表[#{value}] > #{output}"
228
+ debug(output)
229
+ return output
230
+ end
231
+
232
+ # ロールボーナス表コマンド
233
+ def getRollBonusDiceCommandResult(command)
234
+ debug("TorgEternity Roll Bonus Table Command ? ", command)
235
+ m = /(BT|Bonus)(\d+)(([\+\-]\d+)*)/i.match(command)
236
+ unless m
237
+ return nil
238
+ end
239
+
240
+ value_roll = m[2].to_i
241
+ output_bonus = get_torg_eternity_bonus(value_roll)
242
+ debug(output_bonus)
243
+ value_modifier, output_modifier = get_torg_eternity_modifier(m[3])
244
+ if value_roll <= 1
245
+ output = "ロールボーナス表[#{value_roll}] > Mishap!!"
246
+ elsif output_modifier.empty?
247
+ output = "ロールボーナス表[#{value_roll}] > #{output_bonus}"
248
+ else
249
+ value_result = output_bonus.to_i + value_modifier
250
+ debug(value_result)
251
+ output = "ロールボーナス表[#{value_roll}]#{output_modifier} > #{output_bonus}[#{value_roll}]#{output_modifier} > #{value_result}"
252
+ end
253
+ debug(output)
254
+ return output
255
+ end
256
+
257
+ def get_torg_eternity_table_result(value, table)
258
+ output = nil
259
+ table.each do |item|
260
+ item_index = item[0]
261
+ if item_index > value
262
+ break
263
+ end
264
+
265
+ output = item[1]
266
+ end
267
+ return output
268
+ end
269
+
270
+ # 修正式計算サブルーチン
271
+ def get_torg_eternity_modifier(string_modifier)
272
+ debug("modifier check : #{string_modifier}")
273
+ if string_modifier == ''
274
+ value_modifier = 0
275
+ output_modifier = ""
276
+ else
277
+ value_modifier = ArithmeticEvaluator.eval(string_modifier)
278
+ output_modifier = format("%+d", value_modifier)
279
+ end
280
+ debug(value_modifier)
281
+ debug(output_modifier)
282
+ return value_modifier, output_modifier
283
+ end
284
+
285
+ # d20ロールサブルーチン
286
+ def torg_eternity_dice(check_pos, check_mishap)
287
+ isSkilledCritical = true
288
+ isCritical = true
289
+ skilled = 0
290
+ unskilled = 0
291
+ mishap = 0
292
+ dice_str = ""
293
+ while isSkilledCritical
294
+ dice_str += "," unless dice_str.empty?
295
+ dice_n = @randomizer.roll_once(20)
296
+ if check_pos
297
+ if dice_n < 10
298
+ dice_str_now = "#{dice_n}→10"
299
+ dice_n = 10
300
+ isSkilledCritical = false
301
+ else
302
+ dice_str_now = dice_n.to_s
303
+ end
304
+ dice_str += dice_str_now
305
+ else
306
+ dice_str += dice_n.to_s
307
+ end
308
+ skilled += dice_n
309
+ unskilled += dice_n if isCritical
310
+ if dice_n == 20
311
+ isCritical = false
312
+ elsif dice_n != 10
313
+ isSkilledCritical = false
314
+ isCritical = false
315
+ if check_mishap & (dice_n == 1)
316
+ mishap = 1
317
+ end
318
+ end
319
+ check_pos = false
320
+ check_mishap = false
321
+ end
322
+ return skilled, unskilled, dice_str, mishap
323
+ end
324
+
325
+ # ボーナスダイスロールサブルーチン
326
+ def get_torg_eternity_damage_bonus_dice(number)
327
+ debug("bonus dice roll : #{number}")
328
+ value_roll = 0
329
+ output_roll = ""
330
+ if number > 0
331
+ value_roll = 0
332
+ output_roll = ""
333
+ while number > 0
334
+ output_roll = "#{output_roll}," unless output_roll.empty?
335
+
336
+ dice_value = @randomizer.roll_once(6)
337
+ dice_text = dice_value.to_s
338
+
339
+ if dice_value == 6
340
+ dice_value = 5
341
+ dice_text = "5∞"
342
+ number += 1
343
+ end
344
+ value_roll += dice_value
345
+ output_roll = "#{output_roll}#{dice_text}"
346
+ debug(value_roll)
347
+ debug(output_roll)
348
+ number -= 1
349
+ end
350
+ else
351
+ output_roll = "0"
352
+ end
353
+ debug(value_roll)
354
+ debug(output_roll)
355
+ return value_roll, output_roll
356
+ end
357
+
358
+ # 成功レベル表
359
+ def get_torg_eternity_success_level(value)
360
+ success_table = [
361
+ [0, "Success - Standard."],
362
+ [5, "Success - Good!"],
363
+ [10, "Success - Outstanding!!"]
364
+ ]
365
+ return get_torg_eternity_table_result(value, success_table)
366
+ end
367
+
368
+ # ダメージチャート
369
+ def get_torg_eternity_damage_result(value)
370
+ damage_table = [
371
+ [-50, "ノーダメージ"],
372
+ [-5, "1ショック"],
373
+ [0, "2ショック"],
374
+ [5, "1レベル負傷 + 2ショック"],
375
+ [10, "2レベル負傷 + 4ショック"],
376
+ [15, "3レベル負傷 + 6ショック"],
377
+ [20, "4レベル負傷 + 8ショック"],
378
+ [25, "5レベル負傷 + 10ショック"],
379
+ [30, "6レベル負傷 + 12ショック"],
380
+ [35, "7レベル負傷 + 14ショック"],
381
+ [40, "8レベル負傷 + 16ショック"],
382
+ [45, "9レベル負傷 + 18ショック"],
383
+ [50, "10レベル負傷 + 20ショック"]
384
+ ]
385
+ return get_torg_eternity_table_result(value, damage_table)
386
+ end
387
+
388
+ def get_torg_eternity_bonus(value)
389
+ bonus_table = [
390
+ [1, -10],
391
+ [2, -8],
392
+ [3, -6],
393
+ [5, -4],
394
+ [7, -2],
395
+ [9, -1],
396
+ [11, 0],
397
+ [13, 1],
398
+ [15, 2],
399
+ [16, 3],
400
+ [17, 4],
401
+ [18, 5],
402
+ [19, 6],
403
+ [20, 7]
404
+ ]
405
+ bonus = get_torg_eternity_table_result(value, bonus_table)
406
+ if value > 20
407
+ over_value_bonus = ((value - 21) / 5).to_i + 1
408
+ bonus += over_value_bonus
409
+ end
410
+ return bonus
411
+ end
412
+ end
413
+ end
414
+ end