Skip to content

Commit

Permalink
[SW2.5] バーバヤガーの魔女の火を実装
Browse files Browse the repository at this point in the history
記法はゆとチャadv.の記法を輸入
  • Loading branch information
h-mikisato committed Oct 18, 2024
1 parent de290c6 commit 5de89ab
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 2 deletions.
4 changes: 4 additions & 0 deletions lib/bcdice/game_system/SwordWorld.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def rating(string) # レーティング表
round = 0
first_to = command.first_to
first_modify = command.first_modify
first_modify_ssp = command.first_modify_ssp

loop do
dice_raw, diceText = rollDice(command, round)
Expand All @@ -96,6 +97,9 @@ def rating(string) # レーティング表
elsif first_modify != 0
dice += first_modify
first_modify = 0
elsif first_modify_ssp != 0
dice += first_modify_ssp if dice_raw <= 10
first_modify_ssp = 0
end

# 出目がピンゾロの時にはそこで終了
Expand Down
1 change: 1 addition & 0 deletions lib/bcdice/game_system/sword_world/rating_lexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class RatingLexer
"@" => :AT,
"#" => :SHARP,
"$" => :DOLLAR,
"~" => :TILDE,
}.freeze

def initialize(source)
Expand Down
5 changes: 4 additions & 1 deletion lib/bcdice/game_system/sword_world/rating_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ class RatingOptions
# @return [Integer, nil]
attr_accessor :first_modify

# @return [Integer, nil]
attr_accessor :first_modify_ssp

# @return [Integer, nil]
attr_accessor :rateup

Expand All @@ -38,7 +41,7 @@ class RatingOptions
attr_accessor :modifier_after_one_and_a_half

def settable_first_roll_adjust_option?
return first_modify.nil? && first_to.nil?
return first_modify.nil? && first_to.nil? && first_modify_ssp.nil?
end

def settable_non_2d_roll_option?
Expand Down
5 changes: 5 additions & 0 deletions lib/bcdice/game_system/sword_world/rating_parsed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ class RatingParsed
# @return [Integer]
attr_accessor :first_modify

# @return [Integer]
attr_accessor :first_modify_ssp

# @return [Integer]
attr_accessor :rateup

Expand Down Expand Up @@ -47,6 +50,7 @@ def initialize(rate, modifier)
@kept_modify = 0
@first_to = 0
@first_modify = 0
@first_modify_ssp = 0
@greatest_fortune = false
@rateup = 0
@semi_fixed_val = 0
Expand Down Expand Up @@ -85,6 +89,7 @@ def to_s()

output += "c[#{critical}]" if critical < 13
output += "m[#{Format.modifier(first_modify)}]" if first_modify != 0
output += "m[~#{Format.modifier(first_modify_ssp)}]" if first_modify_ssp != 0
output += "m[#{first_to}]" if first_to != 0
output += "r[#{rateup}]" if rateup != 0
output += "gf" if @greatest_fortune
Expand Down
11 changes: 10 additions & 1 deletion lib/bcdice/game_system/sword_world/rating_parser.y
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class RatingParser
token NUMBER K R H O 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 TILDE

expect 4

Expand Down Expand Up @@ -83,6 +83,14 @@ class RatingParser
option.first_modify = -(term.to_i)
result = option
}
| option DOLLAR TILDE PLUS NUMBER
{
option, _, _, _, term = val
raise ParseError unless @version == :v2_5 && option.settable_first_roll_adjust_option?

option.first_modify_ssp = term.to_i
result = option
}
| option H
{
option, _ = val
Expand Down Expand Up @@ -234,6 +242,7 @@ def parsed(rate, modifier, option)
p.kept_modify = option.kept_modify&.eval(@round_type) || 0
p.first_to = option.first_to || 0
p.first_modify = option.first_modify || 0
p.first_modify_ssp = option.first_modify_ssp || 0
p.rateup = option.rateup&.eval(@round_type) || 0
p.greatest_fortune = option.greatest_fortune if !option.greatest_fortune.nil?
p.semi_fixed_val = option.semi_fixed_val&.clamp(1, 6) || 0
Expand Down
33 changes: 33 additions & 0 deletions test/data/SwordWorld2_5.toml
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,39 @@ rands = [
{ sides = 6, value = 2 },
]

[[ test ]]
game_system = "SwordWorld2.5"
input = "k10$~+1+6"
output = "KeyNo.10c[10]m[~+1]+6 > 2D:[4,3]=8 > 4+6 > 10"
rands = [
{ sides = 6, value = 4 },
{ sides = 6, value = 3 },
]

[[ test ]]
game_system = "SwordWorld2.5"
input = "k10$~+1+6"
output = "KeyNo.10c[10]m[~+1]+6 > 2D:[4,5 2,3]=10,5 > 5,2+6 > 1回転 > 13"
critical = true
rands = [
{ sides = 6, value = 4 },
{ sides = 6, value = 5 },
{ sides = 6, value = 2 },
{ sides = 6, value = 3 },
]

[[ test ]]
game_system = "SwordWorld2.5"
input = "k10$~+1+6"
output = "KeyNo.10c[10]m[~+1]+6 > 2D:[6,5 4,5]=11,9 > 6,5+6 > 1回転 > 17"
critical = true
rands = [
{ sides = 6, value = 6 },
{ sides = 6, value = 5 },
{ sides = 6, value = 4 },
{ sides = 6, value = 5 },
]

[[ test ]]
game_system = "SwordWorld2.5"
input = "hk10 HKのクリティカル値は13"
Expand Down

0 comments on commit 5de89ab

Please sign in to comment.