Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion lib/bcdice/game_system/SwordWorld.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,11 @@ def rating(string) # レーティング表

currentKey = (command.rate + round * command.rateup).clamp(0, keyMax)
debug("currentKey", currentKey)
rateValue = newRates[dice][currentKey]
if dice > command.set_zero_val
rateValue = newRates[dice][currentKey]
else
rateValue = 0
end
debug("rateValue", rateValue)

totalValue += rateValue
Expand Down Expand Up @@ -343,6 +347,11 @@ def getResultText(rating_total, command, diceResults, diceResultTotals,
if command.modifier_after_one_and_a_half != 0
text += Format.modifier(command.modifier_after_one_and_a_half)
end
elsif command.double
text = "(#{text})*2"
if command.modifier_after_double != 0
text += Format.modifier(command.modifier_after_double)
end
end
sequence.push(text)
elsif command.half
Expand All @@ -357,6 +366,12 @@ def getResultText(rating_total, command, diceResults, diceResultTotals,
text += Format.modifier(command.modifier_after_one_and_a_half)
end
sequence.push(text)
elsif command.double
text = "#{rateResults.first}*2"
if command.modifier_after_double != 0
text += Format.modifier(command.modifier_after_double)
end
sequence.push(text)
end

if round > 1
Expand All @@ -375,6 +390,11 @@ def getResultText(rating_total, command, diceResults, diceResultTotals,
if command.modifier_after_one_and_a_half != 0
total += command.modifier_after_one_and_a_half
end
elsif command.double
total = (total * 2).ceil
if command.modifier_after_double != 0
total += command.modifier_after_double
end
end

total_text = total.to_s
Expand Down
16 changes: 13 additions & 3 deletions lib/bcdice/game_system/SwordWorld2_5.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,25 @@ class SwordWorld2_5 < SwordWorld2_0

・レーティング表の半減 (HKx, KxH+N)
 レーティング表の先頭または末尾に"H"をつけると、レーティング表を振って最終結果を半減させます。
 末尾につけた場合、直後に修正ををつけることで、半減後の加減算を行うことができます。
 末尾につけた場合、直後に修正をつけることで、半減後の加減算を行うことができます。
 この際、複数の項による修正にはカッコで囲うことが必要です(カッコがないとパースに失敗します)
 クリティカル値を指定しない場合、クリティカルなしと扱われます。
 例)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倍後の加減算を行うことができます。
 末尾につけた場合、直後に修正をつけることで、1.5倍後の加減算を行うことができます。
 この際、複数の項による修正にはカッコで囲うことが必要です(カッコがないとパースに失敗します)
 クリティカル値を指定しない場合、クリティカルなしと扱われます。
 例)OHK20  K20oh  OHK10-5@9  K20+8OH+2  K20+8OH+(1+1)

・レーティング表の2倍 (DBKx, KxDB+N)
 レーティング表の先頭または末尾に"DB"をつけると、レーティング表を振って最終結果を2倍します。
 末尾につけた場合、直後に修正をつけることで、2倍後の加減算を行うことができます。
 この際、複数の項による修正にはカッコで囲うことが必要です(カッコがないとパースに失敗します)
 クリティカル値を指定しない場合、クリティカル値10と扱われます。
 例)DBK20  K20db  DBK10-5@9  K20+8DB+2  K20+8DB+(1+1)

・ダイス目の修正(運命変転やクリティカルレイ、魔女の火用)
 末尾に「$修正値」でダイス目に修正がかかります。
 $+1と修正表記ならダイス目に+修正、$9のように固定値ならダイス目をその出目に差し替え。
Expand All @@ -70,6 +77,9 @@ class SwordWorld2_5 < SwordWorld2_0
・威力表を1d+tfで参照 クリティカル後は2dで参照 tf3
 例)k10tf3 k0+5tf4@13 k70+26tf3@9

・アビスカース「難しい」用に KxSZy 表記でy以下の出目の威力表を0に書き換え。
 例) k10SZ4 k0+5@13sz6 k40+26@9sz3

・超越判定用に2d6ロールに 2D6@10 書式でクリティカル値付与が可能に。
 例)2D6@10 2D6@10+11>=30

Expand All @@ -90,7 +100,7 @@ class SwordWorld2_5 < SwordWorld2_0
 アビスカース表を出すことができます。
INFO_MESSAGE_TEXT

register_prefix('H?K', 'OHK', 'Gr', '2D6?@\d+', 'FT', 'TT', 'Dru', 'ABT')
register_prefix('H?K', 'OHK', 'DBK', 'Gr', '2D6?@\d+', 'FT', 'TT', 'Dru', 'ABT')

def eval_game_system_specific_command(command)
case command
Expand Down
6 changes: 6 additions & 0 deletions lib/bcdice/game_system/sword_world/rating_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ class RatingOptions
# @return [Integer, nil]
attr_accessor :tmp_fixed_val

