bcdice 3.2.0 → 3.3.0

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 (48) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +27 -3
  3. data/README.md +1 -1
  4. data/i18n/MagicaLogia/zh_hans.yml +564 -0
  5. data/i18n/StellarKnights/ja_jp.yml +2 -0
  6. data/i18n/StellarKnights/ko_kr.yml +498 -0
  7. data/i18n/zh_hans.yml +7 -0
  8. data/lib/bcdice/command/parsed.rb +11 -3
  9. data/lib/bcdice/command/parser.rb +179 -100
  10. data/lib/bcdice/common_command/barabara_dice/node.rb +2 -2
  11. data/lib/bcdice/common_command/barabara_dice/result.rb +6 -0
  12. data/lib/bcdice/game_system.rb +3 -0
  13. data/lib/bcdice/game_system/Amadeus.rb +110 -93
  14. data/lib/bcdice/game_system/AnimaAnimus.rb +15 -8
  15. data/lib/bcdice/game_system/BattleTech.rb +109 -28
  16. data/lib/bcdice/game_system/BeastBindTrinity.rb +28 -12
  17. data/lib/bcdice/game_system/BlindMythos.rb +38 -37
  18. data/lib/bcdice/game_system/CodeLayerd.rb +39 -39
  19. data/lib/bcdice/game_system/ColossalHunter.rb +34 -47
  20. data/lib/bcdice/game_system/DeadlineHeroes.rb +9 -8
  21. data/lib/bcdice/game_system/DoubleCross.rb +2 -0
  22. data/lib/bcdice/game_system/Emoklore.rb +22 -17
  23. data/lib/bcdice/game_system/FutariSousa.rb +12 -10
  24. data/lib/bcdice/game_system/GardenOrder.rb +11 -6
  25. data/lib/bcdice/game_system/KemonoNoMori.rb +25 -38
  26. data/lib/bcdice/game_system/KurayamiCrying.rb +86 -0
  27. data/lib/bcdice/game_system/LiveraDoll.rb +254 -304
  28. data/lib/bcdice/game_system/LogHorizon.rb +10 -7
  29. data/lib/bcdice/game_system/MagicaLogia_SimplifiedChinese.rb +66 -0
  30. data/lib/bcdice/game_system/MeikyuKingdomBasic.rb +2 -1
  31. data/lib/bcdice/game_system/Nechronica.rb +57 -91
  32. data/lib/bcdice/game_system/NinjaSlayer.rb +2 -3
  33. data/lib/bcdice/game_system/SRS.rb +17 -16
  34. data/lib/bcdice/game_system/SamsaraBallad.rb +38 -11
  35. data/lib/bcdice/game_system/Satasupe.rb +31 -31
  36. data/lib/bcdice/game_system/ScreamHighSchool.rb +3 -3
  37. data/lib/bcdice/game_system/Skynauts.rb +101 -140
  38. data/lib/bcdice/game_system/StarryDolls.rb +318 -0
  39. data/lib/bcdice/game_system/SteamPunkers.rb +11 -6
  40. data/lib/bcdice/game_system/StellarKnights.rb +28 -12
  41. data/lib/bcdice/game_system/StellarKnights_Korean.rb +79 -0
  42. data/lib/bcdice/game_system/TokumeiTenkousei.rb +4 -3
  43. data/lib/bcdice/game_system/TrinitySeven.rb +275 -276
  44. data/lib/bcdice/game_system/Utakaze.rb +52 -47
  45. data/lib/bcdice/game_system/Yggdrasill.rb +1 -1
  46. data/lib/bcdice/game_system/ZettaiReido.rb +20 -25
  47. data/lib/bcdice/version.rb +1 -1
  48. metadata +8 -2
@@ -82,16 +82,34 @@ module BCDice
82
82
 
83
83
  dice_list_org_str = "[#{dice_list_org.join(',')}]" if dice_list_filtered != dice_list_org
84
84
 
