bcdice 3.0.0.pre.rc.2 → 3.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +49 -1
  3. data/README.md +33 -7
  4. data/i18n/MonotoneMuseum/ja_jp.yml +3 -3
  5. data/lib/bcdice/common_command/add_dice.rb +1 -1
  6. data/lib/bcdice/dice_table/sai_fic_skill_table.rb +1 -1
  7. data/lib/bcdice/game_system.rb +1 -0
  8. data/lib/bcdice/game_system/AlchemiaStruggle.rb +1 -1
  9. data/lib/bcdice/game_system/Alshard.rb +1 -1
  10. data/lib/bcdice/game_system/AngelGear.rb +123 -0
  11. data/lib/bcdice/game_system/ArsMagica.rb +1 -1
  12. data/lib/bcdice/game_system/BBN.rb +1 -1
  13. data/lib/bcdice/game_system/BadLife.rb +1 -1
  14. data/lib/bcdice/game_system/BarnaKronika.rb +1 -1
  15. data/lib/bcdice/game_system/BeastBindTrinity.rb +2 -2
  16. data/lib/bcdice/game_system/BlindMythos.rb +1 -1
  17. data/lib/bcdice/game_system/BloodCrusade.rb +42 -42
  18. data/lib/bcdice/game_system/BloodMoon.rb +41 -0
  19. data/lib/bcdice/game_system/CardRanker.rb +2 -2
  20. data/lib/bcdice/game_system/ChaosFlare.rb +1 -1
  21. data/lib/bcdice/game_system/Chill.rb +1 -1
  22. data/lib/bcdice/game_system/CodeLayerd.rb +3 -1
  23. data/lib/bcdice/game_system/Cthulhu.rb +8 -4
  24. data/lib/bcdice/game_system/Cthulhu7th.rb +40 -334
  25. data/lib/bcdice/game_system/Cthulhu7th_ChineseTraditional.rb +2 -2
  26. data/lib/bcdice/game_system/Cthulhu7th_Korean.rb +2 -2
  27. data/lib/bcdice/game_system/CthulhuTech.rb +1 -1
  28. data/lib/bcdice/game_system/Cthulhu_ChineseTraditional.rb +1 -1
  29. data/lib/bcdice/game_system/Cthulhu_Korean.rb +1 -1
  30. data/lib/bcdice/game_system/DarkBlaze.rb +1 -1
  31. data/lib/bcdice/game_system/DiceOfTheDead.rb +1 -1
  32. data/lib/bcdice/game_system/DoubleCross.rb +1 -1
  33. data/lib/bcdice/game_system/EarthDawn.rb +1 -1
  34. data/lib/bcdice/game_system/EarthDawn3.rb +1 -1
  35. data/lib/bcdice/game_system/EarthDawn4.rb +1 -1
  36. data/lib/bcdice/game_system/Elysion.rb +2 -2
  37. data/lib/bcdice/game_system/EmbryoMachine.rb +1 -1
  38. data/lib/bcdice/game_system/EtrianOdysseySRS.rb +1 -1
  39. data/lib/bcdice/game_system/FilledWith.rb +203 -1274
  40. data/lib/bcdice/game_system/FullMetalPanic.rb +1 -1
  41. data/lib/bcdice/game_system/Garako.rb +12 -4
  42. data/lib/bcdice/game_system/GehennaAn.rb +1 -1
  43. data/lib/bcdice/game_system/GoblinSlayer.rb +1 -1
  44. data/lib/bcdice/game_system/Gorilla.rb +1 -1
  45. data/lib/bcdice/game_system/HarnMaster.rb +1 -1
  46. data/lib/bcdice/game_system/HatsuneMiku.rb +1 -1
  47. data/lib/bcdice/game_system/HouraiGakuen.rb +1 -1
  48. data/lib/bcdice/game_system/Illusio.rb +25 -34
  49. data/lib/bcdice/game_system/LogHorizon.rb +3 -3
  50. data/lib/bcdice/game_system/LostRoyal.rb +1 -1
  51. data/lib/bcdice/game_system/MeikyuDays.rb +1 -1
  52. data/lib/bcdice/game_system/MeikyuKingdom.rb +2 -2
  53. data/lib/bcdice/game_system/MeikyuKingdomBasic.rb +3 -3
  54. data/lib/bcdice/game_system/MetalHeadExtream.rb +1 -1
  55. data/lib/bcdice/game_system/MetallicGuardian.rb +1 -1
  56. data/lib/bcdice/game_system/MonotoneMuseum.rb +1 -1
  57. data/lib/bcdice/game_system/NeverCloud.rb +540 -5
  58. data/lib/bcdice/game_system/NightWizard.rb +1 -1
  59. data/lib/bcdice/game_system/NightWizard3rd.rb +1 -1
  60. data/lib/bcdice/game_system/NinjaSlayer.rb +4 -13
  61. data/lib/bcdice/game_system/OneWayHeroics.rb +1 -1
  62. data/lib/bcdice/game_system/OracleEngine.rb +1 -1
  63. data/lib/bcdice/game_system/OrgaRain.rb +17 -25
  64. data/lib/bcdice/game_system/Paradiso.rb +3 -3
  65. data/lib/bcdice/game_system/ParanoiaRebooted.rb +1 -1
  66. data/lib/bcdice/game_system/Postman.rb +1 -1
  67. data/lib/bcdice/game_system/PulpCthulhu.rb +1 -1
  68. data/lib/bcdice/game_system/RecordOfLodossWar.rb +1 -1
  69. data/lib/bcdice/game_system/RecordOfSteam.rb +1 -1
  70. data/lib/bcdice/game_system/RokumonSekai2.rb +1 -1
  71. data/lib/bcdice/game_system/Ryutama.rb +1 -1
  72. data/lib/bcdice/game_system/SRS.rb +1 -1
  73. data/lib/bcdice/game_system/SamsaraBallad.rb +1 -1
  74. data/lib/bcdice/game_system/Satasupe.rb +79 -860
  75. data/lib/bcdice/game_system/SevenFortressMobius.rb +1 -1
  76. data/lib/bcdice/game_system/SharedFantasia.rb +1 -1
  77. data/lib/bcdice/game_system/ShinkuuGakuen.rb +2 -2
  78. data/lib/bcdice/game_system/ShinobiGami.rb +3 -3
  79. data/lib/bcdice/game_system/Skynauts.rb +2 -2
  80. data/lib/bcdice/game_system/SteamPunkers.rb +1 -1
  81. data/lib/bcdice/game_system/SterileLife.rb +2 -3
  82. data/lib/bcdice/game_system/StrangerOfSwordCity.rb +2 -2
  83. data/lib/bcdice/game_system/SwordWorld.rb +46 -182
  84. data/lib/bcdice/game_system/SwordWorld2_0.rb +21 -149
  85. data/lib/bcdice/game_system/SwordWorld2_5.rb +126 -40
  86. data/lib/bcdice/game_system/Torg.rb +1 -1
  87. data/lib/bcdice/game_system/TorgEternity.rb +2 -2
  88. data/lib/bcdice/game_system/TunnelsAndTrolls.rb +1 -1
  89. data/lib/bcdice/game_system/TwilightGunsmoke.rb +1 -1
  90. data/lib/bcdice/game_system/UnsungDuet.rb +1 -1
  91. data/lib/bcdice/game_system/Utakaze.rb +1 -1
  92. data/lib/bcdice/game_system/VampireTheMasquerade5th.rb +1 -1
  93. data/lib/bcdice/game_system/Warhammer.rb +1 -1
  94. data/lib/bcdice/game_system/Warhammer4.rb +1 -1
  95. data/lib/bcdice/game_system/WorldOfDarkness.rb +1 -1
  96. data/lib/bcdice/game_system/YearZeroEngine.rb +1 -1
  97. data/lib/bcdice/game_system/ZettaiReido.rb +1 -1
  98. data/lib/bcdice/game_system/cthulhu7th/full_auto.rb +294 -0
  99. data/lib/bcdice/game_system/cthulhu7th/rollable.rb +41 -0
  100. data/lib/bcdice/game_system/filled_with/enemy_data_tables.rb +322 -0
  101. data/lib/bcdice/game_system/filled_with/event_tables.rb +392 -0
  102. data/lib/bcdice/game_system/filled_with/tresure_tables.rb +179 -0
  103. data/lib/bcdice/game_system/satasupe/tables.rb +723 -0
  104. data/lib/bcdice/game_system/sword_world/rating_lexer.rb +47 -0
  105. data/lib/bcdice/game_system/sword_world/rating_parsed.rb +99 -0
  106. data/lib/bcdice/game_system/sword_world/rating_parser.rb +457 -0
  107. data/lib/bcdice/game_system/sword_world/transcendent_test.rb +104 -0
  108. data/lib/bcdice/version.rb +1 -1
  109. metadata +15 -4
