Skip to content

Commit

Permalink
[Refactor] #4127 MonsterRace::is_valid() を廃止した
Browse files Browse the repository at this point in the history
  • Loading branch information
Hourier authored and sikabane-works committed Aug 15, 2024
1 parent 88475c5 commit 6bc04b9
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/alliance/alliance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ int64_t Alliance::calcCurrentPower()
for (auto &[r_idx, r_ref] : monraces_info) {
if (r_ref.alliance_idx == this->id) {
if (r_ref.mob_num > 0) {
res += MonsterRace(r_idx).calc_eval() * r_ref.mob_num;
res += MonsterRace(r_idx).calc_power() * r_ref.mob_num;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/knowledge/knowledge-alliance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void do_cmd_knowledge_alliance(PlayerType *player_ptr, bool detail)

for (auto &[r_idx, r_ref] : monraces_info) {
if (r_ref.alliance_idx == a.second->id) {
fprintf(fff, _("%s %-40s レベル %3d 評価値 %9d", "%s %-40s LEVEL %3d POW %9d"), r_ref.kind_flags.has(MonsterKindType::UNIQUE) ? "[U]" : "---", r_ref.name.c_str(), r_ref.level, MonsterRace(r_idx).calc_eval());
fprintf(fff, _("%s %-40s レベル %3d 評価値 %9d", "%s %-40s LEVEL %3d POW %9d"), r_ref.kind_flags.has(MonsterKindType::UNIQUE) ? "[U]" : "---", r_ref.name.c_str(), r_ref.level, MonsterRace(r_idx).calc_power());
if (r_ref.kind_flags.has_not(MonsterKindType::UNIQUE)) {
if (r_ref.mob_num > 0) {
fprintf(fff, "x %d\n", r_ref.mob_num);
Expand Down
17 changes: 0 additions & 17 deletions src/monster-race/monster-race.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,6 @@ MonsterRaceId MonsterRace::pick_one_at_random()
return table.pick_one_at_random();
}

/*!
* @brief コンストラクタに渡された MonsterRaceId が正当なもの(実際に存在するモンスター種族IDである)かどうかを調べる
* @details モンスター種族IDが MonsterRaceDefinitions に実在するもの(MonsterRaceId::PLAYERは除く)であるかどうかの用途の他、
* m_list 上の要素などの r_idx にMonsterRaceId::PLAYER を入れることで死亡扱いとして使われるのでその判定に使用する事もある
* @return 正当なものであれば true、そうでなければ false
*/
bool MonsterRace::is_valid() const
{
return this->r_idx != MonsterRaceId::PLAYER;
}

int MonsterRace::calc_eval() const
{
const auto *r_ptr = &monraces_info[this->r_idx];
return this->calc_power() * r_ptr->level;
}

/*!
* @brief モンスター種族が賞金首の対象かどうかを調べる。日替わり賞金首は対象外。
*
Expand Down
2 changes: 0 additions & 2 deletions src/monster-race/monster-race.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ class MonsterRace {
static MonsterRaceId empty_id();
static MonsterRaceId pick_one_at_random();

bool is_valid() const;
int calc_eval() const;
bool is_bounty(bool unachieved_only) const;
int calc_power() const;

Expand Down
4 changes: 4 additions & 0 deletions src/system/monster-race-info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ MonsterRaceInfo::MonsterRaceInfo()
}

/*!
* @brief 正当なモンスター (実際に存在するモンスター種族IDである)かどうかを調べる
* @details モンスター種族IDが MonsterRaceDefinitions に実在するもの(MonsterRaceId::PLAYERは除く)であるかどうかの用途の他、
* m_list 上の要素などの r_idx にMonsterRaceId::PLAYER を入れることで死亡扱いとして使われるのでその判定に使用する事もある
* @return 正当なものであれば true、そうでなければ false
* @todo 将来的に定義側のIDが廃止されたら有効フラグのフィールド変数を代わりに作る.
*/
bool MonsterRaceInfo::is_valid() const
Expand Down

0 comments on commit 6bc04b9

Please sign in to comment.