1 #include "player/player-race.h"
2 #include "core/player-redraw-types.h"
3 #include "inventory/inventory-slot-types.h"
4 #include "player/player-race-types.h"
5 #include "system/object-type-definition.h"
6 #include "mimic-info-table.h"
7 #include "player/race-info-table.h"
8 #include "system/player-type-definition.h"
9 #include "util/bit-flags-calculator.h"
11 const player_race *rp_ptr;
13 const player_race *get_player_race_info(player_type* creature_ptr, bool base_race = false)
16 return &race_info[creature_ptr->prace];
18 switch (creature_ptr->mimic_form) {
20 case MIMIC_DEMON_LORD:
22 return &mimic_info[creature_ptr->mimic_form];
23 default: // MIMIC_NONE or undefined
24 return &race_info[creature_ptr->prace];
29 * @brief 救援召喚時のモンスターシンボルを返す
30 * @param creature_ptr プレイヤー情報への参照ポインタ
33 SYMBOL_CODE get_summon_symbol_from_player(player_type *creature_ptr)
35 SYMBOL_CODE symbol = 'N';
36 auto mmc_ptr = get_player_race_info(creature_ptr);
38 auto l = strlen(mmc_ptr->symbol);
40 for (size_t i = 0; i < l; i++) {
42 symbol = mmc_ptr->symbol[i];
48 bool is_specific_player_race(player_type *creature_ptr, player_race_type prace) { return (!creature_ptr->mimic_form && (creature_ptr->prace == prace)); }
51 * @brief 種族が指定の耐性/能力フラグを持つか判定する
52 * @param creature_ptr プレイヤー情報への参照ポインタ
54 * @param base_race ベース種族の情報を返すならtrue、ミミック擬態中の種族を返すならfalse
55 * @return 持つならtrue、持たないならfalse
57 bool player_race_has_flag(player_type *creature_ptr, tr_type flag, bool base_race)
59 auto race_ptr = get_player_race_info(creature_ptr, base_race);
61 for (auto& cond : race_ptr->extra_flags) {
62 if (cond.type != flag)
64 if (creature_ptr->lev < cond.level)
66 if (cond.pclass != std::nullopt) {
67 if (cond.not_class && creature_ptr->pclass == cond.pclass)
69 if (!cond.not_class && creature_ptr->pclass != cond.pclass)
80 * @brief 種族固有の耐性/能力フラグをセットする
81 * @param creature_ptr プレイヤー情報への参照ポインタ
82 * @param flags フラグ配列へのポインタ
83 * @param base_race ベース種族の情報を返すならtrue、ミミック擬態中の種族を返すならfalse
86 void add_player_race_flags(player_type *creature_ptr, BIT_FLAGS *flags, bool base_race)
88 auto race_ptr = get_player_race_info(creature_ptr, base_race);
89 if (race_ptr->infra > 0)
90 add_flag(flags, TR_INFRA);
92 for (auto &cond : race_ptr->extra_flags) {
93 if (creature_ptr->lev < cond.level)
95 if (cond.pclass != std::nullopt) {
96 if (cond.not_class && creature_ptr->pclass == cond.pclass)
98 if (!cond.not_class && creature_ptr->pclass != cond.pclass)
102 add_flag(flags, cond.type);
108 * @param creature_ptr プレイヤー情報への参照ポインタ
111 PlayerRaceLife player_race_life(player_type *creature_ptr, bool base_race)
113 auto race_ptr = get_player_race_info(creature_ptr, base_race);
114 return race_ptr->life;