@@ -63,6 +63,47 @@ module BCDice
63
63
  end
64
64
 
65
65
  TABLES = {
66
+ "ST" => DiceTable::Table.new(
67
+ "シーン表",
68
+ "2D6",
69
+ [
70
+ "どこまでも広がる荒野。風が吹き抜けていく。",
71
+ "血まみれの惨劇の跡。いったい誰がこんなことを?",
72
+ "都市の地下。かぼそい明かりがコンクリートを照らす。",
73
+ "豪華な調度が揃えられた室内。くつろぎの空間を演出。",
74
+ "普通の道端。様々な人が道を行き交う。",
75
+ "明るく浮かぶ月の下。暴力の気配が満ちていく。",
76
+ "打ち捨てられた廃墟。荒れ果てた景色に心も荒む。",
77
+ "生活の様子が色濃く残る部屋の中。誰の部屋だろう?",
78
+ "にぎやかな飲食店。騒ぐ人々に紛れつつ事態は進行する。",
79
+ "ざわめく木立。踊る影。",
80
+ "高い塔の上。都市を一望できる。"
81
+ ]
82
+ ),
83
+ "MIT" => DiceTable::Table.new(
84
+ "軽度狂気表",
85
+ "1D6",
86
+ [
87
+ "【誇大妄想】(判定に失敗するたびに【テンション】が1増加する。)",
88
+ "【記憶喪失】(【幸福】の修復判定にマイナス2の修正。)",
89
+ "【こだわり】(戦闘中の行動を「パス」以外で一つ選択し、その行動をすると【テンション】が6増加する。)",
90
+ "【お守り中毒】(「幸運のお守り」を装備していない場合、全ての2d6判定にマイナス1の修正。)",
91
+ "【不死幻想】(自分が受けるダメージが全て1増加する。)",
92
+ "【血の飢え】(戦闘中、ラウンドごとに他のキャラクターにダメージを与えないと、ラウンド終了時に【テンション】4増加。)"
93
+ ]
94
+ ),
95
+ "SIT" => DiceTable::Table.new(
96
+ "重度狂気表",
97
+ "1D6",
98
+ [
99
+ "【幸福依存】(【幸福】を一つ選択し、その【幸福】が結果フェイズに失われたとき、死亡する。)",
100
+ "【見えない友達】(交流判定にマイナス3の修正がつく。)",
101
+ "【臆病】(自分の行う妨害判定にマイナス2の修正がつく。)",
102
+ "【陰謀論】(休息判定にマイナス3の修正がつく。)",
103
+ "【指令受信】(メインフェイズの3サイクル目の自分のシーンでは、可能な範囲でGMが行動を決定する。)",
104
+ "【猜疑心】(自分が「連携攻撃」を行うとき、関係の【深度】をダメージに加えられない。)"
105
+ ]
106
+ ),
66
107
  "CHT" => DiceTable::Table.new(
67
108
  "自信幸福表",
68
109
  "1D6",
@@ -18,7 +18,7 @@ module BCDice
18
18
  ランダム分野表 RCT
19
19
  特定のモンスターカードを選ぶ (CMxy x:色、y:番号)
20
20
   白:W、青:U、緑:V、金:G、赤:R、黒:B
21
-  例)CMW1→白の2:白竜 CMG12→金の12:土精霊
21
+  例)CMW2→白の2:白竜 CMG12→金の12:土精霊
22
22
  場所表 (ST)
