OSDN Git Service

[Refactor] #37353 配列用ポインタ town を他の慣例に従い town_info に改名。 / Rename town pointer to town_...
[hengband/hengband.git] / src / player-status.c
index e21d630..7064df5 100644 (file)
@@ -1,7 +1,9 @@
 #include "angband.h"
-#include "artifact.h"
 #include "player-status.h"
+
+#include "artifact.h"
 #include "avatar.h"
+#include "spells-status.h"
 
 /*
  * Return alignment title
@@ -282,8 +284,8 @@ void calc_bonuses(void)
        /* Base skill -- digging */
        p_ptr->skill_dig = 0;
 
-       if (buki_motteruka(INVEN_RARM)) p_ptr->migite = TRUE;
-       if (buki_motteruka(INVEN_LARM))
+       if (has_melee_weapon(INVEN_RARM)) p_ptr->migite = TRUE;
+       if (has_melee_weapon(INVEN_LARM))
        {
                p_ptr->hidarite = TRUE;
                if (!p_ptr->migite) default_hand = 1;
@@ -1227,8 +1229,8 @@ void calc_bonuses(void)
                }
 
                /* Hack -- do not apply "weapon" bonuses */
-               if (i == INVEN_RARM && buki_motteruka(i)) continue;
-               if (i == INVEN_LARM && buki_motteruka(i)) continue;
+               if (i == INVEN_RARM && has_melee_weapon(i)) continue;
+               if (i == INVEN_LARM && has_melee_weapon(i)) continue;
 
                /* Hack -- do not apply "bow" bonuses */
                if (i == INVEN_BOW) continue;
@@ -1446,10 +1448,7 @@ void calc_bonuses(void)
                {
                        /* Save the new value */
                        p_ptr->stat_top[i] = (s16b)top;
-
-                       /* Redisplay the stats later */
                        p_ptr->redraw |= (PR_STATS);
-
                        p_ptr->window |= (PW_PLAYER);
                }
 
@@ -1471,10 +1470,7 @@ void calc_bonuses(void)
                {
                        /* Save the new value */
                        p_ptr->stat_use[i] = (s16b)use;
-
-                       /* Redisplay the stats later */
                        p_ptr->redraw |= (PR_STATS);
-
                        p_ptr->window |= (PW_PLAYER);
                }
 
@@ -1744,7 +1740,7 @@ void calc_bonuses(void)
                p_ptr->dis_to_h[default_hand] += (p_ptr->skill_exp[GINOU_SUDE] - WEAPON_EXP_BEGINNER) / 200;
        }
 
-       if (buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM))
+       if (has_melee_weapon(INVEN_RARM) && has_melee_weapon(INVEN_LARM))
        {
                int penalty1, penalty2;
                penalty1 = ((100 - p_ptr->skill_exp[GINOU_NITOURYU] / 160) - (130 - inventory[INVEN_RARM].weight) / 8);
@@ -1924,7 +1920,7 @@ void calc_bonuses(void)
                p_ptr->icky_wield[i] = FALSE;
                p_ptr->riding_wield[i] = FALSE;
 
-               if (!buki_motteruka(INVEN_RARM + i))
+               if (!has_melee_weapon(INVEN_RARM + i))
                {
                        p_ptr->num_blow[i] = 1;
                        continue;
@@ -1957,93 +1953,73 @@ void calc_bonuses(void)
                        /* Analyze the class */
                        switch (p_ptr->pclass)
                        {
-                               /* Warrior */
                        case CLASS_WARRIOR:
                                num = 6; wgt = 70; mul = 5; break;
 
-                               /* Berserker */
                        case CLASS_BERSERKER:
                                num = 6; wgt = 70; mul = 7; break;
 
-                               /* Mage */
                        case CLASS_MAGE:
                        case CLASS_HIGH_MAGE:
                        case CLASS_BLUE_MAGE:
                                num = 3; wgt = 100; mul = 2; break;
 
-                               /* Priest, Mindcrafter, Magic-Eater */
                        case CLASS_PRIEST:
                        case CLASS_MAGIC_EATER:
                        case CLASS_MINDCRAFTER:
                                num = 5; wgt = 100; mul = 3; break;
 
-                               /* Rogue */
                        case CLASS_ROGUE:
                                num = 5; wgt = 40; mul = 3; break;
 
-                               /* Ranger */
                        case CLASS_RANGER:
                                num = 5; wgt = 70; mul = 4; break;
 
-                               /* Paladin */
                        case CLASS_PALADIN:
                        case CLASS_SAMURAI:
                                num = 5; wgt = 70; mul = 4; break;
 
-                               /* Weaponsmith */
                        case CLASS_SMITH:
                                num = 5; wgt = 150; mul = 5; break;
 
-                               /* Warrior-Mage */
                        case CLASS_WARRIOR_MAGE:
                        case CLASS_RED_MAGE:
                                num = 5; wgt = 70; mul = 3; break;
 
-                               /* Chaos Warrior */
                        case CLASS_CHAOS_WARRIOR:
                                num = 5; wgt = 70; mul = 4; break;
 
-                               /* Monk */
                        case CLASS_MONK:
                                num = 5; wgt = 60; mul = 3; break;
 
-                               /* Tourist */
                        case CLASS_TOURIST:
                                num = 4; wgt = 100; mul = 3; break;
 
-                               /* Imitator */
                        case CLASS_IMITATOR:
                                num = 5; wgt = 70; mul = 4; break;
 
-                               /* Beastmaster */
                        case CLASS_BEASTMASTER:
                                num = 5; wgt = 70; mul = 3; break;
 
-                               /* Cavalry */
                        case CLASS_CAVALRY:
                                if ((p_ptr->riding) && (have_flag(flgs, TR_RIDING))) { num = 5; wgt = 70; mul = 4; }
                                else { num = 5; wgt = 100; mul = 3; }
                                break;
 
-                               /* Sorcerer */
                        case CLASS_SORCERER:
                                num = 1; wgt = 1; mul = 1; break;
 
-                               /* Archer, Bard, Sniper */
                        case CLASS_ARCHER:
                        case CLASS_BARD:
                        case CLASS_SNIPER:
                                num = 4; wgt = 70; mul = 2; break;
 
-                               /* ForceTrainer */
                        case CLASS_FORCETRAINER:
                                num = 4; wgt = 60; mul = 2; break;
 
-                               /* Mirror Master */
                        case CLASS_MIRROR_MASTER:
                                num = 3; wgt = 100; mul = 3; break;
 
-                               /* Ninja */
                        case CLASS_NINJA:
                                num = 4; wgt = 20; mul = 1; break;
                        }
@@ -2215,7 +2191,7 @@ void calc_bonuses(void)
                        case CLASS_MONK:
                        case CLASS_FORCETRAINER:
                        case CLASS_BERSERKER:
-                               if ((empty_hands(FALSE) != EMPTY_HAND_NONE) && !buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM))
+                               if ((empty_hands(FALSE) != EMPTY_HAND_NONE) && !has_melee_weapon(INVEN_RARM) && !has_melee_weapon(INVEN_LARM))
                                        p_ptr->riding_ryoute = TRUE;
                                break;
                        }
