Skip to content

Commit

Permalink
[StellarKnights] 【アタック判定】のダイス数に 0 が指定された場合を考慮 (#455)
Browse files Browse the repository at this point in the history
* [StellarKnights] ダイス数に 0 が指定された場合を考慮

従来は結果文字列が `"(0SK) > "` のようになって、不自然かつ不親切だったので。

* [StellarKnights] アタック判定のダイス数が 0 なら、成功数を表示しない

* [StellarKnights] アタック判定のダイス数が 0 のときのメッセージをより具体的に

* [StellarKnights] 早期リターン

Co-authored-by: ViVi <[email protected]>
Co-authored-by: SAKATA Sinji <[email protected]>
  • Loading branch information
3 people authored May 12, 2021
1 parent 1609f8a commit ff0cc55
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
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 @@ -81,6 +93,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

0 comments on commit ff0cc55

Please sign in to comment.