#include "player/special-defense-types.h"
#include "racial/class-racial-switcher.h"
#include "racial/mutation-racial-selector.h"
-#include "racial/race-racial-switcher.h"
-#include "racial/racial-switcher.h"
+#include "action/racial-execution.h"
+#include "racial/race-racial-command-setter.h"
#include "racial/racial-util.h"
#include "status/action-setter.h"
#include "term/screen-processor.h"
return FALSE;
}
+static void check_cast_racial_power(player_type *creature_ptr, rc_type *rc_ptr)
+{
+ switch (check_racial_level(creature_ptr, &rc_ptr->power_desc[rc_ptr->command_code])) {
+ case RACIAL_SUCCESS:
+ if (rc_ptr->power_desc[rc_ptr->command_code].number < 0)
+ rc_ptr->cast = exe_racial_power(creature_ptr, rc_ptr->power_desc[rc_ptr->command_code].number);
+ else
+ rc_ptr->cast = exe_mutation_power(creature_ptr, rc_ptr->power_desc[rc_ptr->command_code].number);
+
+ break;
+ case RACIAL_FAILURE:
+ rc_ptr->cast = TRUE;
+ break;
+ case RACIAL_CANCEL:
+ rc_ptr->cast = FALSE;
+ break;
+ }
+}
+
+static bool reduce_mana_by_racial(player_type *creature_ptr, rc_type *rc_ptr)
+{
+ int racial_cost = rc_ptr->power_desc[rc_ptr->command_code].racial_cost;
+ if (racial_cost == 0)
+ return FALSE;
+
+ int actual_racial_cost = racial_cost / 2 + randint1(racial_cost / 2);
+ if (creature_ptr->csp >= actual_racial_cost) {
+ creature_ptr->csp -= actual_racial_cost;
+ return TRUE;
+ }
+
+ actual_racial_cost -= creature_ptr->csp;
+ creature_ptr->csp = 0;
+ take_hit(creature_ptr, DAMAGE_USELIFE, actual_racial_cost, _("過度の集中", "concentrating too hard"), -1);
+ return TRUE;
+}
+
/*!
* @brief レイシャル・パワーコマンドのメインルーチン / Allow user to choose a power (racial / mutation) to activate
* @param creature_ptr プレーヤーへの参照ポインタ
rc_type *rc_ptr = initialize_rc_type(creature_ptr, &tmp_rc);
switch_class_racial(creature_ptr, rc_ptr);
if (creature_ptr->mimic_form)
- switch_mimic_racial(creature_ptr, rc_ptr);
+ set_mimic_racial_command(creature_ptr, rc_ptr);
else
- switch_race_racial(creature_ptr, rc_ptr);
+ set_race_racial_command(creature_ptr, rc_ptr);
select_mutation_racial(creature_ptr, rc_ptr);
rc_ptr->flag = FALSE;
if (repeat_racial_power(creature_ptr, rc_ptr))
return;
- switch (racial_aux(creature_ptr, &rc_ptr->power_desc[rc_ptr->command_code])) {
- case 1:
- if (rc_ptr->power_desc[rc_ptr->command_code].number < 0)
- rc_ptr->cast = exe_racial_power(creature_ptr, rc_ptr->power_desc[rc_ptr->command_code].number);
- else
- rc_ptr->cast = exe_mutation_power(creature_ptr, rc_ptr->power_desc[rc_ptr->command_code].number);
-
- break;
- case 0:
- rc_ptr->cast = FALSE;
- break;
- case -1:
- rc_ptr->cast = TRUE;
- break;
- }
-
+ check_cast_racial_power(creature_ptr, rc_ptr);
if (!rc_ptr->cast) {
free_turn(creature_ptr);
return;
}
- int racial_cost = rc_ptr->power_desc[rc_ptr->command_code].racial_cost;
- if (racial_cost == 0)
+ if (!reduce_mana_by_racial(creature_ptr, rc_ptr))
return;
- int actual_racial_cost = racial_cost / 2 + randint1(racial_cost / 2);
- if (creature_ptr->csp >= actual_racial_cost) {
- creature_ptr->csp -= actual_racial_cost;
- } else {
- actual_racial_cost -= creature_ptr->csp;
- creature_ptr->csp = 0;
- take_hit(creature_ptr, DAMAGE_USELIFE, actual_racial_cost, _("過度の集中", "concentrating too hard"), -1);
- }
-
creature_ptr->redraw |= PR_HP | PR_MANA;
creature_ptr->window |= PW_PLAYER | PW_SPELL;
}