Skip to content

Commit 5bc2c6e

Browse files
neutron317ysakasin
andauthored
[SwordWorld2.5]公式discordで要望のあった機能&アビスカース「難しい」に応じた機能の追加 (#865)
* ダメージ2倍処理の追加 * sz構文の追加 * 説明文を編集 * 衍字の修正 * 説明文を編集 * add_damage処理を追加 * 冗長な処理を修正 * rateValueの定義のリファクタリング Co-authored-by: SAKATA Sinji <ysakasin@gmail.com> * コード整形 --------- Co-authored-by: SAKATA Sinji <ysakasin@gmail.com>
1 parent d0bbe9c commit 5bc2c6e

6 files changed

Lines changed: 412 additions & 8 deletions

File tree

lib/bcdice/game_system/SwordWorld.rb

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,12 @@ def rating(string) # レーティング表
119119

120120
currentKey = (command.rate + round * command.rateup).clamp(0, keyMax)
121121
debug("currentKey", currentKey)
122-
rateValue = newRates[dice][currentKey]
122+
rateValue =
123+
if dice > command.set_zero_val
124+
newRates[dice][currentKey]
125+
else
126+
0
127+
end
123128
debug("rateValue", rateValue)
124129

125130
totalValue += rateValue
@@ -321,6 +326,8 @@ def rollDice(_command, _round)
321326
def getResultText(rating_total, command, diceResults, diceResultTotals,
322327
rateResults, dice_total, round)
323328
sequence = []
329+
critical_count = [round - 1, 0].max
330+
additional_damage = command.add_damage * critical_count
324331

325332
sequence.push("2D:[#{diceResults.join(' ')}]=#{diceResultTotals.join(',')}")
326333

@@ -333,6 +340,9 @@ def getResultText(rating_total, command, diceResults, diceResultTotals,
333340
# rate回数が1回で、修正値がない時には途中式と最終結果が一致するので、途中式を省略する
334341
if rateResults.size > 1 || command.modifier != 0
335342
text = rateResults.join(',') + Format.modifier(command.modifier)
343+
if additional_damage != 0
344+
text += "+#{command.add_damage}*#{critical_count}"
345+
end
336346
if command.half
337347
text = "(#{text})/2"
338348
if command.modifier_after_half != 0
@@ -343,6 +353,11 @@ def getResultText(rating_total, command, diceResults, diceResultTotals,
343353
if command.modifier_after_one_and_a_half != 0
344354
text += Format.modifier(command.modifier_after_one_and_a_half)
345355
end
356+
elsif command.double
357+
text = "(#{text})*2"
358+
if command.modifier_after_double != 0
359+
text += Format.modifier(command.modifier_after_double)
360+
end
346361
end
347362
sequence.push(text)
348363
elsif command.half
@@ -357,14 +372,20 @@ def getResultText(rating_total, command, diceResults, diceResultTotals,
357372
text += Format.modifier(command.modifier_after_one_and_a_half)
358373
end
359374
sequence.push(text)
375+
elsif command.double
376+
text = "#{rateResults.first}*2"
377+
if command.modifier_after_double != 0
378+
text += Format.modifier(command.modifier_after_double)
379+
end
380+
sequence.push(text)
360381
end
361382

362383
if round > 1
363384
round_text = translate("SwordWorld.round_text", reroll_count: round - 1)
364385
sequence.push(round_text)
365386
end
366387

367-
total = rating_total + command.modifier
388+
total = rating_total + command.modifier + additional_damage
368389
if command.half
369390
total = (total / 2.0).ceil
370391
if command.modifier_after_half != 0
@@ -375,6 +396,11 @@ def getResultText(rating_total, command, diceResults, diceResultTotals,
375396
if command.modifier_after_one_and_a_half != 0
376397
total += command.modifier_after_one_and_a_half
377398
end
399+
elsif command.double
400+
total = (total * 2).ceil
401+
if command.modifier_after_double != 0
402+
total += command.modifier_after_double
403+
end
378404
end
379405

380406
total_text = total.to_s

lib/bcdice/game_system/SwordWorld2_5.rb

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,25 @@ class SwordWorld2_5 < SwordWorld2_0
3434
3535
・レーティング表の半減 (HKx, KxH+N)
3636
 レーティング表の先頭または末尾に"H"をつけると、レーティング表を振って最終結果を半減させます。
37-
 末尾につけた場合、直後に修正ををつけることで、半減後の加減算を行うことができます。
37+
 末尾につけた場合、直後に修正をつけることで、半減後の加減算を行うことができます。
3838
 この際、複数の項による修正にはカッコで囲うことが必要です(カッコがないとパースに失敗します)
3939
 クリティカル値を指定しない場合、クリティカルなしと扱われます。
4040
 例)HK20  K20h  HK10-5@9  K10-5@9H  K20gfH  K20+8H+2  K20+8H+(1+1)
4141
4242
・レーティング表の1.5倍 (OHKx, KxOH+N)
4343
 レーティング表の先頭または末尾に"OH"をつけると、レーティング表を振って最終結果を1.5倍します。
44-
 末尾につけた場合、直後に修正ををつけることで、1.5倍後の加減算を行うことができます。
44+
 末尾につけた場合、直後に修正をつけることで、1.5倍後の加減算を行うことができます。
4545
 この際、複数の項による修正にはカッコで囲うことが必要です(カッコがないとパースに失敗します)
4646
 クリティカル値を指定しない場合、クリティカルなしと扱われます。
4747
 例)OHK20  K20oh  OHK10-5@9  K20+8OH+2  K20+8OH+(1+1)
4848
49+
・レーティング表の2倍 (DBKx, KxDB+N)
50+
 レーティング表の先頭または末尾に"DB"をつけると、レーティング表を振って最終結果を2倍します。
51+
 末尾につけた場合、直後に修正をつけることで、2倍後の加減算を行うことができます。
52+
 この際、複数の項による修正にはカッコで囲うことが必要です(カッコがないとパースに失敗します)
53+
 クリティカル値を指定しない場合、クリティカル値10と扱われます。
54+
 例)DBK20  K20db  DBK10-5@9  K20+8DB+2  K20+8DB+(1+1)
55+
4956
・ダイス目の修正(運命変転やクリティカルレイ、魔女の火用)
5057
 末尾に「$修正値」でダイス目に修正がかかります。
5158
 $+1と修正表記ならダイス目に+修正、$9のように固定値ならダイス目をその出目に差し替え。
@@ -61,6 +68,9 @@ class SwordWorld2_5 < SwordWorld2_0
6168
・首切り刀用レーティング上昇 r5
6269
 例)K20r5 K30+24@8R5 K40+24@8$12r5
6370
71+
・肉喰む顎用クリティカルごと追加ダメージ ad2
72+
 例)K20ad2 K30+24@8D2 K40+24@8$12ad2