23
23
  街中場所表 (CST)
24
24
  郊外場所表 (OST)
@@ -202,7 +202,7 @@ module BCDice
202
202
  ]
203
203
  ),
204
204
  }.freeze
205
- register_prefix(RTT.prefixes, 'CM.*', TABLES.keys)
205
+ register_prefix(RTT.prefixes, 'CM', TABLES.keys)
206
206
  end
207
207
  end
208
208
  end
@@ -39,7 +39,7 @@ module BCDice
39
39
  - FT7
40
40
  INFO_MESSAGE_TEXT
41
41
 
42
- register_prefix('\d*CF.*', 'FT\d*')
42
+ register_prefix('\d*CF', 'FT\d*')
43
43
 
44
44
  # ゲーム別成功度判定(2D6)。以前の処理をそのまま残しています。
45
45
  def check_2D6(total, dice_total, _dice_list, cmp_op, target)
@@ -22,7 +22,7 @@ module BCDice
22
22
   例)SR7   sr13   SR(7+4)   Ssr10
23
23
  INFO_MESSAGE_TEXT
24
24
 
25
- register_prefix('SR\d+.*')
25
+ register_prefix('SR\d+')
26
26
 
27
27
  def check_1D100(total, _dice_total, cmp_op, target)
28
28
  return '' if target == '?'
