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

[StellarKnights] 【アタック判定】のダイス数に 0 が指定された場合を考慮 #455

Merged
Merged
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
5 changes: 4 additions & 1 deletion lib/bcdice/game_system/StellarKnights.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,15 @@ def eval_game_system_specific_command(command)
# @param [Integer | nil] defence
# @param [String] dice_change_text
# @param [String] command
# @return [String]
# @return [Result, String]
def resolute_action(num_dices, defence, dice_change_text, command)
dices = @randomizer.roll_barabara(num_dices, 6).sort
dice_text = dices.join(",")

output = "(#{command}) > #{dice_text}"
if dices.empty?
return output + "ダイスが 0 個です(アタック判定が発生しません)"
end

# FAQによると、ダイスの置き換えは宣言された順番に適用されていく
dice_change_rules = parse_dice_change_rules(dice_change_text)
Expand Down
24 changes: 24 additions & 0 deletions test/data/StellarKnights.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ rands = [
{ sides = 6, value = 4 },
]

[[ test ]]
game_system = "StellarKnights"
input = "0SK"
output = "(0SK) > ダイスが 0 個です(アタック判定が発生しません)"
rands = []

[[ test ]]
game_system = "StellarKnights"
input = "5SK3"
Expand All @@ -33,6 +39,12 @@ rands = [
{ sides = 6, value = 2 },
]

[[ test ]]
game_system = "StellarKnights"
input = "0SK6"
output = "(0SK6) > ダイスが 0 個です(アタック判定が発生しません)"
rands = []

[[ test ]]
game_system = "StellarKnights"
input = "3SK,1>6"
Expand Down Expand Up @@ -71,6 +83,18 @@ rands = [
{ sides = 6, value = 6 },
]

[[ test ]]
game_system = "StellarKnights"
input = "0SK,1>6"
output = "(0SK,1>6) > ダイスが 0 個です(アタック判定が発生しません)"
rands = []

[[ test ]]
game_system = "StellarKnights"
input = "0SK4,1>6"
output = "(0SK4,1>6) > ダイスが 0 個です(アタック判定が発生しません)"
rands = []

[[ test ]]
game_system = "StellarKnights"
input = "TT"
Expand Down