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

NinjaSlayer: repeatコマンド使用時のバグを修正する #469

Merged
merged 2 commits into from
May 25, 2021
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
4 changes: 2 additions & 2 deletions lib/bcdice/common_command/barabara_dice/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def eval(game_system, randomizer)
Result.new.tap do |r|
r.secret = @secret
r.text = sequence.join(" > ")
r.rands = randomizer.rand_results
r.detailed_rands = randomizer.detailed_rand_results
r.last_dice_list_list = dice_list_list
r.last_dice_list = dice_list
r.success_num = success_num
end
end
Expand Down
6 changes: 6 additions & 0 deletions lib/bcdice/common_command/barabara_dice/result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@ module CommonCommand
module BarabaraDice
# バラバラロールの結果を表すクラス
class Result < ::BCDice::Result
# @return [Array<Array<Integer>>] 出目のグループの配列
attr_accessor :last_dice_list_list
# @return [Array<Integer>] すべての出目が格納される配列
attr_accessor :last_dice_list
# @return [Integer] 成功数
attr_accessor :success_num

# @param text [String, nil] 結果の文章
def initialize(text = nil)
super(text)

@last_dice_list_list = []
@last_dice_list = []
@success_num = 0
end
end
Expand Down
5 changes: 2 additions & 3 deletions lib/bcdice/game_system/NinjaSlayer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,7 @@ def executeAT(at)
command = bRollCommand(at.num, at.difficulty)
roll_result = BCDice::CommonCommand::BarabaraDice.eval(command, self, @randomizer)

values = roll_result.rands.map { |v, _| v }
num_of_max_values = values.count(6)
num_of_max_values = roll_result.last_dice_list.count(6)

parts = [roll_result.text]

Expand All @@ -195,7 +194,7 @@ def executeEL(el)
command = bRollCommand(el.num, el.difficulty)
roll_result = BCDice::CommonCommand::BarabaraDice.eval(command, self, @randomizer)

values = roll_result.rands.map { |v, _| v }
values = roll_result.last_dice_list
num_of_max_values = values.count(6)
sum_of_true_values = values.count { |v| v >= el.difficulty }

Expand Down
68 changes: 68 additions & 0 deletions test/data/NinjaSlayer.toml
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,17 @@ rands = [
{ sides = 6, value = 6 },
]

[[ test ]]
game_system = "NinjaSlayer"
input = "AT4"
output = "(4B6>=4) > 1,1,1,1 > 成功数0"
rands = [
{ sides = 6, value = 1 },
{ sides = 6, value = 1 },
{ sides = 6, value = 1 },
{ sides = 6, value = 1 },
]

[[ test ]]
game_system = "NinjaSlayer"
input = "AT4"
Expand All @@ -384,6 +395,29 @@ rands = [
{ sides = 6, value = 6 },
]

[[ test ]]
game_system = "NinjaSlayer"
input = "x2 AT4 繰り返し実行で蓄積した出目を用いて判断しない"
output = """
#1
(4B6>=4) > 2,2,6,6 > 成功数2 > サツバツ!!

#2
(4B6>=4) > 1,1,1,1 > 成功数0"""
rands = [
# 1回目
{ sides = 6, value = 2 },
{ sides = 6, value = 2 },
{ sides = 6, value = 6 },
{ sides = 6, value = 6 },

# 2回目
{ sides = 6, value = 1 },
{ sides = 6, value = 1 },
{ sides = 6, value = 1 },
{ sides = 6, value = 1 },
]

[[ test ]]
game_system = "NinjaSlayer"
input = "AT4[n]"
Expand Down Expand Up @@ -461,6 +495,17 @@ rands = [
{ sides = 6, value = 6 },
]

[[ test ]]
game_system = "NinjaSlayer"
input = "EL4"
output = "(4B6>=4) > 1,1,1,1 > 成功数0"
rands = [
{ sides = 6, value = 1 },
{ sides = 6, value = 1 },
{ sides = 6, value = 1 },
{ sides = 6, value = 1 },
]

[[ test ]]
game_system = "NinjaSlayer"
input = "EL4"
Expand All @@ -472,6 +517,29 @@ rands = [
{ sides = 6, value = 6 },
]

[[ test ]]
game_system = "NinjaSlayer"
input = "x2 EL4 繰り返し実行で蓄積した出目を用いて判断しない"
output = """
#1
(4B6>=4) > 2,2,2,6 > 成功数1 + 1 > 2

#2
(4B6>=4) > 1,1,1,1 > 成功数0"""
rands = [
# 1回目
{ sides = 6, value = 2 },
{ sides = 6, value = 2 },
{ sides = 6, value = 2 },
{ sides = 6, value = 6 },

# 2回目
{ sides = 6, value = 1 },
{ sides = 6, value = 1 },
{ sides = 6, value = 1 },
{ sides = 6, value = 1 },
]

[[ test ]]
game_system = "NinjaSlayer"
input = "EL4[n]"
Expand Down