From f3282d01b23eac85b49bab357ceba3a0b2f708e0 Mon Sep 17 00:00:00 2001 From: Deskull Date: Sun, 6 Jan 2019 14:25:54 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#37353=20player-item.c/h=20?= =?utf8?q?=E5=89=8A=E9=99=A4=E3=80=82=20xtra2.c=20=E3=82=92=20player-statu?= =?utf8?q?s.c=20=E3=81=AB=E5=88=86=E9=9B=A2=E3=80=82=20/=20Delete=20player?= =?utf8?q?-item.c/h.=20Separate=20player-status.c=20fro=20xtra2.c.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Hengband_vcs2017/Hengband/Hengband.vcxproj | 4 +-- src/Makefile.am | 2 +- src/cmd-item.c | 1 - src/cmd4.c | 1 + src/externs.h | 4 --- src/files.c | 1 + src/player-item.c | 15 -------- src/player-item.h | 3 -- src/player-status.c | 56 ++++++++++++++++++++++++++++++ src/player-status.h | 4 +++ src/selfinfo.c | 1 + src/spells3.c | 1 + src/xtra2.c | 53 ---------------------------- 13 files changed, 67 insertions(+), 79 deletions(-) delete mode 100644 src/player-item.c delete mode 100644 src/player-item.h create mode 100644 src/player-status.c create mode 100644 src/player-status.h diff --git a/Hengband_vcs2017/Hengband/Hengband.vcxproj b/Hengband_vcs2017/Hengband/Hengband.vcxproj index 0c0c645d7..88aec26ad 100644 --- a/Hengband_vcs2017/Hengband/Hengband.vcxproj +++ b/Hengband_vcs2017/Hengband/Hengband.vcxproj @@ -158,7 +158,7 @@ - + @@ -285,7 +285,7 @@ - + diff --git a/src/Makefile.am b/src/Makefile.am index b2127a3b5..fbfe7cdef 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -25,7 +25,7 @@ hengband_SOURCES = \ object-curse.c object-curse.h \ object-hook.c object-hook.h object1.c object2.c \ objectkind-hook.c objectkind-hook.h obj_kind.c \ - player-damage.c player-damage.h \ + player-damage.c player-damage.h player-status.c player-status.h \ racial.c \ realm-arcane.c \ realm-arcane.h realm-chaos.c realm-chaos.h realm-craft.c realm-craft.h \ diff --git a/src/cmd-item.c b/src/cmd-item.c index ecd9f8365..ce1b30bd4 100644 --- a/src/cmd-item.c +++ b/src/cmd-item.c @@ -21,7 +21,6 @@ #include "cmd-zaprod.h" #include "cmd-zapwand.h" -#include "player-item.h" #include "object-hook.h" diff --git a/src/cmd4.c b/src/cmd4.c index 3d433bfe6..4004316c3 100644 --- a/src/cmd4.c +++ b/src/cmd4.c @@ -42,6 +42,7 @@ #include "angband.h" #include "cmd-pet.h" #include "world.h" +#include "player-status.h" /* diff --git a/src/externs.h b/src/externs.h index 414205e17..77a30f587 100644 --- a/src/externs.h +++ b/src/externs.h @@ -1285,10 +1285,6 @@ extern void change_race(CHARACTER_IDX new_race, cptr effect_msg); extern HIT_POINT mon_damage_mod(monster_type *m_ptr, HIT_POINT dam, bool is_psy_spear); extern ENERGY bow_energy(OBJECT_SUBTYPE_VALUE sval); extern int bow_tmul(OBJECT_SUBTYPE_VALUE sval); -extern cptr your_alignment(void); -extern int weapon_exp_level(int weapon_exp); -extern int riding_exp_level(int riding_exp); -extern int spell_exp_level(int spell_exp); extern void display_rumor(bool ex); /* artifact.c */ diff --git a/src/files.c b/src/files.c index 2bd5070ff..498443844 100644 --- a/src/files.c +++ b/src/files.c @@ -15,6 +15,7 @@ #include "angband.h" #include "world.h" +#include "player-status.h" /* diff --git a/src/player-item.c b/src/player-item.c deleted file mode 100644 index 19ca9adcb..000000000 --- a/src/player-item.c +++ /dev/null @@ -1,15 +0,0 @@ -#include "angband.h" -#include "player-item.h" - -/*! - * @brief get_item()からのリファクタリング - * @return アイテムのポインタ、キャンセルや不能ならNULLを返す。 - */ -object_type *ref_item(player_type *player_ptr, cptr pmt, cptr str, BIT_FLAGS mode) -{ - OBJECT_IDX idx; - (player_ptr); // しばらくは未使用 - - if(!get_item(&idx, pmt, str, mode)) return NULL; - return idx >= 0 ? &inventory[idx] : &o_list[0 - idx]; -} \ No newline at end of file diff --git a/src/player-item.h b/src/player-item.h deleted file mode 100644 index c76647cf8..000000000 --- a/src/player-item.h +++ /dev/null @@ -1,3 +0,0 @@ - -extern object_type *ref_item(player_type *player_ptr, cptr pmt, cptr str, BIT_FLAGS mode); - diff --git a/src/player-status.c b/src/player-status.c new file mode 100644 index 000000000..3d7f389eb --- /dev/null +++ b/src/player-status.c @@ -0,0 +1,56 @@ +#include "angband.h" +#include "player-status.h" + +/* + * Return alignment title + */ +cptr your_alignment(void) +{ + if (p_ptr->align > 150) return _("大善", "Lawful"); + else if (p_ptr->align > 50) return _("中善", "Good"); + else if (p_ptr->align > 10) return _("小善", "Neutral Good"); + else if (p_ptr->align > -11) return _("中立", "Neutral"); + else if (p_ptr->align > -51) return _("小悪", "Neutral Evil"); + else if (p_ptr->align > -151) return _("中悪", "Evil"); + else return _("大悪", "Chaotic"); +} + + +/* + * Return proficiency level of weapons and misc. skills (except riding) + */ +int weapon_exp_level(int weapon_exp) +{ + if (weapon_exp < WEAPON_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED; + else if (weapon_exp < WEAPON_EXP_SKILLED) return EXP_LEVEL_BEGINNER; + else if (weapon_exp < WEAPON_EXP_EXPERT) return EXP_LEVEL_SKILLED; + else if (weapon_exp < WEAPON_EXP_MASTER) return EXP_LEVEL_EXPERT; + else return EXP_LEVEL_MASTER; +} + + +/* + * Return proficiency level of riding + */ +int riding_exp_level(int riding_exp) +{ + if (riding_exp < RIDING_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED; + else if (riding_exp < RIDING_EXP_SKILLED) return EXP_LEVEL_BEGINNER; + else if (riding_exp < RIDING_EXP_EXPERT) return EXP_LEVEL_SKILLED; + else if (riding_exp < RIDING_EXP_MASTER) return EXP_LEVEL_EXPERT; + else return EXP_LEVEL_MASTER; +} + + +/* + * Return proficiency level of spells + */ +int spell_exp_level(int spell_exp) +{ + if (spell_exp < SPELL_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED; + else if (spell_exp < SPELL_EXP_SKILLED) return EXP_LEVEL_BEGINNER; + else if (spell_exp < SPELL_EXP_EXPERT) return EXP_LEVEL_SKILLED; + else if (spell_exp < SPELL_EXP_MASTER) return EXP_LEVEL_EXPERT; + else return EXP_LEVEL_MASTER; +} + diff --git a/src/player-status.h b/src/player-status.h new file mode 100644 index 000000000..070a28a7c --- /dev/null +++ b/src/player-status.h @@ -0,0 +1,4 @@ +extern cptr your_alignment(void); +extern int weapon_exp_level(int weapon_exp); +extern int riding_exp_level(int riding_exp); +extern int spell_exp_level(int spell_exp); diff --git a/src/selfinfo.c b/src/selfinfo.c index 718c11920..302f1011c 100644 --- a/src/selfinfo.c +++ b/src/selfinfo.c @@ -15,6 +15,7 @@ */ #include "angband.h" +#include "player-status.h" /*! * @brief 自己分析処理(Nethackからのアイデア) / self-knowledge... idea from nethack. diff --git a/src/spells3.c b/src/spells3.c index e62ee3d37..b614987d7 100644 --- a/src/spells3.c +++ b/src/spells3.c @@ -14,6 +14,7 @@ #include "angband.h" #include "object-hook.h" #include "melee.h" +#include "player-status.h" /*! テレポート先探索の試行数 / Maximum number of tries for teleporting */ #define MAX_TRIES 100 diff --git a/src/xtra2.c b/src/xtra2.c index 5271123ed..ef5e19407 100644 --- a/src/xtra2.c +++ b/src/xtra2.c @@ -5149,59 +5149,6 @@ int bow_tmul(OBJECT_SUBTYPE_VALUE sval) return (tmul); } -/* - * Return alignment title - */ -cptr your_alignment(void) -{ - if (p_ptr->align > 150) return _("大善", "Lawful"); - else if (p_ptr->align > 50) return _("中善", "Good"); - else if (p_ptr->align > 10) return _("小善", "Neutral Good"); - else if (p_ptr->align > -11) return _("中立", "Neutral"); - else if (p_ptr->align > -51) return _("小悪", "Neutral Evil"); - else if (p_ptr->align > -151) return _("中悪", "Evil"); - else return _("大悪", "Chaotic"); -} - - -/* - * Return proficiency level of weapons and misc. skills (except riding) - */ -int weapon_exp_level(int weapon_exp) -{ - if (weapon_exp < WEAPON_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED; - else if (weapon_exp < WEAPON_EXP_SKILLED) return EXP_LEVEL_BEGINNER; - else if (weapon_exp < WEAPON_EXP_EXPERT) return EXP_LEVEL_SKILLED; - else if (weapon_exp < WEAPON_EXP_MASTER) return EXP_LEVEL_EXPERT; - else return EXP_LEVEL_MASTER; -} - - -/* - * Return proficiency level of riding - */ -int riding_exp_level(int riding_exp) -{ - if (riding_exp < RIDING_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED; - else if (riding_exp < RIDING_EXP_SKILLED) return EXP_LEVEL_BEGINNER; - else if (riding_exp < RIDING_EXP_EXPERT) return EXP_LEVEL_SKILLED; - else if (riding_exp < RIDING_EXP_MASTER) return EXP_LEVEL_EXPERT; - else return EXP_LEVEL_MASTER; -} - - -/* - * Return proficiency level of spells - */ -int spell_exp_level(int spell_exp) -{ - if (spell_exp < SPELL_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED; - else if (spell_exp < SPELL_EXP_SKILLED) return EXP_LEVEL_BEGINNER; - else if (spell_exp < SPELL_EXP_EXPERT) return EXP_LEVEL_SKILLED; - else if (spell_exp < SPELL_EXP_MASTER) return EXP_LEVEL_EXPERT; - else return EXP_LEVEL_MASTER; -} - /* * Display a rumor and apply its effects -- 2.11.0