OSDN Git Service

[Refactor] #2204 HIT_POINTエイリアスをintに揃えた
[hengbandforosx/hengbandosx.git] / src / system / player-type-definition.h
index 717b0f7..021758b 100644 (file)
@@ -2,24 +2,31 @@
 
 #include "mutation/mutation-flag-types.h"
 #include "object-enchant/trc-types.h"
-#include "object/tval-types.h"
 #include "player-ability/player-ability-types.h"
-#include "player/player-class-types.h"
+#include "player-info/class-specific-data.h"
+#include "player-info/class-types.h"
+#include "player-info/race-types.h"
 #include "player/player-personality-types.h"
-#include "player/player-race-types.h"
 #include "player/player-sex.h"
 #include "system/angband.h"
 #include "system/system-variables.h"
 #include "util/flag-group.h"
 
-#define MAX_SKILLS 10
-#define MAX_MANE 16
+#include <array>
+#include <map>
 
-enum class RF_ABILITY;
+enum class ItemKindType : short;
+enum class PlayerSkillKindType;
+enum class MonsterAbilityType;
 
 struct floor_type;
-typedef struct object_type object_type;
-typedef struct player_type {
+class ObjectType;
+class TimedEffects;
+class PlayerType {
+public:
+    PlayerType();
+    bool is_true_winner() const;
+
     int player_uid{};
     int player_euid{};
     int player_egid{};
@@ -29,19 +36,18 @@ typedef struct player_type {
     POSITION oldpx{}; /* Previous player location -KMW- */
 
     player_sex psex{}; /* Sex index */
-    player_race_type prace{}; /* Race index */
-    player_class_type pclass{}; /* Class index */
-    player_personality_type pseikaku{}; /* Seikaku index */
+    PlayerRaceType prace{}; /* Race index */
+    PlayerClassType pclass{}; /* Class index */
+    player_personality_type ppersonality{}; /* Personality index */
     int16_t realm1{}; /* First magic realm */
     int16_t realm2{}; /* Second magic realm */
     int16_t element{}; //!< 元素使い領域番号 / Elementalist system index
-    player_personality_type oops{}; /* Unused */
 
     DICE_SID hitdie{}; /* Hit dice (sides) */
     uint16_t expfact{}; /* Experience factor
-                     * Note: was byte, causing overflow for Amberite
-                     * characters (such as Amberite Paladins)
-                     */
+                         * Note: was byte, causing overflow for Amberite
+                         * characters (such as Amberite Paladins)
+                         */
 
     int16_t age{}; /* Characters age */
     int16_t ht{}; /* Height */
@@ -66,8 +72,8 @@ typedef struct player_type {
     POSITION wilderness_y{};
     bool wild_mode{};
 
-    HIT_POINT mhp{}; /* Max hit pts */
-    HIT_POINT chp{}; /* Cur hit pts */
+    int mhp{}; /* Max hit pts */
+    int chp{}; /* Cur hit pts */
     uint32_t chp_frac{}; /* Cur hit frac (times 2^16) */
     PERCENTAGE mutant_regenerate_mod{};
 
@@ -92,10 +98,8 @@ typedef struct player_type {
     TIME_EFFECT paralyzed{}; /* Timed -- Paralysis */
     TIME_EFFECT confused{}; /* Timed -- Confusion */
     TIME_EFFECT afraid{}; /* Timed -- Fear */
-    TIME_EFFECT image{}; /* Timed -- Hallucination */
+    TIME_EFFECT hallucinated{}; /* Timed -- Hallucination */
     TIME_EFFECT poisoned{}; /* Timed -- Poisoned */
-    TIME_EFFECT cut{}; /* Timed -- Cut */
-    TIME_EFFECT stun{}; /* Timed -- Stun */
 
     TIME_EFFECT protevil{}; /* Timed -- Protection */
     TIME_EFFECT invuln{}; /* Timed -- Invulnerable */
@@ -130,7 +134,7 @@ typedef struct player_type {
     TIME_EFFECT magicdef{};
     TIME_EFFECT tim_res_nether{}; /* Timed -- Nether resistance */
     TIME_EFFECT tim_res_time{}; /* Timed -- Time resistance */
-    int16_t mimic_form{};
+    int16_t mimic_form{}; // @todo 後でPlayerRaceTypeに差し替える.
     TIME_EFFECT tim_mimic{};
     TIME_EFFECT tim_sh_fire{};
     TIME_EFFECT tim_sh_holy{};
@@ -149,7 +153,7 @@ typedef struct player_type {
 
     int16_t chaos_patron{};
 
-    EnumClassFlagGroup<MUTA> muta{}; /*!< 突然変異 / mutations */
+    EnumClassFlagGroup<PlayerMutationType> muta{}; /*!< 突然変異 / mutations */
 
     int16_t virtues[8]{};
     int16_t vir_types[8]{};
@@ -184,22 +188,13 @@ typedef struct player_type {
     SPELL_IDX spell_order[64]{}; /* order spells learned/remembered/forgotten */
 
     SUB_EXP spell_exp[64]{}; /* Proficiency of spells */
-    SUB_EXP weapon_exp[5][64]{}; /* Proficiency of weapons */
-    SUB_EXP skill_exp[MAX_SKILLS]{}; /* Proficiency of misc. skill */
-
-    int32_t magic_num1[MAX_SPELLS]{}; /*!< Array for non-spellbook type magic */
-    byte magic_num2[MAX_SPELLS]{}; /*!< 魔道具術師の取り込み済魔道具使用回数 / Flags for non-spellbook type magics */
-
-    RF_ABILITY mane_spell[MAX_MANE]{};
-    HIT_POINT mane_dam[MAX_MANE]{};
-    int16_t mane_num{};
-    bool new_mane{};
+    std::map<ItemKindType, std::array<SUB_EXP, 64>> weapon_exp{}; /* Proficiency of weapons */
+    std::map<ItemKindType, std::array<SUB_EXP, 64>> weapon_exp_max{}; /* Maximum proficiency of weapons */
+    std::map<PlayerSkillKindType, SUB_EXP> skill_exp{}; /* Proficiency of misc. skill */
 
-#define CONCENT_RADAR_THRESHOLD 2
-#define CONCENT_TELE_THRESHOLD 5
-    int16_t concent{}; /* Sniper's concentration level */
+    ClassSpecificData class_specific_data;
 
-    HIT_POINT player_hp[PY_MAX_LEVEL]{};
+    int player_hp[PY_MAX_LEVEL]{};
     char died_from[MAX_MONSTER_NAME]{}; /* What killed the player */
     concptr last_message{}; /* Last message on death or retirement */
     char history[4][60]{}; /* Textual "history" for the Player */
@@ -212,8 +207,6 @@ typedef struct player_type {
     bool ambush_flag{};
     BIT_FLAGS change_floor_mode{}; /*!<フロア移行処理に関するフラグ / Mode flags for changing floor */
 
-    bool reset_concent{}; /* Concentration reset flag */
-
     MONSTER_IDX riding{}; /* Riding on a monster of this index */
 
 #define KNOW_STAT 0x01
@@ -221,7 +214,7 @@ typedef struct player_type {
     BIT_FLAGS8 knowledge{}; /* Knowledge about yourself */
     BIT_FLAGS visit{}; /* Visited towns */
 
-    player_race_type start_race{}; /* Race at birth */
+    PlayerRaceType start_race{}; /* Race at birth */
     BIT_FLAGS old_race1{}; /* Record of race changes */
     BIT_FLAGS old_race2{}; /* Record of race changes */
     int16_t old_realm{}; /* Record of realm changes */
@@ -239,7 +232,7 @@ typedef struct player_type {
     byte feeling{}; /* Most recent dungeon feeling */
     int32_t feeling_turn{}; /* The turn of the last dungeon feeling */
 
-    object_type *inventory_list{}; /* The player's inventory */
+    std::shared_ptr<ObjectType[]> inventory_list{}; /* The player's inventory */
     int16_t inven_cnt{}; /* Number of items in inventory */
     int16_t equip_cnt{}; /* Number of items in equipment */
 
@@ -327,8 +320,8 @@ typedef struct player_type {
     BIT_FLAGS anti_magic{}; /* Anti-magic */
     BIT_FLAGS anti_tele{}; /* Prevent teleportation */
 
-    EnumClassFlagGroup<TRC> cursed{}; /* Player is cursed */
-    EnumClassFlagGroup<TRCS> cursed_special{}; /* Player is special type cursed */
+    EnumClassFlagGroup<CurseTraitType> cursed{}; /* Player is cursed */
+    EnumClassFlagGroup<CurseSpecialTraitType> cursed_special{}; /* Player is special type cursed */
 
     bool can_swim{}; /* No damage falling */
     BIT_FLAGS levitation{}; /* No damage falling */
@@ -370,7 +363,7 @@ typedef struct player_type {
 
     HIT_PROB dis_to_h[2]{}; /*!< 判明している現在の表記上の近接武器命中修正値 /  Known bonus to hit (wield) */
     HIT_PROB dis_to_h_b{}; /*!< 判明している現在の表記上の射撃武器命中修正値 / Known bonus to hit (bow) */
-    HIT_POINT dis_to_d[2]{}; /*!< 判明している現在の表記上の近接武器ダメージ修正値 / Known bonus to dam (wield) */
+    int dis_to_d[2]{}; /*!< 判明している現在の表記上の近接武器ダメージ修正値 / Known bonus to dam (wield) */
     ARMOUR_CLASS dis_to_a{}; /*!< 判明している現在の表記上の装備AC修正値 / Known bonus to ac */
     ARMOUR_CLASS dis_ac{}; /*!< 判明している現在の表記上の装備AC基礎値 / Known base ac */
 
@@ -411,7 +404,7 @@ typedef struct player_type {
     int16_t num_fire{}; /* Number of shots */
 
     byte tval_xtra{}; /* (Unused)Correct xtra tval */
-    tval_type tval_ammo{}; /* Correct ammo tval */
+    ItemKindType tval_ammo{}; /* Correct ammo tval */
 
     int16_t pspeed{}; /*!< 現在の速度 / Current speed */
 
@@ -421,6 +414,11 @@ typedef struct player_type {
     POSITION x{}; /*!< ダンジョンの現在X座標 / Player location in dungeon */
     GAME_TEXT name[32]{}; /*!< 現在のプレイヤー名 / Current player's character name */
     char base_name[32]{}; /*!< Stripped version of "player_name" */
-} player_type;
 
-extern player_type *p_ptr;
+    std::shared_ptr<TimedEffects> effects() const;
+
+private:
+    std::shared_ptr<TimedEffects> timed_effects;
+};
+
+extern PlayerType *p_ptr;