From bca6c85f60c72dd4a61368a914a720e954d0df47 Mon Sep 17 00:00:00 2001 From: deskull Date: Sat, 17 Aug 2019 00:04:21 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#38997=20select=5Fmagic=5Feater()?= =?utf8?q?=20=E3=81=AB=20player=5Ftype=20*=20=E5=BC=95=E6=95=B0=E3=82=92?= =?utf8?q?=E8=BF=BD=E5=8A=A0=EF=BC=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/cmd/cmd-magiceat.c | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/cmd/cmd-magiceat.c b/src/cmd/cmd-magiceat.c index f66ec8490..52162eedc 100644 --- a/src/cmd/cmd-magiceat.c +++ b/src/cmd/cmd-magiceat.c @@ -73,7 +73,7 @@ * @param only_browse 閲覧するだけならばTRUE * @return 選択した魔力のID、キャンセルならば-1を返す */ -static OBJECT_SUBTYPE_VALUE select_magic_eater(bool only_browse) +static OBJECT_SUBTYPE_VALUE select_magic_eater(player_type *creature_ptr, bool only_browse) { OBJECT_SUBTYPE_VALUE ext = 0; char choice; @@ -89,15 +89,15 @@ static OBJECT_SUBTYPE_VALUE select_magic_eater(bool only_browse) if (repeat_pull(&sn)) { /* Verify the spell */ - if (sn >= EATER_EXT*2 && !(p_ptr->magic_num1[sn] > k_info[lookup_kind(TV_ROD, sn-EATER_EXT*2)].pval * (p_ptr->magic_num2[sn] - 1) * EATER_ROD_CHARGE)) + if (sn >= EATER_EXT*2 && !(creature_ptr->magic_num1[sn] > k_info[lookup_kind(TV_ROD, sn-EATER_EXT*2)].pval * (creature_ptr->magic_num2[sn] - 1) * EATER_ROD_CHARGE)) return sn; - else if (sn < EATER_EXT*2 && !(p_ptr->magic_num1[sn] < EATER_CHARGE)) + else if (sn < EATER_EXT*2 && !(creature_ptr->magic_num1[sn] < EATER_CHARGE)) return sn; } for (i = 0; i < 108; i++) { - if (p_ptr->magic_num2[i]) break; + if (creature_ptr->magic_num2[i]) break; } if (i == 108) { @@ -185,7 +185,7 @@ static OBJECT_SUBTYPE_VALUE select_magic_eater(bool only_browse) } for (i = ext; i < ext + EATER_EXT; i++) { - if (p_ptr->magic_num2[i]) + if (creature_ptr->magic_num2[i]) { if (use_menu) menu_line = i-ext+1; break; @@ -239,7 +239,7 @@ static OBJECT_SUBTYPE_VALUE select_magic_eater(bool only_browse) /* Print list */ for (ctr = 0; ctr < EATER_EXT; ctr++) { - if (!p_ptr->magic_num2[ctr+ext]) continue; + if (!creature_ptr->magic_num2[ctr+ext]) continue; k_idx = lookup_kind(tval, ctr); @@ -264,17 +264,17 @@ static OBJECT_SUBTYPE_VALUE select_magic_eater(bool only_browse) y1 = ((ctr < EATER_EXT/2) ? y + ctr : y + ctr - EATER_EXT/2); level = (tval == TV_ROD ? k_info[k_idx].level * 5 / 6 - 5 : k_info[k_idx].level); chance = level * 4 / 5 + 20; - chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1); + chance -= 3 * (adj_mag_stat[creature_ptr->stat_ind[mp_ptr->spell_stat]] - 1); level /= 2; - if (p_ptr->lev > level) + if (creature_ptr->lev > level) { - chance -= 3 * (p_ptr->lev - level); + chance -= 3 * (creature_ptr->lev - level); } chance = mod_spell_chance_1(chance); - chance = MAX(chance, adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]]); + chance = MAX(chance, adj_mag_fail[creature_ptr->stat_ind[mp_ptr->spell_stat]]); /* Stunning makes spells harder */ - if (p_ptr->stun > 50) chance += 25; - else if (p_ptr->stun) chance += 15; + if (creature_ptr->stun > 50) chance += 25; + else if (creature_ptr->stun) chance += 15; if (chance > 95) chance = 95; @@ -289,15 +289,15 @@ static OBJECT_SUBTYPE_VALUE select_magic_eater(bool only_browse) strcat(dummy, format( _(" %-22.22s 充填:%2d/%2d%3d%%", " %-22.22s (%2d/%2d) %3d%%"), k_name + k_info[k_idx].name, - p_ptr->magic_num1[ctr+ext] ? - (p_ptr->magic_num1[ctr+ext] - 1) / (EATER_ROD_CHARGE * k_info[k_idx].pval) +1 : 0, - p_ptr->magic_num2[ctr+ext], chance)); - if (p_ptr->magic_num1[ctr+ext] > k_info[k_idx].pval * (p_ptr->magic_num2[ctr+ext]-1) * EATER_ROD_CHARGE) col = TERM_RED; + creature_ptr->magic_num1[ctr+ext] ? + (creature_ptr->magic_num1[ctr+ext] - 1) / (EATER_ROD_CHARGE * k_info[k_idx].pval) +1 : 0, + creature_ptr->magic_num2[ctr+ext], chance)); + if (creature_ptr->magic_num1[ctr+ext] > k_info[k_idx].pval * (creature_ptr->magic_num2[ctr+ext]-1) * EATER_ROD_CHARGE) col = TERM_RED; } else { - strcat(dummy, format(" %-22.22s %2d/%2d %3d%%", k_name + k_info[k_idx].name, (s16b)(p_ptr->magic_num1[ctr+ext]/EATER_CHARGE), p_ptr->magic_num2[ctr+ext], chance)); - if (p_ptr->magic_num1[ctr+ext] < EATER_CHARGE) col = TERM_RED; + strcat(dummy, format(" %-22.22s %2d/%2d %3d%%", k_name + k_info[k_idx].name, (s16b)(creature_ptr->magic_num1[ctr+ext]/EATER_CHARGE), creature_ptr->magic_num2[ctr+ext], chance)); + if (creature_ptr->magic_num1[ctr+ext] < EATER_CHARGE) col = TERM_RED; } } else @@ -326,7 +326,7 @@ static OBJECT_SUBTYPE_VALUE select_magic_eater(bool only_browse) { menu_line += EATER_EXT - 1; if (menu_line > EATER_EXT) menu_line -= EATER_EXT; - } while(!p_ptr->magic_num2[menu_line+ext-1]); + } while(!creature_ptr->magic_num2[menu_line+ext-1]); break; } @@ -338,7 +338,7 @@ static OBJECT_SUBTYPE_VALUE select_magic_eater(bool only_browse) { menu_line++; if (menu_line > EATER_EXT) menu_line -= EATER_EXT; - } while(!p_ptr->magic_num2[menu_line+ext-1]); + } while(!creature_ptr->magic_num2[menu_line+ext-1]); break; } @@ -357,7 +357,7 @@ static OBJECT_SUBTYPE_VALUE select_magic_eater(bool only_browse) reverse = TRUE; } else menu_line+=EATER_EXT/2; - while(!p_ptr->magic_num2[menu_line+ext-1]) + while(!creature_ptr->magic_num2[menu_line+ext-1]) { if (reverse) { @@ -427,7 +427,7 @@ static OBJECT_SUBTYPE_VALUE select_magic_eater(bool only_browse) } /* Totally Illegal */ - if ((i < 0) || (i > EATER_EXT) || !p_ptr->magic_num2[i+ext]) + if ((i < 0) || (i > EATER_EXT) || !creature_ptr->magic_num2[i+ext]) { bell(); continue; @@ -448,7 +448,7 @@ static OBJECT_SUBTYPE_VALUE select_magic_eater(bool only_browse) } if (tval == TV_ROD) { - if (p_ptr->magic_num1[ext+i] > k_info[lookup_kind(tval, i)].pval * (p_ptr->magic_num2[ext+i] - 1) * EATER_ROD_CHARGE) + if (creature_ptr->magic_num1[ext+i] > k_info[lookup_kind(tval, i)].pval * (creature_ptr->magic_num2[ext+i] - 1) * EATER_ROD_CHARGE) { msg_print(_("その魔法はまだ充填している最中だ。", "The magic are still charging.")); msg_print(NULL); @@ -458,7 +458,7 @@ static OBJECT_SUBTYPE_VALUE select_magic_eater(bool only_browse) } else { - if (p_ptr->magic_num1[ext+i] < EATER_CHARGE) + if (creature_ptr->magic_num1[ext+i] < EATER_CHARGE) { msg_print(_("その魔法は使用回数が切れている。", "The magic has no charges left.")); msg_print(NULL); @@ -521,7 +521,7 @@ bool do_cmd_magic_eater(bool only_browse, bool powerful) if (cmd_limit_confused(p_ptr)) return FALSE; - item = select_magic_eater(only_browse); + item = select_magic_eater(p_ptr, only_browse); if (item == -1) { free_turn(p_ptr); -- 2.11.0