1 #include "mind/mind-power-getter.h"
2 #include "core/asking-player.h"
3 #include "core/window-redrawer.h"
4 #include "core/stuff-handler.h"
5 #include "game-option/text-display-options.h"
6 #include "inventory/inventory-slot-types.h"
7 #include "io/command-repeater.h"
8 #include "io/input-key-requester.h"
9 #include "main/sound-of-music.h"
10 #include "mind/mind-explanations-table.h"
11 #include "mind/mind-force-trainer.h"
12 #include "mind/mind-info.h"
13 #include "mind/mind-types.h"
14 #include "player/player-class.h"
15 #include "term/screen-processor.h"
16 #include "util/int-char-converter.h"
17 #include "player/player-status-table.h"
20 * @brief 使用可能な特殊技能を選択する /
21 * Allow user to choose a mindcrafter power.
22 * @param sn 選択した特殊技能ID、キャンセルの場合-1、不正な選択の場合-2を返す
23 * @param only_browse 一覧を見るだけの場合TRUEを返す
24 * @return 発動可能な魔法を選択した場合TRUE、キャンセル処理か不正な選択が行われた場合FALSEを返す。
26 * If a valid spell is chosen, saves it in '*sn' and returns TRUE\n
27 * If the user hits escape, returns FALSE, and set '*sn' to -1\n
28 * If there are no legal choices, returns FALSE, and sets '*sn' to -2\n
30 * The "prompt" should be "cast", "recite", or "study"\n
31 * The "known" should be TRUE for cast/pray, FALSE for study\n
33 * nb: This function has a (trivial) display bug which will be obvious\n
34 * when you run it. It's probably easy to fix but I haven't tried,\n
37 bool get_mind_power(player_type *caster_ptr, SPELL_IDX *sn, bool only_browse)
43 PERCENTAGE minfail = 0;
44 PLAYER_LEVEL plev = caster_ptr->lev;
45 PERCENTAGE chance = 0;
53 const mind_power *mind_ptr;
56 int menu_line = (use_menu ? 1 : 0);
58 switch (caster_ptr->pclass) {
59 case CLASS_MINDCRAFTER: {
60 use_mind = MIND_MINDCRAFTER;
61 p = _("超能力", "mindcraft");
64 case CLASS_FORCETRAINER: {
66 p = _("練気術", "Force");
69 case CLASS_BERSERKER: {
70 use_mind = MIND_BERSERKER;
71 p = _("技", "brutal power");
74 case CLASS_MIRROR_MASTER: {
75 use_mind = MIND_MIRROR_MASTER;
76 p = _("鏡魔法", "magic");
80 use_mind = MIND_NINJUTSU;
81 p = _("忍術", "ninjutsu");
86 p = _("超能力", "mindcraft");
91 mind_ptr = &mind_powers[use_mind];
93 if (repeat_pull(&code)) {
94 *sn = (SPELL_IDX)code;
95 if (*sn == INVEN_FORCE)
98 *sn = (SPELL_IDX)code;
99 if (mind_ptr->info[*sn].min_lev <= plev)
106 for (i = 0; i < MAX_MIND_POWERS; i++)
107 if (mind_ptr->info[i].min_lev <= plev)
111 (void)strnfmt(out_val, 78, _("(%^s %c-%c, '*'で一覧, ESC) どの%sについて知りますか?", "(%^ss %c-%c, *=List, ESC=exit) Use which %s? "), p, I2A(0),
115 out_val, 78, _("(%^s %c-%c, '*'で一覧, ESC) どの%sを使いますか?", "(%^ss %c-%c, *=List, ESC=exit) Use which %s? "), p, I2A(0), I2A(num - 1), p);
117 if (use_menu && !only_browse)
120 choice = (always_show_list || use_menu) ? ESCAPE : 1;
122 if (choice == ESCAPE)
124 else if (!get_com(out_val, &choice, TRUE))
127 if (use_menu && choice != ' ') {
138 menu_line += (num - 1);
161 if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && ask)) {
162 if (!redraw || use_menu) {
166 if (!only_browse && !use_menu)
170 put_str(_("名前", "Name"), y, x + 5);
171 put_str(format(_("Lv %s 失率 効果", "Lv %s Fail Info"), ((use_mind == MIND_BERSERKER) || (use_mind == MIND_NINJUTSU)) ? "HP" : "MP"), y,
173 has_weapon[0] = has_melee_weapon(caster_ptr, INVEN_RARM);
174 has_weapon[1] = has_melee_weapon(caster_ptr, INVEN_LARM);
175 for (i = 0; i < MAX_MIND_POWERS; i++) {
177 spell = mind_ptr->info[i];
178 if (spell.min_lev > plev)
182 mana_cost = spell.mana_cost;
184 chance -= 3 * (plev - spell.min_lev);
185 chance -= 3 * (adj_mag_stat[caster_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
186 if (use_mind == MIND_KI) {
187 if (heavy_armor(caster_ptr))
190 if (caster_ptr->icky_wield[0])
192 else if (has_weapon[0])
195 if (caster_ptr->icky_wield[1])
197 else if (has_weapon[1])
202 for (j = 0; j < get_current_ki(caster_ptr) / 50; j++)
203 mana_cost += (j + 1) * 3 / 2;
207 if ((use_mind != MIND_BERSERKER) && (use_mind != MIND_NINJUTSU) && (mana_cost > caster_ptr->csp))
208 chance += 5 * (mana_cost - caster_ptr->csp);
210 chance += caster_ptr->to_m_chance;
211 minfail = adj_mag_fail[caster_ptr->stat_ind[mp_ptr->spell_stat]];
212 if (chance < minfail)
215 if (caster_ptr->stun > 50)
217 else if (caster_ptr->stun)
220 if (use_mind == MIND_KI) {
221 if (heavy_armor(caster_ptr))
223 if (caster_ptr->icky_wield[0])
225 if (caster_ptr->icky_wield[1])
233 mindcraft_info(caster_ptr, comment, use_mind, i);
235 if (i == (menu_line - 1))
236 strcpy(psi_desc, _(" 》 ", " > "));
238 strcpy(psi_desc, " ");
240 sprintf(psi_desc, " %c) ", I2A(i));
243 format("%-30s%2d %4d%s %3d%%%s", spell.name, spell.min_lev, mana_cost,
244 (((use_mind == MIND_MINDCRAFTER) && (i == 13)) ? _("~", "~ ") : " "), chance, comment));
245 prt(psi_desc, y + i + 1, x);
248 prt("", y + i + 1, x);
249 } else if (!only_browse) {
258 ask = isupper(choice);
260 choice = (char)tolower(choice);
262 i = (islower(choice) ? A2I(choice) : -1);
265 if ((i < 0) || (i >= num)) {
270 spell = mind_ptr->info[i];
273 (void)strnfmt(tmp_val, 78, _("%sを使いますか?", "Use %s? "), spell.name);
274 if (!get_check(tmp_val))
281 if (redraw && !only_browse)
284 caster_ptr->window |= PW_SPELL;
285 handle_stuff(caster_ptr);
290 repeat_push((COMMAND_CODE)i);