bcdice 3.0.0.pre.alpha.2 → 3.0.0.pre.rc.1

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 (151) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/README.md +1 -0
  4. data/i18n/KillDeathBusiness/ja_jp.yml +4 -4
  5. data/i18n/KillDeathBusiness/ko_kr.yml +5 -4
  6. data/i18n/MagicaLogia/ko_kr.yml +564 -0
  7. data/i18n/MonotoneMuseum/ja_jp.yml +37 -1
  8. data/i18n/StratoShout/ja_jp.yml +4 -4
  9. data/i18n/StratoShout/ko_kr.yml +4 -4
  10. data/lib/bcdice.rb +2 -1
  11. data/lib/bcdice/arithmetic.rb +22 -0
  12. data/lib/bcdice/arithmetic/node.rb +112 -43
  13. data/lib/bcdice/arithmetic/parser.rb +240 -0
  14. data/lib/bcdice/arithmetic_evaluator.rb +5 -156
  15. data/lib/bcdice/base.rb +8 -1
  16. data/lib/bcdice/command/lexer.rb +57 -0
  17. data/lib/bcdice/command/parsed.rb +65 -0
  18. data/lib/bcdice/command/parser.rb +489 -0
  19. data/lib/bcdice/common_command/add_dice.rb +1 -1
  20. data/lib/bcdice/common_command/add_dice/node.rb +142 -69
  21. data/lib/bcdice/common_command/add_dice/parser.rb +100 -83
  22. data/lib/bcdice/common_command/barabara_dice/node.rb +7 -1
  23. data/lib/bcdice/common_command/barabara_dice/result.rb +22 -0
  24. data/lib/bcdice/common_command/calc/node.rb +10 -1
  25. data/lib/bcdice/common_command/calc/parser.rb +1 -1
  26. data/lib/bcdice/common_command/d66_dice.rb +3 -1
  27. data/lib/bcdice/common_command/lexer.rb +2 -1
  28. data/lib/bcdice/common_command/upper_dice/parser.rb +118 -97
  29. data/lib/bcdice/common_command/version.rb +1 -1
  30. data/lib/bcdice/deprecated/checker.rb +6 -6
  31. data/lib/bcdice/dice_table.rb +1 -0
  32. data/lib/bcdice/dice_table/d66_parity_table.rb +34 -0
  33. data/lib/bcdice/game_system.rb +3 -0
  34. data/lib/bcdice/game_system/AceKillerGene.rb +1 -1
  35. data/lib/bcdice/game_system/AlchemiaStruggle.rb +312 -0
  36. data/lib/bcdice/game_system/Alshard.rb +0 -1
  37. data/lib/bcdice/game_system/Amadeus.rb +1 -1
  38. data/lib/bcdice/game_system/AnimaAnimus.rb +1 -5
  39. data/lib/bcdice/game_system/BadLife.rb +1 -1
  40. data/lib/bcdice/game_system/BeastBindTrinity.rb +1 -10
  41. data/lib/bcdice/game_system/BeginningIdol.rb +4 -4
  42. data/lib/bcdice/game_system/BeginningIdol_Korean.rb +4 -4
  43. data/lib/bcdice/game_system/BladeOfArcana.rb +4 -4
  44. data/lib/bcdice/game_system/BlindMythos.rb +12 -9
  45. data/lib/bcdice/game_system/BloodCrusade.rb +12 -38
  46. data/lib/bcdice/game_system/BloodMoon.rb +2 -2
  47. data/lib/bcdice/game_system/CardRanker.rb +23 -63
  48. data/lib/bcdice/game_system/ChaosFlare.rb +3 -3
  49. data/lib/bcdice/game_system/CodeLayerd.rb +1 -1
  50. data/lib/bcdice/game_system/ColossalHunter.rb +2 -2
  51. data/lib/bcdice/game_system/Cthulhu7th.rb +2 -2
  52. data/lib/bcdice/game_system/CthulhuTech.rb +0 -1
  53. data/lib/bcdice/game_system/DarkBlaze.rb +4 -4
  54. data/lib/bcdice/game_system/DeadlineHeroes.rb +1 -1
  55. data/lib/bcdice/game_system/DoubleCross.rb +60 -93
  56. data/lib/bcdice/game_system/EmbryoMachine.rb +5 -5
  57. data/lib/bcdice/game_system/EtrianOdysseySRS.rb +0 -1
  58. data/lib/bcdice/game_system/FilledWith.rb +3 -3
  59. data/lib/bcdice/game_system/FullMetalPanic.rb +0 -1
  60. data/lib/bcdice/game_system/GURPS.rb +1 -1
  61. data/lib/bcdice/game_system/Garako.rb +3 -2
  62. data/lib/bcdice/game_system/GardenOrder.rb +1 -1
  63. data/lib/bcdice/game_system/GehennaAn.rb +3 -3
  64. data/lib/bcdice/game_system/Gundog.rb +1 -1
  65. data/lib/bcdice/game_system/GundogRevised.rb +3 -3
  66. data/lib/bcdice/game_system/GundogZero.rb +2 -2
  67. data/lib/bcdice/game_system/GurpsFW.rb +2 -5
  68. data/lib/bcdice/game_system/HatsuneMiku.rb +1 -1
  69. data/lib/bcdice/game_system/HuntersMoon.rb +17 -110
  70. data/lib/bcdice/game_system/JuinKansen.rb +251 -0
  71. data/lib/bcdice/game_system/KanColle.rb +17 -166
  72. data/lib/bcdice/game_system/KillDeathBusiness.rb +35 -44
  73. data/lib/bcdice/game_system/KillDeathBusiness_Korean.rb +2 -1
  74. data/lib/bcdice/game_system/LogHorizon.rb +8 -8
  75. data/lib/bcdice/game_system/LostRoyal.rb +1 -3
  76. data/lib/bcdice/game_system/MagicaLogia.rb +3 -3
  77. data/lib/bcdice/game_system/MagicaLogia_Korean.rb +66 -0
  78. data/lib/bcdice/game_system/MeikyuDays.rb +1 -1
  79. data/lib/bcdice/game_system/MeikyuKingdom.rb +1 -1
  80. data/lib/bcdice/game_system/MeikyuKingdomBasic.rb +1 -1
  81. data/lib/bcdice/game_system/MetalHeadExtream.rb +4 -4
  82. data/lib/bcdice/game_system/MetallicGuardian.rb +0 -1
  83. data/lib/bcdice/game_system/MonotoneMuseum.rb +3 -2
  84. data/lib/bcdice/game_system/MonotoneMuseum_Korean.rb +1 -1
  85. data/lib/bcdice/game_system/NSSQ.rb +2 -2
  86. data/lib/bcdice/game_system/Nechronica.rb +3 -3
  87. data/lib/bcdice/game_system/NightWizard.rb +1 -1
  88. data/lib/bcdice/game_system/NightmareHunterDeep.rb +3 -4
  89. data/lib/bcdice/game_system/NinjaSlayer.rb +26 -28
  90. data/lib/bcdice/game_system/OracleEngine.rb +13 -17
  91. data/lib/bcdice/game_system/Paradiso.rb +2 -2
  92. data/lib/bcdice/game_system/PhantasmAdventure.rb +0 -4
  93. data/lib/bcdice/game_system/Raisondetre.rb +1 -1
  94. data/lib/bcdice/game_system/RecordOfLodossWar.rb +2 -3
  95. data/lib/bcdice/game_system/RokumonSekai2.rb +2 -2
  96. data/lib/bcdice/game_system/RuinBreakers.rb +1 -1
  97. data/lib/bcdice/game_system/Ryutama.rb +1 -1
  98. data/lib/bcdice/game_system/SRS.rb +0 -5
  99. data/lib/bcdice/game_system/SamsaraBallad.rb +4 -3
  100. data/lib/bcdice/game_system/Satasupe.rb +22 -14
  101. data/lib/bcdice/game_system/ScreamHighSchool.rb +2 -2
  102. data/lib/bcdice/game_system/ShinkuuGakuen.rb +1 -1
  103. data/lib/bcdice/game_system/ShinobiGami.rb +75 -39
  104. data/lib/bcdice/game_system/StellarKnights.rb +1 -3
  105. data/lib/bcdice/game_system/SterileLife.rb +1 -1
  106. data/lib/bcdice/game_system/StrangerOfSwordCity.rb +1 -1
  107. data/lib/bcdice/game_system/StratoShout.rb +10 -36
  108. data/lib/bcdice/game_system/StratoShout_Korean.rb +2 -1
  109. data/lib/bcdice/game_system/SwordWorld.rb +5 -5
  110. data/lib/bcdice/game_system/SwordWorld2_5.rb +1 -1
  111. data/lib/bcdice/game_system/TherapieSein.rb +2 -2
  112. data/lib/bcdice/game_system/TokumeiTenkousei.rb +2 -2
  113. data/lib/bcdice/game_system/Torg.rb +1 -1
  114. data/lib/bcdice/game_system/TorgEternity.rb +4 -7
  115. data/lib/bcdice/game_system/TrinitySeven.rb +2 -2
  116. data/lib/bcdice/game_system/TunnelsAndTrolls.rb +6 -6
  117. data/lib/bcdice/game_system/TwilightGunsmoke.rb +1 -1
  118. data/lib/bcdice/game_system/Utakaze.rb +1 -1
  119. data/lib/bcdice/game_system/Warhammer.rb +6 -6
  120. data/lib/bcdice/game_system/Warhammer4.rb +9 -12
  121. data/lib/bcdice/game_system/ZettaiReido.rb +1 -1
  122. data/lib/bcdice/normalize.rb +1 -1
  123. data/lib/bcdice/preprocessor.rb +12 -8
  124. data/lib/bcdice/randomizer.rb +12 -0
  125. data/lib/bcdice/repl.rb +1 -1
  126. data/lib/bcdice/result.rb +2 -0
  127. data/lib/bcdice/user_defined_dice_table.rb +26 -15
  128. data/lib/bcdice/version.rb +1 -1
  129. metadata +14 -25
  130. data/.editorconfig +0 -21
  131. data/.github/.codecov.yaml +0 -10
  132. data/.github/workflows/coverage.yaml +0 -21
  133. data/.github/workflows/lint.yaml +0 -13
  134. data/.github/workflows/test.yml +0 -20
  135. data/.gitignore +0 -14
  136. data/.rubocop.yml +0 -108
  137. data/.rubocop_todo.yml +0 -114
  138. data/Gemfile +0 -14
  139. data/ROADMAP.md +0 -30
  140. data/Rakefile +0 -152
  141. data/bcdice.gemspec +0 -29
  142. data/bin/repl.rb +0 -21
  143. data/docs/README.txt +0 -2028
  144. data/docs/dicebot_sort_key.md +0 -72
  145. data/docs/how_to_make_dicebot.md +0 -453
  146. data/lib/bcdice/command_parser.rb +0 -242
  147. data/lib/bcdice/common_command/add_dice/parser.y +0 -153
  148. data/lib/bcdice/common_command/barabara_dice/parser.y +0 -107
  149. data/lib/bcdice/common_command/calc/parser.y +0 -79
  150. data/lib/bcdice/common_command/reroll_dice/parser.y +0 -158
  151. data/lib/bcdice/common_command/upper_dice/parser.y +0 -143