# @return [Integer, nil]
attr_accessor :set_zero_val

# @return [Integer, nil]
attr_accessor :modifier

Expand All @@ -40,6 +43,9 @@ class RatingOptions
# @return [Integer, nil]
attr_accessor :modifier_after_one_and_a_half

# @return [Integer, nil]
attr_accessor :modifier_after_double

def settable_first_roll_adjust_option?
return first_modify.nil? && first_to.nil? && first_modify_ssp.nil?
end
Expand Down
14 changes: 14 additions & 0 deletions lib/bcdice/game_system/sword_world/rating_parsed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ class RatingParsed
# @return [Integer]
attr_accessor :tmp_fixed_val

# @return [Integer]
attr_accessor :set_zero_val

# @return [Integer]
attr_accessor :modifier

Expand All @@ -43,6 +46,9 @@ class RatingParsed
# @return [Integer, nil]
attr_accessor :modifier_after_one_and_a_half

# @return [Integer, nil]
attr_accessor :modifier_after_double

def initialize(rate, modifier)
@rate = rate
@modifier = modifier
Expand All @@ -55,8 +61,10 @@ def initialize(rate, modifier)
@rateup = 0
@semi_fixed_val = 0
@tmp_fixed_val = 0
@set_zero_val = 0
@modifier_after_half = nil
@modifier_after_one_and_a_half = nil
@modifier_after_double = nil
end

# @return [Boolean]
Expand All @@ -69,6 +77,11 @@ def one_and_a_half
return !@modifier_after_one_and_a_half.nil?
end

# @return [Boolean]
def double
return !@modifier_after_double.nil?
end

# @return [Integer]
def min_critical
if @semi_fixed_val <= 1
Expand All @@ -95,6 +108,7 @@ def to_s()
output += "gf" if @greatest_fortune
output += "sf[#{semi_fixed_val}]" if semi_fixed_val != 0
output += "tf[#{tmp_fixed_val}]" if tmp_fixed_val != 0
output += "sz[#{set_zero_val}]" if set_zero_val != 0
output += "a[#{Format.modifier(kept_modify)}]" if kept_modify != 0

if @modifier != 0
Expand Down
40 changes: 37 additions & 3 deletions 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 TILDE
token NUMBER K R H O D B G F S T Z PLUS MINUS ASTERISK SLASH PARENL PARENR BRACKETL BRACKETR AT SHARP DOLLAR TILDE

expect 4

Expand All @@ -13,19 +13,27 @@ class RatingParser
| H rate option
{
_, rate, option = val
raise ParseError if option.modifier_after_one_and_a_half
raise ParseError if option.modifier_after_one_and_a_half or option.modifier_after_double
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
raise ParseError if option.modifier_after_half or option.modifier_after_double
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)
}
| D B rate option
{
_, _, rate, option = val
raise ParseError if option.modifier_after_half or option.modifier_after_one_and_a_half
option.modifier_after_double ||= Arithmetic::Node::Number.new(0)
modifier = option.modifier || Arithmetic::Node::Number.new(0)
result = parsed(rate, modifier.eval(@round_type), option)
}


rate: K NUMBER
Expand Down Expand Up @@ -123,6 +131,22 @@ class RatingParser
option.modifier_after_one_and_a_half = term
result = option
}
| option D B
{
option, _, _ = val
raise ParseError unless option.modifier_after_double.nil?

option.modifier_after_double = Arithmetic::Node::Number.new(0)
result = option
}
| option D B unary
{
option, _, _, term = val
raise ParseError unless option.modifier_after_double.nil?

option.modifier_after_double = term
result = option
}
| option R unary
{
option, _, term = val
Expand Down Expand Up @@ -155,6 +179,14 @@ class RatingParser
option.tmp_fixed_val = term.to_i
result = option
}
| option S Z NUMBER
{
option, _, _, term = val
raise ParseError unless [:v2_5].include?(@version)

option.set_zero_val = term.to_i
result = option
}
| option SHARP unary
{
option, _, term = val
Expand Down Expand Up @@ -247,8 +279,10 @@ def parsed(rate, modifier, option)
p.greatest_fortune = option.greatest_fortune if !option.greatest_fortune.nil?
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.set_zero_val = option.set_zero_val || 0
p.modifier_after_half = option.modifier_after_half&.eval(@round_type)
p.modifier_after_one_and_a_half = option.modifier_after_one_and_a_half&.eval(@round_type)
p.modifier_after_double = option.modifier_after_double&.eval(@round_type)
p.critical = option.critical&.eval(@round_type)&.clamp(0, 13) || (p.half || p.one_and_a_half ? 13 : 10)
end
end
Expand Down
Loading
Loading