OSDN Git Service

[Refactor] #1370 Moved set_racial_chance() from cmd-throw.cpp to throw-util.cpp/h
authorHourier <grapefox.whitelucifer.0408@gmail.com>
Thu, 19 Aug 2021 15:36:07 +0000 (00:36 +0900)
committerHourier <grapefox.whitelucifer.0408@gmail.com>
Thu, 19 Aug 2021 15:36:07 +0000 (00:36 +0900)
src/action/throw-util.cpp
src/action/throw-util.h
src/cmd-item/cmd-throw.cpp

index da50678..871cf13 100644 (file)
@@ -143,6 +143,17 @@ void it_type::set_class_specific_throw_params()
         && ((this->q_ptr->tval == TV_SPIKE) || ((has_flag(this->obj_flags, TR_THROW)) && (this->q_ptr->tval == TV_SWORD)));
 }
 
+void it_type::set_racial_chance()
+{
+    if (has_flag(this->obj_flags, TR_THROW))
+        this->chance = ((this->creature_ptr->skill_tht) + ((this->creature_ptr->to_h_b + this->q_ptr->to_h) * BTH_PLUS_ADJ));
+    else
+        this->chance = (this->creature_ptr->skill_tht + (this->creature_ptr->to_h_b * BTH_PLUS_ADJ));
+
+    if (this->shuriken != 0)
+        this->chance *= 2;
+}
+
 bool it_type::check_what_throw()
 {
     if (this->shuriken >= 0) {
index 7225fb3..03d33b4 100644 (file)
@@ -58,6 +58,7 @@ public:
     bool calc_throw_grid();
     void reflect_inventory_by_throw();
     void set_class_specific_throw_params();
+    void set_racial_chance();
 
 private:
     player_type *creature_ptr;
index ab0d240..8386dcb 100644 (file)
@@ -70,17 +70,6 @@ ThrowCommand::ThrowCommand(player_type* creature_ptr)
 {
 }
 
-static void set_racial_chance(player_type *creature_ptr, it_type *it_ptr)
-{
-    if (has_flag(it_ptr->obj_flags, TR_THROW))
-        it_ptr->chance = ((creature_ptr->skill_tht) + ((creature_ptr->to_h_b + it_ptr->q_ptr->to_h) * BTH_PLUS_ADJ));
-    else
-        it_ptr->chance = (creature_ptr->skill_tht + (creature_ptr->to_h_b * BTH_PLUS_ADJ));
-
-    if (it_ptr->shuriken != 0)
-        it_ptr->chance *= 2;
-}
-
 static bool check_racial_target_bold(player_type *creature_ptr, it_type *it_ptr)
 {
     it_ptr->ny[it_ptr->cur_dis] = it_ptr->y;
@@ -407,7 +396,7 @@ bool ThrowCommand::do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
     }
 
     it_ptr->set_class_specific_throw_params();
-    set_racial_chance(this->creature_ptr, it_ptr);
+    it_ptr->set_racial_chance();
     it_ptr->prev_y = it_ptr->y;
     it_ptr->prev_x = it_ptr->x;
     exe_throw(this->creature_ptr, it_ptr);