OSDN Git Service

[Refactor] #1489 Moved is_wizard_class() from player-realm.cpp/h to player-class...
authorHourier <grapefox.whitelucifer.0408@gmail.com>
Wed, 8 Sep 2021 14:39:09 +0000 (23:39 +0900)
committerHourier <grapefox.whitelucifer.0408@gmail.com>
Wed, 8 Sep 2021 14:39:09 +0000 (23:39 +0900)
src/cmd-io/cmd-diary.cpp
src/mind/mind-mage.cpp
src/player-base/player-class.cpp
src/player-base/player-class.h
src/player/player-realm.cpp
src/player/player-realm.h
src/realm/realm-chaos.cpp
src/realm/realm-death.cpp
src/realm/realm-demon.cpp
src/spell-kind/magic-item-recharger.cpp

index 14b2b37..9ecf726 100644 (file)
@@ -8,8 +8,8 @@
 #include "io/input-key-acceptor.h"
 #include "io/write-diary.h"
 #include "main/sound-of-music.h"
+#include "player-base/player-class.h"
 #include "player/player-personality.h"
-#include "player/player-realm.h"
 #include "system/player-type-definition.h"
 #include "term/screen-processor.h"
 #include "util/angband-files.h"
@@ -33,7 +33,7 @@ static void display_diary(player_type *creature_ptr)
     if (creature_ptr->pclass == CLASS_WARRIOR || creature_ptr->pclass == CLASS_MONK || creature_ptr->pclass == CLASS_SAMURAI
         || creature_ptr->pclass == CLASS_BERSERKER)
         strcpy(tmp, subtitle[randint0(MAX_SUBTITLE - 1)]);
-    else if (is_wizard_class(creature_ptr))
+    else if (PlayerClass(creature_ptr).is_wizard())
         strcpy(tmp, subtitle[randint0(MAX_SUBTITLE - 1) + 1]);
     else
         strcpy(tmp, subtitle[randint0(MAX_SUBTITLE - 2) + 1]);
index 0be0695..e02462d 100644 (file)
@@ -15,7 +15,7 @@
 #include "object/item-tester-hooker.h"
 #include "object/item-use-flags.h"
 #include "object/object-kind.h"
-#include "player/player-realm.h"
+#include "player-base/player-class.h"
 #include "system/object-type-definition.h"
 #include "system/player-type-definition.h"
 #include "view/display-messages.h"