@@ -26,9 +26,11 @@ module BCDice
26
26
  4CL+2@7 または 4CL@7+2 :サイコロ4個で判定値7のロールを行い達成値を出し、修正値2を足す。
27
27
  4CL[2] :サイコロ4個でクリティカル値2のロールを行う。
28
28
  0CL : 1CL[0]と同じ判定
29
+
30
+ デフォルトダイス:10面
29
31
  MESSAGETEXT
30
32
 
31
- register_prefix('[+-]?\d*CL([+-]\d+)?[@\d]*.*')
33
+ register_prefix('[+-]?\d*CL([+-]\d+)?[@\d]*')
32
34
 
33
35
  def initialize(command)
34
36
  super(command)
@@ -48,7 +48,7 @@ module BCDice
48
48
 
49
49
  INFO_MESSAGE_TEXT
50
50
 
51
- register_prefix('CC(B)?\(\d+\)', 'CC(B)?.*', 'RES(B)?.*', 'CBR(B)?\(\d+,\d+\)')
51
+ register_prefix('CC(B)?\(\d+\)', 'CC(B)?', 'RES(B)?', 'CBR(B)?\(\d+,\d+\)')
52
52
 
53
53
  def initialize(command)
54
54
  super(command)
@@ -97,7 +97,11 @@ module BCDice
97
97
  private
98
98
 
99
99
  def getCheckResult(command)