@@ -1,79 +0,0 @@
1
- class BCDice::CommonCommand::Calc::Parser
2
- token NUMBER R U C F S PLUS MINUS ASTERISK SLASH PARENL PARENR
3
-
4
- rule
5
- expr: secret C add
6
- {
7
- result = Node::Command.new(
8
- secret: val[0],
9
- expr: val[2]
10
- )
11
- }
12
-
13
- secret: /* none */
14
- { result = false }
15
- | S
16
- { result = true }
17
-
18
- add: add PLUS mul
19
- { result = Arithmetic::Node::BinaryOp.new(val[0], :+, val[2]) }
20
- | add MINUS mul
21
- { result = Arithmetic::Node::BinaryOp.new(val[0], :-, val[2]) }
22
- | mul
23
-
24
- mul: mul ASTERISK unary
25
- { result = Arithmetic::Node::BinaryOp.new(val[0], :*, val[2]) }
26
- | mul SLASH unary round_type
27
- {
28
- divied_class = val[3]
29
- result = divied_class.new(val[0], val[2])
30
- }
31
- | unary
32
-
33
- round_type: /* none */
34
- { result = Arithmetic::Node::DivideWithGameSystemDefault }
35
- | U
36
- { result = Arithmetic::Node::DivideWithCeil }
37
- | C
38
- { result = Arithmetic::Node::DivideWithCeil }
39
- | R
40
- { result = Arithmetic::Node::DivideWithRound }
41
- | F
42
- { result = Arithmetic::Node::DivideWithFloor }
43
-
44
- unary: PLUS unary
45
- { result = val[1] }
46
- | MINUS unary
47
- { result = Arithmetic::Node::Negative.new(val[1]) }
48
- | term
49
-
50
- term: PARENL add PARENR
51
- { result = val[1] }
52
- | NUMBER
53
- { result = Arithmetic::Node::Number.new(val[0]) }
54
- end
55
-
56
- ---- header
57
-
58
- require "bcdice/common_command/lexer"
59
- require "bcdice/common_command/calc/node"
60
- require "bcdice/arithmetic/node"
61
-
62
- ---- inner
63
-
64
- def self.parse(source)
65
- new.parse(source)
66
- end
67
-
68
- def parse(source)
69
- @lexer = Lexer.new(source)
70
- do_parse()
71
- rescue ParseError
72
- nil
73
- end
74
-
75
- private
76
-
77
- def next_token
78
- @lexer.next_token
79
- end
@@ -1,158 +0,0 @@
1
- class BCDice::CommonCommand::RerollDice::Parser
2
- token NUMBER R U C F S PLUS MINUS ASTERISK SLASH PARENL PARENR BRACKETL BRACKETR LESS GREATER EQUAL NOT AT CMP_OP
3
-
4
- rule
5
- expr: secret notations target
6
- {
7
- result = Node::Command.new(
8
- secret: val[0],
9
- notations: val[1],
10
- cmp_op: val[2][:cmp_op],
11
- target_number: val[2][:target],
12
- source: @lexer.source
13
- )
14
- }
15
- | secret notations bracket target
16
- {
17
- target = val[3]
18
- threshold = val[2]
19
- result = Node::Command.new(
20
- secret: val[0],
21
- notations: val[1],
22
- cmp_op: target[:cmp_op],
23
- target_number: target[:target],
24
- reroll_cmp_op: threshold[:cmp_op],
25
- reroll_threshold: threshold[:threshold],
26
- source: @lexer.source
27
- )
28
- }
29
- | secret notations target at
30
- {
31
- target = val[2]
32
- threshold = val[3]
33
- result = Node::Command.new(
34
- secret: val[0],
35
- notations: val[1],
36
- cmp_op: target[:cmp_op],
37
- target_number: target[:target],
38
- reroll_cmp_op: threshold[:cmp_op],
39
- reroll_threshold: threshold[:threshold],
40
- source: @lexer.source
41
- )
42
- }
43
-
44
- secret: /* none */
45
- { result = false }
46
- | S
47
- { result = true }
48
-
49
- target: /* none */
50
- { result = {} }
51
- | CMP_OP add
52
- {
53
- cmp_op, target = val
54
- raise ParseError unless cmp_op
55
-
56
- result = {cmp_op: cmp_op, target: target}
57
- }
58
-
59
- bracket: BRACKETL add BRACKETR
60
- { result = {threshold: val[1]} }
61
- | BRACKETL CMP_OP add BRACKETR
62
- {
63
- cmp_op = val[1]
64
- threshold = val[2]
65
- raise ParseError unless cmp_op
66
-
67
- result = {cmp_op: cmp_op, threshold: threshold}
68
- }
69
-
70
- at: AT add
71
- { result = {threshold: val[1]} }
72
- | AT CMP_OP add
73
- {
74
- cmp_op = val[1]
75
- threshold = val[2]
76
- raise ParseError unless cmp_op
77
-
78
- result = {cmp_op: cmp_op, threshold: threshold}
79
- }
80
-
81
- notations: notations PLUS dice
82
- {
83
- notations = val[0]
84
- notations.push(val[2])
85
- result = notations
86
- }
87
- | dice
88
- { result = [val[0]] }
89
-
90
- dice: term R term
91
- {
92
- times = val[0]
93
- sides = val[2]
94
- result = Node::Notation.new(times, sides)
95
- }
96
-
97
- add: add PLUS mul
98
- { result = Arithmetic::Node::BinaryOp.new(val[0], :+, val[2]) }
99
- | add MINUS mul
100
- { result = Arithmetic::Node::BinaryOp.new(val[0], :-, val[2]) }
101
- | mul
102
-
103
- mul: mul ASTERISK unary
104
- { result = Arithmetic::Node::BinaryOp.new(val[0], :*, val[2]) }
105
- | mul SLASH unary round_type
106
- {
107
- divied_class = val[3]
108
- result = divied_class.new(val[0], val[2])
109
- }
110
- | unary
111
-
112
- round_type: /* none */
113
- { result = Arithmetic::Node::DivideWithGameSystemDefault }
114
- | U
115
- { result = Arithmetic::Node::DivideWithCeil }
116
- | C
117
- { result = Arithmetic::Node::DivideWithCeil }
118
- | R
119
- { result = Arithmetic::Node::DivideWithRound }
120
- | F
121
- { result = Arithmetic::Node::DivideWithFloor }
122
-
123
- unary: PLUS unary
124
- { result = val[1] }
125
- | MINUS unary
126
- { result = Arithmetic::Node::Negative.new(val[1]) }
127
- | term
128
-
129
- term: PARENL add PARENR
130
- { result = val[1] }
131
- | NUMBER
132
- { result = Arithmetic::Node::Number.new(val[0]) }
133
- end
134
-
135
- ---- header
136
-
137
- require "bcdice/common_command/lexer"
138
- require "bcdice/common_command/barabara_dice/node"
139
- require "bcdice/arithmetic/node"
140
-
141
- ---- inner
142
-
143
- def self.parse(source)
144
- new.parse(source)
145
- end
146
-
147
- def parse(source)
148
- @lexer = Lexer.new(source)
149
- do_parse()
150
- rescue ParseError
151
- nil
152
- end
153
-
154
- private
155
-
156
- def next_token
157
- @lexer.next_token
158
- end
@@ -1,143 +0,0 @@
1
- class BCDice::CommonCommand::UpperDice::Parser
2
- token NUMBER R U C F S PLUS MINUS ASTERISK SLASH PARENL PARENR BRACKETL BRACKETR LESS GREATER EQUAL NOT AT CMP_OP
3
-
4
- rule
5
- expr: secret notations modifier target
6
- {
7
- result = UpperDice::Node::Command.new(
8
- secret: val[0],
9
- notations: val[1],
10
- modifier: val[2],
11
- cmp_op: val[3][:cmp_op],
12
- target_number: val[3][:target]
13
- )
14
- }
15
- | secret notations bracket modifier target
16
- {
17
- result = UpperDice::Node::Command.new(
18
- secret: val[0],
19
- notations: val[1],
20
- modifier: val[3],
21
- cmp_op: val[4][:cmp_op],
22
- target_number: val[4][:target],
23
- reroll_threshold: val[2]
24
- )
25
- }
26
- | secret notations modifier target at
27
- {
28
- result = UpperDice::Node::Command.new(
29
- secret: val[0],
30
- notations: val[1],
31
- modifier: val[2],
32
- cmp_op: val[3][:cmp_op],
33
- target_number: val[3][:target],
34
- reroll_threshold: val[4]
35
- )
36
- }
37
-
38
- secret: /* none */
39
- { result = false }
40
- | S
41
- { result = true }
42
-
43
- modifier: /* none */
44
- { result = Arithmetic::Node::Number.new(0) }
45
- | PLUS add
46
- { result = val[1] }
47
- | MINUS add
48
- { result = Arithmetic::Node::Negative.new(val[1]) }
49
-
50
- target: /* none */
51
- { result = {} }
52
- | CMP_OP add
53
- {
54
- cmp_op, target = val
55
- raise ParseError unless cmp_op
56
-
57
- result = {cmp_op: cmp_op, target: target}
58
- }
59
-
60
- bracket: BRACKETL add BRACKETR
61
- { result = val[1] }
62
-
63
- at: AT add
64
- { result = val[1] }
65
-
66
- notations: notations PLUS dice
67
- {
68
- notations = val[0]
69
- notations.push(val[2])
70
- result = notations
71
- }
72
- | dice
73
- { result = [val[0]] }
74
-
75
- dice: term U term
76
- {
77
- times = val[0]
78
- sides = val[2]
79
- result = UpperDice::Node::Notation.new(times, sides)
80
- }
81
-
82
- add: add PLUS mul
83
- { result = Arithmetic::Node::BinaryOp.new(val[0], :+, val[2]) }
84
- | add MINUS mul
85
- { result = Arithmetic::Node::BinaryOp.new(val[0], :-, val[2]) }
86
- | mul
87
-
88
- mul: mul ASTERISK unary
89
- { result = Arithmetic::Node::BinaryOp.new(val[0], :*, val[2]) }
90
- | mul SLASH unary round_type
91
- {
92
- divied_class = val[3]
93
- result = divied_class.new(val[0], val[2])
94
- }
95
- | unary
96
-
97
- round_type: /* none */
98
- { result = Arithmetic::Node::DivideWithGameSystemDefault }
99
- | U
100
- { result = Arithmetic::Node::DivideWithCeil }
101
- | C
102
- { result = Arithmetic::Node::DivideWithCeil }
103
- | R
104
- { result = Arithmetic::Node::DivideWithRound }
105
- | F
106
- { result = Arithmetic::Node::DivideWithFloor }
107
-
108
- unary: PLUS unary
109
- { result = val[1] }
110
- | MINUS unary
111
- { result = Arithmetic::Node::Negative.new(val[1]) }
112
- | term
113
-
114
- term: PARENL add PARENR
115
- { result = val[1] }
116
- | NUMBER
117
- { result = Arithmetic::Node::Number.new(val[0]) }
118
- end
119
-
120
- ---- header
121
-
122
- require "bcdice/common_command/lexer"
123
- require "bcdice/common_command/upper_dice/node"
124
- require "bcdice/arithmetic/node"
125
-
126
- ---- inner
127
-
128
- def self.parse(source)
129
- new.parse(source)
130
- end
131
-
132
- def parse(source)
133
- @lexer = Lexer.new(source)
134
- do_parse()
135
- rescue ParseError
136
- nil
137
- end
138
-
139
- private
140
-
141
- def next_token
142
- @lexer.next_token
143
- end