@@ -110,7 +110,7 @@ bool eat_magic(player_type *caster_ptr, int power)
     describe_flavor(caster_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
 
     /* Mages recharge objects more safely. */
-    if (is_wizard_class(caster_ptr)) {
+    if (PlayerClass(caster_ptr).is_wizard()) {
         /* 10% chance to blow up one rod, otherwise draining. */
         if (o_ptr->tval == TV_ROD) {
             if (one_in_(10))
index 73993e3..2dd5546 100644 (file)
@@ -16,3 +16,14 @@ bool PlayerClass::can_resist_stun() const
 {
     return (this->player_ptr->pclass == CLASS_BERSERKER) && (this->player_ptr->lev > 34);
 }
+
+bool PlayerClass::is_wizard() const
+{
+    auto is_wizard = this->player_ptr->pclass == CLASS_MAGE;
+    is_wizard |= this->player_ptr->pclass == CLASS_HIGH_MAGE;
+    is_wizard |= this->player_ptr->pclass == CLASS_SORCERER;
+    is_wizard |= this->player_ptr->pclass == CLASS_MAGIC_EATER;
+    is_wizard |= this->player_ptr->pclass == CLASS_BLUE_MAGE;
+    is_wizard |= this->player_ptr->pclass == CLASS_ELEMENTALIST;
+    return is_wizard;
+}
index 088bf65..edbb5bd 100644 (file)
@@ -8,6 +8,7 @@ public:
     virtual ~PlayerClass() = default;
 
     bool can_resist_stun() const;
+    bool is_wizard() const;
 
 private:
     player_type *player_ptr;
index d0fa871..d96a528 100644 (file)
@@ -75,9 +75,3 @@ const uint32_t realm_choices2[MAX_CLASS] = {
 int16_t get_realm1_book(player_type *player_ptr) { return player_ptr->realm1 + TV_LIFE_BOOK - 1; }
 
 int16_t get_realm2_book(player_type *player_ptr) { return player_ptr->realm2 + TV_LIFE_BOOK - 1; }
-
-bool is_wizard_class(player_type *player_ptr)
-{
-    return (player_ptr->pclass == CLASS_MAGE || player_ptr->pclass == CLASS_HIGH_MAGE || player_ptr->pclass == CLASS_SORCERER || player_ptr->pclass == CLASS_MAGIC_EATER
-        || player_ptr->pclass == CLASS_BLUE_MAGE || player_ptr->pclass == CLASS_ELEMENTALIST);
-}
index 6608255..cdf1c8c 100644 (file)
@@ -27,4 +27,3 @@ extern const uint32_t realm_choices2[];
 struct player_type;
 int16_t get_realm1_book(player_type *player_ptr);
 int16_t get_realm2_book(player_type *player_ptr);
-bool is_wizard_class(player_type *player_ptr);
index 0a2f585..024dde5 100644 (file)
@@ -4,8 +4,8 @@
 #include "core/player-redraw-types.h"
 #include "effect/effect-characteristics.h"
 #include "effect/effect-processor.h"
+#include "player-base/player-class.h"
 #include "player/attack-defense-types.h"
-#include "player/player-realm.h"
 #include "spell-kind/magic-item-recharger.h"
 #include "spell-kind/spells-floor.h"
 #include "spell-kind/spells-launcher.h"
@@ -132,7 +132,7 @@ concptr do_chaos_spell(player_type *caster_ptr, SPELL_IDX spell, spell_type mode
             POSITION rad = (plev < 30) ? 2 : 3;
             int base;
 
-            if (is_wizard_class(caster_ptr))
+            if (PlayerClass(caster_ptr).is_wizard())
                 base = plev + plev / 2;
             else
                 base = plev + plev / 4;
index 0e4a156..692f278 100644 (file)
@@ -4,10 +4,10 @@
 #include "effect/effect-characteristics.h"
 #include "effect/effect-processor.h"
 #include "hpmp/hp-mp-processor.h"
+#include "player-base/player-class.h"
 #include "player-info/race-info.h"
 #include "player/digestion-processor.h"
 #include "player/player-damage.h"
-#include "player/player-realm.h"
 #include "spell-kind/spells-charm.h"
 #include "spell-kind/spells-detection.h"
 #include "spell-kind/spells-genocide.h"
@@ -245,7 +245,7 @@ concptr do_death_spell(player_type *caster_ptr, SPELL_IDX spell, spell_type mode
             POSITION rad = (plev < 30) ? 2 : 3;
             int base;
 
-            if (is_wizard_class(caster_ptr))
+            if (PlayerClass(caster_ptr).is_wizard())
                 base = plev + plev / 2;
             else
                 base = plev + plev / 4;
index 75e63df..b8edc7c 100644 (file)
@@ -2,9 +2,9 @@
 #include "cmd-action/cmd-spell.h"
 #include "monster-floor/monster-summon.h"
 #include "monster-floor/place-monster-types.h"
+#include "player-base/player-class.h"
 #include "player-info/race-info.h"
 #include "player/player-damage.h"
-#include "player/player-realm.h"
 #include "spell-kind/spells-charm.h"
 #include "spell-kind/spells-detection.h"
 #include "spell-kind/spells-floor.h"
@@ -195,7 +195,7 @@ concptr do_daemon_spell(player_type *caster_ptr, SPELL_IDX spell, spell_type mod
             POSITION rad = (plev < 30) ? 2 : 3;
             int base;
 
-            if (is_wizard_class(caster_ptr))
+            if (PlayerClass(caster_ptr).is_wizard())
                 base = plev + plev / 2;
             else
                 base = plev + plev / 4;
index 9b1391d..77e09b5 100644 (file)
@@ -21,7 +21,7 @@
 #include "object/item-tester-hooker.h"
 #include "object/item-use-flags.h"
 #include "object/object-kind.h"
-#include "player/player-realm.h"
+#include "player-base/player-class.h"
 #include "system/player-type-definition.h"
 #include "system/object-type-definition.h"
 #include "view/display-messages.h"
@@ -127,7 +127,7 @@ bool recharge(player_type *caster_ptr, int power)
 
     describe_flavor(caster_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
 
-    if (is_wizard_class(caster_ptr) || caster_ptr->pclass == CLASS_MAGIC_EATER || caster_ptr->pclass == CLASS_BLUE_MAGE) {
+    if (PlayerClass(caster_ptr).is_wizard()) {
         /* 10% chance to blow up one rod, otherwise draining. */
         if (o_ptr->tval == TV_ROD) {
             if (one_in_(10))