73+
6474
・グレイテストフォーチュンは末尾に gf
6575
 例)K20gf K30+24@8GF K40+24@8$12r5gf
6676
@@ -70,6 +80,9 @@ class SwordWorld2_5 < SwordWorld2_0
7080
・威力表を1d+tfで参照 クリティカル後は2dで参照 tf3
7181
 例)k10tf3 k0+5tf4@13 k70+26tf3@9
7282
83+
・アビスカース「難しい」用に KxSZy 表記でy以下の出目の威力表を0に書き換え。
84+
 例) k10SZ4 k0+5@13sz6 k40+26@9sz3
85+
7386
・超越判定用に2d6ロールに 2D6@10 書式でクリティカル値付与が可能に。
7487
 例)2D6@10 2D6@10+11>=30
7588
@@ -96,7 +109,7 @@ class SwordWorld2_5 < SwordWorld2_0
96109
 追加アビスカース表を出すことができます。
97110
INFO_MESSAGE_TEXT
98111

99-
register_prefix('H?K', 'OHK', 'Gr', '2D6?@\d+', 'FT', 'TT', 'Dru', 'Bib', 'ABT', 'AABT')
112+
register_prefix('H?K', 'OHK', 'DBK', 'Gr', '2D6?@\d+', 'FT', 'TT', 'Dru', 'Bib', 'ABT', 'AABT')
100113

101114
def eval_game_system_specific_command(command)
102115
case command

