OSDN Git Service

[Refactor] #40466 Separated base-status.c/h from player-effects.c/h
authorHourier <hourier@users.sourceforge.jp>
Tue, 30 Jun 2020 14:38:15 +0000 (23:38 +0900)
committerHourier <hourier@users.sourceforge.jp>
Tue, 30 Jun 2020 14:38:15 +0000 (23:38 +0900)
32 files changed:
Hengband/Hengband/Hengband.vcxproj
Hengband/Hengband/Hengband.vcxproj.filters
src/Makefile.am
src/cmd-action/cmd-spell.c
src/cmd-item/cmd-activate.c
src/cmd-item/cmd-eat.c
src/cmd-item/cmd-quaff.c
src/cmd-item/cmd-usestaff.c
src/effect/effect-player-resist-hurt.c
src/effect/effect-player-spirit.c
src/grid/trap.c
src/mind/mind.c
src/monster-attack/monster-attack-status.c
src/monster-attack/monster-attack-switcher.c
src/mspell/mspell-status.c
src/mspell/mspells3.c
src/mutation/mutation-processor.c
src/player/eldritch-horror.c
src/player/patron.c
src/player/player-damage.c
src/player/player-effects.c
src/player/player-effects.h
src/player/player-status.c
src/specific-object/chest.c
src/spell-kind/spells-random.c
src/spell-realm/spells-trump.c
src/spell/spells-status.c
src/spell/spells3.c
src/status/bad-status-setter.c
src/status/base-status.c [new file with mode: 0644]
src/status/base-status.h [new file with mode: 0644]
src/status/form-changer.c

index d9aacd1..308f24c 100644 (file)
     <ClCompile Include="..\..\src\spell-realm\spells-craft.c" />\r
     <ClCompile Include="..\..\src\spell-realm\spells-demon.c" />\r
     <ClCompile Include="..\..\src\status\bad-status-setter.c" />\r
+    <ClCompile Include="..\..\src\status\base-status.c" />\r
     <ClCompile Include="..\..\src\status\buff-setter.c" />\r
     <ClCompile Include="..\..\src\player\player-realm.c" />\r
     <ClCompile Include="..\..\src\spell-kind\spells-curse-removal.c" />\r
     <ClInclude Include="..\..\src\spell-realm\spells-craft.h" />\r
     <ClInclude Include="..\..\src\spell-realm\spells-demon.h" />\r
     <ClInclude Include="..\..\src\status\bad-status-setter.h" />\r
+    <ClInclude Include="..\..\src\status\base-status.h" />\r
     <ClInclude Include="..\..\src\status\buff-setter.h" />\r
     <ClInclude Include="..\..\src\player\player-realm.h" />\r
     <ClInclude Include="..\..\src\player\special-defense-types.h" />\r
index 2a9ef54..cc22f2e 100644 (file)
     <ClCompile Include="..\..\src\mind\mind-magic-resistance.c">
       <Filter>mind</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\status\base-status.c">
+      <Filter>status</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\cmd\cmd-basic.h">
     <ClInclude Include="..\..\src\mind\mind-magic-resistance.h">
       <Filter>mind</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\status\base-status.h">
+      <Filter>status</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\src\wall.bmp" />
index ee33794..2e4e4f9 100644 (file)
@@ -557,6 +557,7 @@ hengband_SOURCES = \
        spell-realm/spells-trump.c spell-realm/spells-trump.h \
        \
        status/bad-status-setter.c status/bad-status-setter.h \
+       status/base-status.c status/base-status.h \
        status/buff-setter.c status/buff-setter.h \
        status/element-resistance.c status/element-resistance.h \
        status/experience.c status/experience.h \
index 86f25df..8ef59e9 100644 (file)
@@ -50,6 +50,7 @@
 #include "spell/spells-summon.h"
 #include "spell/spells-util.h"
 #include "spell/technic-info-table.h"
+#include "status/base-status.h"
 #include "status/experience.h"
 #include "term/screen-processor.h"
 #include "util/buffer-shaper.h"
index b47e066..9b31f71 100644 (file)
@@ -79,6 +79,7 @@
 #include "spell/spells3.h"
 #include "status/bad-status-setter.h"
 #include "status/buff-setter.h"
+#include "status/base-status.h"
 #include "status/element-resistance.h"
 #include "status/experience.h"
 #include "status/form-changer.h"
index 7a400be..a4952fe 100644 (file)
@@ -33,6 +33,7 @@
 #include "player/special-defense-types.h"
 #include "spell-realm/spells-hex.h"
 #include "spell/spells-status.h"
+#include "status/base-status.h"
 #include "status/element-resistance.h"
 #include "status/experience.h"
 #include "sv-definition/sv-food-types.h"
index 1bc35b3..c7fbecd 100644 (file)
@@ -41,6 +41,7 @@
 #include "spell/spells-status.h"
 #include "spell/spells3.h"
 #include "status/bad-status-setter.h"
+#include "status/base-status.h"
 #include "status/buff-setter.h"
 #include "status/element-resistance.h"
 #include "status/experience.h"
index eb08350..53d869b 100644 (file)
@@ -37,6 +37,7 @@
 #include "spell/spells-staff-only.h"
 #include "spell/spells-status.h"
 #include "spell/spells-summon.h"
+#include "status/base-status.h"
 #include "status/experience.h"
 #include "status/form-changer.h"
 #include "sv-definition/sv-staff-types.h"
index 35f3207..40034ce 100644 (file)
@@ -14,6 +14,7 @@
 #include "spell-kind/spells-teleport.h"
 #include "spell/spells-status.h"
 #include "spell/spells3.h"
+#include "status/base-status.h"
 #include "status/element-resistance.h"
 #include "status/experience.h"
 #include "system/object-type-definition.h"
index a5992f5..837be82 100644 (file)
@@ -3,7 +3,7 @@
 #include "mspell/mspells3.h"
 #include "status/bad-status-setter.h"
 #include "player/player-damage.h"
-#include "player/player-effects.h"
+#include "status/base-status.h"
 #include "view/display-messages.h"
 #include "world/world.h"
 
index 0910b65..aed171c 100644 (file)
@@ -22,7 +22,6 @@
 #include "status/bad-status-setter.h"
 #include "player/player-class.h"
 #include "player/player-damage.h"
-#include "player/player-effects.h"
 #include "player/player-move.h"
 #include "player/player-personalities-types.h"
 #include "player/player-status.h"
@@ -33,6 +32,7 @@
 #include "spell/process-effect.h"
 #include "spell/spells-summon.h"
 #include "spell/spell-types.h"
+#include "status/base-status.h"
 #include "status/element-resistance.h"
 #include "util/bit-flags-calculator.h"
 #include "view/display-messages.h"
index 275b512..e9a66e3 100644 (file)
@@ -64,6 +64,7 @@
 #include "spell/spell-types.h"
 #include "spell/spells3.h"
 #include "status/bad-status-setter.h"
+#include "status/base-status.h"
 #include "status/buff-setter.h"
 #include "status/element-resistance.h"
 #include "status/sight-setter.h"
index 3aca4f1..a56ff70 100644 (file)
@@ -8,8 +8,8 @@
 #include "mind/mind-mirror-master.h"
 #include "monster-race/monster-race.h"
 #include "monster-race/race-indice-types.h"
-#include "player/player-effects.h"
 #include "status/bad-status-setter.h"
+#include "status/base-status.h"
 #include "status/experience.h"
 #include "view/display-messages.h"
 
index 592694c..bdd8b11 100644 (file)
 #include "monster/monster-status.h"
 #include "monster/monster-update.h"
 #include "player/player-damage.h"
-#include "player/player-effects.h"
 #include "spell-kind/earthquake.h"
 #include "spell/spells3.h"
 #include "status/bad-status-setter.h"
+#include "status/base-status.h"
 #include "status/element-resistance.h"
 #include "status/experience.h"
 #include "system/object-type-definition.h"
index 33db1ac..1262e78 100644 (file)
@@ -20,6 +20,7 @@
 #include "mspell/mspells1.h"
 #include "mspell/mspells3.h"
 #include "status/bad-status-setter.h"
+#include "status/base-status.h"
 #include "player/player-effects.h"
 #include "player/player-move.h"
 #include "player/player-personalities-types.h"
index cc459e2..c648fc9 100644 (file)
@@ -43,8 +43,6 @@
 #include "mspell/mspell-mask-definitions.h"
 #include "mspell/mspell-type.h"
 #include "player/avatar.h"
-#include "status/bad-status-setter.h"
-#include "status/buff-setter.h"
 #include "player/player-effects.h"
 #include "player/player-status.h"
 #include "realm/realm-types.h"
@@ -57,6 +55,9 @@
 #include "spell/spell-types.h"
 #include "spell/spells-status.h"
 #include "spell/spells-summon.h"
+#include "status/bad-status-setter.h"
+#include "status/base-status.h"
+#include "status/buff-setter.h"
 #include "status/experience.h"
 #include "term/screen-processor.h"
 #include "util/int-char-converter.h"
index 170d128..c446481 100644 (file)
@@ -25,6 +25,7 @@
 #include "spell/spells-summon.h"
 #include "spell/spells3.h"
 #include "status/bad-status-setter.h"
+#include "status/base-status.h"
 #include "status/buff-setter.h"
 #include "status/form-changer.h"
 #include "status/sight-setter.h"
index 65bc886..3a82e95 100644 (file)
@@ -20,9 +20,9 @@
 #include "monster/monster-util.h"
 #include "monster/smart-learn-types.h"
 #include "status/bad-status-setter.h"
-#include "player/player-effects.h"
 #include "player/player-status.h"
 #include "player/mimic-info-table.h"
+#include "status/base-status.h"
 #include "view/display-messages.h"
 #include "world/world.h"
 
index 8d9e6a2..c51030c 100644 (file)
@@ -24,6 +24,7 @@
 #include "spell/spells-status.h"
 #include "spell/spells-summon.h"
 #include "spell/spell-types.h"
+#include "status/base-status.h"
 #include "status/experience.h"
 #include "view/display-messages.h"
 
index 1ea302d..9af541c 100644 (file)
 #include "object/item-tester-hooker.h"
 #include "player/avatar.h"
 #include "player/player-class.h"
-#include "player/player-effects.h"
 #include "player/player-move.h"
 #include "player/player-personalities-types.h"
 #include "player/player-race-types.h"
 #include "player/race-info-table.h"
 #include "player/special-defense-types.h"
+#include "status/base-status.h"
 #include "status/element-resistance.h"
 #include "term/screen-processor.h"
 #include "term/term-color-types.h"
index 53aa5f5..4c30d71 100644 (file)
 #include "spell-realm/spells-song.h"
 #include "spell/spells-status.h"
 #include "status/bad-status-setter.h"
+#include "status/base-status.h"
 #include "status/buff-setter.h"
 #include "status/element-resistance.h"
-#include "status/form-changer.h" // todo 相互依存.
+#include "status/form-changer.h"
 #include "status/sight-setter.h"
 #include "status/temporary-resistance.h"
 #include "sv-definition/sv-armor-types.h"
@@ -464,160 +465,6 @@ bool set_kabenuke(player_type *creature_ptr, TIME_EFFECT v, bool do_dec)
     return TRUE;
 }
 
-/*!
- * @brief プレイヤーの基本能力値を増加させる / Increases a stat by one randomized level -RAK-
- * @param stat 上昇させるステータスID
- * @return 実際に上昇した場合TRUEを返す。
- * @details
- * Note that this function (used by stat potions) now restores\n
- * the stat BEFORE increasing it.\n
- */
-bool inc_stat(player_type *creature_ptr, int stat)
-{
-    BASE_STATUS gain;
-    BASE_STATUS value = creature_ptr->stat_cur[stat];
-
-    if (value < creature_ptr->stat_max_max[stat]) {
-        if (value < 18) {
-            gain = ((randint0(100) < 75) ? 1 : 2);
-            value += gain;
-        } else if (value < (creature_ptr->stat_max_max[stat] - 2)) {
-            gain = (((creature_ptr->stat_max_max[stat]) - value) / 2 + 3) / 2;
-            if (gain < 1)
-                gain = 1;
-
-            value += randint1(gain) + gain / 2;
-            if (value > (creature_ptr->stat_max_max[stat] - 1))
-                value = creature_ptr->stat_max_max[stat] - 1;
-        } else {
-            value++;
-        }
-
-        creature_ptr->stat_cur[stat] = value;
-        if (value > creature_ptr->stat_max[stat]) {
-            creature_ptr->stat_max[stat] = value;
-        }
-
-        creature_ptr->update |= (PU_BONUS);
-        return TRUE;
-    }
-
-    return FALSE;
-}
-
-/*!
- * @brief プレイヤーの基本能力値を減少させる / Decreases a stat by an amount indended to vary from 0 to 100 percent.
- * @param stat 減少させるステータスID
- * @param amount 減少させる基本量
- * @param permanent TRUEならば現在の最大値を減少させる
- * @return 実際に減少した場合TRUEを返す。
- * @details
- *\n
- * Amount could be a little higher in extreme cases to mangle very high\n
- * stats from massive assaults.  -CWS\n
- *\n
- * Note that "permanent" means that the *given* amount is permanent,\n
- * not that the new value becomes permanent.  This may not work exactly\n
- * as expected, due to "weirdness" in the algorithm, but in general,\n
- * if your stat is already drained, the "max" value will not drop all\n
- * the way down to the "cur" value.\n
- */
-bool dec_stat(player_type *creature_ptr, int stat, int amount, int permanent)
-{
-    int loss;
-    bool res = FALSE;
-
-    BASE_STATUS cur = creature_ptr->stat_cur[stat];
-    BASE_STATUS max = creature_ptr->stat_max[stat];
-    int same = (cur == max);
-    if (cur > 3) {
-        if (cur <= 18) {
-            if (amount > 90)
-                cur--;
-            if (amount > 50)
-                cur--;
-            if (amount > 20)
-                cur--;
-            cur--;
-        } else {
-            loss = (((cur - 18) / 2 + 1) / 2 + 1);
-            if (loss < 1)
-                loss = 1;
-
-            loss = ((randint1(loss) + loss) * amount) / 100;
-            if (loss < amount / 2)
-                loss = amount / 2;
-
-            cur = cur - loss;
-            if (cur < 18)
-                cur = (amount <= 20) ? 18 : 17;
-        }
-
-        if (cur < 3)
-            cur = 3;
-
-        if (cur != creature_ptr->stat_cur[stat])
-            res = TRUE;
-    }
-
-    if (permanent && (max > 3)) {
-        chg_virtue(creature_ptr, V_SACRIFICE, 1);
-        if (stat == A_WIS || stat == A_INT)
-            chg_virtue(creature_ptr, V_ENLIGHTEN, -2);
-
-        if (max <= 18) {
-            if (amount > 90)
-                max--;
-            if (amount > 50)
-                max--;
-            if (amount > 20)
-                max--;
-            max--;
-        } else {
-            loss = (((max - 18) / 2 + 1) / 2 + 1);
-            loss = ((randint1(loss) + loss) * amount) / 100;
-            if (loss < amount / 2)
-                loss = amount / 2;
-
-            max = max - loss;
-            if (max < 18)
-                max = (amount <= 20) ? 18 : 17;
-        }
-
-        if (same || (max < cur))
-            max = cur;
-
-        if (max != creature_ptr->stat_max[stat])
-            res = TRUE;
-    }
-
-    if (res) {
-        creature_ptr->stat_cur[stat] = cur;
-        creature_ptr->stat_max[stat] = max;
-        creature_ptr->redraw |= (PR_STATS);
-        creature_ptr->update |= (PU_BONUS);
-    }
-
-    return (res);
-}
-
-/*!
- * @brief プレイヤーの基本能力値を回復させる / Restore a stat.  Return TRUE only if this actually makes a difference.
- * @param stat 回復ステータスID
- * @return 実際に回復した場合TRUEを返す。
- */
-bool res_stat(player_type *creature_ptr, int stat)
-{
-    if (creature_ptr->stat_cur[stat] != creature_ptr->stat_max[stat]) {
-        creature_ptr->stat_cur[stat] = creature_ptr->stat_max[stat];
-        creature_ptr->update |= (PU_BONUS);
-        creature_ptr->redraw |= (PR_STATS);
-        return TRUE;
-    }
-
-    return FALSE;
-}
-
 /*
  * Increase players hit points, notice effects
  */
@@ -661,136 +508,6 @@ bool hp_player(player_type *creature_ptr, int num)
     return FALSE;
 }
 
-/*
- * Array of stat "descriptions"
- */
-static concptr desc_stat_pos[]
-    = { _("強く", "stronger"), _("知的に", "smarter"), _("賢く", "wiser"), _("器用に", "more dextrous"), _("健康に", "healthier"), _("美しく", "cuter") };
-
-/*
- * Array of stat "descriptions"
- */
-static concptr desc_stat_neg[]
-    = { _("弱く", "weaker"), _("無知に", "stupider"), _("愚かに", "more naive"), _("不器用に", "clumsier"), _("不健康に", "more sickly"), _("醜く", "uglier") };
-
-/*
- * Lose a "point"
- */
-bool do_dec_stat(player_type *creature_ptr, int stat)
-{
-    bool sust = FALSE;
-
-    /* Access the "sustain" */
-    switch (stat) {
-    case A_STR:
-        if (creature_ptr->sustain_str)
-            sust = TRUE;
-        break;
-    case A_INT:
-        if (creature_ptr->sustain_int)
-            sust = TRUE;
-        break;
-    case A_WIS:
-        if (creature_ptr->sustain_wis)
-            sust = TRUE;
-        break;
-    case A_DEX:
-        if (creature_ptr->sustain_dex)
-            sust = TRUE;
-        break;
-    case A_CON:
-        if (creature_ptr->sustain_con)
-            sust = TRUE;
-        break;
-    case A_CHR:
-        if (creature_ptr->sustain_chr)
-            sust = TRUE;
-        break;
-    }
-
-    if (sust && (!ironman_nightmare || randint0(13))) {
-        msg_format(_("%sなった気がしたが、すぐに元に戻った。", "You feel %s for a moment, but the feeling passes."), desc_stat_neg[stat]);
-
-        return TRUE;
-    }
-
-    if (dec_stat(creature_ptr, stat, 10, (ironman_nightmare && !randint0(13)))) {
-        msg_format(_("ひどく%sなった気がする。", "You feel %s."), desc_stat_neg[stat]);
-
-        return TRUE;
-    }
-
-    return FALSE;
-}
-
-/*
- * Restore lost "points" in a stat
- */
-bool do_res_stat(player_type *creature_ptr, int stat)
-{
-    if (res_stat(creature_ptr, stat)) {
-        msg_format(_("元通りに%sなった気がする。", "You feel %s."), desc_stat_pos[stat]);
-        return TRUE;
-    }
-
-    return FALSE;
-}
-
-/*
- * Gain a "point" in a stat
- */
-bool do_inc_stat(player_type *creature_ptr, int stat)
-{
-    bool res = res_stat(creature_ptr, stat);
-    if (inc_stat(creature_ptr, stat)) {
-        if (stat == A_WIS) {
-            chg_virtue(creature_ptr, V_ENLIGHTEN, 1);
-            chg_virtue(creature_ptr, V_FAITH, 1);
-        } else if (stat == A_INT) {
-            chg_virtue(creature_ptr, V_KNOWLEDGE, 1);
-            chg_virtue(creature_ptr, V_ENLIGHTEN, 1);
-        } else if (stat == A_CON)
-            chg_virtue(creature_ptr, V_VITALITY, 1);
-
-        msg_format(_("ワーオ!とても%sなった!", "Wow! You feel %s!"), desc_stat_pos[stat]);
-        return TRUE;
-    }
-
-    if (res) {
-        msg_format(_("元通りに%sなった気がする。", "You feel %s."), desc_stat_pos[stat]);
-        return TRUE;
-    }
-
-    return FALSE;
-}
-
-/*
- * Forget everything
- */
-bool lose_all_info(player_type *creature_ptr)
-{
-    chg_virtue(creature_ptr, V_KNOWLEDGE, -5);
-    chg_virtue(creature_ptr, V_ENLIGHTEN, -5);
-    for (int i = 0; i < INVEN_TOTAL; i++) {
-        object_type *o_ptr = &creature_ptr->inventory_list[i];
-        if (!o_ptr->k_idx)
-            continue;
-        if (object_is_fully_known(o_ptr))
-            continue;
-
-        o_ptr->feeling = FEEL_NONE;
-        o_ptr->ident &= ~(IDENT_EMPTY);
-        o_ptr->ident &= ~(IDENT_KNOWN);
-        o_ptr->ident &= ~(IDENT_SENSE);
-    }
-
-    creature_ptr->update |= (PU_BONUS);
-    creature_ptr->update |= (PU_COMBINE | PU_REORDER);
-    creature_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
-    wiz_dark(creature_ptr);
-    return TRUE;
-}
-
 void do_poly_wounds(player_type *creature_ptr)
 {
     s16b wounds = creature_ptr->cut;
index a090d87..989f145 100644 (file)
@@ -9,14 +9,7 @@ bool set_invuln(player_type *creature_ptr, TIME_EFFECT v, bool do_dec);
 bool set_tim_regen(player_type *creature_ptr, TIME_EFFECT v, bool do_dec);
 bool set_tim_reflect(player_type *creature_ptr, TIME_EFFECT v, bool do_dec);
 bool set_kabenuke(player_type *creature_ptr, TIME_EFFECT v, bool do_dec);
-bool inc_stat(player_type *creature_ptr, int stat);
-bool dec_stat(player_type *creature_ptr, int stat, int amount, int permanent);
-bool res_stat(player_type *creature_ptr, int stat);
 bool hp_player(player_type *creature_ptr, int num);
-bool do_dec_stat(player_type *creature_ptr, int stat);
-bool do_res_stat(player_type *creature_ptr, int stat);
-bool do_inc_stat(player_type *creature_ptr, int stat);
-bool lose_all_info(player_type *creature_ptr);
 void do_poly_self(player_type *creature_ptr);
 void do_poly_wounds(player_type *creature_ptr);
 void change_race(player_type *creature_ptr, player_race_type new_race, concptr effect_msg);
index 5d92495..e7bb640 100644 (file)
@@ -76,6 +76,7 @@
 #include "spell/spells-status.h"
 #include "spell/spells-util.h"
 #include "spell/technic-info-table.h"
+#include "status/base-status.h"
 #include "sv-definition/sv-lite-types.h"
 #include "sv-definition/sv-weapon-types.h"
 #include "term/screen-processor.h"
index 4f6c1be..17b34ad 100644 (file)
 #include "perception/object-perception.h"
 #include "player/player-class.h"
 #include "player/player-damage.h"
-#include "player/player-effects.h"
 #include "spell-kind/spells-launcher.h"
 #include "spell-kind/spells-sight.h"
 #include "spell/spells-summon.h"
 #include "spell/spell-types.h"
 #include "spell/spells3.h"
 #include "status/bad-status-setter.h"
+#include "status/base-status.h"
 #include "status/element-resistance.h"
 #include "sv-definition/sv-other-types.h"
 #include "system/object-type-definition.h"
index 5582ba2..166be76 100644 (file)
@@ -32,6 +32,7 @@
 #include "spell/spells-summon.h"
 #include "spell/spell-types.h"
 #include "spell/spells3.h"
+#include "status/base-status.h"
 #include "status/experience.h"
 #include "view/display-messages.h"
 
index a00cacf..fee8b78 100644 (file)
@@ -6,7 +6,6 @@
 #include "mutation/mutation.h"
 #include "player/avatar.h"
 #include "status/buff-setter.h"
-#include "player/player-effects.h"
 #include "spell-kind/earthquake.h"
 #include "spell-kind/spells-charm.h"
 #include "spell-kind/spells-floor.h"
@@ -17,6 +16,7 @@
 #include "spell-kind/spells-teleport.h"
 #include "spell/spells-status.h"
 #include "spell/spells-summon.h"
+#include "status/base-status.h"
 #include "status/experience.h"
 #include "view/display-messages.h"
 
index e402edd..1f4ef86 100644 (file)
@@ -29,6 +29,7 @@
 #include "spell-kind/spells-launcher.h"
 #include "spell-kind/spells-teleport.h"
 #include "spell/spell-types.h"
+#include "status/base-status.h"
 #include "status/experience.h"
 #include "status/form-changer.h"
 #include "status/sight-setter.h"
index 10540cb..b72e3ea 100644 (file)
@@ -86,7 +86,6 @@
 #include "player/digestion-processor.h"
 #include "player/player-class.h"
 #include "player/player-damage.h"
-#include "player/player-effects.h"
 #include "player/player-move.h"
 #include "player/player-personalities-types.h"
 #include "player/player-skill.h"
 #include "spell/spells-summon.h"
 #include "spell/technic-info-table.h"
 #include "status/bad-status-setter.h"
+#include "status/base-status.h"
 #include "status/experience.h"
 #include "term/screen-processor.h"
 #include "term/term-color-types.h"
index 53fe243..72b4f45 100644 (file)
@@ -3,12 +3,12 @@
 #include "game-option/disturbance-options.h"
 #include "mind/mind-sniper.h"
 #include "player/avatar.h"
-#include "player/player-effects.h" // todo do_dec_stat()、後で依存を消す.
 #include "player/player-move.h"
 #include "player/player-race.h"
 #include "player/special-defense-types.h"
 #include "realm/realm-types.h"
 #include "spell-realm/spells-hex.h"
+#include "status/base-status.h"
 #include "status/form-changer.h"
 #include "view/display-messages.h"
 
diff --git a/src/status/base-status.c b/src/status/base-status.c
new file mode 100644 (file)
index 0000000..3b2bb8b
--- /dev/null
@@ -0,0 +1,289 @@
+#include "status/base-status.h"
+#include "game-option/birth-options.h"
+#include "object-enchant/item-feeling.h"
+#include "object-enchant/special-object-flags.h"
+#include "perception/object-perception.h"
+#include "player/avatar.h"
+#include "spell-kind/spells-floor.h"
+#include "system/object-type-definition.h"
+#include "view/display-messages.h"
+
+/* Array of stat "descriptions" */
+static concptr desc_stat_pos[]
+    = { _("強く", "stronger"), _("知的に", "smarter"), _("賢く", "wiser"), _("器用に", "more dextrous"), _("健康に", "healthier"), _("美しく", "cuter") };
+
+/* Array of stat "descriptions" */
+static concptr desc_stat_neg[]
+    = { _("弱く", "weaker"), _("無知に", "stupider"), _("愚かに", "more naive"), _("不器用に", "clumsier"), _("不健康に", "more sickly"), _("醜く", "uglier") };
+
+/*!
+ * @brief プレイヤーの基本能力値を増加させる / Increases a stat by one randomized level -RAK-
+ * @param stat 上昇させるステータスID
+ * @return 実際に上昇した場合TRUEを返す。
+ * @details
+ * Note that this function (used by stat potions) now restores\n
+ * the stat BEFORE increasing it.\n
+ */
+bool inc_stat(player_type *creature_ptr, int stat)
+{
+    BASE_STATUS gain;
+    BASE_STATUS value = creature_ptr->stat_cur[stat];
+
+    if (value < creature_ptr->stat_max_max[stat]) {
+        if (value < 18) {
+            gain = ((randint0(100) < 75) ? 1 : 2);
+            value += gain;
+        } else if (value < (creature_ptr->stat_max_max[stat] - 2)) {
+            gain = (((creature_ptr->stat_max_max[stat]) - value) / 2 + 3) / 2;
+            if (gain < 1)
+                gain = 1;
+
+            value += randint1(gain) + gain / 2;
+            if (value > (creature_ptr->stat_max_max[stat] - 1))
+                value = creature_ptr->stat_max_max[stat] - 1;
+        } else {
+            value++;
+        }
+
+        creature_ptr->stat_cur[stat] = value;
+        if (value > creature_ptr->stat_max[stat]) {
+            creature_ptr->stat_max[stat] = value;
+        }
+
+        creature_ptr->update |= (PU_BONUS);
+        return TRUE;
+    }
+
+    return FALSE;
+}
+
+/*!
+ * @brief プレイヤーの基本能力値を減少させる / Decreases a stat by an amount indended to vary from 0 to 100 percent.
+ * @param stat 減少させるステータスID
+ * @param amount 減少させる基本量
+ * @param permanent TRUEならば現在の最大値を減少させる
+ * @return 実際に減少した場合TRUEを返す。
+ * @details
+ *\n
+ * Amount could be a little higher in extreme cases to mangle very high\n
+ * stats from massive assaults.  -CWS\n
+ *\n
+ * Note that "permanent" means that the *given* amount is permanent,\n
+ * not that the new value becomes permanent.  This may not work exactly\n
+ * as expected, due to "weirdness" in the algorithm, but in general,\n
+ * if your stat is already drained, the "max" value will not drop all\n
+ * the way down to the "cur" value.\n
+ */
+bool dec_stat(player_type *creature_ptr, int stat, int amount, int permanent)
+{
+    int loss;
+    bool res = FALSE;
+
+    BASE_STATUS cur = creature_ptr->stat_cur[stat];
+    BASE_STATUS max = creature_ptr->stat_max[stat];
+    int same = (cur == max);
+    if (cur > 3) {
+        if (cur <= 18) {
+            if (amount > 90)
+                cur--;
+            if (amount > 50)
+                cur--;
+            if (amount > 20)
+                cur--;
+            cur--;
+        } else {
+            loss = (((cur - 18) / 2 + 1) / 2 + 1);
+            if (loss < 1)
+                loss = 1;
+
+            loss = ((randint1(loss) + loss) * amount) / 100;
+            if (loss < amount / 2)
+                loss = amount / 2;
+
+            cur = cur - loss;
+            if (cur < 18)
+                cur = (amount <= 20) ? 18 : 17;
+        }
+
+        if (cur < 3)
+            cur = 3;
+
+        if (cur != creature_ptr->stat_cur[stat])
+            res = TRUE;
+    }
+
+    if (permanent && (max > 3)) {
+        chg_virtue(creature_ptr, V_SACRIFICE, 1);
+        if (stat == A_WIS || stat == A_INT)
+            chg_virtue(creature_ptr, V_ENLIGHTEN, -2);
+
+        if (max <= 18) {
+            if (amount > 90)
+                max--;
+            if (amount > 50)
+                max--;
+            if (amount > 20)
+                max--;
+            max--;
+        } else {
+            loss = (((max - 18) / 2 + 1) / 2 + 1);
+            loss = ((randint1(loss) + loss) * amount) / 100;
+            if (loss < amount / 2)
+                loss = amount / 2;
+
+            max = max - loss;
+            if (max < 18)
+                max = (amount <= 20) ? 18 : 17;
+        }
+
+        if (same || (max < cur))
+            max = cur;
+
+        if (max != creature_ptr->stat_max[stat])
+            res = TRUE;
+    }
+
+    if (res) {
+        creature_ptr->stat_cur[stat] = cur;
+        creature_ptr->stat_max[stat] = max;
+        creature_ptr->redraw |= (PR_STATS);
+        creature_ptr->update |= (PU_BONUS);
+    }
+
+    return (res);
+}
+
+/*!
+ * @brief プレイヤーの基本能力値を回復させる / Restore a stat.  Return TRUE only if this actually makes a difference.
+ * @param stat 回復ステータスID
+ * @return 実際に回復した場合TRUEを返す。
+ */
+bool res_stat(player_type *creature_ptr, int stat)
+{
+    if (creature_ptr->stat_cur[stat] != creature_ptr->stat_max[stat]) {
+        creature_ptr->stat_cur[stat] = creature_ptr->stat_max[stat];
+        creature_ptr->update |= (PU_BONUS);
+        creature_ptr->redraw |= (PR_STATS);
+        return TRUE;
+    }
+
+    return FALSE;
+}
+
+/*
+ * Lose a "point"
+ */
+bool do_dec_stat(player_type *creature_ptr, int stat)
+{
+    bool sust = FALSE;
+
+    /* Access the "sustain" */
+    switch (stat) {
+    case A_STR:
+        if (creature_ptr->sustain_str)
+            sust = TRUE;
+        break;
+    case A_INT:
+        if (creature_ptr->sustain_int)
+            sust = TRUE;
+        break;
+    case A_WIS:
+        if (creature_ptr->sustain_wis)
+            sust = TRUE;
+        break;
+    case A_DEX:
+        if (creature_ptr->sustain_dex)
+            sust = TRUE;
+        break;
+    case A_CON:
+        if (creature_ptr->sustain_con)
+            sust = TRUE;
+        break;
+    case A_CHR:
+        if (creature_ptr->sustain_chr)
+            sust = TRUE;
+        break;
+    }
+
+    if (sust && (!ironman_nightmare || randint0(13))) {
+        msg_format(_("%sなった気がしたが、すぐに元に戻った。", "You feel %s for a moment, but the feeling passes."), desc_stat_neg[stat]);
+
+        return TRUE;
+    }
+
+    if (dec_stat(creature_ptr, stat, 10, (ironman_nightmare && !randint0(13)))) {
+        msg_format(_("ひどく%sなった気がする。", "You feel %s."), desc_stat_neg[stat]);
+
+        return TRUE;
+    }
+
+    return FALSE;
+}
+
+/*
+ * Restore lost "points" in a stat
+ */
+bool do_res_stat(player_type *creature_ptr, int stat)
+{
+    if (res_stat(creature_ptr, stat)) {
+        msg_format(_("元通りに%sなった気がする。", "You feel %s."), desc_stat_pos[stat]);
+        return TRUE;
+    }
+
+    return FALSE;
+}
+
+/*
+ * Gain a "point" in a stat
+ */
+bool do_inc_stat(player_type *creature_ptr, int stat)
+{
+    bool res = res_stat(creature_ptr, stat);
+    if (inc_stat(creature_ptr, stat)) {
+        if (stat == A_WIS) {
+            chg_virtue(creature_ptr, V_ENLIGHTEN, 1);
+            chg_virtue(creature_ptr, V_FAITH, 1);
+        } else if (stat == A_INT) {
+            chg_virtue(creature_ptr, V_KNOWLEDGE, 1);
+            chg_virtue(creature_ptr, V_ENLIGHTEN, 1);
+        } else if (stat == A_CON)
+            chg_virtue(creature_ptr, V_VITALITY, 1);
+
+        msg_format(_("ワーオ!とても%sなった!", "Wow! You feel %s!"), desc_stat_pos[stat]);
+        return TRUE;
+    }
+
+    if (res) {
+        msg_format(_("元通りに%sなった気がする。", "You feel %s."), desc_stat_pos[stat]);
+        return TRUE;
+    }
+
+    return FALSE;
+}
+
+/*
+ * Forget everything
+ */
+bool lose_all_info(player_type *creature_ptr)
+{
+    chg_virtue(creature_ptr, V_KNOWLEDGE, -5);
+    chg_virtue(creature_ptr, V_ENLIGHTEN, -5);
+    for (int i = 0; i < INVEN_TOTAL; i++) {
+        object_type *o_ptr = &creature_ptr->inventory_list[i];
+        if (!o_ptr->k_idx)
+            continue;
+        if (object_is_fully_known(o_ptr))
+            continue;
+
+        o_ptr->feeling = FEEL_NONE;
+        o_ptr->ident &= ~(IDENT_EMPTY);
+        o_ptr->ident &= ~(IDENT_KNOWN);
+        o_ptr->ident &= ~(IDENT_SENSE);
+    }
+
+    creature_ptr->update |= (PU_BONUS);
+    creature_ptr->update |= (PU_COMBINE | PU_REORDER);
+    creature_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
+    wiz_dark(creature_ptr);
+    return TRUE;
+}
diff --git a/src/status/base-status.h b/src/status/base-status.h
new file mode 100644 (file)
index 0000000..38cf65a
--- /dev/null
@@ -0,0 +1,11 @@
+#pragma once
+
+#include "system/angband.h"
+
+bool inc_stat(player_type *creature_ptr, int stat);
+bool dec_stat(player_type *creature_ptr, int stat, int amount, int permanent);
+bool res_stat(player_type *creature_ptr, int stat);
+bool do_dec_stat(player_type *creature_ptr, int stat);
+bool do_res_stat(player_type *creature_ptr, int stat);
+bool do_inc_stat(player_type *creature_ptr, int stat);
+bool lose_all_info(player_type *creature_ptr);
index 983ab45..bece2d0 100644 (file)
@@ -3,8 +3,8 @@
 #include "game-option/disturbance-options.h"
 #include "player/avatar.h"
 #include "player/player-move.h"
-#include "player/player-effects.h" // todo 相互依存.
 #include "player/player-race.h"
+#include "status/base-status.h"
 #include "status/element-resistance.h"
 #include "view/display-messages.h"