85
+ result = result_compare(total)
86
+ result.critical = critical?
87
+ result.fumble = fumble?
88
+
89
+ dice_status =
90
+ if result.fumble?
91
+ "ファンブル"
92
+ elsif result.critical?
93
+ "クリティカル"
94
+ end
95
+ result_str =
96
+ if result.success?
97
+ "成功"
98
+ elsif result.failure?
99
+ "失敗"
100
+ end
101
+
85
102
  sequence = [
86
103
  command_expr(),
87
104
  dice_list_org_str,
88
105
  interim_expr(dice_list_filtered),
89
- dice_status(),
106
+ dice_status,
90
107
  total.to_s,
91
- result_compare(total)
108
+ result_str
92
109
  ].compact
110
+ result.text = sequence.join(" > ")
93
111
 
94
- return sequence.join(" > ")
112
+ return result
95
113
  end
96
114
 
97
115
  private
@@ -187,14 +205,6 @@ module BCDice
187
205
  return expr
188
206
  end
189
207
 
190
- def dice_status
191
- if fumble?
192
- "ファンブル"
193
- elsif critical?
194
- "クリティカル"
195
- end
196
- end
197
-
198
208
  def fumble?
199
209
  @dice_total <= @fumble
200
210
  end
@@ -220,7 +230,13 @@ module BCDice
220
230
 
221
231
  def result_compare(total)
222
232
  if @cmp_op
223
- total.send(@cmp_op, @target_number) ? "成功" : "失敗"
233
+ if total.send(@cmp_op, @target_number)
234
+ Result.success(nil)
235
+ else
236
+ Result.failure(nil)
237
+ end
238
+ else
239
+ Result.new
224
240
  end
225
241
  end
226
242
  end
@@ -22,7 +22,7 @@ module BCDice
22
22
   BMSは振り足しを自動では行いません。
23
23
  例)BM>=1 BM@3>=1 BMS2>=1
24
24
 
25
- ・判定振り足し:ReRollx,x,x...@y>=1
25
+ ・判定振り足し:ReRollx,x,x...@y>=z
26
26
   x:振るダイスの個数
27
27
    y:目標難易度(省略可。デフォルト4)
28
28
    z:必要成功度
@@ -40,15 +40,15 @@ module BCDice
40
40
  def eval_game_system_specific_command(command)
41
41
  debug("eval_game_system_specific_command Begin")
42
42
 
43
- text = judgeRoll(command)
44
- return text unless text.nil?
43
+ result = judgeRoll(command)
44
+ return result unless result.nil?
45
45
 
46
46
  isStop = true
47
47
  text, = reRoll(command, isStop)
48
48
  return text unless text.nil?
49
49
 
50
- text = getRulingPlanetDiceCommandResult(command)
51
- return text unless text.nil?
50
+ result = getRulingPlanetDiceCommandResult(command)
51
+ return result unless result.nil?
52
52
 
53
53
  text = getDurtyTableCommandReuslt(command)
54
54
  return text unless text.nil?
@@ -72,9 +72,10 @@ module BCDice
72
72
  getRollResult([diceCount], judgeNumberText, judgeNumber, targetNumber, isReRoll, isStop)
73
73
 
74
74
  message += text
75
- message += getTotalResultMessageText(bitList, successList, countOneList, targetNumber, isStop, canReRoll)
75
+ result = getTotalResult(bitList, successList, countOneList, targetNumber, isStop, canReRoll)
76
+ result.text = message + result.text
76
77
 
77
- return message
78
+ return result
78
79
  end
79
80
 
80
81
  def reRoll(command, isStop)
@@ -181,7 +182,7 @@ module BCDice
181
182
  return message, bitList, successList, countOneList, canReRoll
182
183
  end
183
184
 
184
- def getTotalResultMessageText(bitList, successList, countOneList, targetNumber, isStop, canReRoll)
185
+ def getTotalResult(bitList, successList, countOneList, targetNumber, isStop, canReRoll)
185
186
  success = successList.inject { |sum, i| sum + i }
186
187
  countOne = countOneList.inject { |sum, i| sum + i }
187
188
 
@@ -196,27 +197,35 @@ module BCDice
196
197
 
197
198
  if success >= targetNumber
198
199
  result += " > 現状で成功。コマンド実行で追加リロールも可能"
200
+ return Result.success(result)
199
201
  else
200
202
  result += " > 現状のままでは失敗"
201
- result += "。汚染ポイント+#{countOne}" if countOne >= 1
203
+ if countOne >= 1
204
+ result += "。汚染ポイント+#{countOne}"
205
+ return Result.fumble(result)
206
+ else
207
+ return Result.failure(result)
208
+ end
202
209
  end