lib/bcdice/game_system/sword_world/rating_options.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ class RatingOptions
2222
# @return [Integer, nil]
2323
attr_accessor :rateup
2424

25+
# @return [Integer, nil]
26+
attr_accessor :add_damage
27+
2528
# @return [Boolean, nil]
2629
attr_accessor :greatest_fortune
2730

@@ -31,6 +34,9 @@ class RatingOptions
3134
# @return [Integer, nil]
3235
attr_accessor :tmp_fixed_val
3336

37+
# @return [Integer, nil]
38+
attr_accessor :set_zero_val
39+
3440
# @return [Integer, nil]
3541
attr_accessor :modifier
3642

@@ -40,6 +46,9 @@ class RatingOptions
4046
# @return [Integer, nil]
4147
attr_accessor :modifier_after_one_and_a_half
4248

49+
# @return [Integer, nil]
50+
attr_accessor :modifier_after_double
51+
4352
def settable_first_roll_adjust_option?
4453
return first_modify.nil? && first_to.nil? && first_modify_ssp.nil?
4554
end

lib/bcdice/game_system/sword_world/rating_parsed.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ class RatingParsed
2525
# @return [Integer]
2626
attr_accessor :rateup
2727

28+
# @return [Integer]
29+
attr_accessor :add_damage
30+
2831
# @return [Boolean]
2932
attr_accessor :greatest_fortune
3033

@@ -34,6 +37,9 @@ class RatingParsed
3437
# @return [Integer]
3538
attr_accessor :tmp_fixed_val
3639

40+
# @return [Integer]
41+
attr_accessor :set_zero_val
42+
3743
# @return [Integer]
3844
attr_accessor :modifier
3945

@@ -43,6 +49,9 @@ class RatingParsed
4349
# @return [Integer, nil]
4450
attr_accessor :modifier_after_one_and_a_half
4551

52+
# @return [Integer, nil]
53+
attr_accessor :modifier_after_double
54+
4655
def initialize(rate, modifier)
4756
@rate = rate
4857
@modifier = modifier
@@ -53,10 +62,13 @@ def initialize(rate, modifier)
5362
@first_modify_ssp = 0
5463
@greatest_fortune = false
5564
@rateup = 0
65+
@add_damage = 0
5666
@semi_fixed_val = 0
5767
@tmp_fixed_val = 0
68+
@set_zero_val = 0
5869
@modifier_after_half = nil
5970
@modifier_after_one_and_a_half = nil
71+
@modifier_after_double = nil
6072
end
6173

6274
# @return [Boolean]
@@ -69,6 +81,11 @@ def one_and_a_half
6981
return !@modifier_after_one_and_a_half.nil?
7082
end
7183

84+
# @return [Boolean]
85+
def double
86+
return !@modifier_after_double.nil?
87+
end
88+
7289
# @return [Integer]
7390
def min_critical
7491
if @semi_fixed_val <= 1
@@ -92,9 +109,11 @@ def to_s()
92109
output += "m[~#{Format.modifier(first_modify_ssp)}]" if first_modify_ssp != 0
93110
output += "m[#{first_to}]" if first_to != 0
94111
output += "r[#{rateup}]" if rateup != 0
112+
output += "ad[#{add_damage}]" if add_damage != 0
95113
output += "gf" if @greatest_fortune
96114
output += "sf[#{semi_fixed_val}]" if semi_fixed_val != 0
97115
output += "tf[#{tmp_fixed_val}]" if tmp_fixed_val != 0
116+
output += "sz[#{set_zero_val}]" if set_zero_val != 0
98117
output += "a[#{Format.modifier(kept_modify)}]" if kept_modify != 0
99118

100119
if @modifier != 0

lib/bcdice/game_system/sword_world/rating_parser.y

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class RatingParser
2-
token NUMBER K R H O G F S T PLUS MINUS ASTERISK SLASH PARENL PARENR BRACKETL BRACKETR AT SHARP DOLLAR TILDE
2+
token NUMBER K R H O D B G F S T Z A PLUS MINUS ASTERISK SLASH PARENL PARENR BRACKETL BRACKETR AT SHARP DOLLAR TILDE
33

