Skip to content

Commit

Permalink
Merge pull request #699 from h-mikisato/feature/convictor_drive_defau…
Browse files Browse the repository at this point in the history
…lt_target

[ConvictorDrive] 目標値のデフォルト値を5とする
  • Loading branch information
ysakasin authored May 9, 2024
2 parents 667ae36 + a850beb commit e75588c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
9 changes: 5 additions & 4 deletions lib/bcdice/game_system/ConvictorDrive.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ConvictorDrive < Base

# ダイスボットの使い方
HELP_MESSAGE = <<~MESSAGETEXT
xCD@z>=y: x個の10面ダイスで目標値y、クリティカルラインzの判定を行う
xCD@z>=y: x個の10面ダイスで目標値y(省略時5)、クリティカルラインz(省略時10)の判定を行う。
SLT: 技能レベル表を振る
DCT: 遅延イベント表を振る
MESSAGETEXT
Expand Down Expand Up @@ -87,16 +87,17 @@ def roll_command(command)
parser = Command::Parser.new('CD', round_type: round_type)
.has_prefix_number
.enable_critical
.restrict_cmp_op_to(:>=)
.restrict_cmp_op_to(:>=, nil)
cmd = parser.parse(command)

unless cmd
return nil
end

dice_list = @randomizer.roll_barabara(cmd.prefix_number, 10)
critical = cmd.critical&.clamp(cmd.target_number, 10) || 10
succeed_num = dice_list.count { |x| x >= cmd.target_number }
target_num = cmd.target_number || 5
critical = cmd.critical&.clamp(target_num, 10) || 10
succeed_num = dice_list.count { |x| x >= target_num }
critical_num = dice_list.count { |x| x >= critical }

text = [
Expand Down
13 changes: 12 additions & 1 deletion test/data/ConvictorDrive.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,18 @@ rands = [
{ sides = 10, value = 6 },
]

[[ test ]]
game_system = "ConvictorDrive"
input = "4CD デフォルトの目標は5"
output = "4CD > 4,6,5,1 > 成功数2"
success = true
rands = [
{ sides = 10, value = 4 },
{ sides = 10, value = 6 },
{ sides = 10, value = 5 },
{ sides = 10, value = 1 },
]

[[ test ]]
game_system = "ConvictorDrive"
input = "SLT"
Expand Down Expand Up @@ -99,4 +111,3 @@ output = "遅延イベント表(9) > 緊急出撃Ⅲ(ランダムなPC2人
rands = [
{ sides = 10, value = 9 },
]

0 comments on commit e75588c

Please sign in to comment.