203
-
204
- return result
205
210
  end
206
211
 
207
212
  if success >= targetNumber
208
213
  result += " > 成功"
209
-
210
214
  if bitList.size >= 1
211
215
  result += "、禁書ビット発生[#{bitList.join(',')}]"
216
+ return Result.critical(result)
217
+ else
218
+ return Result.success(result)
212
219
  end
213
-
214
220
  else
215
221
  result += " > 失敗"
216
- result += "。汚染ポイント+#{countOne}" if countOne >= 1
222
+ if countOne >= 1
223
+ result += "。汚染ポイント+#{countOne}"
224
+ return Result.fumble(result)
225
+ else
226
+ return Result.failure(result)
227
+ end
217
228
  end
218
-
219
- return result
220
229
  end
221
230
 
222
231
  def getSameDieList(diceList)
@@ -252,44 +261,36 @@ module BCDice
252
261
  end
253
262
 
254
263
  def getRulingPlanetDiceCommandResult(command)
255
- return nil unless command =~ /^RP(\d+)/i
264
+ m = /^RP(\d+)$/i.match(command)
265
+ return nil unless m
256
266
 
257
- targetNumbers = Regexp.last_match(1).split(//).map(&:to_i)
267
+ targetNumbers = m[1].each_char.map(&:to_i)
258
268
  diceList = getRulingPlanetDice
259
269
 
260
- matchResult = "失敗"
261
- targetNumbers.each do |i|
262
- if diceList.include?(i)
263
- matchResult = "発動"
264
- break
265
- end
266
- end
270
+ condition = diceList.any? { |dice| targetNumbers.include?(dice) }
267
271
 
268
- text = "守護星表チェック(#{targetNumbers.join(',')}) #{diceList.count}D10[#{diceList.join(',')}] #{matchResult}"
272
+ result = condition ? "発動" : "失敗"
273
+ text = "守護星表チェック(#{targetNumbers.join(',')}) > #{diceList.count}D10[#{diceList.join(',')}] > #{result}"
269
274
 
270
- return text
275
+ Result.new.tap do |r|
276
+ r.text = text
277
+ r.condition = condition
278
+ end
271
279
  end
272
280
 
273
281
  def getRulingPlanetDice
274
- dice1 = @randomizer.roll_once(10)
275
- dice2 = dice1
282
+ dice1, dice2 = @randomizer.roll_barabara(2, 10)
276
283
 
277
284
  while dice1 == dice2
278
285
  dice2 = @randomizer.roll_once(10)
279
286
  end
280
287
 
281
- dice1 = changeRulingPlanetDice(dice1)
282
- dice2 = changeRulingPlanetDice(dice2)
288
+ dice1 = 0 if dice1 == 10
289
+ dice2 = 0 if dice2 == 10
283
290
 
284
291
  return dice1, dice2
285
292
  end
286
293
 
287
- def changeRulingPlanetDice(dice)
288
- return 0 if dice == 10
289
-
290
- return dice
291
- end
292
-
293
294
  def getDurtyTableCommandReuslt(command)
294
295
  return nil unless /^DT$/i =~ command
295
296
 
@@ -30,7 +30,7 @@ module BCDice
30
30
  デフォルトダイス:10面
31
31
  MESSAGETEXT
32
32
 
33
- register_prefix('[+-]?\d*CL([+-]\d+)?[@\d]*')
33
+ register_prefix('[+-]?\d*CL')
34
34
 
35
35
  def initialize(command)
36
36
  super(command)
@@ -41,61 +41,61 @@ module BCDice
41
41
  def eval_game_system_specific_command(command)
42
42
  debug('eval_game_system_specific_command command', command)
43
43
 
44
- result = ''
45
-
46
- case command
47
- when /([+-]?\d+)?CL([+-]\d+)?(@(\d))?(\[(\d+)\])?([+-]\d+)?(>=(\d+))?/i
48
- m = Regexp.last_match
49
- base = (m[1] || 1).to_i
50
- modifier1 = m[2].to_i
51
- target = (m[4] || 6).to_i
52
- critical_target = (m[6] || 1).to_i
53
- modifier2 = m[7].to_i
54
- diff = m[9].to_i
55
- result = check_roll(base, target, critical_target, diff, modifier1 + modifier2)
56
- end
57
-
58
- return nil if result.empty?
44
+ m = /([+-]?\d+)?CL([+-]\d+)?(@(\d))?(\[(\d+)\])?([+-]\d+)?(>=(\d+))?/i.match(command)
45
+ return nil unless m
59
46
 
60
- return "#{command} #{result}"
47
+ base = (m[1] || 1).to_i
48
+ modifier1 = m[2].to_i
49
+ target = (m[4] || 6).to_i
50
+ critical_target = (m[6] || 1).to_i
51
+ modifier2 = m[7].to_i
52
+ diff = m[9].to_i if m[9]
53
+ check_roll(command, base, target, critical_target, diff, modifier1 + modifier2)
61
54
  end
62
55
 
63
- def check_roll(base, target, critical_target, diff, modifier)
56
+ def check_roll(command, base, target, critical_target, diff, modifier)
64
57
  if base <= 0 # クリティカルしない1D
65
58
  critical_target = 0
66
59
  base = 1
67
60
  end
61
+ result = Result.new
68
62
 
69
63
  target = 10 if target > 10
70
64
  dice_list = @randomizer.roll_barabara(base, 10).sort
71
65
  success_count = dice_list.count { |x| x <= target }
72
66
  critical_count = dice_list.count { |x| x <= critical_target }
67
+ result.critical = critical_count > 0
73
68
  success_total = success_count + critical_count + modifier
74
69
 
75
70
  mod_text = Format.modifier(modifier)
76
71
 
77
72
  # (10d10+5)
78
- result = "(#{base}d10#{mod_text}) > [#{dice_list.join(',')}]#{mod_text} > "
79
- result += "判定値[#{target}] " unless target == 6
80
- result += "クリティカル値[#{critical_target}] " unless critical_target == 1
81
- result += "達成値[#{success_count}]"
82
-
83
- return "#{result} > ファンブル!" if success_count <= 0
84
-
85
- result += "+クリティカル[#{critical_count}]" if critical_count > 0
86
- result += mod_text
87
- result += "=[#{success_total}]" if critical_count > 0 || modifier != 0
88
-
89
- success_text =
90
- if diff == 0
91
- success_total.to_s
92
- elsif success_total >= diff
93
- "成功"
94
- else
95
- "失敗"
96
- end
97
-
98
- return "#{result} #{success_text}"
73
+ text = "#{command} > (#{base}d10#{mod_text}) > [#{dice_list.join(',')}]#{mod_text} > "
74
+ text += "判定値[#{target}] " unless target == 6
75
+ text += "クリティカル値[#{critical_target}] " unless critical_target == 1
76
+ text += "達成値[#{success_count}]"
77
+
78
+ if success_count <= 0
79
+ result.fumble = true
80
+ result.failure = true
81
+ result.text = "#{text} > ファンブル!"
82
+ return result
83
+ end
84
+
85
+ text += "+クリティカル[#{critical_count}]" if result.critical?
86
+ text += mod_text
87
+ text += "=[#{success_total}]" if result.critical? || modifier != 0
88
+
89
+ if diff.nil?
90
+ result.text = "#{text} > #{success_total}"
91
+ elsif success_total >= diff
92
+ result.text = "#{text} > 成功"
93
+ result.success = true
94
+ else
95
+ result.text = "#{text} > 失敗"
96
+ result.failure = true
97
+ end
98
+ return result
99
99
  end
100
100
  end
101
101
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "bcdice/format"
4
+
3
5
  module BCDice
4
6
  module GameSystem
5
7
  class ColossalHunter < Base
@@ -14,10 +16,12 @@ module BCDice
14
16
 
15
17
  # ダイスボットの使い方
16
18
  HELP_MESSAGE = <<~MESSAGETEXT
17
- ・判定(CH±x>=y)
18
-  3D6の判定。クリティカル、ファンブルの自動判定を行います。
19
-  x:修正値。省略可能。y:目標値。省略可能。
20
-  例) CH CH+1 CH+2>=10
19
+ ・判定(nCH±x>=y)
20
+  nD6の判定。クリティカル、ファンブルの自動判定を行います。
21
+  n:ダイス数。省略可能。省略した場合3。
22
+  x:修正値。省略可能。
23
+  y:目標値。省略可能。
24
+  例) CH CH+1 CH+2>=10 4CH+1
21
25
  ・BIG-6表(B6T)
