diff --git a/lib/bcdice/game_system/SwordWorld.rb b/lib/bcdice/game_system/SwordWorld.rb index d48877300..deeaf21d1 100644 --- a/lib/bcdice/game_system/SwordWorld.rb +++ b/lib/bcdice/game_system/SwordWorld.rb @@ -334,6 +334,11 @@ def getResultText(rating_total, command, diceResults, diceResultTotals, if command.modifier_after_half != 0 text += Format.modifier(command.modifier_after_half) end + elsif command.one_and_a_half + text = "(#{text})*1.5" + if command.modifier_after_one_and_a_half != 0 + text += Format.modifier(command.modifier_after_one_and_a_half) + end end sequence.push(text) elsif command.half @@ -342,6 +347,12 @@ def getResultText(rating_total, command, diceResults, diceResultTotals, text += Format.modifier(command.modifier_after_half) end sequence.push(text) + elsif command.one_and_a_half + text = "#{rateResults.first}*1.5" + if command.modifier_after_one_and_a_half != 0 + text += Format.modifier(command.modifier_after_one_and_a_half) + end + sequence.push(text) end if round > 1 @@ -355,6 +366,11 @@ def getResultText(rating_total, command, diceResults, diceResultTotals, if command.modifier_after_half != 0 total += command.modifier_after_half end + elsif command.one_and_a_half + total = (total * 1.5).ceil + if command.modifier_after_one_and_a_half != 0 + total += command.modifier_after_one_and_a_half + end end total_text = total.to_s diff --git a/lib/bcdice/game_system/SwordWorld2_5.rb b/lib/bcdice/game_system/SwordWorld2_5.rb index 45c68dc1f..4fc04ede9 100644 --- a/lib/bcdice/game_system/SwordWorld2_5.rb +++ b/lib/bcdice/game_system/SwordWorld2_5.rb @@ -39,6 +39,13 @@ class SwordWorld2_5 < SwordWorld2_0  クリティカル値を指定しない場合、クリティカルなしと扱われます。  例)HK20  K20h  HK10-5@9  K10-5@9H  K20gfH  K20+8H+2  K20+8H+(1+1) + ・レーティング表の1.5倍 (OHKx, KxOH+N) +  レーティング表の先頭または末尾に"OH"をつけると、レーティング表を振って最終結果を1.5倍します。 +  末尾につけた場合、直後に修正ををつけることで、1.5倍後の加減算を行うことができます。 +  この際、複数の項による修正にはカッコで囲うことが必要です(カッコがないとパースに失敗します) +  クリティカル値を指定しない場合、クリティカルなしと扱われます。 +  例)OHK20  K20oh  OHK10-5@9  K20+8OH+2  K20+8OH+(1+1) + ・ダイス目の修正(運命変転やクリティカルレイ用)  末尾に「$修正値」でダイス目に修正がかかります。  $+1と修正表記ならダイス目に+修正、$9のように固定値ならダイス目をその出目に差し替え。 @@ -82,7 +89,7 @@ class SwordWorld2_5 < SwordWorld2_0  アビスカース表を出すことができます。 INFO_MESSAGE_TEXT - register_prefix('H?K', 'Gr', '2D6?@\d+', 'FT', 'TT', 'Dru', 'ABT') + register_prefix('H?K', 'OHK', 'Gr', '2D6?@\d+', 'FT', 'TT', 'Dru', 'ABT') def eval_game_system_specific_command(command) case command diff --git a/lib/bcdice/game_system/sword_world/rating_options.rb b/lib/bcdice/game_system/sword_world/rating_options.rb index f6e85388b..431f7749e 100644 --- a/lib/bcdice/game_system/sword_world/rating_options.rb +++ b/lib/bcdice/game_system/sword_world/rating_options.rb @@ -34,6 +34,9 @@ class RatingOptions # @return [Integer, nil] attr_accessor :modifier_after_half + # @return [Integer, nil] + attr_accessor :modifier_after_one_and_a_half + def settable_first_roll_adjust_option? return first_modify.nil? && first_to.nil? end diff --git a/lib/bcdice/game_system/sword_world/rating_parsed.rb b/lib/bcdice/game_system/sword_world/rating_parsed.rb index c783acc4e..4d7109114 100644 --- a/lib/bcdice/game_system/sword_world/rating_parsed.rb +++ b/lib/bcdice/game_system/sword_world/rating_parsed.rb @@ -37,6 +37,9 @@ class RatingParsed # @return [Integer, nil] attr_accessor :modifier_after_half + # @return [Integer, nil] + attr_accessor :modifier_after_one_and_a_half + def initialize(rate, modifier) @rate = rate @modifier = modifier @@ -49,6 +52,7 @@ def initialize(rate, modifier) @semi_fixed_val = 0 @tmp_fixed_val = 0 @modifier_after_half = nil + @modifier_after_one_and_a_half = nil end # @return [Boolean] @@ -56,6 +60,11 @@ def half return !@modifier_after_half.nil? end + # @return [Boolean] + def one_and_a_half + return !@modifier_after_one_and_a_half.nil? + end + # @return [Integer] def min_critical if @semi_fixed_val <= 1 diff --git a/lib/bcdice/game_system/sword_world/rating_parser.y b/lib/bcdice/game_system/sword_world/rating_parser.y index 9918706e6..83aa2fbe6 100644 --- a/lib/bcdice/game_system/sword_world/rating_parser.y +++ b/lib/bcdice/game_system/sword_world/rating_parser.y @@ -1,5 +1,5 @@ class RatingParser - token NUMBER K R H G F S T PLUS MINUS ASTERISK SLASH PARENL PARENR BRACKETL BRACKETR AT SHARP DOLLAR + token NUMBER K R H O G F S T PLUS MINUS ASTERISK SLASH PARENL PARENR BRACKETL BRACKETR AT SHARP DOLLAR expect 4 @@ -13,10 +13,19 @@ class RatingParser | H rate option { _, rate, option = val + raise ParseError if option.modifier_after_one_and_a_half option.modifier_after_half ||= Arithmetic::Node::Number.new(0) modifier = option.modifier || Arithmetic::Node::Number.new(0) result = parsed(rate, modifier.eval(@round_type), option) } + | O H rate option + { + _, _, rate, option = val + raise ParseError if option.modifier_after_half + option.modifier_after_one_and_a_half ||= Arithmetic::Node::Number.new(0) + modifier = option.modifier || Arithmetic::Node::Number.new(0) + result = parsed(rate, modifier.eval(@round_type), option) + } rate: K NUMBER @@ -90,6 +99,22 @@ class RatingParser option.modifier_after_half = term result = option } + | option O H + { + option, _ = val + raise ParseError if option.modifier_after_one_and_a_half + + option.modifier_after_one_and_a_half = Arithmetic::Node::Number.new(0) + result = option + } + | option O H unary + { + option, _, term = val + raise ParseError if option.modifier_after_one_and_a_half + + option.modifier_after_one_and_a_half = term + result = option + } | option R unary { option, _, term = val @@ -214,7 +239,8 @@ def parsed(rate, modifier, option) p.semi_fixed_val = option.semi_fixed_val&.clamp(1, 6) || 0 p.tmp_fixed_val = option.tmp_fixed_val&.clamp(1, 6) || 0 p.modifier_after_half = option.modifier_after_half&.eval(@round_type) - p.critical = option.critical&.eval(@round_type)&.clamp(0, 13) || (p.half ? 13 : 10) + p.modifier_after_one_and_a_half = option.modifier_after_one_and_a_half&.eval(@round_type) + p.critical = option.critical&.eval(@round_type)&.clamp(0, 13) || (p.half || p.one_and_a_half ? 13 : 10) end end diff --git a/test/data/SwordWorld2_5.toml b/test/data/SwordWorld2_5.toml index 952c9593e..4061f164a 100644 --- a/test/data/SwordWorld2_5.toml +++ b/test/data/SwordWorld2_5.toml @@ -416,6 +416,95 @@ rands = [ { sides = 6, value = 1 }, ] +[[ test ]] +game_system = "SwordWorld2.5" +input = "OHk10 OHKのクリティカル値は13" +output = "KeyNo.10 > 2D:[6,6]=12 > 7*1.5 > 11" +rands = [ + { sides = 6, value = 6 }, + { sides = 6, value = 6 }, +] + +[[ test ]] +game_system = "SwordWorld2.5" +input = "k10oh" +output = "KeyNo.10 > 2D:[6,6]=12 > 7*1.5 > 11" +rands = [ + { sides = 6, value = 6 }, + { sides = 6, value = 6 }, +] + +[[ test ]] +game_system = "SwordWorld2.5" +input = "ohk10oh" +output = "KeyNo.10 > 2D:[6,6]=12 > 7*1.5 > 11" +rands = [ + { sides = 6, value = 6 }, + { sides = 6, value = 6 }, +] + +[[ test ]] +game_system = "SwordWorld2.5" +input = "ohk10[9]+10" +output = "KeyNo.10c[9]+10 > 2D:[5,3]=8 > (4+10)*1.5 > 21" +rands = [ + { sides = 6, value = 5 }, + { sides = 6, value = 3 }, +] + +[[ test ]] +game_system = "SwordWorld2.5" +input = "ohk10[9]+10 切り上げ" +output = "KeyNo.10c[9]+10 > 2D:[2,4]=6 > (3+10)*1.5 > 20" +rands = [ + { sides = 6, value = 2 }, + { sides = 6, value = 4 }, +] + +[[ test ]] +game_system = "SwordWorld2.5" +input = "OHK20+6@4" +output = "KeyNo.20c[4]+6 > 2D:[4,3 2,5 2,6 1,1]=7,7,8,2 > (5,5,6,**+6)*1.5 > 3回転 > 33" +critical = true +rands = [ + { sides = 6, value = 4 }, + { sides = 6, value = 3 }, + { sides = 6, value = 2 }, + { sides = 6, value = 5 }, + { sides = 6, value = 2 }, + { sides = 6, value = 6 }, + { sides = 6, value = 1 }, + { sides = 6, value = 1 }, +] + +[[ test ]] +game_system = "SwordWorld2.5" +input = "K20+6@4oh" +output = "KeyNo.20c[4]+6 > 2D:[4,3 2,5 2,6 1,1]=7,7,8,2 > (5,5,6,**+6)*1.5 > 3回転 > 33" +critical = true +rands = [ + { sides = 6, value = 4 }, + { sides = 6, value = 3 }, + { sides = 6, value = 2 }, + { sides = 6, value = 5 }, + { sides = 6, value = 2 }, + { sides = 6, value = 6 }, + { sides = 6, value = 1 }, + { sides = 6, value = 1 }, +] + +[[ test ]] +game_system = "SwordWorld2.5" +input = "hk10oh" +output = "" +rands = [] + +[[ test ]] +game_system = "SwordWorld2.5" +input = "ohk10h" +output = "" +rands = [] + [[ test ]] game_system = "SwordWorld2.5" input = "k20sf4 sf通常時"