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,386 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BCDice
4
+ module GameSystem
5
+ class Cthulhu7th_ChineseTraditional < Base
6
+ # ゲームシステムの識別子
7
+ ID = 'Cthulhu7th:ChineseTraditional'
8
+
9
+ # ゲームシステム名
10
+ NAME = '克蘇魯神話第7版'
11
+
12
+ # ゲームシステム名の読みがな
13
+ SORT_KEY = '国際化:Chinese Traditional:克蘇魯神話'
14
+
15
+ # ダイスボットの使い方
16
+ HELP_MESSAGE = <<~INFO_MESSAGE_TEXT
17
+ ・判定 CC(x)<=(目標値)
18
+  x:獎勵骰/懲罰骰:Bonus/Penalty Dice (2~-2)。沒有的話可以省略。
19
+  致命的失敗:Fumble/失敗:Failure/通常成功:Regular success/
20
+  困難成功:Hard success/極限成功:Extreme success/
21
+  決定性的成功:Critical success 自動判定。
22
+ 例)CC<=30 CC(2)<=50 CC(-1)<=75
23
+
24
+ ・組合判定 (CBR(x,y))
25
+  進行目標値 x 和 y 的判定。
26
+  例)CBR(50,20)
27
+
28
+ ・連射(Full Auto)判定 FAR(w,x,y,z)
29
+  w:彈數(1~100)、x:技能値(1~100)、y:故障率
30
+  z:獎勵、懲罰骰(-2~2)。可省略。
31
+  只計算命中數、貫穿數及剩餘彈藥,不計算傷害。
32
+ 例)FAR(25,70,98) FAR(50,80,98,-1)
33
+
34
+ ・瘋狂表
35
+ ・實時型 Short/總結型 Longer
36
+ INFO_MESSAGE_TEXT
37
+
38
+ register_prefix(['CC\(\d+\)', 'CC.*', 'CBR\(\d+,\d+\)', 'FAR\(\d+\)', 'FAR.*'])
39
+
40
+ def initialize(command)
41
+ super(command)
42
+
43
+ @bonus_dice_range = (-2..2)
44
+ end
45
+
46
+ def eval_game_system_specific_command(command)
47
+ case command
48
+ when /CC/i
49
+ return getCheckResult(command)
50
+ when /CBR/i
51
+ return getCombineRoll(command)
52
+ when /FAR/i
53
+ return getFullAutoResult(command)
54
+ end
55
+
56
+ return nil
57
+ end
58
+
59
+ def getCheckResult(command)
60
+ nil unless /^CC([-\d]+)?<=(\d+)/i =~ command
61
+ bonus_dice_count = Regexp.last_match(1).to_i # 獎勵、懲罰骰數量
62
+ diff = Regexp.last_match(2).to_i
63
+
64
+ return "錯誤。目標值需為1以上。" if diff <= 0
65
+
66
+ unless @bonus_dice_range.include?(bonus_dice_count)
67
+ return "錯誤。獎勵、懲罰骰値為#{@bonus_dice_range.min}~#{@bonus_dice_range.max}。"
68
+ end
69
+
70
+ output = ""
71
+ output += "(1D100<=#{diff})"
72
+ output += " 獎勵、懲罰骰値[#{bonus_dice_count}]"
73
+
74
+ units_digit = rollPercentD10
75
+ total_list = getTotalLists(bonus_dice_count, units_digit)
76
+
77
+ total = getTotal(total_list, bonus_dice_count)
78
+ result_text = getCheckResultText(total, diff)
79
+
80
+ output += " > #{total_list.join(', ')} > #{total} > #{result_text}"
81
+
82
+ return output
83
+ end
84
+
85
+ def rollPercentD10
86
+ dice = @randomizer.roll_once(10)
87
+ dice = 0 if dice == 10
88
+
89
+ return dice
90
+ end
91
+
92
+ def getTotalLists(bonus_dice_count, units_digit)
93
+ total_list = []
94
+
95
+ tens_digit_count = 1 + bonus_dice_count.abs
96
+ tens_digit_count.times do
97
+ bonus = rollPercentD10
98
+ total = (bonus * 10) + units_digit
99
+ total = 100 if total == 0
100
+
101
+ total_list.push(total)
102
+ end
103
+
104
+ return total_list
105
+ end
106
+
107
+ def getTotal(total_list, bonus_dice_count)
108
+ return total_list.min if bonus_dice_count >= 0
109
+
110
+ return total_list.max
111
+ end
112
+
113
+ def getCheckResultText(total, diff, fumbleable = false)
114
+ if total <= diff
115
+ return "決定性的成功" if total == 1
116
+ return "極限的成功" if total <= (diff / 5)
117
+ return "困難的成功" if total <= (diff / 2)
118
+
119
+ return "通常成功"
120
+ end
121
+
122
+ fumble_text = "致命的失敗"
123
+
124
+ return fumble_text if total == 100
125
+
126
+ if total >= 96
127
+ if diff < 50
128
+ return fumble_text
129
+ else
130
+ return fumble_text if fumbleable
131
+ end
132
+ end
133
+
134
+ return "失敗"
135
+ end
136
+
137
+ def getCombineRoll(command)
138
+ return nil unless /CBR\((\d+),(\d+)\)/i =~ command
139
+
140
+ diff_1 = Regexp.last_match(1).to_i
141
+ diff_2 = Regexp.last_match(2).to_i
142
+
143
+ total = @randomizer.roll_once(100)
144
+
145
+ result_1 = getCheckResultText(total, diff_1)
146
+ result_2 = getCheckResultText(total, diff_2)
147
+
148
+ successList = ["決定性的成功", "極限的成功", "困難的成功", "通常成功"]
149
+
150
+ succesCount = 0
151
+ succesCount += 1 if successList.include?(result_1)
152
+ succesCount += 1 if successList.include?(result_2)
153
+ debug("succesCount", succesCount)
154
+
155
+ rank =
156
+ if succesCount >= 2
157
+ "成功"
158
+ elsif succesCount == 1
159
+ "部分的成功"
160
+ else
161
+ "失敗"
162
+ end
163
+
164
+ return "(1d100<=#{diff_1},#{diff_2}) > #{total}[#{result_1},#{result_2}] > #{rank}"
165
+ end
166
+
167
+ def getFullAutoResult(command)
168
+ return nil unless /^FAR\((-?\d+)(,(-?\d+))(,(-?\d+))(,(-?\d+))?\)/i =~ command
169
+
170
+ bullet_count = Regexp.last_match(1).to_i
171
+ diff = Regexp.last_match(3).to_i
172
+ broken_number = Regexp.last_match(5).to_i
173
+ bonus_dice_count = (Regexp.last_match(7) || 0).to_i
174
+
175
+ output = ""
176
+
177
+ # 射擊數不超過(8回*(PC技能値最大値/10))=72的上限
178
+ bullet_count_limit = 100
179
+ if bullet_count > bullet_count_limit
180
+ output += "\n彈藥太多。請改裝填#{bullet_count_limit}發。\n"
181
+ bullet_count = bullet_count_limit
182
+ end
183
+
184
+ return "正確裝填數。" if bullet_count <= 0
185
+ return "正確目標值。" if diff <= 0
186
+
187
+ if broken_number < 0
188
+ output += "\n正確故障值。排除獎勵記號。\n"
189
+ broken_number = broken_number.abs
190
+ end
191
+
192
+ unless @bonus_dice_range.include?(bonus_dice_count)
193
+ return "\n錯誤。獎勵、懲罰骰値為#{@bonus_dice_range.min}~#{@bonus_dice_range.max}です。"
194
+ end
195
+
196
+ output += "獎勵、懲罰骰値[#{bonus_dice_count}]"
197
+ output += rollFullAuto(bullet_count, diff, broken_number, bonus_dice_count)
198
+
199
+ return output
200
+ end
201
+
202
+ def rollFullAuto(bullet_count, diff, broken_number, dice_num)
203
+ output = ""
204
+ loopCount = 0
205
+
206
+ counts = {
207
+ hit_bullet: 0,
208
+ impale_bullet: 0,
209
+ bullet: bullet_count,
210
+ }
211
+
212
+ # 難度變更用Loop
213
+ (0..3).each do |more_difficlty|
214
+ output += getNextDifficltyMessage(more_difficlty)
215
+
216
+ # ペナルティダイスを減らしながらロール用ループ削減獎勵骰時角色用Loop
217
+ while dice_num >= @bonus_dice_range.min
218
+
219
+ loopCount += 1
220
+ hit_result, total, total_list = getHitResultInfos(dice_num, diff, more_difficlty)
221
+ output += "\n#{loopCount}次: > #{total_list.join(', ')} > #{hit_result}"
222
+
223
+ if total >= broken_number
224
+ output += "卡彈"
225
+ return getHitResultText(output, counts)
226
+ end
227
+
228
+ hit_type = getHitType(more_difficlty, hit_result)
229
+ hit_bullet, impale_bullet, lost_bullet = getBulletResults(counts[:bullet], hit_type, diff)
230
+
231
+ counts[:hit_bullet] += hit_bullet
232
+ counts[:impale_bullet] += impale_bullet
233
+ counts[:bullet] -= lost_bullet
234
+
235
+ return getHitResultText(output, counts) if counts[:bullet] <= 0
236
+
237
+ dice_num -= 1
238
+ end
239
+
240
+ dice_num += 1
241
+ end
242
+
243
+ return getHitResultText(output, counts)
244
+ end
245
+
246
+ def getHitResultInfos(dice_num, diff, more_difficlty)
247
+ units_digit = rollPercentD10
248
+ total_list = getTotalLists(dice_num, units_digit)
249
+ total = getTotal(total_list, dice_num)
250
+
251
+ fumbleable = getFumbleable(more_difficlty)
252
+ hit_result = getCheckResultText(total, diff, fumbleable)
253
+
254
+ return hit_result, total, total_list
255
+ end
256
+
257
+ def getHitResultText(output, counts)
258
+ return "#{output}\n> #{counts[:hit_bullet]}發射擊命中、#{counts[:impale_bullet]}射擊貫穿、剩餘彈藥#{counts[:bullet]}發"
259
+ end
260
+
261
+ def getHitType(more_difficlty, hit_result)
262
+ successList, impaleBulletList = getSuccessListImpaleBulletList(more_difficlty)
263
+
264
+ return :hit if successList.include?(hit_result)
265
+ return :impale if impaleBulletList.include?(hit_result)
266
+
267
+ return ""
268
+ end
269
+
270
+ def getBulletResults(bullet_count, hit_type, diff)
271
+ bullet_set_count = getSetOfBullet(diff)
272
+ hit_bullet_count_base = getHitBulletCountBase(diff, bullet_set_count)
273
+ impale_bullet_count_base = (bullet_set_count / 2.to_f)
274
+
275
+ lost_bullet_count = 0
276
+ hit_bullet_count = 0
277
+ impale_bullet_count = 0
278
+
279
+ if !isLastBulletTurn(bullet_count, bullet_set_count)
280
+
281
+ case hit_type
282
+ when :hit
283
+ hit_bullet_count = hit_bullet_count_base # 正常命中彈藥數之計算
284
+
285
+ when :impale
286
+ hit_bullet_count = impale_bullet_count_base.floor
287
+ impale_bullet_count = impale_bullet_count_base.ceil # 貫穿彈藥數之計算
288
+ end
289
+
290
+ lost_bullet_count = bullet_set_count
291
+
292
+ else
293
+
294
+ case hit_type
295
+ when :hit
296
+ hit_bullet_count = getLastHitBulletCount(bullet_count)
297
+
298
+ when :impale
299
+ halfbull = bullet_count / 2.to_f
300
+
301
+ hit_bullet_count = halfbull.floor
302
+ impale_bullet_count = halfbull.ceil
303
+ end
304
+
305
+ lost_bullet_count = bullet_count
306
+ end
307
+
308
+ return hit_bullet_count, impale_bullet_count, lost_bullet_count
309
+ end
310
+
311
+ def getSuccessListImpaleBulletList(more_difficlty)
312
+ successList = []
313
+ impaleBulletList = []
314
+
315
+ case more_difficlty
316
+ when 0
317
+ successList = ["困難的成功", "通常成功"]
318
+ impaleBulletList = ["決定性的成功", "極限的成功"]
319
+ when 1
320
+ successList = ["困難的成功"]
321
+ impaleBulletList = ["決定性的成功", "極限的成功"]
322
+ when 2
323
+ successList = []
324
+ impaleBulletList = ["決定性的成功", "極限的成功"]
325
+ when 3
326
+ successList = ["決定性的成功"]
327
+ impaleBulletList = []
328
+ end
329
+
330
+ return successList, impaleBulletList
331
+ end
332
+
333
+ def getNextDifficltyMessage(more_difficlty)
334
+ case more_difficlty
335
+ when 1
336
+ return "\n 變更難度為困難的成功"
337
+ when 2
338
+ return "\n 變更難度為極限的成功"
339
+ when 3
340
+ return "\n 變更難度為決定性的成功"
341
+ end
342
+
343
+ return ""
344
+ end
345
+
346
+ def getSetOfBullet(diff)
347
+ bullet_set_count = diff / 10
348
+
349
+ if (diff >= 1) && (diff < 10)
350
+ bullet_set_count = 1 # 技能值9以下的最低限度保障處理
351
+ end
352
+
353
+ return bullet_set_count
354
+ end
355
+
356
+ def getHitBulletCountBase(diff, bullet_set_count)
357
+ hit_bullet_count_base = (bullet_set_count / 2)
358
+
359
+ if (diff >= 1) && (diff < 10)
360
+ hit_bullet_count_base = 1 # 技能值9以下的最低限度保障處理
361
+ end
362
+
363
+ return hit_bullet_count_base
364
+ end
365
+
366
+ def isLastBulletTurn(bullet_count, bullet_set_count)
367
+ ((bullet_count - bullet_set_count) < 0)
368
+ end
369
+
370
+ def getLastHitBulletCount(bullet_count)
371
+ # 在剩餘彈藥為1的最低限度保障處理
372
+ if bullet_count == 1
373
+ return 1
374
+ end
375
+
376
+ count = (bullet_count / 2.to_f).floor
377
+ return count
378
+ end
379
+
380
+ def getFumbleable(more_difficlty)
381
+ # 成功判定時因只擲出49以下數值,而大失敗率上昇
382
+ return (more_difficlty >= 1)
383
+ end
384
+ end
385
+ end
386
+ end
@@ -0,0 +1,383 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BCDice
4
+ module GameSystem
5
+ class Cthulhu7th_Korean < Base
6
+ # ゲームシステムの識別子
7
+ ID = 'Cthulhu7th:Korean'
8
+
9
+ # ゲームシステム名
10
+ NAME = '크툴루의 부름 7판'
11
+
12
+ # ゲームシステム名の読みがな
13
+ SORT_KEY = '国際化:Korean:크툴루'
14
+
15
+ # ダイスボットの使い方
16
+ HELP_MESSAGE = <<~INFO_MESSAGE_TEXT
17
+ ・판정 CC(x)<=(목표치)
18
+  x:보너스, 패널티 주사위:Bonus/Penalty Dice (2~-2). 생략 가능.
19
+  대실패:Fumble/실패:Failure/보통 성공:Regular success/
20
+  어려운 성공:Hard success/대단한 성공:Extreme success/
21
+  대성공:Critical success 을 자동판정.
22
+ 예)CC<=30 CC(2)<=50 CC(-1)<=75
23
+
24
+ ・조합 판정 (CBR(x,y))
25
+  목표치 x 와 y 로 동시에 %판정을 한다.
26
+  예)CBR(50,20)
27
+
28
+ ・연사(Full Auto)판정 FAR(w,x,y,z)
29
+  w:탄수(1~100), x:기능 수치(1~100), y:고장 넘버
30
+  z:보너스, 패널티 주사위(-2~2). 생략 가능.
31
+  명중수와 관통수, 잔탄수만을 계산. 데미지는 계산하지 않습니다.
32
+ 예)FAR(25,70,98) FAR(50,80,98,-1)
33
+ INFO_MESSAGE_TEXT
34
+
35
+ register_prefix(['CC\(\d+\)', 'CC.*', 'CBR\(\d+,\d+\)', 'FAR\(\d+\)', 'FAR.*'])
36
+
37
+ def initialize(command)
38
+ super(command)
39
+
40
+ @bonus_dice_range = (-2..2)
41
+ end
42
+
43
+ def eval_game_system_specific_command(command)
44
+ case command
45
+ when /CC/i
46
+ return getCheckResult(command)
47
+ when /CBR/i
48
+ return getCombineRoll(command)
49
+ when /FAR/i
50
+ return getFullAutoResult(command)
51
+ end
52
+
53
+ return nil
54
+ end
55
+
56
+ def getCheckResult(command)
57
+ nil unless /^CC([-\d]+)?<=(\d+)/i =~ command
58
+ bonus_dice_count = Regexp.last_match(1).to_i # 보너스, 패널티 주사위의 개수
59
+ diff = Regexp.last_match(2).to_i
60
+
61
+ return "에러. 목표치는 1 이상입니다." if diff <= 0
62
+
63
+ unless @bonus_dice_range.include?(bonus_dice_count)
64
+ return "에러. 보너스, 패널티 주사위의 수치는 #{@bonus_dice_range.min}~#{@bonus_dice_range.max}입니다."
65
+ end
66
+
67
+ output = ""
68
+ output += "(1D100<=#{diff})"
69
+ output += " 보너스, 패널티 주사위[#{bonus_dice_count}]"
70
+
71
+ units_digit = rollPercentD10
72
+ total_list = getTotalLists(bonus_dice_count, units_digit)
73
+
74
+ total = getTotal(total_list, bonus_dice_count)
75
+ result_text = getCheckResultText(total, diff)
76
+
77
+ output += " > #{total_list.join(', ')} > #{total} > #{result_text}"
78
+
79
+ return output
80
+ end
81
+
82
+ def rollPercentD10
83
+ dice = @randomizer.roll_once(10)
84
+ dice = 0 if dice == 10
85
+
86
+ return dice
87
+ end
88
+
89
+ def getTotalLists(bonus_dice_count, units_digit)
90
+ total_list = []
91
+
92
+ tens_digit_count = 1 + bonus_dice_count.abs
93
+ tens_digit_count.times do
94
+ bonus = rollPercentD10
95
+ total = (bonus * 10) + units_digit
96
+ total = 100 if total == 0
97
+
98
+ total_list.push(total)
99
+ end
100
+
101
+ return total_list
102
+ end
103
+
104
+ def getTotal(total_list, bonus_dice_count)
105
+ return total_list.min if bonus_dice_count >= 0
106
+
107
+ return total_list.max
108
+ end
109
+
110
+ def getCheckResultText(total, diff, fumbleable = false)
111
+ if total <= diff
112
+ return "대성공" if total == 1
113
+ return "대단한 성공" if total <= (diff / 5)
114
+ return "어려운 성공" if total <= (diff / 2)
115
+
116
+ return "보통 성공"
117
+ end
118
+
119
+ fumble_text = "대실패"
120
+
121
+ return fumble_text if total == 100
122
+
123
+ if total >= 96
124
+ if diff < 50
125
+ return fumble_text
126
+ else
127
+ return fumble_text if fumbleable
128
+ end
129
+ end
130
+
131
+ return "실패"
132
+ end
133
+
134
+ def getCombineRoll(command)
135
+ return nil unless /CBR\((\d+),(\d+)\)/i =~ command
136
+
137
+ diff_1 = Regexp.last_match(1).to_i
138
+ diff_2 = Regexp.last_match(2).to_i
139
+
140
+ total = @randomizer.roll_once(100)
141
+
142
+ result_1 = getCheckResultText(total, diff_1)
143
+ result_2 = getCheckResultText(total, diff_2)
144
+
145
+ successList = ["대성공", "대단한 성공", "어려운 성공", "보통성공"]
146
+
147
+ succesCount = 0
148
+ succesCount += 1 if successList.include?(result_1)
149
+ succesCount += 1 if successList.include?(result_2)
150
+ debug("succesCount", succesCount)
151
+
152
+ rank =
153
+ if succesCount >= 2
154
+ "성공"
155
+ elsif succesCount == 1
156
+ "부분적 성공"
157
+ else
158
+ "실패"
159
+ end
160
+
161
+ return "(1d100<=#{diff_1},#{diff_2}) > #{total}[#{result_1},#{result_2}] > #{rank}"
162
+ end
163
+
164
+ def getFullAutoResult(command)
165
+ return nil unless /^FAR\((-?\d+)(,(-?\d+))(,(-?\d+))(,(-?\d+))?\)/i =~ command
166
+
167
+ bullet_count = Regexp.last_match(1).to_i
168
+ diff = Regexp.last_match(3).to_i
169
+ broken_number = Regexp.last_match(5).to_i
170
+ bonus_dice_count = (Regexp.last_match(7) || 0).to_i
171
+
172
+ output = ""
173
+
174
+ # 최대(8번*(PC기능 수치 최대값/10))=72발밖에 쏠 수 없으니 상한
175
+ bullet_count_limit = 100
176
+ if bullet_count > bullet_count_limit
177
+ output += "\n탄약이 너무 많습니다. 장전된 탄약을 #{bullet_count_limit}개로 변경합니다.\n"
178
+ bullet_count = bullet_count_limit
179
+ end
180
+
181
+ return "탄약은 1 이상입니다." if bullet_count <= 0
182
+ return "목표치는 1 이상입니다." if diff <= 0
183
+
184
+ if broken_number < 0
185
+ output += "\n고장 넘버는 1 이상입니다. 마이너스 기호를 제거합니다.\n"
186
+ broken_number = broken_number.abs
187
+ end
188
+
189
+ unless @bonus_dice_range.include?(bonus_dice_count)
190
+ return "\n에러. 보너스, 패널티 주사위의 수치는 #{@bonus_dice_range.min}~#{@bonus_dice_range.max}입니다."
191
+ end
192
+
193
+ output += "보너스, 패널티 주사위 [#{bonus_dice_count}]"
194
+ output += rollFullAuto(bullet_count, diff, broken_number, bonus_dice_count)
195
+
196
+ return output
197
+ end
198
+
199
+ def rollFullAuto(bullet_count, diff, broken_number, dice_num)
200
+ output = ""
201
+ loopCount = 0
202
+
203
+ counts = {
204
+ hit_bullet: 0,
205
+ impale_bullet: 0,
206
+ bullet: bullet_count,
207
+ }
208
+
209
+ # 난이도 변경용 루프
210
+ (0..3).each do |more_difficlty|
211
+ output += getNextDifficltyMessage(more_difficlty)
212
+
213
+ # 패널티 다이스를 줄이면서 굴리는 용 루프
214
+ while dice_num >= @bonus_dice_range.min
215
+
216
+ loopCount += 1
217
+ hit_result, total, total_list = getHitResultInfos(dice_num, diff, more_difficlty)
218
+ output += "\n#{loopCount}번째: > #{total_list.join(', ')} > #{hit_result}"
219
+
220
+ if total >= broken_number
221
+ output += " 총알 걸림"
222
+ return getHitResultText(output, counts)
223
+ end
224
+
225
+ hit_type = getHitType(more_difficlty, hit_result)
226
+ hit_bullet, impale_bullet, lost_bullet = getBulletResults(counts[:bullet], hit_type, diff)
227
+
228
+ counts[:hit_bullet] += hit_bullet
229
+ counts[:impale_bullet] += impale_bullet
230
+ counts[:bullet] -= lost_bullet
231
+
232
+ return getHitResultText(output, counts) if counts[:bullet] <= 0
233
+
234
+ dice_num -= 1
235
+ end
236
+
237
+ dice_num += 1
238
+ end
239
+
240
+ return getHitResultText(output, counts)
241
+ end
242
+
243
+ def getHitResultInfos(dice_num, diff, more_difficlty)
244
+ units_digit = rollPercentD10
245
+ total_list = getTotalLists(dice_num, units_digit)
246
+ total = getTotal(total_list, dice_num)
247
+
248
+ fumbleable = getFumbleable(more_difficlty)
249
+ hit_result = getCheckResultText(total, diff, fumbleable)
250
+
251
+ return hit_result, total, total_list
252
+ end
253
+
254
+ def getHitResultText(output, counts)
255
+ return "#{output}\n> #{counts[:hit_bullet]}발이 명중, #{counts[:impale_bullet]}발이 관통, 잔탄 #{counts[:bullet]}발"
256
+ end
257
+
258
+ def getHitType(more_difficlty, hit_result)
259
+ successList, impaleBulletList = getSuccessListImpaleBulletList(more_difficlty)
260
+
261
+ return :hit if successList.include?(hit_result)
262
+ return :impale if impaleBulletList.include?(hit_result)
263
+
264
+ return ""
265
+ end
266
+
267
+ def getBulletResults(bullet_count, hit_type, diff)
268
+ bullet_set_count = getSetOfBullet(diff)
269
+ hit_bullet_count_base = getHitBulletCountBase(diff, bullet_set_count)
270
+ impale_bullet_count_base = (bullet_set_count / 2.to_f)
271
+
272
+ lost_bullet_count = 0
273
+ hit_bullet_count = 0
274
+ impale_bullet_count = 0
275
+
276
+ if !isLastBulletTurn(bullet_count, bullet_set_count)
277
+
278
+ case hit_type
279
+ when :hit
280
+ hit_bullet_count = hit_bullet_count_base # 보통명중한 탄수의 계산
281
+
282
+ when :impale
283
+ hit_bullet_count = impale_bullet_count_base.floor
284
+ impale_bullet_count = impale_bullet_count_base.ceil # 관통한 탄수의 계산
285
+ end
286
+
287
+ lost_bullet_count = bullet_set_count
288
+
289
+ else
290
+
291
+ case hit_type
292
+ when :hit
293
+ hit_bullet_count = getLastHitBulletCount(bullet_count)
294
+
295
+ when :impale
296
+ halfbull = bullet_count / 2.to_f
297
+
298
+ hit_bullet_count = halfbull.floor
299
+ impale_bullet_count = halfbull.ceil
300
+ end
301
+
302
+ lost_bullet_count = bullet_count
303
+ end
304
+
305
+ return hit_bullet_count, impale_bullet_count, lost_bullet_count
306
+ end
307
+
308
+ def getSuccessListImpaleBulletList(more_difficlty)
309
+ successList = []
310
+ impaleBulletList = []
311
+
312
+ case more_difficlty
313
+ when 0
314
+ successList = ["어려운 성공", "보통 성공"]
315
+ impaleBulletList = ["대성공", "대단한 성공"]
316
+ when 1
317
+ successList = ["어려운 성공"]
318
+ impaleBulletList = ["대성공", "대단한 성공"]
319
+ when 2
320
+ successList = []
321
+ impaleBulletList = ["대성공", "대단한 성공"]
322
+ when 3
323
+ successList = ["대성공"]
324
+ impaleBulletList = []
325
+ end
326
+
327
+ return successList, impaleBulletList
328
+ end
329
+
330
+ def getNextDifficltyMessage(more_difficlty)
331
+ case more_difficlty
332
+ when 1
333
+ return "\n 난이도가 어려운 성공으로 변경"
334
+ when 2
335
+ return "\n 난이도가 대단한 성공으로 변경"
336
+ when 3
337
+ return "\n 난이도가 대성공으로 변경"
338
+ end
339
+
340
+ return ""
341
+ end
342
+
343
+ def getSetOfBullet(diff)
344
+ bullet_set_count = diff / 10
345
+
346
+ if (diff >= 1) && (diff < 10)
347
+ bullet_set_count = 1 # 기능 수치가 9 이하일 때의 최저수치 보장 처리
348
+ end
349
+
350
+ return bullet_set_count
351
+ end
352
+
353
+ def getHitBulletCountBase(diff, bullet_set_count)
354
+ hit_bullet_count_base = (bullet_set_count / 2)
355
+
356
+ if (diff >= 1) && (diff < 10)
357
+ hit_bullet_count_base = 1 # 기능 수치가 9 이하일 때의 최저수치 보장
358
+ end
359
+
360
+ return hit_bullet_count_base
361
+ end
362
+
363
+ def isLastBulletTurn(bullet_count, bullet_set_count)
364
+ ((bullet_count - bullet_set_count) < 0)
365
+ end
366
+
367
+ def getLastHitBulletCount(bullet_count)
368
+ # 잔탄 1발일 때의 최저수치 보장 처리
369
+ if bullet_count == 1
370
+ return 1
371
+ end
372
+
373
+ count = (bullet_count / 2.to_f).floor
374
+ return count
375
+ end
376
+
377
+ def getFumbleable(more_difficlty)
378
+ # 성공이 49 이하일때만이기 때문에 펌블치는 상승
379
+ return (more_difficlty >= 1)
380
+ end
381
+ end
382
+ end
383
+ end