22
26
  ・覚醒表(AWT)
23
27
  ・現状表(CST)
@@ -45,65 +49,48 @@ module BCDice
45
49
  def getCheckRollDiceCommandResult(command)
46
50
  debug("getCheckRollDiceCommandResult command", command)
47
51
 
48
- return nil unless command =~ /(\d+)?CH([+\-\d]*)(>=([+\-\d]*))?$/i
52
+ parser = Command::Parser.new(/\d*CH/, round_type: round_type)
53
+ .restrict_cmp_op_to(nil, :>=)
49
54
 
50
- diceCount = (Regexp.last_match(1) || 3).to_i
51
- modifyText = (Regexp.last_match(2) || '')
52
- difficultyText = Regexp.last_match(4)
55
+ parsed = parser.parse(command)
56
+ unless parsed
57
+ return nil
58
+ end
53
59
 
54
- # 修正値の計算
55
- modify = getValue(modifyText, 0)
60
+ parsed.command = "3CH" unless parsed.command.start_with?(/\d/)
56
61
 
57
- # 目標値の計算
58
- difficulty = getValue(difficultyText, nil)
62
+ dice_count = parsed.command.to_i
63
+ modify = parsed.modify_number
59
64
 
60
65
  # ダイスロール
61
- dice_list = @randomizer.roll_barabara(diceCount, 6)
66
+ dice_list = @randomizer.roll_barabara(dice_count, 6)
62
67
  dice = dice_list.sum()
