6 #include "action/open-util.h"
7 #include "floor/geometry.h"
9 #include "perception/object-perception.h"
10 #include "system/floor-type-definition.h"
11 #include "system/grid-type-definition.h"
12 #include "system/object-type-definition.h"
13 #include "system/player-type-definition.h"
16 * @brief 該当のマスに存在している箱のオブジェクトIDを返す。
17 * @param y 走査対象にしたいマスのY座標
18 * @param x 走査対象にしたいマスのX座標
19 * @param trapped TRUEならばトラップが存在する箱のみ、FALSEならば空でない箱全てを対象にする
20 * @return 箱が存在する場合そのオブジェクトID、存在しない場合0を返す。
22 OBJECT_IDX chest_check(floor_type *floor_ptr, POSITION y, POSITION x, bool trapped)
24 grid_type *g_ptr = &floor_ptr->grid_array[y][x];
25 for (const auto this_o_idx : g_ptr->o_idx_list) {
27 o_ptr = &floor_ptr->o_list[this_o_idx];
28 if ((o_ptr->tval == ItemKindType::CHEST)
29 && (((!trapped) && (o_ptr->pval)) || /* non empty */
30 ((trapped) && (o_ptr->pval > 0)))) /* trapped only */
38 * @brief プレイヤーの周辺9マスに箱のあるマスがいくつあるかを返す /
39 * Return the number of chests around (or under) the character.
40 * @param y 該当するマスの中から1つのY座標を返す参照ポインタ
41 * @param x 該当するマスの中から1つのX座標を返す参照ポインタ
42 * @param trapped TRUEならばトラップの存在が判明している箱のみ対象にする
45 * If requested, count only trapped chests.
47 int count_chests(player_type *player_ptr, POSITION *y, POSITION *x, bool trapped)
50 for (DIRECTION d = 0; d < 9; d++) {
51 POSITION yy = player_ptr->y + ddy_ddd[d];
52 POSITION xx = player_ptr->x + ddx_ddd[d];
53 OBJECT_IDX o_idx = chest_check(player_ptr->current_floor_ptr, yy, xx, false);
58 o_ptr = &player_ptr->current_floor_ptr->o_list[o_idx];
62 if (trapped && (!o_ptr->is_known() || chest_traps[o_ptr->pval].none()))