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

[Emoklore] クリティカル・ダイスの処理を修正 #654

Merged
merged 1 commit into from
Nov 28, 2023
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
10 changes: 4 additions & 6 deletions lib/bcdice/game_system/Emoklore.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,12 @@ def eval_game_system_specific_command(command)
def dice_roll(num_dice, success_threshold)
# ダイスを振った結果を配列として取得
values = @randomizer.roll_barabara(num_dice, 10)
values_without_critical = values.reject { |num| num <= CRITICAL_VALUE }

critical = values.size - values_without_critical.size
success = values_without_critical.count { |num| num <= success_threshold }
fumble = values_without_critical.count { |num| num >= FUMBLE_VALUE }
critical = values.count(CRITICAL_VALUE)
success = values.count { |num| num <= success_threshold }
fumble = values.count(FUMBLE_VALUE)

# 成功値
success_value = 2 * critical + success - fumble
success_value = critical + success - fumble
result = compare_result(success_value)

result.text = "#{values} > #{success_value} > #{translate('Emoklore.success_count', count: success_value)} #{result.text}"
Expand Down
18 changes: 18 additions & 0 deletions test/data/Emoklore.toml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,24 @@ rands = [
{ sides = 10, value = 8 },
]

[[ test ]]
game_system = "Emoklore"
input = "1DM<=0"
output = "(1DM<=0) > [1] > 1 > 成功数1 成功"
success = true
rands = [
{ sides = 10, value = 1 },
]

[[ test ]]
game_system = "Emoklore"
input = "1DM<=10"
output = "(1DM<=10) > [10] > 0 > 成功数0 失敗"
failure = true
rands = [
{ sides = 10, value = 10 },
]

[[ test ]]
game_system = "Emoklore"
input = "2DA3"
Expand Down
Loading