63
68
  dice_str = dice_list.join(",")
64
69
 
65
70
  total = dice + modify
66
71
 
67
- # 出力用ダイスコマンドを生成
68
- command = "#{diceCount}CH#{modifyText}"
69
- command += ">=#{difficulty}" unless difficulty.nil?
70
-
71
72
  # 出力文の生成
72
- result = "(#{command}) > #{dice}[#{dice_str}]#{modifyText} > #{total}"
73
+ text = "(#{parsed}) > #{dice}[#{dice_str}]#{Format.modifier(modify)} > #{total}"
73
74
 
74
- # クリティカル・ファンブルチェック
75
- if isFamble(dice)
76
- result += " > ファンブル"
77
- elsif isCritical(total)
78
- result += " > クリティカル"
79
- else
80
- result += getJudgeResultString(difficulty, total)
81
- end
75
+ result = get_judge_result(dice, total, parsed)
82
76
 
77
+ result.text = text + result.text
83
78
  return result
84
79
  end
85
80
 
86
81
  # 成否判定
87
- def getJudgeResultString(difficulty, total)
88
- return '' if difficulty.nil?
89
-
90
- return " > 成功" if total >= difficulty
91
-
92
- return " > 失敗"
93
- end
94
-
95
- def getValue(text, defaultValue)
96
- return defaultValue if text.nil? || text.empty?
97
-
98
- ArithmeticEvaluator.eval(text)
99
- end
100
-
101
- def isCritical(total)
102
- (total >= 16)
103
- end
104
-
105
- def isFamble(total)
106
- (total <= 5)
82
+ def get_judge_result(dice, total, parsed)
83
+ if dice <= 5
84
+ Result.fumble(" > ファンブル")
85
+ elsif total >= 16
86
+ Result.critical(" > クリティカル")
87
+ elsif parsed.cmp_op.nil?
88
+ Result.new("")
89
+ elsif total >= parsed.target_number
90
+ Result.success(" > 成功")
91
+ else
92
+ Result.failure(" > 失敗")
93
+ end
107
94
  end
108
95
 
109
96
  def getSourceSceneDiceCommandResult(command)
@@ -562,7 +549,7 @@ module BCDice
562
549
 
563
550
  }.freeze
564
551
 
565
- register_prefix("CH.*", "B6T", "CNP", TABLES.keys)
552
+ register_prefix('\d*CH', "B6T", "CNP", TABLES.keys)
566
553
  end
567
554
  end
568
555
  end