Skip to content

Commit

Permalink
[Refactor] #4127 MonsterRaceInfo::get_next() を実装し、MonsterRace::is_val…
Browse files Browse the repository at this point in the history
…id() をを使わないようにメソッドを差し替えた
  • Loading branch information
Hourier authored and sikabane-works committed Aug 15, 2024
1 parent 07fe247 commit 42ebe25
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/spell-kind/spells-sight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ std::string probed_monster_info(PlayerType *player_ptr, MonsterEntity *m_ptr, Mo
constexpr auto mes = _("%s ... 属性:%s HP:%d/%d AC:%d 速度:%s%d 経験:", "%s ... align:%s HP:%d/%d AC:%d speed:%s%d exp:");
auto result = format(mes, m_name.data(), align, (int)m_ptr->hp, (int)m_ptr->maxhp, r_ptr->ac, (speed > 0) ? "+" : "", speed);

if (MonsterRace(r_ptr->next_r_idx).is_valid()) {
if (r_ptr->get_next().is_valid()) {
result.append(format("%d/%d ", m_ptr->exp, r_ptr->next_exp));
} else {
result.append("xxx ");
Expand Down
9 changes: 9 additions & 0 deletions src/system/monster-race-info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,15 @@ std::string MonsterRaceInfo::get_pronoun_of_summoned_kin() const
}
}

/*!
* @brief 進化先モンスターを返す. 進化しなければプレイヤー (無効値の意)
* @return 進化先モンスター
*/
const MonsterRaceInfo &MonsterRaceInfo::get_next() const
{
return MonraceList::get_instance()[this->next_r_idx];
}

const std::map<MonsterRaceId, std::set<MonsterRaceId>> MonraceList::unified_uniques = {
{ MonsterRaceId::BANORLUPART, { MonsterRaceId::BANOR, MonsterRaceId::LUPART } },
};
Expand Down
1 change: 1 addition & 0 deletions src/system/monster-race-info.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ class MonsterRaceInfo {
std::optional<bool> order_pet(const MonsterRaceInfo &other) const;
void kill_unique();
std::string get_pronoun_of_summoned_kin() const;
const MonsterRaceInfo &get_next() const;
};

class MonraceList {
Expand Down
6 changes: 3 additions & 3 deletions src/view/display-lore-status.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,10 @@ void display_monster_evolution(lore_type *lore_ptr)
return;
}

if (MonsterRace(lore_ptr->r_ptr->next_r_idx).is_valid()) {
const auto &monrace_next = lore_ptr->r_ptr->get_next();
if (monrace_next.is_valid()) {
hooked_roff(format(_("%s^は経験を積むと、", "%s^ will evolve into "), Who::who(lore_ptr->msex)));
hook_c_roff(TERM_YELLOW, format("%s", monraces_info[lore_ptr->r_ptr->next_r_idx].name.data()));

hook_c_roff(TERM_YELLOW, format("%s", monrace_next.name.data()));
hooked_roff(_(format("に進化する。"), format(" when %s gets enough experience. ", Who::who(lore_ptr->msex))));
} else if (lore_ptr->r_ptr->kind_flags.has_not(MonsterKindType::UNIQUE)) {
hooked_roff(format(_("%sは進化しない。", "%s won't evolve. "), Who::who(lore_ptr->msex)));
Expand Down
16 changes: 8 additions & 8 deletions src/wizard/wizard-spoiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static auto get_mon_evol_roots()
std::set<MonsterRaceId> evol_parents;
std::set<MonsterRaceId> evol_children;
for (const auto &[monrace_id, monrace] : monraces_info) {
if (MonsterRace(monrace.next_r_idx).is_valid()) {
if (monrace.get_next().is_valid()) {
evol_parents.emplace(monrace_id);
evol_children.emplace(monrace.next_r_idx);
}
Expand Down Expand Up @@ -105,15 +105,15 @@ static SpoilerOutputResultType spoil_mon_evol()
spoil_out(ss.str());
spoil_out("------------------------------------------\n\n");
for (auto monrace_id : get_mon_evol_roots()) {
const auto *r_ptr = &monraces_info[monrace_id];
const auto *monrace_ptr = &monraces_info[monrace_id];
constexpr auto fmt_before = _("[%d]: %s (レベル%d, '%c')\n", "[%d]: %s (Level %d, '%c')\n");
fprintf(spoiler_file, fmt_before, enum2i(monrace_id), r_ptr->name.data(), r_ptr->level, r_ptr->symbol_definition.character);
for (auto n = 1; MonsterRace(r_ptr->next_r_idx).is_valid(); n++) {
fprintf(spoiler_file, "%*s-(%d)-> ", n * 2, "", r_ptr->next_exp);
fprintf(spoiler_file, "[%d]: ", enum2i(r_ptr->next_r_idx));
r_ptr = &monraces_info[r_ptr->next_r_idx];
fprintf(spoiler_file, fmt_before, enum2i(monrace_id), monrace_ptr->name.data(), monrace_ptr->level, monrace_ptr->symbol_definition.character);
for (auto n = 1; monrace_ptr->get_next().is_valid(); n++) {
fprintf(spoiler_file, "%*s-(%d)-> ", n * 2, "", monrace_ptr->next_exp);
monrace_ptr = &monrace_ptr->get_next();
fprintf(spoiler_file, "[%d]: ", enum2i(monrace_ptr->idx));
constexpr auto fmt_after = _("%s (レベル%d, '%c')\n", "%s (Level %d, '%c')\n");
fprintf(spoiler_file, fmt_after, r_ptr->name.data(), r_ptr->level, r_ptr->symbol_definition.character);
fprintf(spoiler_file, fmt_after, monrace_ptr->name.data(), monrace_ptr->level, monrace_ptr->symbol_definition.character);
}

fputc('\n', spoiler_file);
Expand Down

0 comments on commit 42ebe25

Please sign in to comment.