write_birth_diary(player_ptr);
for (int i = 1; i < max_towns; i++) {
- for (int j = 0; j < MAX_STORES; j++) {
- store_init(i, j);
+ for (auto sst : StoreSaleType()) {
+ store_init(i, sst);
}
}
calc_android_exp(player_ptr);
init_riding_pet(player_ptr, new_game);
- (void)combine_and_reorder_home(player_ptr, STORE_HOME);
- (void)combine_and_reorder_home(player_ptr, STORE_MUSEUM);
+ (void)combine_and_reorder_home(player_ptr, StoreSaleType::HOME);
+ (void)combine_and_reorder_home(player_ptr, StoreSaleType::MUSEUM);
select_floor_music(player_ptr);
process_game_turn(player_ptr);
close_game(player_ptr);
static void dump_aux_home_museum(player_type *player_ptr, FILE *fff)
{
store_type *store_ptr;
- store_ptr = &town_info[1].store[STORE_HOME];
+ store_ptr = &town_info[1].store[enum2i(StoreSaleType::HOME)];
GAME_TEXT o_name[MAX_NLEN];
if (store_ptr->stock_num) {
fprintf(fff, "\n\n");
}
- store_ptr = &town_info[1].store[STORE_MUSEUM];
+ store_ptr = &town_info[1].store[enum2i(StoreSaleType::MUSEUM)];
if (store_ptr->stock_num == 0)
return;
spoil_random_artifact_aux(player_ptr, q_ptr, tval);
}
- store_ptr = &town_info[1].store[STORE_HOME];
+ store_ptr = &town_info[1].store[enum2i(StoreSaleType::HOME)];
for (int i = 0; i < store_ptr->stock_num; i++) {
q_ptr = &store_ptr->stock[i];
spoil_random_artifact_aux(player_ptr, q_ptr, tval);
}
- store_ptr = &town_info[1].store[STORE_MUSEUM];
+ store_ptr = &town_info[1].store[enum2i(StoreSaleType::MUSEUM)];
for (int i = 0; i < store_ptr->stock_num; i++) {
q_ptr = &store_ptr->stock[i];
spoil_random_artifact_aux(player_ptr, q_ptr, tval);
}
case '=': {
do_cmd_options(player_ptr);
- (void)combine_and_reorder_home(player_ptr, STORE_HOME);
+ (void)combine_and_reorder_home(player_ptr, StoreSaleType::HOME);
do_cmd_redraw(player_ptr);
break;
}
static void show_home_equipment_resistances(player_type *player_ptr, tval_type tval, int *label_number, FILE *fff)
{
store_type *store_ptr;
- store_ptr = &town_info[1].store[STORE_HOME];
+ store_ptr = &town_info[1].store[enum2i(StoreSaleType::HOME)];
char where[32];
strcpy(where, _("家", "H "));
for (int i = 0; i < store_ptr->stock_num; i++) {
return;
store_type *store_ptr;
- store_ptr = &town_info[1].store[STORE_HOME];
+ store_ptr = &town_info[1].store[enum2i(StoreSaleType::HOME)];
if (store_ptr->stock_num) {
#ifdef JP
return;
}
- if (store_ptr->stock_num >= store_get_stock_max(STORE_HOME))
+ if (store_ptr->stock_num >= store_get_stock_max(StoreSaleType::HOME))
return;
int32_t value = object_value(o_ptr);
{
store_type *store_ptr;
bool sort = false;
- if (h_older_than(0, 3, 3) && (store_number == STORE_HOME)) {
+ if (h_older_than(0, 3, 3) && (i2enum<StoreSaleType>(store_number) == StoreSaleType::HOME)) {
store_ptr = &town_info[1].store[store_number];
if (store_ptr->stock_num)
sort = true;
rd_item(q_ptr);
- auto stock_max = store_get_stock_max(i2enum<STORE_TYPE_IDX>(store_number));
+ auto stock_max = store_get_stock_max(i2enum<StoreSaleType>(store_number));
if (store_ptr->stock_num >= stock_max)
continue;
town_info = std::vector<town_type>(max_towns);
for (int i = 1; i < max_towns; i++) {
town_info[i].store = std::vector<store_type>(MAX_STORES);
- for (int j = 0; j < MAX_STORES; j++) {
- store_type *store_ptr = &town_info[i].store[j];
- if ((i > 1) && (j == STORE_MUSEUM || j == STORE_HOME))
+ for (auto sst : StoreSaleType()) {
+ store_type *store_ptr = &town_info[i].store[enum2i(sst)];
+ if ((i > 1) && (sst == StoreSaleType::MUSEUM || sst == StoreSaleType::HOME))
continue;
/*
* 我が家が 20 ページまで使える隠し機能のための準備。
* オプションが有効でもそうでなくても一応スペースを作っておく。
*/
- store_ptr->stock_size = store_get_stock_max(i2enum<STORE_TYPE_IDX>(j));
+ store_ptr->stock_size = store_get_stock_max(sst);
store_ptr->stock = std::make_unique<object_type[]>(store_ptr->stock_size);
- if ((j == STORE_BLACK) || (j == STORE_HOME) || (j == STORE_MUSEUM))
+ if ((sst == StoreSaleType::BLACK) || (sst == StoreSaleType::HOME) || (sst == StoreSaleType::MUSEUM))
continue;
for (int k = 0; k < STORE_INVEN_MAX; k++) {
- int tv = store_regular_table[j][k].tval;
- int sv = store_regular_table[j][k].sval;
+ int tv = store_regular_table[enum2i(sst)][k].tval;
+ int sv = store_regular_table[enum2i(sst)][k].sval;
if (tv == 0)
break;
}
for (int k = 0; k < STORE_CHOICES; k++) {
- int tv = store_table[j][k].tval;
- int sv = store_table[j][k].sval;
+ int tv = store_table[enum2i(sst)][k].tval;
+ int sv = store_table[enum2i(sst)][k].sval;
if (tv == 0)
break;
banish_monsters(player_ptr, 100);
if (!is_in_dungeon(player_ptr) && player_ptr->town_num) {
- int n;
+ StoreSaleType sst;
do {
- n = randint0(MAX_STORES);
- } while ((n == STORE_HOME) || (n == STORE_MUSEUM));
+ sst = i2enum<StoreSaleType>(randint0(MAX_STORES));
+ } while ((sst == StoreSaleType::HOME) || (sst == StoreSaleType::MUSEUM));
msg_print(_("店の主人が丘に向かって走っている!", "You see one of the shopkeepers running for the hills!"));
- store_shuffle(player_ptr, n);
+ store_shuffle(player_ptr, sst);
}
msg_print(nullptr);
}
object_type *o_ptr;
store_type *store_ptr;
for (int i = 1; i < max_towns; i++) {
- store_ptr = &town_info[i].store[STORE_HOME];
+ store_ptr = &town_info[i].store[enum2i(StoreSaleType::HOME)];
for (int j = 0; j < store_ptr->stock_num; j++) {
o_ptr = &store_ptr->stock[j];
if (!o_ptr->k_idx)
{
for (int l = 1; l < max_towns; l++) {
store_type *store_ptr;
- store_ptr = &town_info[l].store[STORE_HOME];
+ store_ptr = &town_info[l].store[enum2i(StoreSaleType::HOME)];
if (store_ptr->stock_num == 0)
continue;
* @note
* Note: ltcy and ltcx indicate "left top corner".
*/
-static void build_stores(player_type *player_ptr, POSITION ltcy, POSITION ltcx, int stores[], int n, const std::vector<ugbldg_type>& ugbldg)
+static void build_stores(player_type *player_ptr, POSITION ltcy, POSITION ltcx, StoreSaleType stores[], int n, const std::vector<ugbldg_type>& ugbldg)
{
int i;
POSITION y, x;
if (auto it = std::find_if(f_info.begin(), f_info.end(),
[subtype = stores[i]](const feature_type &f_ref) {
- return f_ref.flags.has(FF::STORE) && (f_ref.subtype == subtype);
+ return f_ref.flags.has(FF::STORE) && (i2enum<StoreSaleType>(static_cast<int>(f_ref.subtype)) == subtype);
});
it != f_info.end()) {
cave_set_feat(player_ptr, ltcy + y, ltcx + x, (*it).idx);
*/
bool build_type16(player_type *player_ptr, dun_data_type *dd_ptr)
{
- int stores[] = {
- STORE_GENERAL,
- STORE_ARMOURY,
- STORE_WEAPON,
- STORE_TEMPLE,
- STORE_ALCHEMIST,
- STORE_MAGIC,
- STORE_BLACK,
- STORE_BOOK,
+ StoreSaleType stores[] = {
+ StoreSaleType::GENERAL,
+ StoreSaleType::ARMOURY,
+ StoreSaleType::WEAPON,
+ StoreSaleType::TEMPLE,
+ StoreSaleType::ALCHEMIST,
+ StoreSaleType::MAGIC,
+ StoreSaleType::BLACK,
+ StoreSaleType::BOOK,
};
int n = sizeof stores / sizeof(int);
POSITION y1, x1, yval, xval;
/* Black market in a dungeon */
case 'S':
set_cave_feat(floor_ptr, y, x, feat_black_market);
- store_init(NO_TOWN, STORE_BLACK);
+ store_init(NO_TOWN, StoreSaleType::BLACK);
break;
/* The Pattern */
if (o_ptr->to_d > 0)
return false;
- for (int i = 0; i < MAX_STORES; i++) {
- if (i == STORE_HOME)
- continue;
- if (i == STORE_MUSEUM)
+ for (auto sst : StoreSaleType()) {
+ if (sst == StoreSaleType::HOME || sst == StoreSaleType::MUSEUM) {
continue;
+ }
- for (int j = 0; j < town_info[player_ptr->town_num].store[i].stock_num; j++) {
- object_type *j_ptr = &town_info[player_ptr->town_num].store[i].stock[j];
+ for (int j = 0; j < town_info[player_ptr->town_num].store[enum2i(sst)].stock_num; j++) {
+ object_type *j_ptr = &town_info[player_ptr->town_num].store[enum2i(sst)].stock[j];
if (o_ptr->k_idx == j_ptr->k_idx)
return true;
}
// inner_town_num は、施設内で C コマンドなどを使ったときにそのままでは現在地の偽装がバレる
// ため、それを糊塗するためのグローバル変数。
// この辺はリファクタしたい。
- int which = f_info[g_ptr->feat].subtype;
+ StoreSaleType which = i2enum<StoreSaleType>(f_info[g_ptr->feat].subtype);
old_town_num = player_ptr->town_num;
- if ((which == STORE_HOME) || (which == STORE_MUSEUM))
+ if ((which == StoreSaleType::HOME) || (which == StoreSaleType::MUSEUM))
player_ptr->town_num = 1;
if (is_in_dungeon(player_ptr))
player_ptr->town_num = NO_TOWN;
inner_town_num = player_ptr->town_num;
- if ((town_info[player_ptr->town_num].store[which].store_open >= w_ptr->game_turn) || ironman_shops) {
+ if ((town_info[player_ptr->town_num].store[enum2i(which)].store_open >= w_ptr->game_turn) || ironman_shops) {
msg_print(_("ドアに鍵がかかっている。", "The doors are locked."));
player_ptr->town_num = old_town_num;
return;
}
- int maintain_num = (w_ptr->game_turn - town_info[player_ptr->town_num].store[which].last_visit) / (TURNS_PER_TICK * STORE_TICKS);
+ int maintain_num = (w_ptr->game_turn - town_info[player_ptr->town_num].store[enum2i(which)].last_visit) / (TURNS_PER_TICK * STORE_TICKS);
if (maintain_num > 10)
maintain_num = 10;
if (maintain_num) {
store_maintenance(player_ptr, player_ptr->town_num, which, maintain_num);
- town_info[player_ptr->town_num].store[which].last_visit = w_ptr->game_turn;
+ town_info[player_ptr->town_num].store[enum2i(which)].last_visit = w_ptr->game_turn;
}
forget_lite(player_ptr->current_floor_ptr);
get_com_no_macros = true;
cur_store_num = which;
cur_store_feat = g_ptr->feat;
- st_ptr = &town_info[player_ptr->town_num].store[cur_store_num];
- ot_ptr = &owners[cur_store_num][st_ptr->owner];
+ st_ptr = &town_info[player_ptr->town_num].store[enum2i(cur_store_num)];
+ ot_ptr = &owners[enum2i(cur_store_num)][st_ptr->owner];
store_top = 0;
play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_BUILD);
display_store(player_ptr);
prt(_(" スペース) 次ページ", " SPACE) Next page"), 23 + xtra_stock, 0);
}
- if (cur_store_num == STORE_HOME) {
+ if (cur_store_num == StoreSaleType::HOME) {
prt(_("g) アイテムを取る", "g) Get an item."), 21 + xtra_stock, 27);
prt(_("d) アイテムを置く", "d) Drop an item."), 22 + xtra_stock, 27);
prt(_("x) 家のアイテムを調べる", "x) eXamine an item in the home."), 23 + xtra_stock, 27);
- } else if (cur_store_num == STORE_MUSEUM) {
+ } else if (cur_store_num == StoreSaleType::MUSEUM) {
prt(_("d) アイテムを置く", "d) Drop an item."), 21 + xtra_stock, 27);
prt(_("r) アイテムの展示をやめる", "r) order to Remove an item."), 22 + xtra_stock, 27);
prt(_("x) 博物館のアイテムを調べる", "x) eXamine an item in the museum."), 23 + xtra_stock, 27);
if (player_ptr->inventory_list[INVEN_PACK].k_idx) {
INVENTORY_IDX item = INVEN_PACK;
object_type *o_ptr = &player_ptr->inventory_list[item];
- if (cur_store_num != STORE_HOME) {
- if (cur_store_num == STORE_MUSEUM)
+ if (cur_store_num != StoreSaleType::HOME) {
+ if (cur_store_num == StoreSaleType::MUSEUM)
msg_print(_("ザックからアイテムがあふれそうなので、あわてて博物館から出た...", "Your pack is so full that you flee the Museum..."));
else
msg_print(_("ザックからアイテムがあふれそうなので、あわてて店から出た...", "Your pack is so full that you flee the store..."));
{
bool old_stack_force_notes = stack_force_notes;
bool old_stack_force_costs = stack_force_costs;
- if (cur_store_num != STORE_HOME) {
+ if (cur_store_num != StoreSaleType::HOME) {
stack_force_notes = false;
stack_force_costs = false;
}
j_ptr = &st_ptr->stock[slot];
if (object_similar(j_ptr, o_ptr)) {
object_absorb(j_ptr, o_ptr);
- if (cur_store_num != STORE_HOME) {
+ if (cur_store_num != StoreSaleType::HOME) {
stack_force_notes = old_stack_force_notes;
stack_force_costs = old_stack_force_costs;
}
}
}
- if (cur_store_num != STORE_HOME) {
+ if (cur_store_num != StoreSaleType::HOME) {
stack_force_notes = old_stack_force_notes;
stack_force_costs = old_stack_force_costs;
}
* 隠し機能: オプション powerup_home が設定されていると
* 我が家が 20 ページまで使える
*/
- if ((cur_store_num != STORE_HOME) || powerup_home) {
+ if ((cur_store_num != StoreSaleType::HOME) || powerup_home) {
if (st_ptr->stock_num >= st_ptr->stock_size) {
return -1;
}
* @param store_num 店舗ID
* @return 実際に整理が行われたならばTRUEを返す。
*/
-bool combine_and_reorder_home(player_type *player_ptr, const int store_num)
+bool combine_and_reorder_home(player_type *player_ptr, const StoreSaleType store_num)
{
bool old_stack_force_notes = stack_force_notes;
bool old_stack_force_costs = stack_force_costs;
store_type *old_st_ptr = st_ptr;
- st_ptr = &town_info[1].store[store_num];
+ st_ptr = &town_info[1].store[enum2i(store_num)];
bool flag = false;
- if (store_num != STORE_HOME) {
+ if (store_num != StoreSaleType::HOME) {
stack_force_notes = false;
stack_force_costs = false;
}
exe_reorder_store_item(player_ptr, &flag);
st_ptr = old_st_ptr;
- if (store_num != STORE_HOME) {
+ if (store_num != StoreSaleType::HOME) {
stack_force_notes = old_stack_force_notes;
stack_force_costs = old_stack_force_costs;
}
#pragma once
-struct object_type;;
+struct object_type;
struct player_type;
+enum class StoreSaleType;
int home_carry(player_type *player_ptr, object_type *o_ptr);
-bool combine_and_reorder_home(player_type *player_ptr, const int store_num);
+bool combine_and_reorder_home(player_type *player_ptr, const StoreSaleType store_num);
msg_format(_("%sの展示をやめさせた。", "You ordered to remove %s."), o_name);
store_item_increase(item, -o_ptr->number);
store_item_optimize(item);
- (void)combine_and_reorder_home(player_ptr, STORE_MUSEUM);
+ (void)combine_and_reorder_home(player_ptr, StoreSaleType::MUSEUM);
if (st_ptr->stock_num == 0)
store_top = 0;
else if (store_top >= st_ptr->stock_num)
if (adjust > 100)
adjust = 100;
- if (cur_store_num == STORE_BLACK)
+ if (cur_store_num == StoreSaleType::BLACK)
price = price / 2;
price = (price * adjust + 50L) / 100L;
if (adjust < 100)
adjust = 100;
- if (cur_store_num == STORE_BLACK)
+ if (cur_store_num == StoreSaleType::BLACK)
price = price * 2;
price = (int32_t)(((uint32_t)price * (uint32_t)adjust + 50UL) / 100UL);
char out_val[160];
switch (cur_store_num) {
- case STORE_HOME:
+ case StoreSaleType::HOME:
sprintf(out_val, _("どのアイテムを取りますか? ", "Which item do you want to take? "));
break;
- case STORE_BLACK:
+ case StoreSaleType::BLACK:
sprintf(out_val, _("どれ? ", "Which item, huh? "));
break;
default:
store_item_increase(item, -amt);
store_item_optimize(item);
- auto combined_or_reordered = combine_and_reorder_home(player_ptr, STORE_HOME);
+ auto combined_or_reordered = combine_and_reorder_home(player_ptr, StoreSaleType::HOME);
if (i == st_ptr->stock_num) {
if (combined_or_reordered)
*/
void store_purchase(player_type *player_ptr)
{
- if (cur_store_num == STORE_MUSEUM) {
+ if (cur_store_num == StoreSaleType::MUSEUM) {
msg_print(_("博物館から取り出すことはできません。", "Items cannot be taken out of the Museum."));
return;
}
if (st_ptr->stock_num <= 0) {
- if (cur_store_num == STORE_HOME)
+ if (cur_store_num == StoreSaleType::HOME)
msg_print(_("我が家には何も置いてありません。", "Your home is empty."));
else
msg_print(_("現在商品の在庫を切らしています。", "I am currently out of stock."));
PRICE best = price_item(player_ptr, j_ptr, ot_ptr->inflate, false);
if (o_ptr->number > 1) {
- if (cur_store_num != STORE_HOME) {
+ if (cur_store_num != StoreSaleType::HOME) {
msg_format(_("一つにつき $%ldです。", "That costs %ld gold per item."), (long)(best));
}
return;
}
- if (cur_store_num == STORE_HOME) {
+ if (cur_store_num == StoreSaleType::HOME) {
take_item_from_home(player_ptr, o_ptr, j_ptr, item);
return;
}
}
store_owner_says_comment(player_ptr);
- if (cur_store_num == STORE_BLACK)
+ if (cur_store_num == StoreSaleType::BLACK)
chg_virtue(player_ptr, V_JUSTICE, -1);
- if ((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME))
+ if ((o_ptr->tval == TV_BOTTLE) && (cur_store_num != StoreSaleType::HOME))
chg_virtue(player_ptr, V_NATURE, -1);
sound(SOUND_BUY);
*/
void store_owner_says_comment(player_type *player_ptr)
{
- if (cur_store_num == STORE_BLACK)
+ if (cur_store_num == StoreSaleType::BLACK)
msg_print(comment_1_B[randint0(MAX_COMMENT_1)]);
else
msg_print(comment_1[randint0(MAX_COMMENT_1)]);
concptr s_none; //!< @note 売る/置くものがない場合のメッセージ
concptr s_full; //!< @note もう置けない場合のメッセージ
switch (cur_store_num) {
- case STORE_HOME:
+ case StoreSaleType::HOME:
q = _("どのアイテムを置きますか? ", "Drop which item? ");
s_none = _("置けるアイテムを持っていません。", "You don't have any items to drop.");
s_full = _("我が家にはもう置く場所がない。", "Your home is full.");
break;
- case STORE_MUSEUM:
+ case StoreSaleType::MUSEUM:
q = _("どのアイテムを寄贈しますか? ", "Give which item? ");
s_none = _("寄贈できるアイテムを持っていません。", "You don't have any items to give.");
s_full = _("博物館はもう満杯だ。", "The Museum is full.");
GAME_TEXT o_name[MAX_NLEN];
describe_flavor(player_ptr, o_name, q_ptr, 0);
- if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM)) {
+ if ((cur_store_num != StoreSaleType::HOME) && (cur_store_num != StoreSaleType::MUSEUM)) {
q_ptr->inscription = 0;
q_ptr->feeling = FEEL_NONE;
}
}
bool placed = false;
- if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM)) {
+ if ((cur_store_num != StoreSaleType::HOME) && (cur_store_num != StoreSaleType::MUSEUM)) {
msg_format(_("%s(%c)を売却する。", "Selling %s (%c)."), o_name, index_to_label(item));
msg_print(nullptr);
store_owner_says_comment(player_ptr);
sound(SOUND_SELL);
- if (cur_store_num == STORE_BLACK)
+ if (cur_store_num == StoreSaleType::BLACK)
chg_virtue(player_ptr, V_JUSTICE, -1);
- if ((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME))
+ if ((o_ptr->tval == TV_BOTTLE) && (cur_store_num != StoreSaleType::HOME))
chg_virtue(player_ptr, V_NATURE, 1);
player_ptr->au += price;
display_store_inventory(player_ptr);
}
}
- } else if (cur_store_num == STORE_MUSEUM) {
+ } else if (cur_store_num == StoreSaleType::MUSEUM) {
char o2_name[MAX_NLEN];
describe_flavor(player_ptr, o2_name, q_ptr, OD_NAME_ONLY);
static bool switch_store_check(const object_type *o_ptr)
{
switch (cur_store_num) {
- case STORE_GENERAL:
+ case StoreSaleType::GENERAL:
return check_store_general(o_ptr);
- case STORE_ARMOURY:
+ case StoreSaleType::ARMOURY:
return check_store_armoury(o_ptr);
- case STORE_WEAPON:
+ case StoreSaleType::WEAPON:
return check_store_weapon(o_ptr);
- case STORE_TEMPLE:
+ case StoreSaleType::TEMPLE:
return check_store_temple(o_ptr);
- case STORE_ALCHEMIST:
+ case StoreSaleType::ALCHEMIST:
return check_store_alchemist(o_ptr);
- case STORE_MAGIC:
+ case StoreSaleType::MAGIC:
return check_store_magic(o_ptr);
- case STORE_BOOK:
+ case StoreSaleType::BOOK:
return check_store_book(o_ptr);
default:
return true;
*/
bool store_will_buy(player_type *, const object_type *o_ptr)
{
- if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM))
+ if ((cur_store_num == StoreSaleType::HOME) || (cur_store_num == StoreSaleType::MUSEUM))
return true;
if (!switch_store_check(o_ptr))
static int mass_magic_produce(const PRICE cost)
{
int size = 1;
- if ((cur_store_num != STORE_BLACK) || !one_in_(3))
+ if ((cur_store_num != StoreSaleType::BLACK) || !one_in_(3))
return size;
if (cost < 1601L)
if (store_top < 0)
store_top = ((st_ptr->stock_num - 1) / store_bottom) * store_bottom;
- if ((cur_store_num == STORE_HOME) && !powerup_home)
+ if ((cur_store_num == StoreSaleType::HOME) && !powerup_home)
if (store_top >= store_bottom)
store_top = store_bottom;
* 隠しオプション(powerup_home)がセットされていないときは
* 我が家では 2 ページまでしか表示しない
*/
- auto inven_max = store_get_stock_max(STORE_HOME, powerup_home);
+ auto inven_max = store_get_stock_max(StoreSaleType::HOME, powerup_home);
if (store_top >= st_ptr->stock_num || store_top >= inven_max)
store_top = 0;
}
case '=': {
do_cmd_options(player_ptr);
- (void)combine_and_reorder_home(player_ptr, STORE_HOME);
+ (void)combine_and_reorder_home(player_ptr, StoreSaleType::HOME);
do_cmd_redraw(player_ptr);
display_store(player_ptr);
break;
break;
}
default: {
- if ((cur_store_num == STORE_MUSEUM) && (command_cmd == 'r')) {
+ if ((cur_store_num == StoreSaleType::MUSEUM) && (command_cmd == 'r')) {
museum_remove_object(player_ptr);
} else {
msg_print(_("そのコマンドは店の中では使えません。", "That command does not work in stores."));
#include "system/object-type-definition.h"
#include "world/world-object.h"
-int cur_store_num = 0;
+StoreSaleType cur_store_num = StoreSaleType::GENERAL;
store_type *st_ptr = nullptr;
+StoreSaleType begin(StoreSaleType)
+{
+ return StoreSaleType::GENERAL;
+}
+
+StoreSaleType end(StoreSaleType)
+{
+ return StoreSaleType::MAX;
+}
+
+StoreSaleType operator*(StoreSaleType s)
+{
+ return s;
+}
+
+StoreSaleType operator++(StoreSaleType &s)
+{
+ return s = StoreSaleType(std::underlying_type<StoreSaleType>::type(s) + 1);
+}
+
/*!
* @brief 店舗のオブジェクト数を増やす /
* Add the item "o_ptr" to a real stores inventory.
for (int tries = 0; tries < 4; tries++) {
KIND_OBJECT_IDX k_idx;
DEPTH level;
- if (cur_store_num == STORE_BLACK) {
+ if (cur_store_num == StoreSaleType::BLACK) {
level = 25 + randint0(25);
k_idx = get_obj_num(player_ptr, level, 0x00000000);
if (k_idx == 0)
if (q_ptr->tval == TV_CHEST)
continue;
- if (cur_store_num == STORE_BLACK) {
+ if (cur_store_num == StoreSaleType::BLACK) {
if (black_market_crap(player_ptr, q_ptr) || (object_value(q_ptr) < 10))
continue;
} else {
#define STORE_OBJ_LEVEL 5 //!< 通常店舗の階層レベル / Magic Level for normal stores
-enum STORE_TYPE_IDX {
- STORE_GENERAL = 0, //!< 店舗の種類: 雑貨屋
- STORE_ARMOURY = 1, //!< 店舗の種類: 防具屋
- STORE_WEAPON = 2, //!< 店舗の種類: 武器屋
- STORE_TEMPLE = 3, //!< 店舗の種類: 寺院
- STORE_ALCHEMIST = 4, //!< 店舗の種類: 錬金術の店
- STORE_MAGIC = 5, //!< 店舗の種類: 魔道具屋
- STORE_BLACK = 6, //!< 店舗の種類: ブラック・マーケット
- STORE_HOME = 7, //!< 店舗の種類: 我が家
- STORE_BOOK = 8, //!< 店舗の種類: 書店
- STORE_MUSEUM = 9, //!< 店舗の種類: 博物館
- STORE_MAX = 10
+enum class StoreSaleType {
+ GENERAL = 0, //!< 店舗の種類: 雑貨屋
+ ARMOURY = 1, //!< 店舗の種類: 防具屋
+ WEAPON = 2, //!< 店舗の種類: 武器屋
+ TEMPLE = 3, //!< 店舗の種類: 寺院
+ ALCHEMIST = 4, //!< 店舗の種類: 錬金術の店
+ MAGIC = 5, //!< 店舗の種類: 魔道具屋
+ BLACK = 6, //!< 店舗の種類: ブラック・マーケット
+ HOME = 7, //!< 店舗の種類: 我が家
+ BOOK = 8, //!< 店舗の種類: 書店
+ MUSEUM = 9, //!< 店舗の種類: 博物館
+ MAX = 10
};
+StoreSaleType begin(StoreSaleType);
+StoreSaleType end(StoreSaleType);
+StoreSaleType operator*(StoreSaleType s);
+StoreSaleType operator++(StoreSaleType &s);
+
using store_k_idx = std::vector<KIND_OBJECT_IDX>;
/*!
store_type &operator=(const store_type &) = delete;
};
-extern int cur_store_num;
+extern StoreSaleType cur_store_num;
extern store_type *st_ptr;
struct player_type;
* @param store_idx 店舗ID
* @return 店舗の最大スロット数
*/
-int16_t store_get_stock_max(STORE_TYPE_IDX store_idx, bool powerup)
+int16_t store_get_stock_max(StoreSaleType sst, bool powerup)
{
- switch (store_idx) {
- case STORE_HOME:
+ switch (sst) {
+ case StoreSaleType::HOME:
return powerup ? STORE_INVEN_MAX * 10 : STORE_INVEN_MAX;
- case STORE_MUSEUM:
+ case StoreSaleType::MUSEUM:
return STORE_INVEN_MAX * 50;
default:
return STORE_INVEN_MAX * 3 / 2;
*/
static int check_free_space(void)
{
- if ((cur_store_num == STORE_HOME) && !powerup_home) {
+ if ((cur_store_num == StoreSaleType::HOME) && !powerup_home) {
if (st_ptr->stock_num < ((st_ptr->stock_size) / 10))
return 1;
} else if (st_ptr->stock_num < st_ptr->stock_size)
int store_check_num(object_type *o_ptr)
{
object_type *j_ptr;
- if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) {
+ if ((cur_store_num == StoreSaleType::HOME) || (cur_store_num == StoreSaleType::MUSEUM)) {
bool old_stack_force_notes = stack_force_notes;
bool old_stack_force_costs = stack_force_costs;
- if (cur_store_num != STORE_HOME) {
+ if (cur_store_num != StoreSaleType::HOME) {
stack_force_notes = false;
stack_force_costs = false;
}
if (!object_similar(j_ptr, o_ptr))
continue;
- if (cur_store_num != STORE_HOME) {
+ if (cur_store_num != StoreSaleType::HOME) {
stack_force_notes = old_stack_force_notes;
stack_force_costs = old_stack_force_costs;
}
return -1;
}
- if (cur_store_num != STORE_HOME) {
+ if (cur_store_num != StoreSaleType::HOME) {
stack_force_notes = old_stack_force_notes;
stack_force_costs = old_stack_force_costs;
}
char hi = (j > 25) ? toupper(I2A(j - 26)) : I2A(j);
char out_val[160];
#ifdef JP
- (void)sprintf(out_val, "(%s:%c-%c, ESCで中断) %s", (((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) ? "アイテム" : "商品"), lo, hi, pmt);
+ (void)sprintf(out_val, "(%s:%c-%c, ESCで中断) %s", (((cur_store_num == StoreSaleType::HOME) || (cur_store_num == StoreSaleType::MUSEUM)) ? "アイテム" : "商品"), lo, hi, pmt);
#else
(void)sprintf(out_val, "(Items %c-%c, ESC to exit) %s", lo, hi, pmt);
#endif
void store_examine(player_type *player_ptr)
{
if (st_ptr->stock_num <= 0) {
- if (cur_store_num == STORE_HOME)
+ if (cur_store_num == StoreSaleType::HOME)
msg_print(_("我が家には何も置いてありません。", "Your home is empty."));
- else if (cur_store_num == STORE_MUSEUM)
+ else if (cur_store_num == StoreSaleType::MUSEUM)
msg_print(_("博物館には何も置いてありません。", "The Museum is empty."));
else
msg_print(_("現在商品の在庫を切らしています。", "I am currently out of stock."));
* Shuffle one of the stores.
* @param which 店舗種類のID
*/
-void store_shuffle(player_type *player_ptr, int which)
+void store_shuffle(player_type *player_ptr, StoreSaleType which)
{
- if ((which == STORE_HOME) || (which == STORE_MUSEUM))
+ if ((which == StoreSaleType::HOME) || (which == StoreSaleType::MUSEUM))
return;
cur_store_num = which;
- st_ptr = &town_info[player_ptr->town_num].store[cur_store_num];
+ st_ptr = &town_info[player_ptr->town_num].store[enum2i(cur_store_num)];
int j = st_ptr->owner;
while (true) {
st_ptr->owner = (byte)randint0(MAX_OWNERS);
if (i == player_ptr->town_num)
continue;
- if (st_ptr->owner == town_info[i].store[cur_store_num].owner)
+ if (st_ptr->owner == town_info[i].store[enum2i(cur_store_num)].owner)
break;
}
break;
}
- ot_ptr = &owners[cur_store_num][st_ptr->owner];
+ ot_ptr = &owners[enum2i(cur_store_num)][st_ptr->owner];
st_ptr->insult_cur = 0;
st_ptr->store_open = 0;
st_ptr->good_buy = 0;
* @param store_num 店舗種類のID
* @param chance 更新商品数
*/
-void store_maintenance(player_type *player_ptr, int town_num, int store_num, int chance)
+void store_maintenance(player_type *player_ptr, int town_num, StoreSaleType store_num, int chance)
{
cur_store_num = store_num;
- if ((store_num == STORE_HOME) || (store_num == STORE_MUSEUM))
+ if ((store_num == StoreSaleType::HOME) || (store_num == StoreSaleType::MUSEUM))
return;
- st_ptr = &town_info[town_num].store[store_num];
- ot_ptr = &owners[store_num][st_ptr->owner];
+ st_ptr = &town_info[town_num].store[enum2i(store_num)];
+ ot_ptr = &owners[enum2i(store_num)][st_ptr->owner];
st_ptr->insult_cur = 0;
- if (store_num == STORE_BLACK) {
+ if (store_num == StoreSaleType::BLACK) {
for (INVENTORY_IDX j = st_ptr->stock_num - 1; j >= 0; j--) {
object_type *o_ptr = &st_ptr->stock[j];
if (black_market_crap(player_ptr, o_ptr)) {
* @param town_num 町のID
* @param store_num 店舗種類のID
*/
-void store_init(int town_num, int store_num)
+void store_init(int town_num, StoreSaleType store_num)
{
cur_store_num = store_num;
- st_ptr = &town_info[town_num].store[store_num];
+ st_ptr = &town_info[town_num].store[enum2i(store_num)];
while (true) {
st_ptr->owner = (byte)randint0(MAX_OWNERS);
int i;
for (i = 1; i < max_towns; i++) {
if (i == town_num)
continue;
- if (st_ptr->owner == town_info[i].store[store_num].owner)
+ if (st_ptr->owner == town_info[i].store[enum2i(store_num)].owner)
break;
}
break;
}
- ot_ptr = &owners[store_num][st_ptr->owner];
+ ot_ptr = &owners[enum2i(store_num)][st_ptr->owner];
st_ptr->store_open = 0;
st_ptr->insult_cur = 0;
st_ptr->good_buy = 0;
for (int k = 0; k < st_ptr->stock_size; k++)
(&st_ptr->stock[k])->wipe();
}
+
extern bool allow_inc;
struct player_type;
-int16_t store_get_stock_max(STORE_TYPE_IDX store_idx, bool powerup = true);
-void store_shuffle(player_type *player_ptr, int which);
-void store_maintenance(player_type *player_ptr, int town_num, int store_num, int chance);
-void store_init(int town_num, int store_num);
+int16_t store_get_stock_max(StoreSaleType sst, bool powerup = true);
+void store_shuffle(player_type *player_ptr, StoreSaleType which);
+void store_maintenance(player_type *player_ptr, int town_num, StoreSaleType store_num, int chance);
+void store_init(int town_num, StoreSaleType store_num);
void store_examine(player_type *player_ptr);
int store_check_num(object_type *o_ptr);
int get_stock(COMMAND_CODE *com_val, concptr pmt, int i, int j);
/* Describe an item in the home */
int maxwid = 75;
- if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) {
+ if ((cur_store_num == StoreSaleType::HOME) || (cur_store_num == StoreSaleType::MUSEUM)) {
maxwid = 75;
if (show_weights)
maxwid -= 10;
put_str(format(_("(%dページ) ", "(Page %d) "), store_top / store_bottom + 1), 5, _(20, 22));
}
- if (cur_store_num == STORE_HOME || cur_store_num == STORE_MUSEUM) {
+ if (cur_store_num == StoreSaleType::HOME || cur_store_num == StoreSaleType::MUSEUM) {
k = st_ptr->stock_size;
- if (cur_store_num == STORE_HOME && !powerup_home)
+ if (cur_store_num == StoreSaleType::HOME && !powerup_home)
k /= 10;
put_str(format(_("アイテム数: %4d/%4d", "Objects: %4d/%4d"), st_ptr->stock_num, k), 19 + xtra_stock, _(27, 30));
void display_store(player_type *player_ptr)
{
term_clear();
- if (cur_store_num == STORE_HOME) {
+ if (cur_store_num == StoreSaleType::HOME) {
put_str(_("我が家", "Your Home"), 3, 31);
put_str(_("アイテムの一覧", "Item Description"), 5, 4);
if (show_weights) {
return;
}
- if (cur_store_num == STORE_MUSEUM) {
+ if (cur_store_num == StoreSaleType::MUSEUM) {
put_str(_("博物館", "Museum"), 3, 31);
put_str(_("アイテムの一覧", "Item Description"), 5, 4);
if (show_weights) {
int n;
do {
n = randint0(MAX_STORES);
- if ((n == STORE_HOME) || (n == STORE_MUSEUM)) {
+ if ((n == enum2i(StoreSaleType::HOME)) || (n == enum2i(StoreSaleType::MUSEUM))) {
break;
}
} while (true);
msg_format(_("%sの店主をシャッフルします。", "Shuffle a Shopkeeper of %s."), f_ref.name.c_str());
}
- store_shuffle(this->player_ptr, n);
+ store_shuffle(this->player_ptr, i2enum<StoreSaleType>(n));
break;
}
}