100
- m = %r{CCB?(\d+)?(?:<=([+-/*\d]+))?}i.match(command)
100
+ m = %r{^CCB?(\d+)?(?:<=([+-/*\d]+))?$}i.match(command)
101
+ unless m
102
+ return nil
103
+ end
104
+
101
105
  broken_num = m[1].to_i
102
106
  diff = ArithmeticEvaluator.eval(m[2])
103
107
 
@@ -189,7 +193,7 @@ module BCDice
189
193
  end
190
194
 
191
195
  def getRegistResult(command)
192
- m = /RES(B)?([-\d]+)/i.match(command)
196
+ m = /^RES(B)?([-\d]+)$/i.match(command)
193
197
  unless m
194
198
  return nil
195
199
  end
@@ -215,7 +219,7 @@ module BCDice
215
219
  end
216
220
 
217
221
  def getCombineRoll(command)
218
- m = /CBR(B)?\((\d+),(\d+)\)/i.match(command)
222
+ m = /^CBR(B)?\((\d+),(\d+)\)$/i.match(command)
219
223
  unless m
220
224
  return nil
221
225
  end
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "bcdice/game_system/cthulhu7th/rollable"
4
+ require "bcdice/game_system/cthulhu7th/full_auto"
5
+
3
6
  module BCDice
4
7
  module GameSystem
5
8
  class Cthulhu7th < Base
@@ -45,37 +48,31 @@ module BCDice
45
48
    強力でない呪文の場合 FCL/強力な呪文の場合 FCM
46
49
  INFO_MESSAGE_TEXT
47
50
 
48
- register_prefix('CC\(\d+\)', 'CC.*', 'CBR\(\d+,\d+\)', 'FAR.*', 'BMR', 'BMS', 'FCL', 'FCM', 'PH', 'MA')
49
-
50
- BONUS_DICE_RANGE = (-2..2).freeze
51
+ register_prefix('CC', 'CBR\(\d+,\d+\)', 'FAR', 'BMR', 'BMS', 'FCL', 'FCM', 'PH', 'MA')
51
52
 
52
53
  def eval_game_system_specific_command(command)
53
54
  case command
54
55
  when /^CC/i
55
- return skill_roll(command)
56
+ skill_roll(command)
56
57
  when /^CBR/i
57
- return combine_roll(command)
58
+ combine_roll(command)
58
59
  when /^FAR/i
59
- return getFullAutoResult(command)
60
+ getFullAutoResult(command)
60
61
  when /^BMR/i # 狂気の発作(リアルタイム)
61
- return roll_bmr_table()
62
+ roll_bmr_table()
62
63
  when /^BMS/i # 狂気の発作(サマリー)
63
- return roll_bms_table()
64
+ roll_bms_table()
64
65
  when /^FCL/i # キャスティング・ロールのプッシュに失敗した場合(小)
65
- return roll_1d8_table("キャスティング・ロール失敗(小)表", FAILED_CASTING_L_TABLE)
66
+ roll_1d8_table("キャスティング・ロール失敗(小)表", FAILED_CASTING_L_TABLE)
66
67
  when /^FCM/i # キャスティング・ロールのプッシュに失敗した場合(大)
67
- return roll_1d8_table("キャスティング・ロール失敗(大)表", FAILED_CASTING_M_TABLE)
68
+ roll_1d8_table("キャスティング・ロール失敗(大)表", FAILED_CASTING_M_TABLE)
68
69
  when /^PH/i # 恐怖症表
69
- return roll_1d100_table("恐怖症表", PHOBIAS_TABLE)
70
+ roll_1d100_table("恐怖症表", PHOBIAS_TABLE)
70
71
  when /^MA/i # マニア表
71
- return roll_1d100_table("マニア表", MANIAS_TABLE)
72
- else
73
- return nil
72
+ roll_1d100_table("マニア表", MANIAS_TABLE)
74
73
  end
75
74
  end
76
75
 
77
- private
78
-
79
76
  class ResultLevel
80
77
  LEVEL = [
81
78
  :fumble,
@@ -95,6 +92,24 @@ module BCDice
95
92
  failure: "失敗",
96
93
  }.freeze
97
94
 
95
+ def self.from_values(total, difficulty, fumbleable = false)
96
+ fumble = difficulty < 50 || fumbleable ? 96 : 100
97
+
98
+ if total == 1
99
+ ResultLevel.new(:critical)
100
+ elsif total <= (difficulty / 5)
101
+ ResultLevel.new(:extreme_success)
102
+ elsif total <= (difficulty / 2)
103
+ ResultLevel.new(:hard_success)
104
+ elsif total <= difficulty
105
+ ResultLevel.new(:regular_success)
106
+ elsif total >= fumble
107
+ ResultLevel.new(:fumble)
108
+ else
109
+ ResultLevel.new(:failure)
110
+ end
111
+ end
112
+
98
113
  def initialize(level)
99
114
  @level = level
100
115
  @level_index = LEVEL.index(level)
@@ -122,6 +137,10 @@ module BCDice
122
137
  end
123
138
  end
124
139
 
140
+ private
141
+
142
+ include Rollable
143
+
125
144
  def roll_1d8_table(table_name, table)
126
145
  total_n = @randomizer.roll_once(8)
127
146
  index = total_n - 1
@@ -161,7 +180,7 @@ module BCDice
161
180
  total, total_list = roll_with_bonus(bonus_dice)
162
181
 
163
182
  expr = difficulty.zero? ? "1D100" : "1D100<=#{difficulty}"
164
- result = result_level(total, difficulty) unless difficulty.zero?
183
+ result = ResultLevel.from_values(total, difficulty) unless difficulty.zero?
165
184
 
166
185
  sequence = [
167
186
  "(#{expr}) ボーナス・ペナルティダイス[#{bonus_dice}]",
@@ -180,54 +199,8 @@ module BCDice
180
199
  end
181
200
  end
182
201
 
183
- # 1D100の一の位用のダイスロール
184
- # 0から9までの値を返す
185
- #
186
- # @return [Integer]
187
- def roll_ones_d10
188
- dice = @randomizer.roll_once(10)
189
- return 0 if dice == 10
190
-
191
- return dice
192
- end
193
-
194
- # @param bonus [Integer] ボーナス・ペナルティダイスの数。負の数ならペナルティダイス。
195
- # @return [Array<(Integer, Array<Integer>)>]
196
- def roll_with_bonus(bonus)
197
- tens_list = Array.new(bonus.abs + 1) { @randomizer.roll_tens_d10 }
198
- ones = roll_ones_d10()
199
-
200
- dice_list = tens_list.map do |tens|
201
- dice = tens + ones
202
- dice == 0 ? 100 : dice
203
- end
204
-
205
- dice =
206
- if bonus >= 0
207
- dice_list.min
208
- else
209
- dice_list.max
210
- end
211
-
212
- return dice, dice_list
213
- end
214
-
215
- def result_level(total, difficulty, fumbleable = false)
216
- fumble = difficulty < 50 || fumbleable ? 96 : 100
217
-
218
- if total == 1
219
- ResultLevel.new(:critical)
220
- elsif total <= (difficulty / 5)
221
- ResultLevel.new(:extreme_success)
222
- elsif total <= (difficulty / 2)
223
- ResultLevel.new(:hard_success)
224
- elsif total <= difficulty
225
- ResultLevel.new(:regular_success)
226
- elsif total >= fumble
227
- ResultLevel.new(:fumble)
228
- else
229
- ResultLevel.new(:failure)
230
- end
202
+ def getFullAutoResult(command)
203
+ FullAuto.eval(command, @randomizer)
231
204
  end
232
205
 
233
206
  def combine_roll(command)
@@ -239,8 +212,8 @@ module BCDice
239
212
 
240
213
  total = @randomizer.roll_once(100)
241
214
 
242
- result_1 = result_level(total, difficulty_1)
243
- result_2 = result_level(total, difficulty_2)
215
+ result_1 = ResultLevel.from_values(total, difficulty_1)
216
+ result_2 = ResultLevel.from_values(total, difficulty_2)
244
217
 
245
218
  rank =
246
219
  if result_1.success? && result_2.success?
@@ -258,273 +231,6 @@ module BCDice
258
231
  end
259
232
  end
260
233
 
261
- def getFullAutoResult(command)
262
- return nil unless /^FAR\((-?\d+),(-?\d+),(-?\d+)(?:,(-?\d+)?)?(?:,(-?\w+)?)?(?:,(-?\d+)?)?\)/i =~ command
263
-
264
- bullet_count = Regexp.last_match(1).to_i
265
- diff = Regexp.last_match(2).to_i
266
- broken_number = Regexp.last_match(3).to_i
267
- bonus_dice_count = (Regexp.last_match(4) || 0).to_i
268
- stop_count = (Regexp.last_match(5) || "").to_s.downcase
269
- bullet_set_count_cap = (Regexp.last_match(6) || diff / 10).to_i
270
-
271
- output = ""
272
-
273
- # 最大で(8回*(PC技能値最大値/10))=72発しか撃てないはずなので上限
274
- bullet_count_limit = 100
275
- if bullet_count > bullet_count_limit
276
- output += "弾薬が多すぎます。装填された弾薬を#{bullet_count_limit}発に変更します。\n"
277
- bullet_count = bullet_count_limit
278
- end
279
-
280
- # ボレーの上限の設定がおかしい場合の注意表示
281
- if (bullet_set_count_cap > diff / 10) && (diff > 39) && !Regexp.last_match(6).nil?
282
- bullet_set_count_cap = diff / 10
283
- output += "ボレーの弾丸の数の上限は\[技能値÷10(切り捨て)\]発なので、それより高い数を指定できません。ボレーの弾丸の数を#{bullet_set_count_cap}発に変更します。\n"
284
- elsif (diff <= 39) && (bullet_set_count_cap > 3) && !Regexp.last_match(6).nil?
285
- bullet_set_count_cap = 3
286
- output += "技能値が39以下ではボレーの弾丸の数の上限および下限は3発です。ボレーの弾丸の数を#{bullet_set_count_cap}発に変更します。\n"
287
- end
288
-
289
- # ボレーの下限の設定がおかしい場合の注意表示およびエラー表示
290
- return "ボレーの弾丸の数は正の数です。" if (bullet_set_count_cap <= 0) && !Regexp.last_match(6).nil?
291
-
292
- if (bullet_set_count_cap < 3) && !Regexp.last_match(6).nil?
293
- bullet_set_count_cap = 3
294
- output += "ボレーの弾丸の数の下限は3発です。ボレーの弾丸の数を3発に変更します。\n"
295
- end
296
-
297
- return "弾薬は正の数です。" if bullet_count <= 0
298
- return "目標値は正の数です。" if diff <= 0
299
-
300
- if broken_number < 0
301
- output += "故障ナンバーは正の数です。マイナス記号を外します。\n"
302
- broken_number = broken_number.abs
303
- end
304
-
305
- unless BONUS_DICE_RANGE.include?(bonus_dice_count)
306
- return "エラー。ボーナス・ペナルティダイスの値は#{BONUS_DICE_RANGE.min}~#{BONUS_DICE_RANGE.max}です。"
307
- end
308
-
309
- output += "ボーナス・ペナルティダイス[#{bonus_dice_count}]"
310
- output += rollFullAuto(bullet_count, diff, broken_number, bonus_dice_count, stop_count, bullet_set_count_cap)
311
-
312
- return output
313
- end
314
-
315
- def rollFullAuto(bullet_count, diff, broken_number, dice_num, stop_count, bullet_set_count_cap)
316
- output = ""
317
- loopCount = 0
318
-
319
- counts = {
320
- hit_bullet: 0,
321
- impale_bullet: 0,
322
- bullet: bullet_count,
323
- }
324
-
325
- # 難易度変更用ループ
326
- (0..3).each do |more_difficulty|
327
- output += getNextDifficultyMessage(more_difficulty)
328
-
329
- # ペナルティダイスを減らしながらロール用ループ
330
- while dice_num >= BONUS_DICE_RANGE.min
331
-
332
- loopCount += 1
333
- hit_result, total, total_list = getHitResultInfos(dice_num, diff, more_difficulty)
334
- output += "\n#{loopCount}回目: > #{total_list.join(', ')} > #{hit_result}"
335
-
336
- if total >= broken_number
337
- output += " ジャム"
338
- return getHitResultText(output, counts)
339
- end
340
-
341
- hit_type = getHitType(more_difficulty, hit_result)
342
- hit_bullet, impale_bullet, lost_bullet = getBulletResults(counts[:bullet], hit_type, diff, bullet_set_count_cap)
343
-
344
- output += " (#{hit_bullet}発が命中、#{impale_bullet}発が貫通)"
345
-
346
- counts[:hit_bullet] += hit_bullet
347
- counts[:impale_bullet] += impale_bullet
348
- counts[:bullet] -= lost_bullet
349
-
350
- return getHitResultText(output, counts) if counts[:bullet] <= 0
351
-
352
- dice_num -= 1
353
- end
354
-
355
- # 指定された難易度となった場合、連射処理を途中で止める
356
- if shouldStopRollFullAuto?(stop_count, more_difficulty)
357
- output += "\n【指定の難易度となったので、処理を終了します。】"
358
- break
359
- end
360
-
361
- dice_num += 1
362
- end
363
-
364
- return getHitResultText(output, counts)
365
- end
366
-
367
- # 連射処理を止める条件(難易度の閾値)
368
- # @return [Hash<String, Integer>]
369
- #
370
- # 成功の種類の小文字表記 => 難易度の閾値
371
- ROLL_FULL_AUTO_DIFFICULTY_THRESHOLD = {
372
- # レギュラー
373
- 'r' => 0,
374
- # ハード
375
- 'h' => 1,
376
- # イクストリーム
377
- 'e' => 2
378
- }.freeze
379
-
380
- # 連射処理を止めるべきかどうかを返す
381
- # @param [String] stop_count 成功の種類
382
- # @param [Integer] difficulty 難易度
383
- # @return [Boolean]
384
- def shouldStopRollFullAuto?(stop_count, difficulty)
385
- difficulty_threshold = ROLL_FULL_AUTO_DIFFICULTY_THRESHOLD[stop_count]
386
- return difficulty_threshold && difficulty >= difficulty_threshold
387
- end
388
-
389
- def getHitResultInfos(dice_num, diff, more_difficulty)
390
- total, total_list = roll_with_bonus(dice_num)
391
-
392
- fumbleable = getFumbleable(more_difficulty)
393
- hit_result = result_level(total, diff, fumbleable).to_s
394
-
395
- return hit_result, total, total_list
396
- end
397
-
398
- def getHitResultText(output, counts)
399
- return "#{output}\n> #{counts[:hit_bullet]}発が通常命中、#{counts[:impale_bullet]}発が貫通、残弾#{counts[:bullet]}発"
400
- end
401
-
402
- def getHitType(more_difficulty, hit_result)
403
- successList, impaleBulletList = getSuccessListImpaleBulletList(more_difficulty)
404
-
405
- return :hit if successList.include?(hit_result)
406
- return :impale if impaleBulletList.include?(hit_result)
407
-
408
- return ""
409
- end
410
-
411
- def getBulletResults(bullet_count, hit_type, diff, bullet_set_count_cap)
412
- bullet_set_count = getSetOfBullet(diff, bullet_set_count_cap)
413
- hit_bullet_count_base = getHitBulletCountBase(diff, bullet_set_count)
414
- impale_bullet_count_base = (bullet_set_count / 2.to_f)
415
-
416
- lost_bullet_count = 0
417
- hit_bullet_count = 0
418
- impale_bullet_count = 0
419
-
420
- if !isLastBulletTurn(bullet_count, bullet_set_count)
421
-
422
- case hit_type
423
- when :hit
424
- hit_bullet_count = hit_bullet_count_base # 通常命中した弾数の計算
425
-
426
- when :impale
427
- impale_bullet_count = impale_bullet_count_base.floor # 貫通した弾数の計算
428
- hit_bullet_count = impale_bullet_count_base.ceil
429
- end
430
-
431
- lost_bullet_count = bullet_set_count
432
-
433
- else
434
-
435
- case hit_type
436
- when :hit
437
- hit_bullet_count = getLastHitBulletCount(bullet_count)
438
-
439
- when :impale
440
- impale_bullet_count = getLastHitBulletCount(bullet_count)
441
- hit_bullet_count = bullet_count - impale_bullet_count
442
- end
443
-
444
- lost_bullet_count = bullet_count
445
- end
446
-
447
- return hit_bullet_count, impale_bullet_count, lost_bullet_count
448
- end
449
-
450
- def getSuccessListImpaleBulletList(more_difficulty)
451
- successList = []
452
- impaleBulletList = []
453
-
454
- case more_difficulty
455
- when 0
456
- successList = ["ハード成功", "レギュラー成功"]
457
- impaleBulletList = ["クリティカル", "イクストリーム成功"]
458
- when 1
459
- successList = ["ハード成功"]
460
- impaleBulletList = ["クリティカル", "イクストリーム成功"]
461
- when 2
462
- successList = []
463
- impaleBulletList = ["クリティカル", "イクストリーム成功"]
464
- when 3
465
- successList = ["クリティカル"]
466
- impaleBulletList = []
467
- end
468
-
469
- return successList, impaleBulletList
470
- end
471
-
472
- def getNextDifficultyMessage(more_difficulty)
473
- case more_difficulty
474
- when 1
475
- return "\n【難易度がハードに変更】"
476
- when 2
477
- return "\n【難易度がイクストリームに変更】"
478
- when 3
479
- return "\n【難易度がクリティカルに変更】"
480
- end
481
-
482
- return ""
483
- end
484
-
485
- def getSetOfBullet(diff, bullet_set_count_cap)
486
- bullet_set_count = diff / 10
487
-
488
- if bullet_set_count_cap < bullet_set_count
489
- bullet_set_count = bullet_set_count_cap
490
- end
491
-
492
- if (diff >= 1) && (diff < 30)
493
- bullet_set_count = 3 # 技能値が29以下での最低値保障処理
494
- end
495
-
496
- return bullet_set_count
497
- end
498
-
499
- def getHitBulletCountBase(diff, bullet_set_count)
500
- hit_bullet_count_base = (bullet_set_count / 2)
501
-
502
- if (diff >= 1) && (diff < 30)
503
- hit_bullet_count_base = 1 # 技能値29以下での最低値保障
504
- end
505
-
506
- return hit_bullet_count_base
507
- end
508
-
509
- def isLastBulletTurn(bullet_count, bullet_set_count)
510
- ((bullet_count - bullet_set_count) < 0)
511
- end
512
-
513
- def getLastHitBulletCount(bullet_count)
514
- # 残弾1での最低値保障処理
515
- if bullet_count == 1
516
- return 1
517
- end
518
-
519
- count = (bullet_count / 2.to_f).floor
520
- return count
521
- end
522
-
523
- def getFumbleable(more_difficulty)
524
- # 成功が49以下の出目のみとなるため、ファンブル値は上昇
525
- return (more_difficulty >= 1)
526
- end
527
-
528
234
  # 表一式
529
235
  # 即時の恐怖症表
530
236
  def roll_bmr_table()