#include "main/sound-definitions-table.h"
#include "main/sound-of-music.h"
#include "perception/object-perception.h"
+#include "player-base/player-class.h"
#include "player-status/player-energy.h"
#include "player/player-status-table.h"
#include "specific-object/chest.h"
#include "system/object-type-definition.h"
#include "system/player-type-definition.h"
#include "term/screen-processor.h"
+#include "timed-effect/player-blindness.h"
+#include "timed-effect/player-confusion.h"
+#include "timed-effect/player-hallucination.h"
+#include "timed-effect/timed-effects.h"
#include "util/bit-flags-calculator.h"
#include "view/display-messages.h"
* @param x 対象を行うマスのX座標
* @return 連続でコマンドを実行する時のみTRUE、1回きりの時はFALSE
*/
-bool exe_open(player_type *creature_ptr, POSITION y, POSITION x)
+bool exe_open(PlayerType *player_ptr, POSITION y, POSITION x)
{
- grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
- feature_type *f_ptr = &f_info[g_ptr->feat];
- PlayerEnergy(creature_ptr).set_player_turn_energy(100);
- if (!has_flag(f_ptr->flags, FF_OPEN)) {
+ auto *g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
+ auto *f_ptr = &f_info[g_ptr->feat];
+ PlayerEnergy(player_ptr).set_player_turn_energy(100);
+ if (f_ptr->flags.has_not(FloorFeatureType::OPEN)) {
msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_info[g_ptr->get_feat_mimic()].name.c_str());
return false;
}
if (!f_ptr->power) {
- cave_alter_feat(creature_ptr, y, x, FF_OPEN);
+ cave_alter_feat(player_ptr, y, x, FloorFeatureType::OPEN);
sound(SOUND_OPENDOOR);
return false;
}
- int i = creature_ptr->skill_dis;
- if (creature_ptr->blind || no_lite(creature_ptr))
+ int i = player_ptr->skill_dis;
+ const auto effects = player_ptr->effects();
+ if (effects->blindness()->is_blind() || no_lite(player_ptr)) {
i = i / 10;
+ }
- if (creature_ptr->confused || creature_ptr->image)
+ if (effects->confusion()->is_confused() || effects->hallucination()->is_hallucinated()) {
i = i / 10;
+ }
int j = f_ptr->power;
j = i - (j * 4);
- if (j < 2)
+ if (j < 2) {
j = 2;
+ }
if (randint0(100) >= j) {
- if (flush_failure)
+ if (flush_failure) {
flush();
+ }
msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
return true;
}
msg_print(_("鍵をはずした。", "You have picked the lock."));
- cave_alter_feat(creature_ptr, y, x, FF_OPEN);
+ cave_alter_feat(player_ptr, y, x, FloorFeatureType::OPEN);
sound(SOUND_OPENDOOR);
- gain_exp(creature_ptr, 1);
+ gain_exp(player_ptr, 1);
return false;
}
* Returns TRUE if repeated commands may continue
* @todo 常にFALSEを返している
*/
-bool exe_close(player_type *creature_ptr, POSITION y, POSITION x)
+bool exe_close(PlayerType *player_ptr, POSITION y, POSITION x)
{
- grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
+ auto *g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
FEAT_IDX old_feat = g_ptr->feat;
bool more = false;
- PlayerEnergy(creature_ptr).set_player_turn_energy(100);
- if (!has_flag(f_info[old_feat].flags, FF_CLOSE))
+ PlayerEnergy(player_ptr).set_player_turn_energy(100);
+ if (f_info[old_feat].flags.has_not(FloorFeatureType::CLOSE)) {
return more;
+ }
- int16_t closed_feat = feat_state(creature_ptr->current_floor_ptr, old_feat, FF_CLOSE);
- if ((!g_ptr->o_idx_list.empty() || g_ptr->is_object()) && (closed_feat != old_feat) && !has_flag(f_info[closed_feat].flags, FF_DROP)) {
+ int16_t closed_feat = feat_state(player_ptr->current_floor_ptr, old_feat, FloorFeatureType::CLOSE);
+ if ((!g_ptr->o_idx_list.empty() || g_ptr->is_object()) && (closed_feat != old_feat) && f_info[closed_feat].flags.has_not(FloorFeatureType::DROP)) {
msg_print(_("何かがつっかえて閉まらない。", "Something prevents it from closing."));
return more;
}
- cave_alter_feat(creature_ptr, y, x, FF_CLOSE);
+ cave_alter_feat(player_ptr, y, x, FloorFeatureType::CLOSE);
if (old_feat == g_ptr->feat) {
msg_print(_("ドアは壊れてしまっている。", "The door appears to be broken."));
} else {
* do_cmd_open_test() and exe_open().
* </pre>
*/
-bool easy_open_door(player_type *creature_ptr, POSITION y, POSITION x)
+bool easy_open_door(PlayerType *player_ptr, POSITION y, POSITION x)
{
int i, j;
- grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
- feature_type *f_ptr = &f_info[g_ptr->feat];
- if (!is_closed_door(creature_ptr, g_ptr->feat))
+ auto *g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
+ auto *f_ptr = &f_info[g_ptr->feat];
+ if (!is_closed_door(player_ptr, g_ptr->feat)) {
return false;
+ }
- if (!has_flag(f_ptr->flags, FF_OPEN)) {
+ if (f_ptr->flags.has_not(FloorFeatureType::OPEN)) {
msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_info[g_ptr->get_feat_mimic()].name.c_str());
} else if (f_ptr->power) {
- i = creature_ptr->skill_dis;
- if (creature_ptr->blind || no_lite(creature_ptr))
+ i = player_ptr->skill_dis;
+ const auto effects = player_ptr->effects();
+ if (effects->blindness()->is_blind() || no_lite(player_ptr)) {
i = i / 10;
+ }
- if (creature_ptr->confused || creature_ptr->image)
+ if (effects->confusion()->is_confused() || effects->hallucination()->is_hallucinated()) {
i = i / 10;
+ }
j = f_ptr->power;
j = i - (j * 4);
- if (j < 2)
+ if (j < 2) {
j = 2;
+ }
if (randint0(100) < j) {
msg_print(_("鍵をはずした。", "You have picked the lock."));
- cave_alter_feat(creature_ptr, y, x, FF_OPEN);
+ cave_alter_feat(player_ptr, y, x, FloorFeatureType::OPEN);
sound(SOUND_OPENDOOR);
- gain_exp(creature_ptr, 1);
+ gain_exp(player_ptr, 1);
} else {
- if (flush_failure)
+ if (flush_failure) {
flush();
+ }
msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
}
} else {
- cave_alter_feat(creature_ptr, y, x, FF_OPEN);
+ cave_alter_feat(player_ptr, y, x, FloorFeatureType::OPEN);
sound(SOUND_OPENDOOR);
}
* Returns TRUE if repeated commands may continue
* </pre>
*/
-bool exe_disarm_chest(player_type *creature_ptr, POSITION y, POSITION x, OBJECT_IDX o_idx)
+bool exe_disarm_chest(PlayerType *player_ptr, POSITION y, POSITION x, OBJECT_IDX o_idx)
{
bool more = false;
- object_type *o_ptr = &creature_ptr->current_floor_ptr->o_list[o_idx];
- PlayerEnergy(creature_ptr).set_player_turn_energy(100);
- int i = creature_ptr->skill_dis;
- if (creature_ptr->blind || no_lite(creature_ptr))
+ auto *o_ptr = &player_ptr->current_floor_ptr->o_list[o_idx];
+ PlayerEnergy(player_ptr).set_player_turn_energy(100);
+ int i = player_ptr->skill_dis;
+ const auto effects = player_ptr->effects();
+ if (effects->blindness()->is_blind() || no_lite(player_ptr)) {
i = i / 10;
+ }
- if (creature_ptr->confused || creature_ptr->image)
+ if (effects->confusion()->is_confused() || effects->hallucination()->is_hallucinated()) {
i = i / 10;
+ }
int j = i - o_ptr->pval;
- if (j < 2)
+ if (j < 2) {
j = 2;
+ }
- if (!object_is_known(o_ptr)) {
+ if (!o_ptr->is_known()) {
msg_print(_("トラップが見あたらない。", "I don't see any traps."));
} else if (o_ptr->pval <= 0) {
msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
- } else if (!chest_traps[o_ptr->pval]) {
+ } else if (chest_traps[o_ptr->pval].none()) {
msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
} else if (randint0(100) < j) {
msg_print(_("箱に仕掛けられていたトラップを解除した。", "You have disarmed the chest."));
- gain_exp(creature_ptr, o_ptr->pval);
+ gain_exp(player_ptr, o_ptr->pval);
o_ptr->pval = (0 - o_ptr->pval);
} else if ((i > 5) && (randint1(i) > 5)) {
more = true;
- if (flush_failure)
+ if (flush_failure) {
flush();
+ }
msg_print(_("箱のトラップ解除に失敗した。", "You failed to disarm the chest."));
} else {
msg_print(_("トラップを作動させてしまった!", "You set off a trap!"));
sound(SOUND_FAIL);
- chest_trap(creature_ptr, y, x, o_idx);
+ Chest(player_ptr).chest_trap(y, x, o_idx);
}
return more;
* </pre>
*/
-bool exe_disarm(player_type *creature_ptr, POSITION y, POSITION x, DIRECTION dir)
+bool exe_disarm(PlayerType *player_ptr, POSITION y, POSITION x, DIRECTION dir)
{
- grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
- feature_type *f_ptr = &f_info[g_ptr->feat];
+ auto *g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
+ auto *f_ptr = &f_info[g_ptr->feat];
concptr name = f_ptr->name.c_str();
int power = f_ptr->power;
bool more = false;
- int i = creature_ptr->skill_dis;
- PlayerEnergy(creature_ptr).set_player_turn_energy(100);
- if (creature_ptr->blind || no_lite(creature_ptr))
+ int i = player_ptr->skill_dis;
+ PlayerEnergy(player_ptr).set_player_turn_energy(100);
+ auto effects = player_ptr->effects();
+ if (effects->blindness()->is_blind() || no_lite(player_ptr)) {
i = i / 10;
+ }
- if (creature_ptr->confused || creature_ptr->image)
+ if (effects->confusion()->is_confused() || effects->hallucination()->is_hallucinated()) {
i = i / 10;
+ }
int j = i - power;
- if (j < 2)
+ if (j < 2) {
j = 2;
+ }
if (randint0(100) < j) {
msg_format(_("%sを解除した。", "You have disarmed the %s."), name);
- gain_exp(creature_ptr, power);
- cave_alter_feat(creature_ptr, y, x, FF_DISARM);
- exe_movement(creature_ptr, dir, easy_disarm, false);
+ gain_exp(player_ptr, power);
+ cave_alter_feat(player_ptr, y, x, FloorFeatureType::DISARM);
+ exe_movement(player_ptr, dir, easy_disarm, false);
} else if ((i > 5) && (randint1(i) > 5)) {
- if (flush_failure)
+ if (flush_failure) {
flush();
+ }
msg_format(_("%sの解除に失敗した。", "You failed to disarm the %s."), name);
more = true;
} else {
msg_format(_("%sを作動させてしまった!", "You set off the %s!"), name);
- exe_movement(creature_ptr, dir, easy_disarm, false);
+ exe_movement(player_ptr, dir, easy_disarm, false);
}
return more;
* Returns TRUE if repeated commands may continue
* </pre>
*/
-bool exe_bash(player_type *creature_ptr, POSITION y, POSITION x, DIRECTION dir)
+bool exe_bash(PlayerType *player_ptr, POSITION y, POSITION x, DIRECTION dir)
{
- grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
- feature_type *f_ptr = &f_info[g_ptr->feat];
- int bash = adj_str_blow[creature_ptr->stat_index[A_STR]];
+ auto *g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
+ auto *f_ptr = &f_info[g_ptr->feat];
+ int bash = adj_str_blow[player_ptr->stat_index[A_STR]];
int temp = f_ptr->power;
bool more = false;
concptr name = f_info[g_ptr->get_feat_mimic()].name.c_str();
- PlayerEnergy(creature_ptr).set_player_turn_energy(100);
+ PlayerEnergy(player_ptr).set_player_turn_energy(100);
msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
temp = (bash - (temp * 10));
- if (creature_ptr->pclass == CLASS_BERSERKER)
+ if (PlayerClass(player_ptr).equals(PlayerClassType::BERSERKER)) {
temp *= 2;
+ }
- if (temp < 1)
+ if (temp < 1) {
temp = 1;
+ }
if (randint0(100) < temp) {
msg_format(_("%sを壊した!", "The %s crashes open!"), name);
- sound(has_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
- if ((randint0(100) < 50) || (feat_state(creature_ptr->current_floor_ptr, g_ptr->feat, FF_OPEN) == g_ptr->feat) || has_flag(f_ptr->flags, FF_GLASS)) {
- cave_alter_feat(creature_ptr, y, x, FF_BASH);
+ sound(f_ptr->flags.has(FloorFeatureType::GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
+ if ((randint0(100) < 50) || (feat_state(player_ptr->current_floor_ptr, g_ptr->feat, FloorFeatureType::OPEN) == g_ptr->feat) || f_ptr->flags.has(FloorFeatureType::GLASS)) {
+ cave_alter_feat(player_ptr, y, x, FloorFeatureType::BASH);
} else {
- cave_alter_feat(creature_ptr, y, x, FF_OPEN);
+ cave_alter_feat(player_ptr, y, x, FloorFeatureType::OPEN);
}
- exe_movement(creature_ptr, dir, false, false);
- } else if (randint0(100) < adj_dex_safe[creature_ptr->stat_index[A_DEX]] + creature_ptr->lev) {
+ exe_movement(player_ptr, dir, false, false);
+ } else if (randint0(100) < adj_dex_safe[player_ptr->stat_index[A_DEX]] + player_ptr->lev) {
msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
more = true;
} else {
msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
- (void)set_paralyzed(creature_ptr, creature_ptr->paralyzed + 2 + randint0(2));
+ (void)BadStatusSetter(player_ptr).mod_paralysis(2 + randint0(2));
}
return more;