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
player_type から時限ステータスを分離した (朦朧のみ) #1548
player_type から時限ステータスを分離した (朦朧のみ) #1548
Conversation
4e473b2
to
9ddef9e
Compare
src/system/player-type-definition.h
Outdated
@@ -10,6 +10,7 @@ | |||
#include "player/player-sex.h" | |||
#include "system/angband.h" | |||
#include "system/system-variables.h" | |||
#include "timed-effect/timed-effects.h" |
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.
ここまでヘッダ同士の依存を減らす方向で来ているので、ここでのインクルードは無くして実装ファイルのコンストラクタで timed_efffect を初期化するようにしたほうがいいのではないでしょうか。
TimeEffects を使用する実装ファイルすべてでインクルードが必要になりますが依存を減らしていく方針ではしかたないかと思います。
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/system/player-type-definition.h
Outdated
std::shared_ptr<TimedEffects> effects() const; | ||
|
||
private: | ||
std::shared_ptr<TimedEffects> timed_effects = std::shared_ptr<TimedEffects>(new TimedEffects()); |
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.
std::shared_ptr の初期化は特に理由が無い限り、以下の点で std::make_shared を使用したほうがいいです。
- 同じ型を何度も書く必要がない
- クラス本体とコントロールブロックのメモリ領域の確保がまとめて行われるので効率的
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.
実装途中はmake_shared() だと実行時エラーでソフトが落ちていました (この形式だと何故かOKだった)が、設計が完成した現在は大丈夫なようです
問題ないようなのでmake_shared() の方に切り替えます
@@ -19,8 +20,9 @@ enum class RF_ABILITY; | |||
|
|||
struct floor_type; | |||
struct object_type; | |||
; | |||
typedef struct player_type { | |||
class TimedEffects; |
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.
上述したようにヘッダの依存を減らすのであれば前方宣言が必要ですが、"timed-effects.h"をplayer-type-definition.hからインクルードする方針なのであれば必要ありません。
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/timed-effect/player-stun.h
Outdated
#include <string> | ||
#include <tuple> | ||
|
||
enum class StunRank { |
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.
モンスターにも朦朧状態はあるので、PlayerStunRankにしたほうが良いです。
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.
Playerを付けます
src/timed-effect/player-stun.h
Outdated
short current() const; | ||
StunRank get_rank() const; | ||
StunRank get_rank(short value) const; | ||
std::string_view get_stun_mes(StunRank stun_rank) const; |
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.
引数付きの get_rank() と、get_stun_mes はインスタンス変数に依存しないので、static メンバ関数にしたほうがいいです。
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.
staticにします
src/timed-effect/player-stun.h
Outdated
StunRank get_rank(short value) const; | ||
std::string_view get_stun_mes(StunRank stun_rank) const; | ||
int decrease_chance() const; | ||
short decrease_damage() const; |
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.
decrese は他動詞として使うのが一般的なので、意味が通じにくいかもしれません。(名詞として使うにしても、chance_decreseのように単語の順序を逆にするのが適切のように感じます)
get_chance_penalty のような名前にしたらどうでしょうか。
src/timed-effect/timed-effects.h
Outdated
@@ -0,0 +1,16 @@ | |||
#pragma once | |||
|
|||
#include "timed-effect/player-stun.h" |
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.
player-type-definition.h でのコメントと同様、ヘッダファイルの依存を減らすならここでインクルードするのはやめたほうがよいと思います。
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.
ここも設計途中にコンパイルエラーが出ていたのみの部分です
削除します
9ddef9e
to
de79b7d
Compare
頂いた指摘を修正し、更に言語が正しく選択されない場合がある事象を解決させました |
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.
1点だけコメントしました。
|
||
player_type::player_type() | ||
{ | ||
this->timed_effects = std::make_shared<TimedEffects>(); |
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.
細かいところですが、メンバ初期化子で初期化できるときはそうしたほうがよいので、
player_type::player_type()
: timed_effects(std::make_shared<TimedEffects>())
{
}
としたほうが良いでしょう。(TimedEffects クラスも同様)
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.
スマートポインタを初期化子リストで初期化する方法が分からなかったので放置してました
ぜひ採用します!
…ffect variables from player_type
…rent() and so on
…rease_chance()
…to decrease_damage()
… that the expression of stun is English always in some environments
de79b7d
to
130d537
Compare
コメントを反映させてforce pushしました |
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.
対応おつかれさまです。修正を確認しました。
朦朧の動作自体は大丈夫そうなので、Approveします。
レビュー・動作確認ありがとうございました! |
#553 の前段対応で、#1498 の設計変更を実施しました
ご確認下さい