Skip to content

[Aionia]慈悲なきアイオニアのダイスボット改善#835

Merged
ysakasin merged 3 commits intobcdice:masterfrom
8409jp:feature/aionia-improvement
Feb 23, 2026
Merged

[Aionia]慈悲なきアイオニアのダイスボット改善#835
ysakasin merged 3 commits intobcdice:masterfrom
8409jp:feature/aionia-improvement

Conversation

@8409jp
Copy link
Copy Markdown
Contributor

@8409jp 8409jp commented Feb 20, 2026

慈悲なきアイオニアのダイスボットを改善しました。

変更内容

  1. AB(T)コマンドの修正値計算の改善
  2. DMGコマンドの新規追加
  3. 改善・追加に伴うテストコードの追加

備考

以下のコマンドのpassを確認しています。
bundle exec rubocop -a
bundle exec rake test

Copy link
Copy Markdown
Member

@ysakasin ysakasin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

寄稿ありがとうございます。気になるところが何点かあったので、修正をおねがいします。

Comment thread lib/bcdice/game_system/Aionia.rb Outdated
INFO_MESSAGE_TEXT

register_prefix('ABT?\d+([\+\-]\d+)?>=\d+(\/\d+)*')
register_prefix('ABT?\d+.*', 'DMG.*')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
register_prefix('ABT?\d+.*', 'DMG.*')
register_prefix('ABT?', 'DMG')

先頭一致のみ指定すれば良いので、 .*は不要です。

Comment thread lib/bcdice/game_system/Aionia.rb Outdated
Comment on lines 37 to 41
if command.start_with?('DMG')
return roll_damage_check(command)
end

return roll_skills(command)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if command.start_with?('DMG')
return roll_damage_check(command)
end
return roll_skills(command)
return roll_skills(command) || roll_damage_check(command)

Comment thread lib/bcdice/game_system/Aionia.rb Outdated
targets = m[4].split('/').map(&:to_i)

# 値の計算
bonus = Arithmetic.eval(m[3] == '' ? '0' : m[3], RoundType::FLOOR)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bonus = Arithmetic.eval(m[3] == '' ? '0' : m[3], RoundType::FLOOR)
bonus = m[3] != '' ? Arithmetic.eval(m[3], RoundType::FLOOR) : 0

文字列 '0' をパースしてもあまりうれしくないので、パース後の値をそのまま指定するようにした方がよさそうです。

Comment thread lib/bcdice/game_system/Aionia.rb Outdated
return nil unless bonus

base_targets = m[4].split('/').map(&:to_i)
target_bonus = Arithmetic.eval(m[5] == '' ? '0' : m[5], RoundType::FLOOR)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
target_bonus = Arithmetic.eval(m[5] == '' ? '0' : m[5], RoundType::FLOOR)
target_bonus = m[5] != '' ? Arithmetic.eval(m[5], RoundType::FLOOR) : 0

Comment thread lib/bcdice/game_system/Aionia.rb Outdated
end

def roll_damage_check(command)
m = /^DMG>=(.+)$/.match(command)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

このようなシンプルなコマンドであれば、 Command::Parser を使ってパースする方良さそうです。その方がよくある処理を書かずにすみます。

@8409jp
Copy link
Copy Markdown
Contributor Author

8409jp commented Feb 21, 2026

@ysakasin

寄稿ありがとうございます。気になるところが何点かあったので、修正をおねがいします。

レビューありがとうございます。
suggestionの適用を以下のコミットで行いました。ご確認よろしくお願いいたします。
3a79ffe

Comment thread lib/bcdice/game_system/Aionia.rb Outdated
end

def roll_damage_check(command)
parser = Command::Parser.new("DMG", round_type: BCDice::RoundType::FLOOR)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

このままだと、比較の記号が指定されていないため、>= 意外の記号でもパースが通過されてしまいます。BCDice::Command::Parser#restrict_cmp_op_to を使って >= のみ受け付けるようにしてください。

例:

parser = Command::Parser.new(/CD[A-E1-5]/, round_type: @round_type).disable_modifier.restrict_cmp_op_to(:>=)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

失礼いたしました。
以下のコミットで修正いたしました。合わせてテストも追加しております。
99e10c7

@ysakasin ysakasin merged commit 58077cf into bcdice:master Feb 23, 2026
8 checks passed
@ysakasin
Copy link
Copy Markdown
Member

ありがとうございます。マージしました。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants