From fb979a7a9a2ef71c8b050268288f784f0dee0183 Mon Sep 17 00:00:00 2001 From: Hourier Date: Thu, 20 Aug 2020 15:53:25 +0900 Subject: [PATCH] [Refactor] #40560 Separated decide_magic_book_exp() from do_cmd_destory() --- src/cmd-item/cmd-destroy.c | 44 ++++++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/src/cmd-item/cmd-destroy.c b/src/cmd-item/cmd-destroy.c index ebed77e63..8fcd47c63 100644 --- a/src/cmd-item/cmd-destroy.c +++ b/src/cmd-item/cmd-destroy.c @@ -101,6 +101,35 @@ static bool select_destroying_item(player_type *creature_ptr, destroy_type *dest } /*! + * @brief ˆê•”E‹Æ‚ō‚ˆÊ–‚–@‘‚Ì”j‰ó‚É‚æ‚éŒoŒ±’lã¸‚Ì”»’è + * @param creature_ptr ƒvƒŒ[ƒ„[‚Ö‚ÌŽQÆƒ|ƒCƒ“ƒ^ + * @param destory_ptr ƒAƒCƒeƒ€”j‰ó\‘¢‘Ì‚Ö‚ÌŽQÆƒ|ƒCƒ“ƒ^ + * return –‚–@‘‚Ì”j‰ó‚É‚æ‚Á‚ÄŒoŒ±’l‚ª“ü‚é‚È‚ç‚ÎTRUE + */ +static bool decide_magic_book_exp(player_type *creature_ptr, destroy_type *destroy_ptr) +{ + if (creature_ptr->prace == RACE_ANDROID) + return FALSE; + + if ((creature_ptr->pclass == CLASS_WARRIOR) || (creature_ptr->pclass == CLASS_BERSERKER)) + return TRUE; + + if (creature_ptr->pclass != CLASS_PALADIN) + return FALSE; + + bool gain_expr = FALSE; + if (is_good_realm(creature_ptr->realm1)) { + if (!is_good_realm(tval2realm(destroy_ptr->q_ptr->tval))) + gain_expr = TRUE; + } else { + if (is_good_realm(tval2realm(destroy_ptr->q_ptr->tval))) + gain_expr = TRUE; + } + + return gain_expr; +} + +/*! * @brief ƒAƒCƒeƒ€‚ð”j‰ó‚·‚éƒRƒ}ƒ“ƒh‚̃ƒCƒ“ƒ‹[ƒ`ƒ“ / Destroy an item * @param creature_ptr ƒvƒŒ[ƒ„[‚Ö‚ÌŽQÆƒ|ƒCƒ“ƒ^ * @return ‚È‚µ @@ -136,20 +165,7 @@ void do_cmd_destroy(player_type *creature_ptr) reduce_charges(destroy_ptr->o_ptr, destroy_ptr->amt); vary_item(creature_ptr, destroy_ptr->item, -destroy_ptr->amt); if (item_tester_high_level_book(destroy_ptr->q_ptr)) { - bool gain_expr = FALSE; - if (creature_ptr->prace == RACE_ANDROID) { - } else if ((creature_ptr->pclass == CLASS_WARRIOR) || (creature_ptr->pclass == CLASS_BERSERKER)) { - gain_expr = TRUE; - } else if (creature_ptr->pclass == CLASS_PALADIN) { - if (is_good_realm(creature_ptr->realm1)) { - if (!is_good_realm(tval2realm(destroy_ptr->q_ptr->tval))) - gain_expr = TRUE; - } else { - if (is_good_realm(tval2realm(destroy_ptr->q_ptr->tval))) - gain_expr = TRUE; - } - } - + bool gain_expr = decide_magic_book_exp(creature_ptr, destroy_ptr); if (gain_expr && (creature_ptr->exp < PY_MAX_EXP)) { s32b tester_exp = creature_ptr->max_exp / 20; if (tester_exp > 10000) -- 2.11.0