@@ -2331,7 +2307,7 @@ void calc_bonuses(void)
 
        for (i = 0; i < 2; i++)
        {
-               if (buki_motteruka(INVEN_RARM + i))
+               if (has_melee_weapon(INVEN_RARM + i))
                {
                        OBJECT_TYPE_VALUE tval = inventory[INVEN_RARM + i].tval - TV_WEAPON_BEGIN;
                        OBJECT_SUBTYPE_VALUE sval = inventory[INVEN_RARM + i].sval;
@@ -2552,7 +2528,7 @@ void calc_bonuses(void)
                        {
                                msg_print(_("こんな重い武器を装備しているのは大変だ。", "You have trouble wielding such a heavy weapon."));
                        }
-                       else if (buki_motteruka(INVEN_RARM + i))
+                       else if (has_melee_weapon(INVEN_RARM + i))
                        {
                                msg_print(_("これなら装備していても辛くない。", "You have no trouble wielding your weapon."));
                        }
@@ -2580,7 +2556,7 @@ void calc_bonuses(void)
                        {
                                msg_print(_("この武器は徒歩で使いやすい。", "This weapon was not suitable for use while riding."));
                        }
-                       else if (buki_motteruka(INVEN_RARM + i))
+                       else if (has_melee_weapon(INVEN_RARM + i))
                        {
                                msg_print(_("これなら乗馬中にぴったりだ。", "This weapon is suitable for use while riding."));
                        }
@@ -2599,7 +2575,7 @@ void calc_bonuses(void)
                                        chg_virtue(V_FAITH, -1);
                                }
                        }
-                       else if (buki_motteruka(INVEN_RARM + i))
+                       else if (has_melee_weapon(INVEN_RARM + i))
                        {
                                msg_print(_("今の装備は自分にふさわしい気がする。", "You feel comfortable with your weapon."));
                        }
@@ -2837,7 +2813,7 @@ static void calc_torch(void)
 
        /* max radius is 14 (was 5) without rewriting other code -- */
        /* see cave.c:update_lite() and defines.h:LITE_MAX */
-       if (d_info[dungeon_type].flags1 & DF1_DARKNESS && p_ptr->cur_lite > 1)
+       if (d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS && p_ptr->cur_lite > 1)
                p_ptr->cur_lite = 1;
 
        /*
@@ -3228,7 +3204,7 @@ static void calc_mana(void)
 {
        int msp, levels, cur_wgt, max_wgt;
 
-       object_type     *o_ptr;
+       object_type *o_ptr;
 
 
        /* Hack -- Must be literate */
@@ -3634,7 +3610,7 @@ WEIGHT weight_limit(void)
  * @param i 判定する手のID(右手:0 左手:1)
  * @return 持っているならばTRUE
  */
-bool buki_motteruka(int i)
+bool has_melee_weapon(int i)
 {
        return ((inventory[i].k_idx && object_is_melee_weapon(&inventory[i])) ? TRUE : FALSE);
 }
@@ -3812,3 +3788,37 @@ void update_creature(player_type *creature_ptr)
                update_monsters(FALSE);
        }
 }
+
+/*!
+ * @brief プレイヤーが魔道書を一冊も持っていないかを判定する
+ * @return 魔道書を一冊も持っていないならTRUEを返す
+ */
+bool player_has_no_spellbooks(void)
+{
+       int i;
+       object_type *o_ptr;
+
+       for (i = 0; i < INVEN_PACK; i++)
+       {
+               o_ptr = &inventory[i];
+               if (o_ptr->k_idx && check_book_realm(o_ptr->tval, o_ptr->sval)) return FALSE;
+       }
+
+       for (i = cave[p_ptr->y][p_ptr->x].o_idx; i; i = o_ptr->next_o_idx)
+       {
+               o_ptr = &o_list[i];
+               if (o_ptr->k_idx && (o_ptr->marked & OM_FOUND) && check_book_realm(o_ptr->tval, o_ptr->sval)) return FALSE;
+       }
+
+       return TRUE;
+}
+
+void take_turn(player_type *creature_ptr, PERCENTAGE need_cost)
+{
+       creature_ptr->energy_use = (ENERGY)need_cost;
+}
+
+void free_turn(player_type *creature_ptr)
+{
+       creature_ptr->energy_use = 0;
+}