44
expect 4
55

@@ -13,19 +13,27 @@ class RatingParser
1313
| H rate option
1414
{
1515
_, rate, option = val
16-
raise ParseError if option.modifier_after_one_and_a_half
16+
raise ParseError if option.modifier_after_one_and_a_half or option.modifier_after_double
1717
option.modifier_after_half ||= Arithmetic::Node::Number.new(0)
1818
modifier = option.modifier || Arithmetic::Node::Number.new(0)
1919
result = parsed(rate, modifier.eval(@round_type), option)
2020
}
2121
| O H rate option
2222
{
2323
_, _, rate, option = val
24-
raise ParseError if option.modifier_after_half
24+
raise ParseError if option.modifier_after_half or option.modifier_after_double
2525
option.modifier_after_one_and_a_half ||= Arithmetic::Node::Number.new(0)
2626
modifier = option.modifier || Arithmetic::Node::Number.new(0)
2727
result = parsed(rate, modifier.eval(@round_type), option)
2828
}
29+
| D B rate option
30+
{
31+
_, _, rate, option = val
32+
raise ParseError if option.modifier_after_half or option.modifier_after_one_and_a_half
33+
option.modifier_after_double ||= Arithmetic::Node::Number.new(0)
34+
modifier = option.modifier || Arithmetic::Node::Number.new(0)
35+
result = parsed(rate, modifier.eval(@round_type), option)
36+
}
2937

3038

3139
rate: K NUMBER
@@ -123,6 +131,22 @@ class RatingParser
123131
option.modifier_after_one_and_a_half = term
124132
result = option
125133
}
134+
| option D B
135+
{
136+
option, _, _ = val
137+
raise ParseError unless option.modifier_after_double.nil?
138+
139+
option.modifier_after_double = Arithmetic::Node::Number.new(0)
140+
result = option
141+
}
142+
| option D B unary
143+
{
144+
option, _, _, term = val
145+
raise ParseError unless option.modifier_after_double.nil?
146+
147+
option.modifier_after_double = term
148+
result = option
149+
}
126150
| option R unary
127151
{
128152
option, _, term = val
@@ -131,6 +155,14 @@ class RatingParser
131155
option.rateup = term
132156
result = option
133157
}
158+
| option A D unary
159+
{
160+
option, _, _, term = val
161+
raise ParseError unless [:v2_5].include?(@version) && option.add_damage.nil?
162+
163+
option.add_damage = term
164+
result = option
165+
}
134166
| option G F
135167
{
136168
option, _, _ = val
@@ -155,6 +187,14 @@ class RatingParser
155187
option.tmp_fixed_val = term.to_i
156188
result = option
157189
}
190+
| option S Z NUMBER
191+
{
192+
option, _, _, term = val
193+
raise ParseError unless [:v2_5].include?(@version)
194+
195+
option.set_zero_val = term.to_i
196+
result = option
197+
}
158198
| option SHARP unary
159199
{
160200
option, _, term = val
@@ -244,11 +284,14 @@ def parsed(rate, modifier, option)
244284
p.first_modify = option.first_modify || 0
245285
p.first_modify_ssp = option.first_modify_ssp || 0
246286
p.rateup = option.rateup&.eval(@round_type) || 0
287+
p.add_damage = option.add_damage&.eval(@round_type) || 0
247288
p.greatest_fortune = option.greatest_fortune if !option.greatest_fortune.nil?
248289
p.semi_fixed_val = option.semi_fixed_val&.clamp(1, 6) || 0
249290
p.tmp_fixed_val = option.tmp_fixed_val&.clamp(1, 6) || 0
291+
p.set_zero_val = option.set_zero_val || 0
250292
p.modifier_after_half = option.modifier_after_half&.eval(@round_type)
251293
p.modifier_after_one_and_a_half = option.modifier_after_one_and_a_half&.eval(@round_type)
294+
p.modifier_after_double = option.modifier_after_double&.eval(@round_type)
252295
p.critical = option.critical&.eval(@round_type)&.clamp(0, 13) || (p.half || p.one_and_a_half ? 13 : 10)
253296
end
254297
end

0 commit comments

Comments
 (0)