-
Notifications
You must be signed in to change notification settings - Fork 186
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
ナイトウィザードのリファクタリング #252
ナイトウィザードのリファクタリング #252
Conversation
Codecov Report
@@ Coverage Diff @@
## master #252 +/- ##
==========================================
+ Coverage 87.86% 88.01% +0.14%
==========================================
Files 220 224 +4
Lines 22942 23270 +328
==========================================
+ Hits 20158 20481 +323
- Misses 2784 2789 +5
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
処理は大変読みやすくなり、問題ないと思います。細かいところにコメントしましたので、ご検討よろしくおねがいします。
src/utils/format.rb
Outdated
# | ||
# @param number [Integer] | ||
# @return [String] | ||
def modify_number(number) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
英語では一単語のmodifierの方が自然だと思います。
Terms used to play role-playing games
- Modifier: A number added to or subtracted from a die roll.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
修正しました。
src/diceBot/NightWizard.rb
Outdated
# @return [Symbol, nil] 比較演算子 | ||
# @!attribute target_number | ||
# @return [Integer, nil] 目標値 | ||
attr_accessor :critical_numbers, :fumble_numbers, :active_modify_number, :cmp_op, :target_number |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
このままで動作上は問題ないですが、@!attribute
はやむを得ない場合(例えばメタプログラミングで動的にメソッドが定義されるとき)のみ使用するように書かれているので、単純に以下のように書くのはいかがでしょうか。重複もなくなります。
# @return [Array<Integer>] クリティカルになる出目の一覧
attr_accessor :critical_numbers
# @return [Array<Integer>] ファンブルになる出目の一覧
attr_accessor :fumble_numbers
# ...
# @return [Integer, nil] 目標値
attr_accessor :target_number
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@return
が使えたんですね!
この記法でかけるならこちらの方が読みやすいので修正しました。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
やったこと
DiceBot#changeText
での変換をしない追加機能のための布石としてのリファクタリング
NWコマンドの仕様概要
@6,7,9
のように指定する#3,5