bcdice 3.1.0 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +78 -1
  3. data/README.md +1 -1
  4. data/i18n/MagicaLogia/zh_hans.yml +564 -0
  5. data/i18n/StellarKnights/ja_jp.yml +498 -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/add_dice.rb +1 -1
  11. data/lib/bcdice/common_command/barabara_dice/node.rb +2 -2
  12. data/lib/bcdice/common_command/barabara_dice/result.rb +6 -0
  13. data/lib/bcdice/common_command/calc.rb +1 -1
  14. data/lib/bcdice/dice_table.rb +2 -0
  15. data/lib/bcdice/dice_table/d66_half_grid_table.rb +33 -0
  16. data/lib/bcdice/dice_table/d66_one_third_table.rb +34 -0
  17. data/lib/bcdice/dice_table/sai_fic_skill_table.rb +1 -1
  18. data/lib/bcdice/game_system.rb +6 -0
  19. data/lib/bcdice/game_system/AceKillerGene.rb +1 -1
  20. data/lib/bcdice/game_system/Ainecadette.rb +68 -0
  21. data/lib/bcdice/game_system/Airgetlamh.rb +1 -1
  22. data/lib/bcdice/game_system/Alsetto.rb +1 -1
  23. data/lib/bcdice/game_system/AlterRaise.rb +2 -2
  24. data/lib/bcdice/game_system/Amadeus.rb +110 -93
  25. data/lib/bcdice/game_system/AngelGear.rb +2 -2
  26. data/lib/bcdice/game_system/AnimaAnimus.rb +16 -9
  27. data/lib/bcdice/game_system/Arianrhod.rb +6 -8
  28. data/lib/bcdice/game_system/Avandner.rb +1 -1
  29. data/lib/bcdice/game_system/BarnaKronika.rb +1 -1
  30. data/lib/bcdice/game_system/BattleTech.rb +109 -28
  31. data/lib/bcdice/game_system/BeastBindTrinity.rb +28 -12
  32. data/lib/bcdice/game_system/BeginningIdol.rb +5 -5
  33. data/lib/bcdice/game_system/BeginningIdol_Korean.rb +5 -5
  34. data/lib/bcdice/game_system/BladeOfArcana.rb +1 -1
  35. data/lib/bcdice/game_system/BlindMythos.rb +39 -38
  36. data/lib/bcdice/game_system/BloodCrusade.rb +6 -7
  37. data/lib/bcdice/game_system/BloodMoon.rb +9 -8
  38. data/lib/bcdice/game_system/CardRanker.rb +8 -7
  39. data/lib/bcdice/game_system/ChaosFlare.rb +21 -15
  40. data/lib/bcdice/game_system/Chill.rb +10 -10
  41. data/lib/bcdice/game_system/Chill3.rb +9 -9
  42. data/lib/bcdice/game_system/CodeLayerd.rb +39 -39
  43. data/lib/bcdice/game_system/ColossalHunter.rb +34 -47
  44. data/lib/bcdice/game_system/CrashWorld.rb +1 -1
  45. data/lib/bcdice/game_system/Cthulhu.rb +1 -1
  46. data/lib/bcdice/game_system/Cthulhu7th.rb +48 -10
  47. data/lib/bcdice/game_system/Cthulhu7th_ChineseTraditional.rb +2 -2
  48. data/lib/bcdice/game_system/Cthulhu7th_Korean.rb +2 -2
  49. data/lib/bcdice/game_system/Cthulhu_ChineseTraditional.rb +1 -1
  50. data/lib/bcdice/game_system/Cthulhu_Korean.rb +1 -1
  51. data/lib/bcdice/game_system/DarkBlaze.rb +0 -11
  52. data/lib/bcdice/game_system/DarkDaysDrive.rb +8 -7
  53. data/lib/bcdice/game_system/DeadlineHeroes.rb +11 -10
  54. data/lib/bcdice/game_system/DemonParasite.rb +5 -13
  55. data/lib/bcdice/game_system/DesperateRun.rb +1 -1
  56. data/lib/bcdice/game_system/DoubleCross.rb +3 -1
  57. data/lib/bcdice/game_system/Dracurouge.rb +1 -1
  58. data/lib/bcdice/game_system/EclipsePhase.rb +14 -14
  59. data/lib/bcdice/game_system/Elric.rb +18 -14
  60. data/lib/bcdice/game_system/Elysion.rb +1 -1
  61. data/lib/bcdice/game_system/EmbryoMachine.rb +9 -8
  62. data/lib/bcdice/game_system/Emoklore.rb +25 -20
  63. data/lib/bcdice/game_system/Fiasco.rb +1 -1
  64. data/lib/bcdice/game_system/FilledWith.rb +205 -1272
  65. data/lib/bcdice/game_system/FutariSousa.rb +12 -10
  66. data/lib/bcdice/game_system/GURPS.rb +17 -28
  67. data/lib/bcdice/game_system/Garako.rb +1 -1
  68. data/lib/bcdice/game_system/GardenOrder.rb +12 -7
  69. data/lib/bcdice/game_system/GeishaGirlwithKatana.rb +1 -1
  70. data/lib/bcdice/game_system/GoblinSlayer.rb +1 -1
  71. data/lib/bcdice/game_system/Gorilla.rb +2 -8
  72. data/lib/bcdice/game_system/GranCrest.rb +18 -11
  73. data/lib/bcdice/game_system/Gundog.rb +9 -8
  74. data/lib/bcdice/game_system/GundogRevised.rb +10 -9
  75. data/lib/bcdice/game_system/GundogZero.rb +1 -1
  76. data/lib/bcdice/game_system/GurpsFW.rb +16 -16
  77. data/lib/bcdice/game_system/HarnMaster.rb +19 -26
  78. data/lib/bcdice/game_system/HatsuneMiku.rb +1 -1
  79. data/lib/bcdice/game_system/Hieizan.rb +12 -21
  80. data/lib/bcdice/game_system/HouraiGakuen.rb +1 -1
  81. data/lib/bcdice/game_system/HuntersMoon.rb +5 -10
  82. data/lib/bcdice/game_system/InfiniteFantasia.rb +19 -17
  83. data/lib/bcdice/game_system/Insane.rb +13 -20
  84. data/lib/bcdice/game_system/IthaWenUa.rb +8 -15
  85. data/lib/bcdice/game_system/JamesBond.rb +10 -10
  86. data/lib/bcdice/game_system/JekyllAndHyde.rb +1 -1
  87. data/lib/bcdice/game_system/Kamigakari.rb +1 -1
  88. data/lib/bcdice/game_system/KanColle.rb +4 -9
  89. data/lib/bcdice/game_system/KemonoNoMori.rb +26 -39
  90. data/lib/bcdice/game_system/KillDeathBusiness.rb +7 -15
  91. data/lib/bcdice/game_system/KurayamiCrying.rb +141 -2
  92. data/lib/bcdice/game_system/LiveraDoll.rb +254 -304
  93. data/lib/bcdice/game_system/LogHorizon.rb +13 -10
  94. data/lib/bcdice/game_system/MagicaLogia_SimplifiedChinese.rb +66 -0
  95. data/lib/bcdice/game_system/MeikyuDays.rb +10 -8
  96. data/lib/bcdice/game_system/MeikyuKingdom.rb +26 -26
  97. data/lib/bcdice/game_system/MeikyuKingdomBasic.rb +5 -4
  98. data/lib/bcdice/game_system/MetalHead.rb +12 -22
  99. data/lib/bcdice/game_system/MetalHeadExtream.rb +5 -5
  100. data/lib/bcdice/game_system/MonotoneMuseum.rb +8 -6
  101. data/lib/bcdice/game_system/Nechronica.rb +63 -90
  102. data/lib/bcdice/game_system/NinjaSlayer.rb +6 -7
  103. data/lib/bcdice/game_system/NjslyrBattle.rb +8 -11
  104. data/lib/bcdice/game_system/OneWayHeroics.rb +1 -1
  105. data/lib/bcdice/game_system/Paradiso.rb +3 -3
  106. data/lib/bcdice/game_system/ParasiteBlood.rb +1 -1
  107. data/lib/bcdice/game_system/Peekaboo.rb +4 -9
  108. data/lib/bcdice/game_system/Pendragon.rb +7 -7
  109. data/lib/bcdice/game_system/PhantasmAdventure.rb +8 -8
  110. data/lib/bcdice/game_system/Postman.rb +1 -1
  111. data/lib/bcdice/game_system/PulpCthulhu.rb +1 -1
  112. data/lib/bcdice/game_system/Raisondetre.rb +2 -2
  113. data/lib/bcdice/game_system/Revulture.rb +123 -0
  114. data/lib/bcdice/game_system/RuneQuest.rb +8 -8
  115. data/lib/bcdice/game_system/Ryutama.rb +1 -1
  116. data/lib/bcdice/game_system/SRS.rb +17 -16
  117. data/lib/bcdice/game_system/SamsaraBallad.rb +38 -11
  118. data/lib/bcdice/game_system/Satasupe.rb +32 -32
  119. data/lib/bcdice/game_system/ScreamHighSchool.rb +5 -5
  120. data/lib/bcdice/game_system/SharedFantasia.rb +19 -23
  121. data/lib/bcdice/game_system/ShinobiGami.rb +14 -6
  122. data/lib/bcdice/game_system/Skynauts.rb +103 -142
  123. data/lib/bcdice/game_system/SkynautsBouken.rb +228 -0
  124. data/lib/bcdice/game_system/StarryDolls.rb +318 -0
  125. data/lib/bcdice/game_system/SteamPunkers.rb +11 -6
  126. data/lib/bcdice/game_system/StellarKnights.rb +85 -706
  127. data/lib/bcdice/game_system/StellarKnights_Korean.rb +79 -0
  128. data/lib/bcdice/game_system/SterileLife.rb +2 -3
  129. data/lib/bcdice/game_system/StrangerOfSwordCity.rb +1 -1
  130. data/lib/bcdice/game_system/StratoShout.rb +8 -16
  131. data/lib/bcdice/game_system/Strave.rb +1 -1
  132. data/lib/bcdice/game_system/SwordWorld.rb +16 -7
  133. data/lib/bcdice/game_system/SwordWorld2_0.rb +2 -2
  134. data/lib/bcdice/game_system/SwordWorld2_5.rb +2 -2
  135. data/lib/bcdice/game_system/TherapieSein.rb +1 -1
  136. data/lib/bcdice/game_system/TokumeiTenkousei.rb +4 -3
  137. data/lib/bcdice/game_system/TokyoGhostResearch.rb +1 -1
  138. data/lib/bcdice/game_system/TrinitySeven.rb +279 -280
  139. data/lib/bcdice/game_system/TunnelsAndTrolls.rb +1 -1
  140. data/lib/bcdice/game_system/Utakaze.rb +53 -48
  141. data/lib/bcdice/game_system/Villaciel.rb +1 -1
  142. data/lib/bcdice/game_system/WARPS.rb +11 -9
  143. data/lib/bcdice/game_system/WaresBlade.rb +4 -9
  144. data/lib/bcdice/game_system/Warhammer.rb +15 -6
  145. data/lib/bcdice/game_system/Warhammer4.rb +15 -11
  146. data/lib/bcdice/game_system/WitchQuest.rb +1 -1
  147. data/lib/bcdice/game_system/YankeeYogSothoth.rb +4 -9
  148. data/lib/bcdice/game_system/Yggdrasill.rb +1 -1
  149. data/lib/bcdice/game_system/ZettaiReido.rb +20 -25
  150. data/lib/bcdice/game_system/filled_with/enemy_data_tables.rb +322 -0
  151. data/lib/bcdice/game_system/filled_with/event_tables.rb +392 -0
  152. data/lib/bcdice/game_system/filled_with/tresure_tables.rb +179 -0
  153. data/lib/bcdice/game_system/meikyu_kingdom_basic/kingdom_table.rb +1 -1
  154. data/lib/bcdice/game_system/sword_world/rating_parsed.rb +4 -4
  155. data/lib/bcdice/game_system/sword_world/rating_parser.rb +1 -1
  156. data/lib/bcdice/game_system/sword_world/transcendent_test.rb +26 -8
  157. data/lib/bcdice/repl.rb +1 -1
  158. data/lib/bcdice/result.rb +26 -0
  159. data/lib/bcdice/version.rb +1 -1
  160. metadata +18 -4
@@ -7,7 +7,7 @@ require "bcdice/common_command/add_dice/randomizer"
7
7
  module BCDice
8
8
  module CommonCommand
9
9
  module AddDice
10
- PREFIX_PATTERN = /[+\-\dD(\[]+/.freeze
10
+ PREFIX_PATTERN = /[+\-(]*\d+/.freeze
11
11
 
12
12
  class << self
13
13
  def eval(command, game_system, randomizer)
@@ -43,8 +43,8 @@ module BCDice
43
43
  Result.new.tap do |r|
44
44
  r.secret = @secret
45
45
  r.text = sequence.join(" > ")
46
- r.rands = randomizer.rand_results
47
- r.detailed_rands = randomizer.detailed_rand_results
46
+ r.last_dice_list_list = dice_list_list
47
+ r.last_dice_list = dice_list
48
48
  r.success_num = success_num
49
49
  end
50
50
  end
@@ -7,6 +7,10 @@ module BCDice
7
7
  module BarabaraDice
8
8
  # バラバラロールの結果を表すクラス
9
9
  class Result < ::BCDice::Result
10
+ # @return [Array<Array<Integer>>] 出目のグループの配列
11
+ attr_accessor :last_dice_list_list
12
+ # @return [Array<Integer>] すべての出目が格納される配列
13
+ attr_accessor :last_dice_list
10
14
  # @return [Integer] 成功数
11
15
  attr_accessor :success_num
12
16
 
@@ -14,6 +18,8 @@ module BCDice
14
18
  def initialize(text = nil)
15
19
  super(text)
16
20
 
21
+ @last_dice_list_list = []
22
+ @last_dice_list = []
17
23
  @success_num = 0
18
24
  end
19
25
  end
@@ -5,7 +5,7 @@ require "bcdice/common_command/calc/parser"
5
5
  module BCDice
6
6
  module CommonCommand
7
7
  module Calc
8
- PREFIX_PATTERN = /C/.freeze
8
+ PREFIX_PATTERN = /C[+\-(]*\d+/.freeze
9
9
 
10
10
  class << self
11
11
  def eval(command, game_system, _randomizer)
@@ -3,6 +3,8 @@
3
3
  require "bcdice/dice_table/roll_result"
4
4
  require "bcdice/dice_table/chain_table"
5
5
  require "bcdice/dice_table/d66_grid_table"
6
+ require "bcdice/dice_table/d66_half_grid_table"
7
+ require "bcdice/dice_table/d66_one_third_table"
6
8
  require "bcdice/dice_table/d66_parity_table"
7
9
  require "bcdice/dice_table/d66_range_table"
8
10
  require "bcdice/dice_table/d66_table"
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bcdice/dice_table/d66_grid_table"
4
+
5
+ module BCDice
6
+ module DiceTable
7
+ # D66を振って6x6マスの表を参照する
8
+ class D66HalfGridTable < D66GridTable
9
+ # @param key [String]
10
+ # @param locale [Symbol]
11
+ # @return [D66HalfGridTable]
12
+ def self.from_i18n(key, locale)
13
+ table = I18n.t(key, locale: locale, raise: true)
14
+ new(table[:name], table[:items_1_2_3], table[:items_4_5_6])
15
+ end
16
+
17
+ # @param [String] name 表の名前
18
+ # @param [Array<String>] items_1_2_3
19
+ # @param [Array<String>] items_4_5_6
20
+ def initialize(name, items_1_2_3, items_4_5_6)
21
+ @name = name
22
+ @items = [
23
+ items_1_2_3,
24
+ items_1_2_3,
25
+ items_1_2_3,
26
+ items_4_5_6,
27
+ items_4_5_6,
28
+ items_4_5_6,
29
+ ].freeze
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bcdice/dice_table/d66_grid_table"
4
+
5
+ module BCDice
6
+ module DiceTable
7
+ # D66を振って6x6マスの表を参照する
8
+ class D66OneThirdTable < D66GridTable
9
+ # @param key [String]
10
+ # @param locale [Symbol]
11
+ # @return [D66OneThirdTable]
12
+ def self.from_i18n(key, locale)
13
+ table = I18n.t(key, locale: locale, raise: true)
14
+ new(table[:name], table[:items_1_2], table[:items_3_4], table[:items_5_6])
15
+ end
16
+
17
+ # @param [String] name 表の名前
18
+ # @param [Array<String>] items_1_2
19
+ # @param [Array<String>] items_3_4
20
+ # @param [Array<String>] items_5_6
21
+ def initialize(name, items_1_2, items_3_4, items_5_6)
22
+ @name = name
23
+ @items = [
24
+ items_1_2,
25
+ items_1_2,
26
+ items_3_4,
27
+ items_3_4,
28
+ items_5_6,
29
+ items_5_6,
30
+ ].freeze
31
+ end
32
+ end
33
+ end
34
+ end
@@ -77,7 +77,7 @@ module BCDice
77
77
  end
78
78
 
79
79
  def prefixes
80
- ([/RTT[1-6]?/i, "RCT", @rtt, @rct] + @rttn).compact
80
+ (["RTT[1-6]?", "RCT", @rtt, @rct] + @rttn).compact
81
81
  end
82
82
 
83
83
  private
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "bcdice/game_system/AFF2e"
4
4
  require "bcdice/game_system/AceKillerGene"
5
+ require "bcdice/game_system/Ainecadette"
5
6
  require "bcdice/game_system/Airgetlamh"
6
7
  require "bcdice/game_system/AlchemiaStruggle"
7
8
  require "bcdice/game_system/Alsetto"
@@ -112,6 +113,7 @@ require "bcdice/game_system/LostRecord"
112
113
  require "bcdice/game_system/LostRoyal"
113
114
  require "bcdice/game_system/MagicaLogia"
114
115
  require "bcdice/game_system/MagicaLogia_Korean"
116
+ require "bcdice/game_system/MagicaLogia_SimplifiedChinese"
115
117
  require "bcdice/game_system/MeikyuDays"
116
118
  require "bcdice/game_system/MeikyuKingdom"
117
119
  require "bcdice/game_system/MeikyuKingdomBasic"
@@ -147,6 +149,7 @@ require "bcdice/game_system/PulpCthulhu"
147
149
  require "bcdice/game_system/Raisondetre"
148
150
  require "bcdice/game_system/RecordOfLodossWar"
149
151
  require "bcdice/game_system/RecordOfSteam"
152
+ require "bcdice/game_system/Revulture"
150
153
  require "bcdice/game_system/RokumonSekai2"
151
154
  require "bcdice/game_system/RoleMaster"
152
155
  require "bcdice/game_system/RuinBreakers"
@@ -167,8 +170,11 @@ require "bcdice/game_system/ShinkuuGakuen"
167
170
  require "bcdice/game_system/ShinobiGami"
168
171
  require "bcdice/game_system/ShoujoTenrankai"
169
172
  require "bcdice/game_system/Skynauts"
173
+ require "bcdice/game_system/SkynautsBouken"
174
+ require "bcdice/game_system/StarryDolls"
170
175
  require "bcdice/game_system/SteamPunkers"
171
176
  require "bcdice/game_system/StellarKnights"
177
+ require "bcdice/game_system/StellarKnights_Korean"
172
178
  require "bcdice/game_system/SterileLife"
173
179
  require "bcdice/game_system/StrangerOfSwordCity"
174
180
  require "bcdice/game_system/StratoShout"
@@ -28,7 +28,7 @@ module BCDice
28
28
  INFO_MESSAGE_TEXT
29
29
 
30
30
  register_prefix(
31
- '(AK|AKG)(\-?\d+)(\/\d+)?(@\d+)?',
31
+ '(AK|AKG)',
32
32
  'DC(SL|BL|IM|BR|RF|EL).+'
33
33
  )
34
34
 
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BCDice
4
+ module GameSystem
5
+ class Ainecadette < Base
6
+ # ゲームシステムの識別子
7
+ ID = "Ainecadette"
8
+
9
+ # ゲームシステム名
10
+ NAME = "エネカデット"
11
+
12
+ # ゲームシステム名の読みがな
13
+ SORT_KEY = "えねかてつと"
14
+
15
+ # ダイスボットの使い方
16
+ HELP_MESSAGE = <<~MESSAGETEXT
17
+ ■ 判定
18
+ - 先輩 (AI) 10面ダイスを2つ振って判定します。『有利』なら【3AI】、『不利』なら【1AI】を使います。
19
+ - 後輩 (CA) 6面ダイスを2つ振って判定します。『有利』なら【3CA】、『不利』なら【1CA】を使います。
20
+ MESSAGETEXT
21
+
22
+ register_prefix('(\d+)?AI', '(\d+)?CA')
23
+
24
+ def eval_game_system_specific_command(command)
25
+ roll_action(command)
26
+ end
27
+
28
+ private
29
+
30
+ # 成功の目標値
31
+ SUCCESS_THRESHOLD = 4
32
+
33
+ # スペシャルとなる出目
34
+ SPECIAL_DICE = 6
35
+
36
+ def roll_action(command)
37
+ m = /^(\d+)?(AI|CA)$/.match(command)
38
+ return nil unless m
39
+
40
+ is_senpai = m[2] == "AI"
41
+
42
+ times = m[1]&.to_i || 2
43
+ sides = is_senpai ? 10 : 6
44
+ return nil if times <= 0
45
+
46
+ dice_list = @randomizer.roll_barabara(times, sides)
47
+ max = dice_list.max
48
+
49
+ result =
50
+ if max <= 1
51
+ Result.fumble("ファンブル(もやもやカウンターを2個獲得)")
52
+ elsif dice_list.include?(6)
53
+ me = is_senpai ? "先輩" : "後輩"
54
+ target = is_senpai ? "後輩" : "先輩"
55
+ Result.critical("スペシャル(絆カウンターを1個獲得し、#{target}は#{me}への感情を1つ獲得)")
56
+ elsif max >= SUCCESS_THRESHOLD
57
+ Result.success("成功")
58
+ else
59
+ Result.failure("失敗")
60
+ end
61
+
62
+ result.text = "(#{command}) > [#{dice_list.join(',')}] > #{result.text}"
63
+
64
+ return result
65
+ end
66
+ end
67
+ end
68
+ end
@@ -42,7 +42,7 @@ module BCDice
42
42
  MESSAGETEXT
43
43
 
44
44
  register_prefix(
45
- '(\d+)?A(A|L)(\d+)?((x|\*)(\d+)(\+(\d+))?)?(C(\d+))?'
45
+ '\d*A[AL]'
46
46
  )
47
47
 
48
48
  def initialize(command)
@@ -37,7 +37,7 @@ module BCDice
37
37
  ・8ALC4x5 → 8d6で目標値4、攻撃力5、トライアンフ無しの命中判定。
38
38
  MESSAGETEXT
39
39
 
40
- register_prefix('\d+AL(C|G)?(\d+)?(x|\*)\d+', '\d+ALC?(\d+)?')
40
+ register_prefix('\d+AL[CG]?')
41
41
 
42
42
  def initialize(command)
43
43
  super(command)
@@ -35,8 +35,8 @@ module BCDice
35
35
  MESSAGETEXT
36
36
 
37
37
  register_prefix(
38
- 'EMA(\d+)?', 'PER(\d+)?', 'LOC(\d+)?', 'QUI(\d+)?', 'DEL(\d+)?',
39
- 'TRA(\d+)?', 'SCE(\d+)?', 'STA(\d+)?', 'EMO(\d+)?'
38
+ 'EMA', 'PER', 'LOC', 'QUI', 'DEL',
39
+ 'TRA', 'SCE', 'STA', 'EMO'
40
40
  )
41
41
 
42
42
  def eval_game_system_specific_command(command)
@@ -1,5 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "bcdice/arithmetic_evaluator"
4
+ require "bcdice/format"
5
+ require "bcdice/normalize"
6
+
3
7
  module BCDice
4
8
  module GameSystem
5
9
  class Amadeus < Base
@@ -46,111 +50,124 @@ module BCDice
46
50
  end
47
51
 
48
52
  def eval_game_system_specific_command(command)
49
- text = amadeusDice(command)
50
- return text unless text.nil?
51
-
52
- return roll_tables(command, self.class::TABLES)
53
+ roll_amadeus(command) ||
54
+ roll_tables(command, self.class::TABLES)
53
55
  end
54
56
 
55
- def amadeusDice(command)
56
- return nil unless /^(R([A-DS])([+\-\d]*))(@(\d))?((>(=)?)([+\-\d]*))?(@(\d))?$/i =~ command
57
-
58
- commandText = Regexp.last_match(1)
59
- skillRank = Regexp.last_match(2)
60
- modifyText = Regexp.last_match(3)
61
- signOfInequality = (Regexp.last_match(7).nil? ? ">=" : Regexp.last_match(7))
62
- targetText = (Regexp.last_match(9).nil? ? "4" : Regexp.last_match(9))
63
- if nil | Regexp.last_match(5)
64
- specialNum = Regexp.last_match(5).to_i
65
- elsif nil | Regexp.last_match(11)
66
- specialNum = Regexp.last_match(11).to_i
67
- else
68
- specialNum = 6
57
+ private
58
+
59
+ def roll_amadeus(command)
60
+ m = /^R([A-DS])([+\-\d]*)(@(\d))?((>=?)([+\-\d]*))?(@(\d))?$/i.match(command)
61
+ unless m
62
+ return nil
69
63
  end
70
64
 
71
- diceCount = CHECK_DICE_COUNT[skillRank]
72
- modify = ArithmeticEvaluator.eval(modifyText)
73
- target = ArithmeticEvaluator.eval(targetText)
74
-
75
- diceList = @randomizer.roll_barabara(diceCount, 6)
76
- diceText = diceList.join(",")
77
- specialText = (specialNum == 6 ? "" : "@#{specialNum}")
78
-
79
- message = "(#{commandText}#{specialText}#{signOfInequality}#{targetText}) > [#{diceText}]#{modifyText} > "
80
- diceList = [diceList.min] if skillRank == "D"
81
- is_loop = false
82
- diceList.each do |dice|
83
- if is_loop
84
- message += " / "
85
- elsif diceList.length > 1
86
- is_loop = true
65
+ rank = m[1]
66
+ modifier = ArithmeticEvaluator.eval(m[2])
67
+ cmp_op = m[6] ? Normalize.comparison_operator(m[6]) : :>=
68
+ target = m[7] ? ArithmeticEvaluator.eval(m[7]) : 4
69
+ special = (m[4] || m[9] || 6).to_i
70
+
71
+ dice_count = CHECK_DICE_COUNT[rank]
72
+
73
+ dice_list = @randomizer.roll_barabara(dice_count, 6)
74
+ dice_text = dice_list.join(",")
75
+ special_text = (special == 6 ? "" : "@#{special}")
76
+
77
+ dice_list = [dice_list.min] if rank == "D"
78
+ available_inga = dice_list.size > 1
79
+ inga_table = translate("Amadeus.inga_table")
80
+
81
+ success = false
82
+ critical = false
83
+ fumble = false
84
+
85
+ results =
86
+ dice_list.map do |dice|
87
+ total = dice + modifier
88
+ result =
89
+ if dice == 1
90
+ fumble = true
91
+ translate("Amadeus.fumble")
92
+ elsif dice >= special
93
+ critical = true
94
+ success = true
95
+ translate("Amadeus.special")
96
+ elsif total.send(cmp_op, target)
97
+ success = true
98
+ translate("success")
99
+ else
100
+ translate("failure")
101
+ end
102
+
103
+ if available_inga
104
+ inga = inga_table[dice - 1]
105
+ "#{total}_#{result}[#{dice}#{inga}]"
106
+ else
107
+ "#{total}_#{result}[#{dice}]"
108
+ end
87
109
  end
88
- achieve = dice + modify
89
- result = check_success(achieve, dice, signOfInequality, target, specialNum)
90
- if is_loop
91
- inga_table = translate("Amadeus.inga_table")
92
- inga = inga_table[dice - 1]
93
- message += "#{achieve}_#{result}[#{dice}#{inga}]"
110
+
111
+ sequence = [
112
+ "(R#{rank}#{Format.modifier(modifier)}#{special_text}#{cmp_op}#{target})",
113
+ "[#{dice_text}]#{Format.modifier(modifier)}",
114
+ results.join(" / ")
115
+ ]
116
+
117
+ Result.new.tap do |r|
118
+ r.text = sequence.join(" > ")
119
+ if success
120
+ r.success = true
121
+ r.critical = critical
94
122
  else
95
- message += "#{achieve}_#{result}[#{dice}]"
123
+ r.failure = true
124
+ r.fumble = fumble
96
125
  end
97
126
  end
98
-
99
- return message
100
- end
101
-
102
- def check_success(total_n, dice_n, signOfInequality, diff, special_n)
103
- return translate("Amadeus.fumble") if dice_n == 1
104
- return translate("Amadeus.special") if dice_n >= special_n
105
-
106
- cmp_op = Normalize.comparison_operator(signOfInequality)
107
- target_num = diff.to_i
108
-
109
- if total_n.send(cmp_op, target_num)
110
- translate("success")
111
- else
112
- translate("failure")
113
- end
114
127
  end
115
128
 
116
129
  CHECK_DICE_COUNT = {"S" => 4, "A" => 3, "B" => 2, "C" => 1, "D" => 2}.freeze
117
130
 
118
- def self.translate_tables(locale)
119
- {
120
- "ECT" => DiceTable::Table.from_i18n("Amadeus.table.ECT", locale),
121
- "BST" => DiceTable::Table.from_i18n("Amadeus.table.BST", locale),
122
- "RT" => DiceTable::Table.from_i18n("Amadeus.table.RT", locale),
123
- "PRT" => DiceTable::Table.from_i18n("Amadeus.table.PRT", locale),
124
- "FT" => DiceTable::Table.from_i18n("Amadeus.table.FT", locale),
125
- "BT" => DiceTable::D66Table.from_i18n("Amadeus.table.BT", locale),
126
- "FWT" => DiceTable::Table.from_i18n("Amadeus.table.FWT", locale),
127
- "BRT" => DiceTable::Table.from_i18n("Amadeus.table.BRT", locale),
128
- "RIT" => DiceTable::Table.from_i18n("Amadeus.table.RIT", locale),
129
- "WT" => DiceTable::Table.from_i18n("Amadeus.table.WT", locale),
130
- "NMT" => DiceTable::Table.from_i18n("Amadeus.table.NMT", locale),
131
- "TGT" => DiceTable::Table.from_i18n("Amadeus.table.TGT", locale),
132
- "CST" => DiceTable::Table.from_i18n("Amadeus.table.CST", locale),
133
- "GCVT" => DiceTable::Table.from_i18n("Amadeus.table.GCVT", locale),
134
- "YCVT" => DiceTable::Table.from_i18n("Amadeus.table.YCVT", locale),
135
- "ECVT" => DiceTable::Table.from_i18n("Amadeus.table.ECVT", locale),
136
- "CCVT" => DiceTable::Table.from_i18n("Amadeus.table.CCVT", locale),
137
- "NCVT" => DiceTable::Table.from_i18n("Amadeus.table.NCVT", locale),
138
- "DGVT" => DiceTable::Table.from_i18n("Amadeus.table.DGVT", locale),
139
- "DAVT" => DiceTable::Table.from_i18n("Amadeus.table.DAVT", locale),
140
- "PRCT" => DiceTable::Table.from_i18n("Amadeus.table.PRCT", locale),
141
- "TCCT" => DiceTable::Table.from_i18n("Amadeus.table.TCCT", locale),
142
- "INCT" => DiceTable::Table.from_i18n("Amadeus.table.INCT", locale),
143
- "PSCT" => DiceTable::Table.from_i18n("Amadeus.table.PSCT", locale),
144
- "LVCT" => DiceTable::Table.from_i18n("Amadeus.table.LVCT", locale),
145
- "DACT" => DiceTable::Table.from_i18n("Amadeus.table.DACT", locale),
146
- "RGT" => DiceTable::Table.from_i18n("Amadeus.table.RGT", locale),
147
- "FBT" => DiceTable::Table.from_i18n("Amadeus.table.FBT", locale),
148
- "CHVT" => DiceTable::Table.from_i18n("Amadeus.table.CHVT", locale),
149
- "LCVT" => DiceTable::Table.from_i18n("Amadeus.table.LCVT", locale),
150
- "KCVT" => DiceTable::Table.from_i18n("Amadeus.table.KCVT", locale),
151
- "SAT" => DiceTable::D66Table.from_i18n("Amadeus.table.SAT", locale),
152
- "SMT" => DiceTable::D66Table.from_i18n("Amadeus.table.SMT", locale),
153
- }
131
+ class << self
132
+ private
133
+
134
+ def translate_tables(locale)
135
+ {
136
+ "ECT" => DiceTable::Table.from_i18n("Amadeus.table.ECT", locale),
137
+ "BST" => DiceTable::Table.from_i18n("Amadeus.table.BST", locale),
138
+ "RT" => DiceTable::Table.from_i18n("Amadeus.table.RT", locale),
139
+ "PRT" => DiceTable::Table.from_i18n("Amadeus.table.PRT", locale),
140
+ "FT" => DiceTable::Table.from_i18n("Amadeus.table.FT", locale),
141
+ "BT" => DiceTable::D66Table.from_i18n("Amadeus.table.BT", locale),
142
+ "FWT" => DiceTable::Table.from_i18n("Amadeus.table.FWT", locale),
143
+ "BRT" => DiceTable::Table.from_i18n("Amadeus.table.BRT", locale),
144
+ "RIT" => DiceTable::Table.from_i18n("Amadeus.table.RIT", locale),
145
+ "WT" => DiceTable::Table.from_i18n("Amadeus.table.WT", locale),
146
+ "NMT" => DiceTable::Table.from_i18n("Amadeus.table.NMT", locale),
147
+ "TGT" => DiceTable::Table.from_i18n("Amadeus.table.TGT", locale),
148
+ "CST" => DiceTable::Table.from_i18n("Amadeus.table.CST", locale),
149
+ "GCVT" => DiceTable::Table.from_i18n("Amadeus.table.GCVT", locale),
150
+ "YCVT" => DiceTable::Table.from_i18n("Amadeus.table.YCVT", locale),
151
+ "ECVT" => DiceTable::Table.from_i18n("Amadeus.table.ECVT", locale),
152
+ "CCVT" => DiceTable::Table.from_i18n("Amadeus.table.CCVT", locale),
153
+ "NCVT" => DiceTable::Table.from_i18n("Amadeus.table.NCVT", locale),
154
+ "DGVT" => DiceTable::Table.from_i18n("Amadeus.table.DGVT", locale),
155
+ "DAVT" => DiceTable::Table.from_i18n("Amadeus.table.DAVT", locale),
156
+ "PRCT" => DiceTable::Table.from_i18n("Amadeus.table.PRCT", locale),
157
+ "TCCT" => DiceTable::Table.from_i18n("Amadeus.table.TCCT", locale),
158
+ "INCT" => DiceTable::Table.from_i18n("Amadeus.table.INCT", locale),
159
+ "PSCT" => DiceTable::Table.from_i18n("Amadeus.table.PSCT", locale),
160
+ "LVCT" => DiceTable::Table.from_i18n("Amadeus.table.LVCT", locale),
161
+ "DACT" => DiceTable::Table.from_i18n("Amadeus.table.DACT", locale),
162
+ "RGT" => DiceTable::Table.from_i18n("Amadeus.table.RGT", locale),
163
+ "FBT" => DiceTable::Table.from_i18n("Amadeus.table.FBT", locale),
164
+ "CHVT" => DiceTable::Table.from_i18n("Amadeus.table.CHVT", locale),
165
+ "LCVT" => DiceTable::Table.from_i18n("Amadeus.table.LCVT", locale),
166
+ "KCVT" => DiceTable::Table.from_i18n("Amadeus.table.KCVT", locale),
167
+ "SAT" => DiceTable::D66Table.from_i18n("Amadeus.table.SAT", locale),
168
+ "SMT" => DiceTable::D66Table.from_i18n("Amadeus.table.SMT", locale),
169
+ }
170
+ end
154
171
  end
155
172
 
156
173
  TABLES = translate_tables(:ja_jp)