Skip to content

Commit

Permalink
[Revulture] 【アタック判定】のダイス数が 0 となる場合はメッセージにそれを明示する
Browse files Browse the repository at this point in the history
  • Loading branch information
ViVi committed Apr 21, 2021
1 parent 86e0cdb commit 9613d18
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/bcdice/game_system/Revulture.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,13 @@ def eval_game_system_specific_command(command)

def roll_attack(dice_count_expression, border_expression, additional_damage_rules)
dice_count = Arithmetic.eval(dice_count_expression, round_type: RoundType::FLOOR)
raise if dice_count < 1

border = border_expression.nil? ? nil : Arithmetic.eval(border_expression, round_type: RoundType::FLOOR).clamp(1, 6)

dices = @randomizer.roll_barabara(dice_count, 6).sort
dices = dice_count > 0 ? @randomizer.roll_barabara(dice_count, 6).sort : []
critical_hit_count = dices.count { |dice| dice == 1 }
hit_count = border.nil? ? nil : dices.count { |dice| dice <= border.to_i } + critical_hit_count
damage = additional_damage_rules.nil? ? nil : hit_count.to_i
hit_count = dices.empty? || border.nil? ? nil : dices.count { |dice| dice <= border.to_i } + critical_hit_count
damage = dices.empty? || additional_damage_rules.nil? ? nil : hit_count.to_i

if !damage.nil? && !additional_damage_rules.nil?
self.class.parse_additional_damage_rules(additional_damage_rules).each do |rule|
Expand All @@ -68,7 +67,8 @@ def roll_attack(dice_count_expression, border_expression, additional_damage_rule

message_elements = []
message_elements << self.class.make_command_text(dice_count, border, additional_damage_rules)
message_elements << dices.join(',')
message_elements << dices.join(',') unless dices.empty?
message_elements << 'ダイス数が 0 です' if dices.empty?
message_elements << "クリティカル #{critical_hit_count}" if critical_hit_count > 0
message_elements << "ヒット数 #{hit_count}" unless hit_count.nil?
message_elements << "ダメージ #{damage}" unless damage.nil?
Expand Down
30 changes: 30 additions & 0 deletions test/data/Revulture.toml
Original file line number Diff line number Diff line change
Expand Up @@ -427,3 +427,33 @@ rands = [
{ sides = 6, value = 5 },
{ sides = 6, value = 4 },
]

[[ test ]]
game_system = "Revulture"
input = "0at"
output = "(0attack) > ダイス数が 0 です"
rands = []

[[ test ]]
game_system = "Revulture"
input = "1/2at"
output = "(0attack) > ダイス数が 0 です"
rands = []

[[ test ]]
game_system = "Revulture"
input = "0at<=3"
output = "(0attack<=3) > ダイス数が 0 です"
rands = []

[[ test ]]
game_system = "Revulture"
input = "0at[>=2:+3]"
output = "(0attack[>=2:+3]) > ダイス数が 0 です"
rands = []

[[ test ]]
game_system = "Revulture"
input = "0at<=3[>=2:+3]"
output = "(0attack<=3[>=2:+3]) > ダイス数が 0 です"
rands = []

0 comments on commit 9613d18

Please sign in to comment.