From: Hourier Date: Sat, 4 Jul 2020 04:41:45 +0000 (+0900) Subject: [Refactor] #40482 Separated display-sub-window-spells.c/h from spells3.c/h X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=afc372fbff68d4f572fbf0a5b24d430ca5e1ba70;p=hengband%2Fhengband.git [Refactor] #40482 Separated display-sub-window-spells.c/h from spells3.c/h --- diff --git a/Hengband/Hengband/Hengband.vcxproj b/Hengband/Hengband/Hengband.vcxproj index baa5cf690..4b741c91c 100644 --- a/Hengband/Hengband/Hengband.vcxproj +++ b/Hengband/Hengband/Hengband.vcxproj @@ -257,6 +257,7 @@ + @@ -1121,6 +1122,7 @@ + diff --git a/Hengband/Hengband/Hengband.vcxproj.filters b/Hengband/Hengband/Hengband.vcxproj.filters index c7e9008f7..eebad3087 100644 --- a/Hengband/Hengband/Hengband.vcxproj.filters +++ b/Hengband/Hengband/Hengband.vcxproj.filters @@ -1577,6 +1577,9 @@ spell-kind + + view + @@ -3451,6 +3454,9 @@ spell-kind + + view + diff --git a/src/Makefile.am b/src/Makefile.am index 8bea2517f..0adc9e117 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -628,7 +628,6 @@ hengband_SOURCES = \ \ view/display-birth.c view/display-birth.h \ view/display-characteristic.c view/display-characteristic.h \ - view/display-sub-windows.c view/display-sub-windows.h \ view/display-fruit.c view/display-fruit.h \ view/display-inventory.c view/display-inventory.h\ view/display-lore-attacks.c view/display-lore-attacks.h \ @@ -643,6 +642,8 @@ hengband_SOURCES = \ view/display-player-misc-info.c view/display-player-misc-info.h \ view/display-player-middle.c view/display-player-middle.h \ view/display-player.c view/display-player.h \ + view/display-sub-window-spells.c view/display-sub-window-spells.h \ + view/display-sub-windows.c view/display-sub-windows.h \ view/display-util.c view/display-util.h \ view/main-window-left-frame.c view/main-window-left-frame.h \ view/main-window-row-column.h \ diff --git a/src/core/window-redrawer.c b/src/core/window-redrawer.c index 1d3a905cf..48b15d8c0 100644 --- a/src/core/window-redrawer.c +++ b/src/core/window-redrawer.c @@ -14,6 +14,7 @@ #include "view/display-messages.h" #include "view/display-player.h" #include "view/display-sub-windows.h" +#include "view/display-sub-window-spells.h" #include "view/main-window-left-frame.h" #include "view/main-window-row-column.h" #include "view/main-window-stat-poster.h" diff --git a/src/effect/effect-monster-resist-hurt.c b/src/effect/effect-monster-resist-hurt.c index 185ed5776..b79cd4618 100644 --- a/src/effect/effect-monster-resist-hurt.c +++ b/src/effect/effect-monster-resist-hurt.c @@ -6,7 +6,6 @@ #include "monster-race/race-indice-types.h" #include "monster/monster-status.h" #include "monster/monster-info.h" -#include "spell-kind/spells-equipment.h" gf_switch_result effect_monster_void(effect_monster_type *em_ptr) { diff --git a/src/effect/effect-player-resist-hurt.c b/src/effect/effect-player-resist-hurt.c index b80d06ce3..f30f67948 100644 --- a/src/effect/effect-player-resist-hurt.c +++ b/src/effect/effect-player-resist-hurt.c @@ -12,6 +12,7 @@ #include "player/player-race-types.h" #include "player/player-race.h" #include "spell-kind/spells-teleport.h" +#include "spell-kind/spells-equipment.h" #include "spell/spells-status.h" #include "spell/spells3.h" #include "status/bad-status-setter.h" diff --git a/src/spell/spells3.c b/src/spell/spells3.c index d8f28cb1a..9c2484d00 100644 --- a/src/spell/spells3.c +++ b/src/spell/spells3.c @@ -455,156 +455,6 @@ bool recharge(player_type *caster_ptr, int power) } /*! - * @brief クリーチャー全既知呪文を表示する / - * Hack -- Display all known spells in a window - * @param caster_ptr 術者の参照ポインタ - * return なし - * @details - * Need to analyze size of the window. - * Need more color coding. - */ -void display_spell_list(player_type *caster_ptr) -{ - TERM_LEN y, x; - int m[9]; - const magic_type *s_ptr; - GAME_TEXT name[MAX_NLEN]; - char out_val[160]; - - clear_from(0); - - if (caster_ptr->pclass == CLASS_SORCERER) - return; - if (caster_ptr->pclass == CLASS_RED_MAGE) - return; - if (caster_ptr->pclass == CLASS_SNIPER) { - display_snipe_list(caster_ptr); - return; - } - - if ((caster_ptr->pclass == CLASS_MINDCRAFTER) || (caster_ptr->pclass == CLASS_BERSERKER) || (caster_ptr->pclass == CLASS_NINJA) - || (caster_ptr->pclass == CLASS_MIRROR_MASTER) || (caster_ptr->pclass == CLASS_FORCETRAINER)) { - PERCENTAGE minfail = 0; - PLAYER_LEVEL plev = caster_ptr->lev; - PERCENTAGE chance = 0; - mind_type spell; - char comment[80]; - char psi_desc[80]; - int use_mind; - bool use_hp = FALSE; - - y = 1; - x = 1; - - prt("", y, x); - put_str(_("名前", "Name"), y, x + 5); - put_str(_("Lv MP 失率 効果", "Lv Mana Fail Info"), y, x + 35); - - switch (caster_ptr->pclass) { - case CLASS_MINDCRAFTER: - use_mind = MIND_MINDCRAFTER; - break; - case CLASS_FORCETRAINER: - use_mind = MIND_KI; - break; - case CLASS_BERSERKER: - use_mind = MIND_BERSERKER; - use_hp = TRUE; - break; - case CLASS_MIRROR_MASTER: - use_mind = MIND_MIRROR_MASTER; - break; - case CLASS_NINJA: - use_mind = MIND_NINJUTSU; - use_hp = TRUE; - break; - default: - use_mind = 0; - break; - } - - for (int i = 0; i < MAX_MIND_POWERS; i++) { - byte a = TERM_WHITE; - spell = mind_powers[use_mind].info[i]; - if (spell.min_lev > plev) - break; - - chance = spell.fail; - chance -= 3 * (caster_ptr->lev - spell.min_lev); - chance -= 3 * (adj_mag_stat[caster_ptr->stat_ind[mp_ptr->spell_stat]] - 1); - if (!use_hp) { - if (spell.mana_cost > caster_ptr->csp) { - chance += 5 * (spell.mana_cost - caster_ptr->csp); - a = TERM_ORANGE; - } - } else { - if (spell.mana_cost > caster_ptr->chp) { - chance += 100; - a = TERM_RED; - } - } - - minfail = adj_mag_fail[caster_ptr->stat_ind[mp_ptr->spell_stat]]; - if (chance < minfail) - chance = minfail; - - if (caster_ptr->stun > 50) - chance += 25; - else if (caster_ptr->stun) - chance += 15; - - if (chance > 95) - chance = 95; - - mindcraft_info(caster_ptr, comment, use_mind, i); - sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s", I2A(i), spell.name, spell.min_lev, spell.mana_cost, chance, comment); - - Term_putstr(x, y + i + 1, -1, a, psi_desc); - } - - return; - } - - if (REALM_NONE == caster_ptr->realm1) - return; - - for (int j = 0; j < ((caster_ptr->realm2 > REALM_NONE) ? 2 : 1); j++) { - m[j] = 0; - y = (j < 3) ? 0 : (m[j - 3] + 2); - x = 27 * (j % 3); - int n = 0; - for (int i = 0; i < 32; i++) { - byte a = TERM_WHITE; - - if (!is_magic((j < 1) ? caster_ptr->realm1 : caster_ptr->realm2)) { - s_ptr = &technic_info[((j < 1) ? caster_ptr->realm1 : caster_ptr->realm2) - MIN_TECHNIC][i % 32]; - } else { - s_ptr = &mp_ptr->info[((j < 1) ? caster_ptr->realm1 : caster_ptr->realm2) - 1][i % 32]; - } - - strcpy(name, exe_spell(caster_ptr, (j < 1) ? caster_ptr->realm1 : caster_ptr->realm2, i % 32, SPELL_NAME)); - - if (s_ptr->slevel >= 99) { - strcpy(name, _("(判読不能)", "(illegible)")); - a = TERM_L_DARK; - } else if ((j < 1) ? ((caster_ptr->spell_forgotten1 & (1L << i))) : ((caster_ptr->spell_forgotten2 & (1L << (i % 32))))) { - a = TERM_ORANGE; - } else if (!((j < 1) ? (caster_ptr->spell_learned1 & (1L << i)) : (caster_ptr->spell_learned2 & (1L << (i % 32))))) { - a = TERM_RED; - } else if (!((j < 1) ? (caster_ptr->spell_worked1 & (1L << i)) : (caster_ptr->spell_worked2 & (1L << (i % 32))))) { - a = TERM_YELLOW; - } - - sprintf(out_val, "%c/%c) %-20.20s", I2A(n / 8), I2A(n % 8), name); - - m[j] = y + n; - Term_putstr(x, m[j], -1, a, out_val); - n++; - } - } -} - -/*! * @brief 変身処理向けにモンスターの近隣レベル帯モンスターを返す / * Helper function -- return a "nearby" race for polymorphing * @param floor_ptr 配置するフロアの参照ポインタ diff --git a/src/spell/spells3.h b/src/spell/spells3.h index 7cd2bc896..ab0f00cef 100644 --- a/src/spell/spells3.h +++ b/src/spell/spells3.h @@ -6,7 +6,6 @@ void reserve_alter_reality(player_type* caster_ptr); bool artifact_scroll(player_type* caster_ptr); bool mundane_spell(player_type* ownner_ptr, bool only_equip); bool recharge(player_type* caster_ptr, int power); -void display_spell_list(player_type* caster_ptr); bool polymorph_monster(player_type* caster_ptr, POSITION y, POSITION x); void massacre(player_type* caster_ptr); bool eat_rock(player_type* caster_ptr); diff --git a/src/view/display-sub-window-spells.c b/src/view/display-sub-window-spells.c new file mode 100644 index 000000000..9114f3ec7 --- /dev/null +++ b/src/view/display-sub-window-spells.c @@ -0,0 +1,187 @@ +#include "view/display-sub-window-spells.h" +#include "game-option/option-flags.h" +#include "mind/mind-sniper.h" +#include "mind/mind.h" +#include "player/player-class.h" +#include "realm/realm-names-table.h" +#include "spell/spells-execution.h" +#include "spell/spells-util.h" +#include "spell/technic-info-table.h" +#include "term/gameterm.h" +#include "term/screen-processor.h" +#include "term/term-color-types.h" +#include "util/int-char-converter.h" +#include "view/display-messages.h" + +/*! + * @brief クリーチャー全既知呪文を表示する / + * Hack -- Display all known spells in a window + * @param caster_ptr 術者の参照ポインタ + * return なし + * @details + * Need to analyze size of the window. + * Need more color coding. + */ +static void display_spell_list(player_type *caster_ptr) +{ + TERM_LEN y, x; + int m[9]; + const magic_type *s_ptr; + GAME_TEXT name[MAX_NLEN]; + char out_val[160]; + + clear_from(0); + + if (caster_ptr->pclass == CLASS_SORCERER) + return; + if (caster_ptr->pclass == CLASS_RED_MAGE) + return; + if (caster_ptr->pclass == CLASS_SNIPER) { + display_snipe_list(caster_ptr); + return; + } + + if ((caster_ptr->pclass == CLASS_MINDCRAFTER) || (caster_ptr->pclass == CLASS_BERSERKER) || (caster_ptr->pclass == CLASS_NINJA) + || (caster_ptr->pclass == CLASS_MIRROR_MASTER) || (caster_ptr->pclass == CLASS_FORCETRAINER)) { + PERCENTAGE minfail = 0; + PLAYER_LEVEL plev = caster_ptr->lev; + PERCENTAGE chance = 0; + mind_type spell; + char comment[80]; + char psi_desc[80]; + int use_mind; + bool use_hp = FALSE; + + y = 1; + x = 1; + + prt("", y, x); + put_str(_("名前", "Name"), y, x + 5); + put_str(_("Lv MP 失率 効果", "Lv Mana Fail Info"), y, x + 35); + + switch (caster_ptr->pclass) { + case CLASS_MINDCRAFTER: + use_mind = MIND_MINDCRAFTER; + break; + case CLASS_FORCETRAINER: + use_mind = MIND_KI; + break; + case CLASS_BERSERKER: + use_mind = MIND_BERSERKER; + use_hp = TRUE; + break; + case CLASS_MIRROR_MASTER: + use_mind = MIND_MIRROR_MASTER; + break; + case CLASS_NINJA: + use_mind = MIND_NINJUTSU; + use_hp = TRUE; + break; + default: + use_mind = 0; + break; + } + + for (int i = 0; i < MAX_MIND_POWERS; i++) { + byte a = TERM_WHITE; + spell = mind_powers[use_mind].info[i]; + if (spell.min_lev > plev) + break; + + chance = spell.fail; + chance -= 3 * (caster_ptr->lev - spell.min_lev); + chance -= 3 * (adj_mag_stat[caster_ptr->stat_ind[mp_ptr->spell_stat]] - 1); + if (!use_hp) { + if (spell.mana_cost > caster_ptr->csp) { + chance += 5 * (spell.mana_cost - caster_ptr->csp); + a = TERM_ORANGE; + } + } else { + if (spell.mana_cost > caster_ptr->chp) { + chance += 100; + a = TERM_RED; + } + } + + minfail = adj_mag_fail[caster_ptr->stat_ind[mp_ptr->spell_stat]]; + if (chance < minfail) + chance = minfail; + + if (caster_ptr->stun > 50) + chance += 25; + else if (caster_ptr->stun) + chance += 15; + + if (chance > 95) + chance = 95; + + mindcraft_info(caster_ptr, comment, use_mind, i); + sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s", I2A(i), spell.name, spell.min_lev, spell.mana_cost, chance, comment); + + Term_putstr(x, y + i + 1, -1, a, psi_desc); + } + + return; + } + + if (REALM_NONE == caster_ptr->realm1) + return; + + for (int j = 0; j < ((caster_ptr->realm2 > REALM_NONE) ? 2 : 1); j++) { + m[j] = 0; + y = (j < 3) ? 0 : (m[j - 3] + 2); + x = 27 * (j % 3); + int n = 0; + for (int i = 0; i < 32; i++) { + byte a = TERM_WHITE; + + if (!is_magic((j < 1) ? caster_ptr->realm1 : caster_ptr->realm2)) { + s_ptr = &technic_info[((j < 1) ? caster_ptr->realm1 : caster_ptr->realm2) - MIN_TECHNIC][i % 32]; + } else { + s_ptr = &mp_ptr->info[((j < 1) ? caster_ptr->realm1 : caster_ptr->realm2) - 1][i % 32]; + } + + strcpy(name, exe_spell(caster_ptr, (j < 1) ? caster_ptr->realm1 : caster_ptr->realm2, i % 32, SPELL_NAME)); + + if (s_ptr->slevel >= 99) { + strcpy(name, _("(判読不能)", "(illegible)")); + a = TERM_L_DARK; + } else if ((j < 1) ? ((caster_ptr->spell_forgotten1 & (1L << i))) : ((caster_ptr->spell_forgotten2 & (1L << (i % 32))))) { + a = TERM_ORANGE; + } else if (!((j < 1) ? (caster_ptr->spell_learned1 & (1L << i)) : (caster_ptr->spell_learned2 & (1L << (i % 32))))) { + a = TERM_RED; + } else if (!((j < 1) ? (caster_ptr->spell_worked1 & (1L << i)) : (caster_ptr->spell_worked2 & (1L << (i % 32))))) { + a = TERM_YELLOW; + } + + sprintf(out_val, "%c/%c) %-20.20s", I2A(n / 8), I2A(n % 8), name); + + m[j] = y + n; + Term_putstr(x, m[j], -1, a, out_val); + n++; + } + } +} + +/*! + * @brief 現在の習得済魔法をサブウィンドウに表示する / + * @param player_ptr プレーヤーへの参照ポインタ + * Hack -- display spells in sub-windows + * @return なし + */ +void fix_spell(player_type *player_ptr) +{ + for (int j = 0; j < 8; j++) { + term *old = Term; + if (!angband_term[j]) + continue; + + if (!(window_flag[j] & (PW_SPELL))) + continue; + + Term_activate(angband_term[j]); + display_spell_list(player_ptr); + Term_fresh(); + Term_activate(old); + } +} diff --git a/src/view/display-sub-window-spells.h b/src/view/display-sub-window-spells.h new file mode 100644 index 000000000..4d86fa9a6 --- /dev/null +++ b/src/view/display-sub-window-spells.h @@ -0,0 +1,5 @@ +#pragma once + +#include "system/angband.h" + +void fix_spell(player_type *player_ptr); diff --git a/src/view/display-sub-windows.c b/src/view/display-sub-windows.c index ac5a13d5a..43e6fc1db 100644 --- a/src/view/display-sub-windows.c +++ b/src/view/display-sub-windows.c @@ -266,29 +266,6 @@ void fix_equip(player_type *player_ptr, tval_type item_tester_tval) } /*! - * @brief 現在の習得済魔法をサブウィンドウに表示する / - * @param player_ptr プレーヤーへの参照ポインタ - * Hack -- display spells in sub-windows - * @return なし - */ -void fix_spell(player_type *player_ptr) -{ - for (int j = 0; j < 8; j++) { - term *old = Term; - if (!angband_term[j]) - continue; - - if (!(window_flag[j] & (PW_SPELL))) - continue; - - Term_activate(angband_term[j]); - display_spell_list(player_ptr); - Term_fresh(); - Term_activate(old); - } -} - -/*! * @brief 現在のプレイヤーステータスをサブウィンドウに表示する / * @param player_ptr プレーヤーへの参照ポインタ * Hack -- display character in sub-windows diff --git a/src/view/display-sub-windows.h b/src/view/display-sub-windows.h index 20e581314..b6ac6b5c3 100644 --- a/src/view/display-sub-windows.h +++ b/src/view/display-sub-windows.h @@ -7,7 +7,6 @@ void fix_inventory(player_type *player_ptr, tval_type item_tester_tval); void print_monster_list(floor_type *floor_ptr, TERM_LEN x, TERM_LEN y, TERM_LEN max_lines); void fix_monster_list(player_type *player_ptr); void fix_equip(player_type *player_ptr, tval_type item_tester_tval); -void fix_spell(player_type *player_ptr); void fix_player(player_type *player_ptr); void fix_message(void); void fix_overhead(player_type *player_ptr);