Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TorgEternity]高揚(UP)コマンドに修正値指定が出来るように拡張 #580

Merged
merged 3 commits into from
Nov 12, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
50 changes: 43 additions & 7 deletions lib/bcdice/game_system/TorgEternity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ class TorgEternity < Base
  振り足しを自動で行い、20の出目が出たときには技能無し値も並記します。
  出目1の時には「Mishap! 自動失敗!」と出力されます。
 ・UP
  "UP"で高揚状態のロール(通常の1d20に加え、1d20を追加で振り足し)を行います。
  "UP[m]"で高揚状態のロール(通常の1d20に加え、1d20を追加で振り足し)を行います。
ysakasin marked this conversation as resolved.
Show resolved Hide resolved
  mは技能基本値を入れて下さい。
  各ロールでの振り足しを自動で行い、20の出目が出たときには技能無し値も並記します。
  一投目で出目1の時には「Mishap! 自動失敗!」と出力され、二投目は行われません。
 ・POS
Expand Down Expand Up @@ -123,27 +124,62 @@ def getRolld20DiceCommandResult(command)
# ロールコマンド (高揚ロール)
def getUpRollDiceCommandResult(command)
debug("Torg Eternity Dice Roll ( UP ) Command ? ", command)
m = /(^|\s)(S)?(UP)$/i.match(command)
m = /(^|\s)(S)?(UP)(\d*)(\s|$)/i.match(command)
unless m
return nil
end

sequence = []
mod = m[4].to_i
skilled1, unskilled1, dice_str1, mishap = torg_eternity_dice(false, true)
if mishap == 1
output = "d20ロール(高揚) > 1d20[#{dice_str1}] > Mishap! 絶対失敗!"
sequence = [
"d20ロール(高揚)",
"1d20[#{dice_str1}]",
"Mishap! 絶対失敗!",
].compact
else
skilled2, unskilled2, dice_str2, = torg_eternity_dice(false, false)
subtotal_skilled = skilled1 + skilled2
subtotal_unskilled = unskilled1 + unskilled2
value_skilled = format("%+d", get_torg_eternity_bonus(subtotal_skilled))
if subtotal_skilled != subtotal_unskilled
value_unskilled = format("%+d", get_torg_eternity_bonus(subtotal_unskilled))
output = "d20ロール(高揚) > 1d20[#{dice_str1}] + 1d20[#{dice_str2}] > #{value_skilled}[#{subtotal_skilled}](技能有) / #{value_unskilled}[#{subtotal_unskilled}](技能無)"
value_unskilled = format("%+d", get_torg_eternity_bonus(subtotal_unskilled))

if mod <= 0
if subtotal_skilled != subtotal_unskilled
sequence = [
"d20ロール(高揚)",
"1d20[#{dice_str1}] + 1d20[#{dice_str2}]",
"#{value_skilled}[#{subtotal_skilled}](技能有) / #{value_unskilled}[#{subtotal_unskilled}](技能無)",
].compact
else
sequence = [
"d20ロール(高揚)",
"1d20[#{dice_str1}] + 1d20[#{dice_str2}]",
"#{value_skilled}[#{subtotal_skilled}]",
].compact
end
else
output = "d20ロール(高揚) > 1d20[#{dice_str1}] + 1d20[#{dice_str2}] > #{value_skilled}[#{subtotal_skilled}]"
if subtotal_skilled != subtotal_unskilled
sequence = [
"d20ロール(高揚)",
"1d20[#{dice_str1}] + 1d20[#{dice_str2}] + #{mod}",
"#{value_skilled}[#{subtotal_skilled}]+#{mod}(技能有) / #{value_unskilled}[#{subtotal_unskilled}]+#{mod}(技能無)",
format("%+d", (value_skilled.to_i + mod)) + "(技能有) / " + format("%+d", (value_unskilled.to_i + mod)) + "(技能無)",
].compact
else
sequence = [
"d20ロール(高揚)",
"1d20[#{dice_str1}] + 1d20[#{dice_str2}] + #{mod}",
"#{value_skilled}[#{subtotal_skilled}]+#{mod}",
format("%+d", (value_skilled.to_i + mod)),
].compact
end
end
end

output = sequence.join(" > ")

return output
end

Expand Down
29 changes: 29 additions & 0 deletions test/data/TorgEternity.toml
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,35 @@ rands = [
{ sides = 20, value = 1 },
]

[[ test ]]
game_system = "TorgEternity"
input = "UP10 #高揚修正付き"
output = "d20ロール(高揚) > 1d20[5] + 1d20[10,20,11] + 10 > +13[46]+10(技能有) / +10[35]+10(技能無) > +23(技能有) / +20(技能無)"
rands = [
{ sides = 20, value = 5 },
{ sides = 20, value = 10 },
{ sides = 20, value = 20 },
{ sides = 20, value = 11 },
]

[[ test ]]
game_system = "TorgEternity"
input = "UP10 #高揚修正付き"
output = "d20ロール(高揚) > 1d20[17] + 1d20[1] + 10 > +5[18]+10 > +15"
rands = [
{ sides = 20, value = 17 },
{ sides = 20, value = 1 },
]

[[ test ]]
game_system = "TorgEternity"
input = "UP3 #高揚修正付き"
output = "d20ロール(高揚) > 1d20[2] + 1d20[1] + 3 > -6[3]+3 > -3"
rands = [
{ sides = 20, value = 2 },
{ sides = 20, value = 1 },
]

[[ test ]]
game_system = "TorgEternity"
input = "UP1+2+3"
Expand Down