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

Conversation

ochaochaocha3
Copy link
Member

ニンジャスレイヤーTRPGの ATEL コマンドに存在した、repeat コマンドで繰り返し実行した場合のバグを修正しました。

症状

これまで repeat コマンドで繰り返し実行した場合に、後の方の回で出目が悪い場合でも、意図せず「サツバツ!」等が表示される場合がありました。

原因

roll_result = BCDice::CommonCommand::BarabaraDice.eval(command, self, @randomizer)
values = roll_result.rands.map { |v, _| v }

上記の部分で、複数回の実行で蓄積された出目を取り、「サツバツ!」等の判定を行っていました。BarabaraDice::Result#rands には、複数回の実行結果が蓄積される Randomizer#rand_results の値が入ります。#335 で私がこの部分を実装したときに repeat を考慮し忘れていたため、 Randomizer#rand_results を使ってしまいました。

対策

BarabaraDice::Result に、最後に振ったときの出目を記録する以下のメンバを加えました。

  • last_dice_list_list:出目のグループの配列(例:[[1, 3], [5, 2]]
  • last_dice_list:すべての出目の配列(例:[1, 3, 5, 2]

NinjaSlayer側では、BarabaraDice::Result#last_dice_list を使うように変更しました。関連するテストケースも追加しました。

@ochaochaocha3 ochaochaocha3 added the bug バグってる! label May 22, 2021
@ochaochaocha3 ochaochaocha3 requested a review from ysakasin May 22, 2021 07:35
@ochaochaocha3 ochaochaocha3 self-assigned this May 22, 2021
@codecov
Copy link

codecov bot commented May 22, 2021

Codecov Report

Merging #469 (7c89d5b) into master (7c0b4e7) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #469   +/-   ##
=======================================
  Coverage   95.26%   95.26%           
=======================================
  Files         290      290           
  Lines       18783    18786    +3     
=======================================
+ Hits        17893    17896    +3     
  Misses        890      890           
Impacted Files Coverage Δ
lib/bcdice/common_command/barabara_dice/node.rb 100.00% <100.00%> (ø)
lib/bcdice/common_command/barabara_dice/result.rb 100.00% <100.00%> (ø)
lib/bcdice/game_system/NinjaSlayer.rb 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7c0b4e7...7c89d5b. Read the comment docs.

Copy link
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.

LGTM!

@ysakasin ysakasin merged commit 2fc707d into master May 25, 2021
@ysakasin ysakasin deleted the NinjaSlayer-fix-rand_results branch May 25, 2021 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug バグってる!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants