OSDN Git Service

[Refactor] #39962 display_player_various() からstrengthen_basedam() を分離 / Separated...
authorHourier <hourier@users.sourceforge.jp>
Sun, 23 Feb 2020 14:11:35 +0000 (23:11 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sun, 23 Feb 2020 14:11:35 +0000 (23:11 +0900)
src/view/status-first-page.c

index 6e24032..05cbff3 100644 (file)
@@ -102,6 +102,39 @@ static bool calc_weapon_one_hand(object_type *o_ptr, int hand, int *damage, int
 
 
 /*!
+ * @brief \83\94\83H\81[\83p\83\8b\95\90\8aí\93\99\82É\82æ\82é\83_\83\81\81[\83W\8b­\89»
+ * @param creature_ptr \83v\83\8c\81[\83\84\81[\82Ö\82Ì\8eQ\8fÆ\83|\83C\83\93\83^
+ * @param o_ptr \91\95\94õ\92\86\82Ì\95\90\8aí\82Ö\82Ì\8eQ\8fÆ\83|\83C\83\93\83^
+ * @param basedam \91f\8eè\82É\82¨\82¯\82é\92¼\90Ú\8dU\8c\82\82Ì\83_\83\81\81[\83W
+ * @param flgs \83I\83u\83W\83F\83N\83g\83t\83\89\83O\8cQ
+ * @return \8b­\89»\8cã\82Ì\91f\8eè\83_\83\81\81[\83W
+ */
+static int strengthen_basedam(player_type *creature_ptr, object_type *o_ptr, int basedam, BIT_FLAGS *flgs)
+{
+       if (OBJECT_IS_FULL_KNOWN(o_ptr) && ((o_ptr->name1 == ART_VORPAL_BLADE) || (o_ptr->name1 == ART_CHAINSWORD)))
+       {
+               /* vorpal blade */
+               basedam *= 5;
+               basedam /= 3;
+       }
+       else if (have_flag(flgs, TR_VORPAL))
+       {
+               /* vorpal flag only */
+               basedam *= 11;
+               basedam /= 9;
+       }
+
+       // \97\9d\97Í
+       bool is_force = creature_ptr->pclass != CLASS_SAMURAI;
+       is_force &= have_flag(flgs, TR_FORCE_WEAPON);
+       is_force &= creature_ptr->csp > (o_ptr->dd * o_ptr->ds / 5);
+       if (is_force) basedam = basedam * 7 / 2;
+
+       return basedam;
+}
+
+
+/*!
  * @brief \8bZ\94\\83\89\83\93\83N\82Ì\95\\8e¦\8aî\8f\80\82ð\92è\82ß\82é
  * Returns a "rating" of x depending on y
  * @param x \8bZ\94\\92l
@@ -327,22 +360,7 @@ void display_player_various(player_type *creature_ptr, void(*display_player_one_
                object_flags_known(o_ptr, flgs);
 
                basedam = calc_expect_crit(creature_ptr, o_ptr->weight, to_h[i], basedam, creature_ptr->dis_to_h[i], poison_needle);
-               if (OBJECT_IS_FULL_KNOWN(o_ptr) && ((o_ptr->name1 == ART_VORPAL_BLADE) || (o_ptr->name1 == ART_CHAINSWORD)))
-               {
-                       /* vorpal blade */
-                       basedam *= 5;
-                       basedam /= 3;
-               }
-               else if (have_flag(flgs, TR_VORPAL))
-               {
-                       /* vorpal flag only */
-                       basedam *= 11;
-                       basedam /= 9;
-               }
-
-               if ((creature_ptr->pclass != CLASS_SAMURAI) && have_flag(flgs, TR_FORCE_WEAPON) && (creature_ptr->csp > (o_ptr->dd * o_ptr->ds / 5)))
-                       basedam = basedam * 7 / 2;
-
+               basedam = strengthen_basedam(creature_ptr, o_ptr, basedam, flgs);
                damage[i] += basedam;
                if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_POISON_NEEDLE)) damage[i] = 1;
                if (damage[i] < 0) damage[i] = 0;