};
-
#define MAX_COMMENT_3B 12
static concptr comment_3b[MAX_COMMENT_3B] =
}
};
-
-
/*!
* @brief 取引成功時の店主のメッセージ処理 /
+ * ブラックマーケットのときは別のメッセージを出す
* Successful haggle.
* @param player_ptr プレーヤーへの参照ポインタ
* @return なし
static void say_comment_1(player_type *player_ptr)
{
#ifdef JP
- /* ブラックマーケットのときは別のメッセージを出す */
if ( cur_store_num == STORE_BLACK ) {
msg_print(comment_1_B[randint0(MAX_COMMENT_1)]);
}
msg_print(comment_1[randint0(MAX_COMMENT_1)]);
#endif
-
if (one_in_(RUMOR_CHANCE))
{
#ifdef JP
*/
static void say_comment_2(PRICE value, int annoyed)
{
- char tmp_val[80];
-
/* Prepare a string to insert */
+ char tmp_val[80];
sprintf(tmp_val, "%ld", (long)value);
/* Final offer */
{
/* Formatted message */
msg_format(comment_2a[randint0(MAX_COMMENT_2A)], tmp_val);
+ return;
}
/* Normal offer */
+ /* Formatted message */
+#ifdef JP
+ if (cur_store_num == STORE_BLACK) {
+ msg_format(comment_2b_B[randint0(MAX_COMMENT_2B)], tmp_val);
+ }
else
{
- /* Formatted message */
-#ifdef JP
- /* ブラックマーケットの時は別のメッセージを出す */
- if ( cur_store_num == STORE_BLACK ){
- msg_format(comment_2b_B[randint0(MAX_COMMENT_2B)], tmp_val);
- }
- else{
msg_format(comment_2b[randint0(MAX_COMMENT_2B)], tmp_val);
}
#else
- msg_format(comment_2b[randint0(MAX_COMMENT_2B)], tmp_val);
+ msg_format(comment_2b[randint0(MAX_COMMENT_2B)], tmp_val);
#endif
-
- }
}
/*!
* @brief プレイヤーがアイテムを売る時の価格代案メッセージ処理 /
+ * ブラックマーケットのときは別のメッセージを出す
* Continue haggling (player is selling)
* @param value 店主の提示価格
* @param annoyed 店主のいらつき度
*/
static void say_comment_3(PRICE value, int annoyed)
{
- char tmp_val[80];
-
/* Prepare a string to insert */
+ char tmp_val[80];
sprintf(tmp_val, "%ld", (long)value);
/* Final offer */
/* Formatted message */
#ifdef JP
/* ブラックマーケットの時は別のメッセージを出す */
- if ( cur_store_num == STORE_BLACK ){
+ if ( cur_store_num == STORE_BLACK )
+ {
msg_format(comment_3b_B[randint0(MAX_COMMENT_3B)], tmp_val);
}
- else{
+
+ else
+ {
msg_format(comment_3b[randint0(MAX_COMMENT_3B)], tmp_val);
- }
+ }
#else
msg_format(comment_3b[randint0(MAX_COMMENT_3B)], tmp_val);
#endif
-
}
}
/*!
* @brief 店主がプレイヤーを追い出す時のメッセージ処理 /
+ * ブラックマーケットの時は別のメッセージを出す
* Kick 'da bum out. -RAK-
* @return なし
*/
static void say_comment_4(void)
{
#ifdef JP
- /* ブラックマーケットの時は別のメッセージを出す */
if ( cur_store_num == STORE_BLACK ){
msg_print(comment_4a_B[randint0(MAX_COMMENT_4A)]);
msg_print(comment_4b_B[randint0(MAX_COMMENT_4B)]);
}
- else{
+ else
+ {
msg_print(comment_4a[randint0(MAX_COMMENT_4A)]);
msg_print(comment_4b[randint0(MAX_COMMENT_4B)]);
}
/*!
* @brief 店主がプレイヤーに取り合わない時のメッセージ処理 /
+ * ブラックマーケットの時は別のメッセージを出す
* You are insulting me
* @return なし
*/
static void say_comment_5(void)
{
#ifdef JP
- /* ブラックマーケットの時は別のメッセージを出す */
- if ( cur_store_num == STORE_BLACK ){
+ if ( cur_store_num == STORE_BLACK )
+ {
msg_print(comment_5_B[randint0(MAX_COMMENT_5)]);
}
- else{
+ else
+ {
msg_print(comment_5[randint0(MAX_COMMENT_5)]);
}
#else
msg_print(comment_6[randint0(MAX_COMMENT_6)]);
}
-
#define MAX_COMMENT_7A 4
static concptr comment_7a[MAX_COMMENT_7A] =
chg_virtue(player_ptr, V_HONOUR, -1);
chg_virtue(player_ptr, V_JUSTICE, -1);
sound(SOUND_STORE1);
+ return;
}
/* Item was cheaper than we thought, and we paid more than necessary */
- else if ((value < guess) && (price > value))
+ if ((value < guess) && (price > value))
{
msg_print(comment_7b[randint0(MAX_COMMENT_7B)]);
chg_virtue(player_ptr, V_JUSTICE, -1);
if (one_in_(4)) chg_virtue(player_ptr, V_HONOUR, -1);
sound(SOUND_STORE2);
+ return;
}
/* Item was a good bargain, and we got away with it */
- else if ((value > guess) && (value < (4 * guess)) && (price < value))
+ if ((value > guess) && (value < (4 * guess)) && (price < value))
{
msg_print(comment_7c[randint0(MAX_COMMENT_7C)]);
if (one_in_(4)) chg_virtue(player_ptr, V_HONOUR, -1);
else if (one_in_(4)) chg_virtue(player_ptr, V_HONOUR, 1);
sound(SOUND_STORE3);
+ return;
}
/* Item was a great bargain, and we got away with it */
- else if ((value > guess) && (price < value))
+ if ((value > guess) && (price < value))
{
msg_print(comment_7d[randint0(MAX_COMMENT_7D)]);
if (one_in_(2)) chg_virtue(player_ptr, V_HONOUR, -1);
if (one_in_(4)) chg_virtue(player_ptr, V_HONOUR, 1);
if (10 * price < value) chg_virtue(player_ptr, V_SACRIFICE, 1);
sound(SOUND_STORE4);
+ return;
}
}
-
-
/*
* We store the current "store feat" here so everyone can access it
*/
static int cur_store_feat;
-
/*
* Buying and selling adjustments for race combinations.
* Entry[owner][player] gives the basic "cost inflation".
};
-
/*!
- * @brief 店舗価格を決定する /
+ * @brief 店舗価格を決定する. 無料にはならない /
* Determine the price of an item (qty one) in a store.
* @param o_ptr 店舗に並べるオブジェクト構造体の参照ポインタ
* @param greed 店主の強欲度
*/
static PRICE price_item(player_type *player_ptr, object_type *o_ptr, int greed, bool flip)
{
- int factor;
- int adjust;
- PRICE price;
-
/* Get the value of one of the items */
- price = object_value(o_ptr);
+ PRICE price = object_value(o_ptr);
/* Worthless items */
if (price <= 0) return (0L);
/* Compute the racial factor */
- factor = rgold_adj[ot_ptr->owner_race][player_ptr->prace];
+ int factor = rgold_adj[ot_ptr->owner_race][player_ptr->prace];
/* Add in the charisma factor */
factor += adj_chr_gold[player_ptr->stat_ind[A_CHR]];
-
/* Shop is buying */
+ int adjust;
if (flip)
{
/* Adjust for greed */
price = (s32b)(((u32b)price * (u32b)adjust + 50UL) / 100UL);
}
- /* Note -- Never become "free" */
if (price <= 0L) return (1L);
-
- /* Return the price */
return (price);
}
*/
static void mass_produce(object_type *o_ptr)
{
+ /* Analyze the type */
int size = 1;
- DISCOUNT_RATE discount = 0;
-
PRICE cost = object_value(o_ptr);
-
-
- /* Analyze the type */
switch (o_ptr->tval)
{
/* Food, Flasks, and Lites */
}
}
-
/* Pick a discount */
+ DISCOUNT_RATE discount = 0;
if (cost < 5)
{
discount = 0;
}
-
/*!
* @brief 店舗に並べた品を同一品であるかどうか判定する /
* Determine if a store item can "absorb" another item
*/
static bool store_object_similar(object_type *o_ptr, object_type *j_ptr)
{
- int i;
-
/* Hack -- Identical items cannot be stacked */
if (o_ptr == j_ptr) return 0;
if (object_is_artifact(o_ptr) || object_is_artifact(j_ptr)) return 0;
/* Hack -- Identical art_flags! */
- for (i = 0; i < TR_FLAG_SIZE; i++)
+ for (int i = 0; i < TR_FLAG_SIZE; i++)
if (o_ptr->art_flags[i] != j_ptr->art_flags[i]) return 0;
/* Hack -- Never stack "powerful" items */
*/
static int store_check_num(object_type *o_ptr)
{
- int i;
object_type *j_ptr;
/* The "home" acts like the player */
}
/* Check all the items */
- for (i = 0; i < st_ptr->stock_num; i++)
+ for (int i = 0; i < st_ptr->stock_num; i++)
{
/* Get the existing item */
j_ptr = &st_ptr->stock[i];
else
{
/* Check all the items */
- for (i = 0; i < st_ptr->stock_num; i++)
+ for (int i = 0; i < st_ptr->stock_num; i++)
{
/* Get the existing item */
j_ptr = &st_ptr->stock[i];
return 0;
}
+
/*!
* @brief オブジェクトが祝福されているかの判定を返す /
* @param o_ptr 判定したいオブジェクト構造体の参照ポインタ
}
-
/*!
* @brief オブジェクトが所定の店舗で引き取れるかどうかを返す /
* Determine if the current store will purchase the given item
}
}
- /* Ignore "worthless" items */
if (object_value(o_ptr) <= 0) return FALSE;
-
- /* Assume okay */
return TRUE;
}
*/
bool combine_and_reorder_home(int store_num)
{
- int i, j, k;
- s32b o_value;
- object_type forge, *o_ptr, *j_ptr;
- bool flag = FALSE, combined;
- store_type *old_st_ptr = st_ptr;
- 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];
+ bool flag = FALSE;
if (store_num != STORE_HOME)
{
stack_force_notes = FALSE;
stack_force_costs = FALSE;
}
- do
+ bool combined = TRUE;
+ while (combined)
{
combined = FALSE;
/* Combine the items in the home (backwards) */
- for (i = st_ptr->stock_num - 1; i > 0; i--)
+ for (int i = st_ptr->stock_num - 1; i > 0; i--)
{
+ object_type *o_ptr;
o_ptr = &st_ptr->stock[i];
/* Skip empty items */
if (!o_ptr->k_idx) continue;
/* Scan the items above that item */
- for (j = 0; j < i; j++)
+ for (int j = 0; j < i; j++)
{
- int max_num;
-
+ object_type *j_ptr;
j_ptr = &st_ptr->stock[j];
/* Skip empty items */
* Get maximum number of the stack if these
* are similar, get zero otherwise.
*/
- max_num = object_similar_part(j_ptr, o_ptr);
+ int max_num = object_similar_part(j_ptr, o_ptr);
/* Can we (partialy) drop "o_ptr" onto "j_ptr"? */
- if (max_num && j_ptr->number < max_num)
- {
- if (o_ptr->number + j_ptr->number <= max_num)
- {
- /* Add together the item counts */
- object_absorb(j_ptr, o_ptr);
+ if (max_num && j_ptr->number >= max_num) continue;
- /* One object is gone */
- st_ptr->stock_num--;
+ if (o_ptr->number + j_ptr->number <= max_num)
+ {
+ /* Add together the item counts */
+ object_absorb(j_ptr, o_ptr);
- /* Slide everything down */
- for (k = i; k < st_ptr->stock_num; k++)
- {
- /* Structure copy */
- st_ptr->stock[k] = st_ptr->stock[k + 1];
- }
+ /* One object is gone */
+ st_ptr->stock_num--;
- /* Erase the "final" slot */
- object_wipe(&st_ptr->stock[k]);
- }
- else
+ /* Slide everything down */
+ int k;
+ for (k = i; k < st_ptr->stock_num; k++)
{
- ITEM_NUMBER old_num = o_ptr->number;
- ITEM_NUMBER remain = j_ptr->number + o_ptr->number - max_num;
-
- /* Add together the item counts */
- object_absorb(j_ptr, o_ptr);
-
- o_ptr->number = remain;
-
- /* Hack -- if rods are stacking, add the pvals (maximum timeouts) and current timeouts together. -LM- */
- if (o_ptr->tval == TV_ROD)
- {
- o_ptr->pval = o_ptr->pval * remain / old_num;
- o_ptr->timeout = o_ptr->timeout * remain / old_num;
- }
-
- /* Hack -- if wands are stacking, combine the charges. -LM- */
- else if (o_ptr->tval == TV_WAND)
- {
- o_ptr->pval = o_ptr->pval * remain / old_num;
- }
+ /* Structure copy */
+ st_ptr->stock[k] = st_ptr->stock[k + 1];
}
- /* Take note */
+ /* Erase the "final" slot */
+ object_wipe(&st_ptr->stock[k]);
combined = TRUE;
break;
}
+
+ ITEM_NUMBER old_num = o_ptr->number;
+ ITEM_NUMBER remain = j_ptr->number + o_ptr->number - max_num;
+
+ /* Add together the item counts */
+ object_absorb(j_ptr, o_ptr);
+
+ o_ptr->number = remain;
+
+ /* Hack -- if rods are stacking, add the pvals (maximum timeouts) and current timeouts together. -LM- */
+ if (o_ptr->tval == TV_ROD)
+ {
+ o_ptr->pval = o_ptr->pval * remain / old_num;
+ o_ptr->timeout = o_ptr->timeout * remain / old_num;
+ }
+
+ /* Hack -- if wands are stacking, combine the charges. -LM- */
+ else if (o_ptr->tval == TV_WAND)
+ {
+ o_ptr->pval = o_ptr->pval * remain / old_num;
+ }
+
+ combined = TRUE;
+ break;
}
}
flag |= combined;
}
- while (combined);
/* Re-order the items in the home (forwards) */
- for (i = 0; i < st_ptr->stock_num; i++)
+ for (int i = 0; i < st_ptr->stock_num; i++)
{
+ object_type *o_ptr;
o_ptr = &st_ptr->stock[i];
/* Skip empty slots */
if (!o_ptr->k_idx) continue;
/* Get the "value" of the item */
- o_value = object_value(o_ptr);
+ s32b o_value = object_value(o_ptr);
/* Scan every occupied slot */
+ int j;
for (j = 0; j < st_ptr->stock_num; j++)
{
if (object_sort_comp(o_ptr, o_value, &st_ptr->stock[j])) break;
/* Take note */
flag = TRUE;
+ object_type *j_ptr;
+ object_type forge;
j_ptr = &forge;
/* Save a copy of the moving item */
object_copy(j_ptr, &st_ptr->stock[i]);
/* Slide the objects */
- for (k = i; k > j; k--)
+ for (int k = i; k > j; k--)
{
/* Slide the item */
object_copy(&st_ptr->stock[k], &st_ptr->stock[k - 1]);
}
st_ptr = old_st_ptr;
+ bool old_stack_force_notes = stack_force_notes;
+ bool old_stack_force_costs = stack_force_costs;
if (store_num != STORE_HOME)
{
stack_force_notes = old_stack_force_notes;
*/
static int home_carry(player_type *player_ptr, object_type *o_ptr)
{
- int slot;
- PRICE value;
- int i;
- object_type *j_ptr;
- bool old_stack_force_notes = stack_force_notes;
- bool old_stack_force_costs = stack_force_costs;
-
if (cur_store_num != STORE_HOME)
{
stack_force_notes = FALSE;
}
/* Check each existing item (try to combine) */
- for (slot = 0; slot < st_ptr->stock_num; slot++)
+ bool old_stack_force_notes = stack_force_notes;
+ bool old_stack_force_costs = stack_force_costs;
+ for (int slot = 0; slot < st_ptr->stock_num; slot++)
{
/* Get the existing item */
+ object_type *j_ptr;
j_ptr = &st_ptr->stock[slot];
/* The home acts just like the player */
}
}
-
/* Determine the "value" of the item */
- value = object_value(o_ptr);
+ PRICE value = object_value(o_ptr);
/* Check existing slots to see if we must "slide" */
+ int slot;
for (slot = 0; slot < st_ptr->stock_num; slot++)
{
if (object_sort_comp(o_ptr, value, &st_ptr->stock[slot])) break;
}
/* Slide the others up */
- for (i = st_ptr->stock_num; i > slot; i--)
+ for (int i = st_ptr->stock_num; i > slot; i--)
{
st_ptr->stock[i] = st_ptr->stock[i-1];
}
chg_virtue(player_ptr, V_SACRIFICE, -1);
(void)combine_and_reorder_home(cur_store_num);
-
- /* Return the location */
- return (slot);
+ return slot;
}
*/
static int store_carry(object_type *o_ptr)
{
- int i, slot;
- PRICE value, j_value;
- object_type *j_ptr;
-
-
- /* Evaluate the object */
- value = object_value(o_ptr);
+ PRICE value = object_value(o_ptr);
/* Cursed/Worthless items "disappear" when sold */
if (value <= 0) return -1;
o_ptr->feeling = FEEL_NONE;
/* Check each existing item (try to combine) */
+ int slot;
for (slot = 0; slot < st_ptr->stock_num; slot++)
{
/* Get the existing item */
+ object_type *j_ptr;
j_ptr = &st_ptr->stock[slot];
/* Can the existing items be incremented? */
store_object_absorb(j_ptr, o_ptr);
/* All done */
- return (slot);
+ return slot;
}
}
/* No space? */
if (st_ptr->stock_num >= st_ptr->stock_size) return -1;
-
/* Check existing slots to see if we must "slide" */
for (slot = 0; slot < st_ptr->stock_num; slot++)
{
/* Get that item */
+ object_type *j_ptr;
j_ptr = &st_ptr->stock[slot];
/* Objects sort by decreasing type */
}
/* Evaluate that slot */
- j_value = object_value(j_ptr);
+ PRICE j_value = object_value(j_ptr);
/* Objects sort by decreasing value */
if (value > j_value) break;
}
/* Slide the others up */
- for (i = st_ptr->stock_num; i > slot; i--)
+ for (int i = st_ptr->stock_num; i > slot; i--)
{
st_ptr->stock[i] = st_ptr->stock[i-1];
}
- /* More stuff now */
st_ptr->stock_num++;
-
- /* Insert the new item */
st_ptr->stock[slot] = *o_ptr;
-
- /* Return the location */
- return (slot);
+ return slot;
}
*/
static void store_item_increase(INVENTORY_IDX item, int num)
{
- int cnt;
object_type *o_ptr;
-
o_ptr = &st_ptr->stock[item];
/* Verify the number */
- cnt = o_ptr->number + num;
+ int cnt = o_ptr->number + num;
if (cnt > 255) cnt = 255;
else if (cnt < 0) cnt = 0;
num = cnt - o_ptr->number;
- /* Save the new number */
o_ptr->number += (ITEM_NUMBER)num;
}
*/
static void store_item_optimize(INVENTORY_IDX item)
{
- int j;
object_type *o_ptr;
-
o_ptr = &st_ptr->stock[item];
/* Must exist */
st_ptr->stock_num--;
/* Slide everyone */
- for (j = item; j < st_ptr->stock_num; j++)
+ for (int j = item; j < st_ptr->stock_num; j++)
{
st_ptr->stock[j] = st_ptr->stock[j + 1];
}
/* Nuke the final slot */
- object_wipe(&st_ptr->stock[j]);
+ object_wipe(&st_ptr->stock[st_ptr->stock_num]);
}
+
/*!
* @brief ブラックマーケット用の無価値品の排除判定 /
* This function will keep 'crap' out of the black market.
*/
static bool black_market_crap(player_type *player_ptr, object_type *o_ptr)
{
- int i, j;
-
- /* Ego items are never crap */
if (object_is_ego(o_ptr)) return FALSE;
/* Good items are never crap */
if (o_ptr->to_d > 0) return FALSE;
/* Check all stores */
- for (i = 0; i < MAX_STORES; i++)
+ for (int i = 0; i < MAX_STORES; i++)
{
if (i == STORE_HOME) continue;
if (i == STORE_MUSEUM) continue;
/* Check every item in the store */
- for (j = 0; j < town_info[player_ptr->town_num].store[i].stock_num; j++)
+ 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];
}
}
- /* Assume okay */
return FALSE;
}
*/
static void store_delete(void)
{
- INVENTORY_IDX what;
- int num;
-
/* Pick a random slot */
- what = (INVENTORY_IDX)randint0(st_ptr->stock_num);
+ INVENTORY_IDX what = (INVENTORY_IDX)randint0(st_ptr->stock_num);
/* Determine how many items are here */
- num = st_ptr->stock[what].number;
+ int num = st_ptr->stock[what].number;
/* Hack -- sometimes, only destroy half the items */
if (randint0(100) < 50) num = (num + 1) / 2;
*/
static void store_create(player_type *player_ptr)
{
- OBJECT_IDX i;
- int tries;
- DEPTH level;
-
- object_type forge;
- object_type *q_ptr;
-
/* Paranoia -- no room left */
if (st_ptr->stock_num >= st_ptr->stock_size) return;
/* Hack -- consider up to four items */
- for (tries = 0; tries < 4; tries++)
+ for (int tries = 0; tries < 4; tries++)
{
/* Black Market */
+ OBJECT_IDX i;
+ DEPTH level;
if (cur_store_num == STORE_BLACK)
{
/* Pick a level for object/magic */
i = get_obj_num(player_ptr, level, 0x00000000);
/* Handle failure */
- if (!i) continue;
+ if (i == 0) continue;
}
/* Normal Store */
level = rand_range(1, STORE_OBJ_LEVEL);
}
+ object_type forge;
+ object_type *q_ptr;
q_ptr = &forge;
/* Create a new object of the chosen kind */
/* Attempt to carry the (known) item */
(void)store_carry(q_ptr);
-
- /* Definitely done */
break;
}
}
*/
static void display_entry(player_type *player_ptr, int pos)
{
- int i, cur_col;
object_type *o_ptr;
- s32b x;
-
- GAME_TEXT o_name[MAX_NLEN];
- char out_val[160];
-
- int maxwid = 75;
-
o_ptr = &st_ptr->stock[pos];
/* Get the "offset" */
- i = (pos % store_bottom);
+ int i = (pos % store_bottom);
/* Label it, clear the line --(-- */
+ char out_val[160];
(void)sprintf(out_val, "%c) ", ((i > 25) ? toupper(I2A(i - 26)) : I2A(i)));
prt(out_val, i+6, 0);
- cur_col = 3;
+ int cur_col = 3;
if (show_item_graph)
{
TERM_COLOR a = object_attr(o_ptr);
}
/* Describe an item in the home */
+ int maxwid = 75;
if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM))
{
maxwid = 75;
/* Leave room for weights, if necessary -DRS- */
if (show_weights) maxwid -= 10;
+ GAME_TEXT o_name[MAX_NLEN];
object_desc(o_name, o_ptr, 0);
o_name[maxwid] = '\0';
c_put_str(tval_to_attr[o_ptr->tval], o_name, i+6, cur_col);
#endif
}
+
+ return;
}
/* Describe an item (fully) in a store */
- else
- {
- /* Must leave room for the "price" */
- maxwid = 65;
+ /* Must leave room for the "price" */
+ maxwid = 65;
- /* Leave room for weights, if necessary -DRS- */
- if (show_weights) maxwid -= 7;
+ /* Leave room for weights, if necessary -DRS- */
+ if (show_weights) maxwid -= 7;
- /* Describe the object (fully) */
- object_desc(o_name, o_ptr, 0);
- o_name[maxwid] = '\0';
- c_put_str(tval_to_attr[o_ptr->tval], o_name, i+6, cur_col);
+ /* Describe the object (fully) */
+ GAME_TEXT o_name[MAX_NLEN];
+ object_desc(o_name, o_ptr, 0);
+ o_name[maxwid] = '\0';
+ c_put_str(tval_to_attr[o_ptr->tval], o_name, i + 6, cur_col);
- /* Show weights */
- if (show_weights)
- {
- /* Only show the weight of an individual item */
- int wgt = o_ptr->weight;
+ /* Show weights */
+ if (show_weights)
+ {
+ /* Only show the weight of an individual item */
+ int wgt = o_ptr->weight;
#ifdef JP
- sprintf(out_val, "%3d.%1d", lbtokg1(wgt) , lbtokg2(wgt) );
- put_str(out_val, i+6, 60);
+ sprintf(out_val, "%3d.%1d", lbtokg1(wgt), lbtokg2(wgt));
+ put_str(out_val, i + 6, 60);
#else
- (void)sprintf(out_val, "%3d.%d", wgt / 10, wgt % 10);
- put_str(out_val, i+6, 61);
+ (void)sprintf(out_val, "%3d.%d", wgt / 10, wgt % 10);
+ put_str(out_val, i + 6, 61);
#endif
- }
+ }
- /* Display a "fixed" cost */
- if (o_ptr->ident & (IDENT_FIXED))
- {
- /* Extract the "minimum" price */
- x = price_item(player_ptr, o_ptr, ot_ptr->min_inflate, FALSE);
+ /* Display a "fixed" cost */
+ s32b x;
+ if (o_ptr->ident & (IDENT_FIXED))
+ {
+ /* Extract the "minimum" price */
+ x = price_item(player_ptr, o_ptr, ot_ptr->min_inflate, FALSE);
- /* Actually draw the price (not fixed) */
+ /* Actually draw the price (not fixed) */
#ifdef JP
- (void)sprintf(out_val, "%9ld固", (long)x);
+ (void)sprintf(out_val, "%9ld固", (long)x);
#else
- (void)sprintf(out_val, "%9ld F", (long)x);
+ (void)sprintf(out_val, "%9ld F", (long)x);
#endif
- put_str(out_val, i+6, 68);
- }
+ put_str(out_val, i + 6, 68);
+ return;
+ }
- /* Display a "taxed" cost */
- else if (!manual_haggle)
- {
- /* Extract the "minimum" price */
- x = price_item(player_ptr, o_ptr, ot_ptr->min_inflate, FALSE);
+ /* Display a "taxed" cost */
+ if (!manual_haggle)
+ {
+ /* Extract the "minimum" price */
+ x = price_item(player_ptr, o_ptr, ot_ptr->min_inflate, FALSE);
- /* Hack -- Apply Sales Tax if needed */
- if (!noneedtobargain(x)) x += x / 10;
+ /* Hack -- Apply Sales Tax if needed */
+ if (!noneedtobargain(x)) x += x / 10;
- /* Actually draw the price (with tax) */
- (void)sprintf(out_val, "%9ld ", (long)x);
- put_str(out_val, i+6, 68);
- }
+ /* Actually draw the price (with tax) */
+ (void)sprintf(out_val, "%9ld ", (long)x);
+ put_str(out_val, i + 6, 68);
+ return;
+ }
- /* Display a "haggle" cost */
- else
- {
- /* Extrect the "maximum" price */
- x = price_item(player_ptr, o_ptr, ot_ptr->max_inflate, FALSE);
+ /* Display a "haggle" cost */
+ /* Extrect the "maximum" price */
+ x = price_item(player_ptr, o_ptr, ot_ptr->max_inflate, FALSE);
- /* Actually draw the price (not fixed) */
- (void)sprintf(out_val, "%9ld ", (long)x);
- put_str(out_val, i+6, 68);
- }
- }
+ /* Actually draw the price (not fixed) */
+ (void)sprintf(out_val, "%9ld ", (long)x);
+ put_str(out_val, i + 6, 68);
}
*/
static void display_inventory(player_type *player_ptr)
{
- int i, k;
-
/* Display the next 12 items */
+ int k;
for (k = 0; k < store_bottom; k++)
{
/* Do not display "dead" items */
}
/* Erase the extra lines and the "more" prompt */
- for (i = k; i < store_bottom + 1; i++) prt("", i + 6, 0);
+ for (int i = k; i < store_bottom + 1; i++) prt("", i + 6, 0);
/* Assume "no current page" */
#ifdef JP
put_str(" ", 5, 20);
#endif
-
/* Visual reminder of "more items" */
if (st_ptr->stock_num > store_bottom)
{
*/
static void store_prt_gold(player_type *player_ptr)
{
- char out_val[64];
-
prt(_("手持ちのお金: ", "Gold Remaining: "), 19 + xtra_stock, 53);
+ char out_val[64];
sprintf(out_val, "%9ld", (long)player_ptr->au);
prt(out_val, 19 + xtra_stock, 68);
}
+
/*!
* @brief 店舗情報全体を表示するメインルーチン /
* Displays store (after clearing screen) -RAK-
*/
static void display_store(player_type *player_ptr)
{
- char buf[80];
-
Term_clear();
/* The "Home" is special */
{
put_str(_(" 重さ", "Weight"), 5, 70);
}
+
+ store_prt_gold(player_ptr);
+ display_inventory(player_ptr);
+ return;
}
/* The "Home" is special */
- else if (cur_store_num == STORE_MUSEUM)
+ if (cur_store_num == STORE_MUSEUM)
{
/* Put the owner name */
put_str(_("博物館", "Museum"), 3, 31);
{
put_str(_(" 重さ", "Weight"), 5, 70);
}
+
+ store_prt_gold(player_ptr);
+ display_inventory(player_ptr);
+ return;
}
/* Normal stores */
- else
- {
- concptr store_name = (f_name + f_info[cur_store_feat].name);
- concptr owner_name = (ot_ptr->owner_name);
- concptr race_name = race_info[ot_ptr->owner_race].title;
-
- /* Put the owner name and race */
- sprintf(buf, "%s (%s)", owner_name, race_name);
- put_str(buf, 3, 10);
+ concptr store_name = (f_name + f_info[cur_store_feat].name);
+ concptr owner_name = (ot_ptr->owner_name);
+ concptr race_name = race_info[ot_ptr->owner_race].title;
- /* Show the max price in the store (above prices) */
- sprintf(buf, "%s (%ld)", store_name, (long)(ot_ptr->max_cost));
- prt(buf, 3, 50);
+ /* Put the owner name and race */
+ char buf[80];
+ sprintf(buf, "%s (%s)", owner_name, race_name);
+ put_str(buf, 3, 10);
- /* Label the item descriptions */
- put_str(_("商品の一覧", "Item Description"), 5, 5);
+ /* Show the max price in the store (above prices) */
+ sprintf(buf, "%s (%ld)", store_name, (long)(ot_ptr->max_cost));
+ prt(buf, 3, 50);
+ /* Label the item descriptions */
+ put_str(_("商品の一覧", "Item Description"), 5, 5);
- /* If showing weights, show label */
- if (show_weights)
- {
- put_str(_(" 重さ", "Weight"), 5, 60);
- }
- /* Label the asking price (in stores) */
- put_str(_(" 価格", "Price"), 5, 72);
+ /* If showing weights, show label */
+ if (show_weights)
+ {
+ put_str(_(" 重さ", "Weight"), 5, 60);
}
- /* Display the current gold */
+ /* Label the asking price (in stores) */
+ put_str(_(" 価格", "Price"), 5, 72);
store_prt_gold(player_ptr);
display_inventory(player_ptr);
}
*/
static int get_stock(COMMAND_CODE *com_val, concptr pmt, int i, int j)
{
- char command;
- char out_val[160];
- char lo, hi;
-
/* Get the item index */
- if (repeat_pull(com_val))
+ if (repeat_pull(com_val) && (*com_val >= i) && (*com_val <= j))
{
- /* Verify the item */
- if ((*com_val >= i) && (*com_val <= j))
- {
- /* Success */
- return TRUE;
- }
+ return TRUE;
}
+
msg_print(NULL);
/* Assume failure */
*com_val = (-1);
/* Build the prompt */
- lo = I2A(i);
- hi = (j > 25) ? toupper(I2A(j - 26)) : I2A(j);
+ char lo = I2A(i);
+ 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);
#endif
-
/* Ask until done */
+ char command;
while (TRUE)
{
- COMMAND_CODE k;
-
- /* Escape */
if (!get_com(out_val, &command, FALSE)) break;
/* Convert */
+ COMMAND_CODE k;
if (islower(command))
k = A2I(command);
else if (isupper(command))
if (command == ESCAPE) return FALSE;
repeat_push(*com_val);
-
- /* Success */
return TRUE;
}
st_ptr->insult_cur++;
/* Become insulted */
- if (st_ptr->insult_cur > ot_ptr->insult_max)
- {
- /* Complain */
- say_comment_4();
+ if (st_ptr->insult_cur <= ot_ptr->insult_max) return FALSE;
- /* Reset insults */
- st_ptr->insult_cur = 0;
- st_ptr->good_buy = 0;
- st_ptr->bad_buy = 0;
+ /* Complain */
+ say_comment_4();
- /* Open tomorrow */
- st_ptr->store_open = current_world_ptr->game_turn + TURNS_PER_TICK*TOWN_DAWN/8 + randint1(TURNS_PER_TICK*TOWN_DAWN/8);
+ /* Reset insults */
+ st_ptr->insult_cur = 0;
+ st_ptr->good_buy = 0;
+ st_ptr->bad_buy = 0;
- /* Closed */
- return TRUE;
- }
+ /* Open tomorrow */
+ st_ptr->store_open = current_world_ptr->game_turn + TURNS_PER_TICK * TOWN_DAWN / 8 + randint1(TURNS_PER_TICK*TOWN_DAWN / 8);
- /* Not closed */
- return FALSE;
+ return TRUE;
}
return FALSE;
}
-
/*
* Mega-Hack -- Enable "increments"
*/
*/
static s32b last_inc = 0L;
-
/*!
* @brief 交渉価格を確認と認証の是非を行う /
* Get a haggle
*/
static int get_haggle(concptr pmt, s32b *poffer, PRICE price, int final)
{
- s32b i;
- concptr p;
- GAME_TEXT buf[128];
- GAME_TEXT out_val[160];
-
/* Clear old increment if necessary */
+ GAME_TEXT buf[128];
if (!allow_inc) last_inc = 0L;
/* Final offer */
{
sprintf(buf, "%s ", pmt);
}
+
msg_print(NULL);
+ GAME_TEXT out_val[160];
/* Ask until done */
while (TRUE)
{
if (!res) return FALSE;
/* Skip leading spaces */
+ concptr p;
for (p = out_val; *p == ' '; p++) /* loop */;
/* Empty response */
*poffer += last_inc;
break;
}
+
+ msg_print(_("値がおかしいです。", "Invalid response."));
+ msg_print(NULL);
}
/* Normal response */
- else
- {
- /* Extract a number */
- i = atol(p);
-
- /* Handle "incremental" number */
- if ((*p == '+' || *p == '-'))
- {
- /* Allow increments */
- if (allow_inc)
- {
- /* Use the given "increment" */
- *poffer += i;
- last_inc = i;
- break;
- }
- }
+ /* Extract a number */
+ s32b i = atol(p);
- /* Handle normal number */
- else
+ /* Handle "incremental" number */
+ if ((*p == '+' || *p == '-'))
+ {
+ /* Allow increments */
+ if (allow_inc)
{
- /* Use the given "number" */
- *poffer = i;
- last_inc = 0L;
+ /* Use the given "increment" */
+ *poffer += i;
+ last_inc = i;
break;
}
}
- /* Warning */
- msg_print(_("値がおかしいです。", "Invalid response."));
- msg_print(NULL);
+ /* Handle normal number */
+ else
+ {
+ /* Use the given "number" */
+ *poffer = i;
+ last_inc = 0L;
+ break;
+ }
}
- /* Success */
return TRUE;
}
* @return プレイヤーの価格に対して不服ならばTRUEを返す /
* Return TRUE if offer is NOT okay
*/
-static bool receive_offer(concptr pmt, s32b *poffer,
- s32b last_offer, int factor,
- PRICE price, int final)
+static bool receive_offer(concptr pmt, s32b *poffer, s32b last_offer, int factor, PRICE price, int final)
{
/* Haggle till done */
while (TRUE)
(*poffer) = last_offer;
}
- /* Success */
return FALSE;
}
*/
static bool purchase_haggle(player_type *player_ptr, object_type *o_ptr, s32b *price)
{
- s32b cur_ask, final_ask;
- s32b last_offer, offer;
- s32b x1, x2, x3;
- s32b min_per, max_per;
- int flag, loop_flag, noneed;
- int annoyed = 0, final = FALSE;
- bool cancel = FALSE;
- char out_val[160];
- *price = 0;
-
- concptr pmt = _("提示価格", "Asking");
-
/* Extract the starting offer and the final offer */
- cur_ask = price_item(player_ptr, o_ptr, ot_ptr->max_inflate, FALSE);
- final_ask = price_item(player_ptr, o_ptr, ot_ptr->min_inflate, FALSE);
+ s32b cur_ask = price_item(player_ptr, o_ptr, ot_ptr->max_inflate, FALSE);
+ s32b final_ask = price_item(player_ptr, o_ptr, ot_ptr->min_inflate, FALSE);
/* Determine if haggling is necessary */
- noneed = noneedtobargain(final_ask);
+ int noneed = noneedtobargain(final_ask);
/* No need to haggle */
+ bool final = FALSE;
+ concptr pmt = _("提示価格", "Asking");
if (noneed || !manual_haggle)
{
/* No need to haggle */
/* Haggle parameters */
- min_per = ot_ptr->haggle_per;
- max_per = min_per * 3;
+ s32b min_per = ot_ptr->haggle_per;
+ s32b max_per = min_per * 3;
/* Mega-Hack -- artificial "last offer" value */
- last_offer = object_value(o_ptr) * o_ptr->number;
+ s32b last_offer = object_value(o_ptr) * o_ptr->number;
last_offer = last_offer * (200 - (int)(ot_ptr->max_inflate)) / 100L;
if (last_offer <= 0) last_offer = 1;
/* No offer yet */
- offer = 0;
+ s32b offer = 0;
/* No incremental haggling yet */
allow_inc = FALSE;
/* Haggle until done */
- for (flag = FALSE; !flag; )
+ bool flag = FALSE;
+ int annoyed = 0;
+ bool cancel = FALSE;
+ *price = 0;
+ while (!flag)
{
- loop_flag = TRUE;
+ bool loop_flag = TRUE;
while (!flag && loop_flag)
{
+ char out_val[160];
(void)sprintf(out_val, "%s : %ld", pmt, (long)cur_ask);
put_str(out_val, 1, 0);
cancel = receive_offer(_("提示する金額? ", "What do you offer? "), &offer, last_offer, 1, cur_ask, final);
}
}
- if (!flag)
+ if (flag) continue;
+
+ s32b x1 = 100 * (offer - last_offer) / (cur_ask - last_offer);
+ if (x1 < min_per)
{
- x1 = 100 * (offer - last_offer) / (cur_ask - last_offer);
- if (x1 < min_per)
- {
- if (haggle_insults())
- {
- flag = TRUE;
- cancel = TRUE;
- }
- }
- else if (x1 > max_per)
- {
- x1 = x1 * 3 / 4;
- if (x1 < max_per) x1 = max_per;
- }
- x2 = rand_range(x1-2, x1+2);
- x3 = ((cur_ask - offer) * x2 / 100L) + 1;
- /* don't let the price go up */
- if (x3 < 0) x3 = 0;
- cur_ask -= x3;
-
- /* Too little */
- if (cur_ask < final_ask)
- {
- final = TRUE;
- cur_ask = final_ask;
- pmt = _("最終提示価格", "What do you offer? ");
- annoyed++;
- if (annoyed > 3)
- {
- (void)(increase_insults());
- cancel = TRUE;
- flag = TRUE;
- }
- }
- else if (offer >= cur_ask)
+ if (haggle_insults())
{
flag = TRUE;
- *price = offer;
+ cancel = TRUE;
}
+ }
+ else if (x1 > max_per)
+ {
+ x1 = x1 * 3 / 4;
+ if (x1 < max_per) x1 = max_per;
+ }
- if (!flag)
+ s32b x2 = rand_range(x1 - 2, x1 + 2);
+ s32b x3 = ((cur_ask - offer) * x2 / 100L) + 1;
+ /* don't let the price go up */
+ if (x3 < 0) x3 = 0;
+ cur_ask -= x3;
+
+ /* Too little */
+ if (cur_ask < final_ask)
+ {
+ final = TRUE;
+ cur_ask = final_ask;
+ pmt = _("最終提示価格", "What do you offer? ");
+ annoyed++;
+ if (annoyed > 3)
{
- last_offer = offer;
- allow_inc = TRUE;
- prt("", 1, 0);
- (void)sprintf(out_val, _("前回の提示金額: $%ld", "Your last offer: %ld"), (long)last_offer);
- put_str(out_val, 1, 39);
- say_comment_2(cur_ask, annoyed);
+ (void)(increase_insults());
+ cancel = TRUE;
+ flag = TRUE;
}
}
- }
+ else if (offer >= cur_ask)
+ {
+ flag = TRUE;
+ *price = offer;
+ }
+
+ last_offer = offer;
+ allow_inc = TRUE;
+ prt("", 1, 0);
+ char out_val[160];
+ (void)sprintf(out_val, _("前回の提示金額: $%ld", "Your last offer: %ld"), (long)last_offer);
+ put_str(out_val, 1, 39);
+ say_comment_2(cur_ask, annoyed);
+ }
if (cancel) return TRUE;
*/
static bool sell_haggle(player_type *player_ptr, object_type *o_ptr, s32b *price)
{
- s32b purse, cur_ask, final_ask;
- s32b last_offer = 0, offer = 0;
- s32b x1, x2, x3;
- s32b min_per, max_per;
- int flag, loop_flag, noneed;
- int annoyed = 0, final = FALSE;
- bool cancel = FALSE;
- concptr pmt = _("提示金額", "Offer");
-
- char out_val[160];
-
- *price = 0;
-
/* Obtain the starting offer and the final offer */
- cur_ask = price_item(player_ptr, o_ptr, ot_ptr->max_inflate, TRUE);
- final_ask = price_item(player_ptr, o_ptr, ot_ptr->min_inflate, TRUE);
+ s32b cur_ask = price_item(player_ptr, o_ptr, ot_ptr->max_inflate, TRUE);
+ s32b final_ask = price_item(player_ptr, o_ptr, ot_ptr->min_inflate, TRUE);
/* Determine if haggling is necessary */
- noneed = noneedtobargain(final_ask);
+ int noneed = noneedtobargain(final_ask);
/* Get the owner's payout limit */
- purse = (s32b)(ot_ptr->max_cost);
+ s32b purse = (s32b)(ot_ptr->max_cost);
/* No need to haggle */
+ bool final = FALSE;
+ concptr pmt = _("提示金額", "Offer");
if (noneed || !manual_haggle || (final_ask >= purse))
{
/* Apply Sales Tax (if needed) */
cur_ask *= o_ptr->number;
final_ask *= o_ptr->number;
-
/* Display commands */
/* Haggling parameters */
- min_per = ot_ptr->haggle_per;
- max_per = min_per * 3;
+ s32b min_per = ot_ptr->haggle_per;
+ s32b max_per = min_per * 3;
/* Mega-Hack -- artificial "last offer" value */
- last_offer = object_value(o_ptr) * o_ptr->number;
+ s32b last_offer = object_value(o_ptr) * o_ptr->number;
last_offer = last_offer * ot_ptr->max_inflate / 100L;
/* No offer yet */
- offer = 0;
+ s32b offer = 0;
/* No incremental haggling yet */
allow_inc = FALSE;
/* Haggle */
- for (flag = FALSE; !flag; )
+ bool flag = FALSE;
+ bool loop_flag;
+ int annoyed = 0;
+ bool cancel = FALSE;
+ *price = 0;
+ while (!flag)
{
while (TRUE)
{
loop_flag = TRUE;
+ char out_val[160];
(void)sprintf(out_val, "%s : %ld", pmt, (long)cur_ask);
put_str(out_val, 1, 0);
cancel = receive_offer(_("提示する価格? ", "What price do you ask? "),
if (flag || !loop_flag) break;
}
- if (!flag)
+ if (flag) continue;
+
+ s32b x1 = 100 * (last_offer - offer) / (last_offer - cur_ask);
+ if (x1 < min_per)
{
- x1 = 100 * (last_offer - offer) / (last_offer - cur_ask);
- if (x1 < min_per)
- {
- if (haggle_insults())
- {
- flag = TRUE;
- cancel = TRUE;
- }
- }
- else if (x1 > max_per)
+ if (haggle_insults())
{
- x1 = x1 * 3 / 4;
- if (x1 < max_per) x1 = max_per;
+ flag = TRUE;
+ cancel = TRUE;
}
- x2 = rand_range(x1-2, x1+2);
- x3 = ((offer - cur_ask) * x2 / 100L) + 1;
- /* don't let the price go down */
- if (x3 < 0) x3 = 0;
- cur_ask += x3;
+ }
+ else if (x1 > max_per)
+ {
+ x1 = x1 * 3 / 4;
+ if (x1 < max_per) x1 = max_per;
+ }
- if (cur_ask > final_ask)
- {
- cur_ask = final_ask;
- final = TRUE;
- pmt = _("最終提示金額", "Final Offer");
+ s32b x2 = rand_range(x1 - 2, x1 + 2);
+ s32b x3 = ((offer - cur_ask) * x2 / 100L) + 1;
+ /* don't let the price go down */
+ if (x3 < 0) x3 = 0;
+ cur_ask += x3;
- annoyed++;
- if (annoyed > 3)
- {
- flag = TRUE;
+ if (cur_ask > final_ask)
+ {
+ cur_ask = final_ask;
+ final = TRUE;
+ pmt = _("最終提示金額", "Final Offer");
+
+ annoyed++;
+ if (annoyed > 3)
+ {
+ flag = TRUE;
#ifdef JP
/* 追加 $0 で買い取られてしまうのを防止 By FIRST*/
- cancel = TRUE;
+ cancel = TRUE;
#endif
- (void)(increase_insults());
- }
- }
- else if (offer <= cur_ask)
- {
- flag = TRUE;
- *price = offer;
- }
-
- if (!flag)
- {
- last_offer = offer;
- allow_inc = TRUE;
- prt("", 1, 0);
- (void)sprintf(out_val,
- _("前回の提示価格 $%ld", "Your last bid %ld"), (long)last_offer);
- put_str(out_val, 1, 39);
- say_comment_3(cur_ask, annoyed);
+ (void)(increase_insults());
}
}
+ else if (offer <= cur_ask)
+ {
+ flag = TRUE;
+ *price = offer;
+ }
+
+ last_offer = offer;
+ allow_inc = TRUE;
+ prt("", 1, 0);
+ char out_val[160];
+ (void)sprintf(out_val, _("前回の提示価格 $%ld", "Your last bid %ld"), (long)last_offer);
+ put_str(out_val, 1, 39);
+ say_comment_3(cur_ask, annoyed);
}
if (cancel) return TRUE;
updatebargain(*price, final_ask, o_ptr->number);
-
- /* Do not cancel */
return FALSE;
}
*/
static void store_purchase(player_type *player_ptr)
{
- int i, choice;
- COMMAND_CODE item, item_new;
-
- ITEM_NUMBER amt;
-
- PRICE price, best;
-
- object_type forge;
- object_type *j_ptr;
-
- object_type *o_ptr;
-
- GAME_TEXT o_name[MAX_NLEN];
-
- char out_val[160];
-
if (cur_store_num == STORE_MUSEUM)
{
msg_print(_("博物館から取り出すことはできません。", "Museum."));
}
/* Find the number of objects on this and following pages */
- i = (st_ptr->stock_num - store_top);
+ int i = (st_ptr->stock_num - store_top);
/* And then restrict it to the current page */
if (i > store_bottom) i = store_bottom;
- /* Prompt */
+ char out_val[160];
#ifdef JP
/* ブラックマーケットの時は別のメッセージ */
switch( cur_store_num ) {
/* Get the item number to be bought */
+ COMMAND_CODE item;
if (!get_stock(&item, out_val, 0, i - 1)) return;
/* Get the actual index */
item = item + store_top;
/* Get the actual item */
+ object_type *o_ptr;
o_ptr = &st_ptr->stock[item];
/* Assume the player wants just one of them */
- amt = 1;
+ ITEM_NUMBER amt = 1;
+ object_type forge;
+ object_type *j_ptr;
j_ptr = &forge;
/* Get a copy of the object */
}
/* Determine the "best" price (per item) */
- best = price_item(player_ptr, j_ptr, ot_ptr->min_inflate, FALSE);
+ PRICE best = price_item(player_ptr, j_ptr, ot_ptr->min_inflate, FALSE);
/* Find out how many the player wants */
if (o_ptr->number > 1)
amt = get_quantity(NULL, o_ptr->number);
if (amt <= 0) return;
}
+
j_ptr = &forge;
/* Get desired object */
}
/* Attempt to buy it */
- if (cur_store_num != STORE_HOME)
+ int choice;
+ COMMAND_CODE item_new;
+ PRICE price;
+ if (cur_store_num == STORE_HOME)
{
- /* Fixed price, quick buy */
- if (o_ptr->ident & (IDENT_FIXED))
- {
- /* Assume accept */
- choice = 0;
-
- /* Go directly to the "best" deal */
- price = (best * j_ptr->number);
- }
+ bool combined_or_reordered;
- /* Haggle for it */
- else
- {
- /* Describe the object (fully) */
- object_desc(o_name, j_ptr, 0);
- msg_format(_("%s(%c)を購入する。", "Buying %s (%c)."), o_name, I2A(item));
- msg_print(NULL);
+ /* Distribute charges of wands/rods */
+ distribute_charges(o_ptr, j_ptr, amt);
- /* Haggle for a final price */
- choice = purchase_haggle(player_ptr, j_ptr, &price);
+ /* Give it to the player */
+ item_new = inven_carry(player_ptr, j_ptr);
- /* Hack -- Got kicked out */
- if (st_ptr->store_open >= current_world_ptr->game_turn) return;
- }
+ /* Describe just the result */
+ GAME_TEXT o_name[MAX_NLEN];
+ object_desc(o_name, &player_ptr->inventory_list[item_new], 0);
- /* Player wants it */
- if (choice == 0)
- {
- /* Fix the item price (if "correctly" haggled) */
- if (price == (best * j_ptr->number)) o_ptr->ident |= (IDENT_FIXED);
+ msg_format(_("%s(%c)を取った。", "You have %s (%c)."), o_name, index_to_label(item_new));
+ handle_stuff(player_ptr);
- /* Player can afford it */
- if (player_ptr->au >= price)
- {
- /* Say "okay" */
- say_comment_1(player_ptr);
+ /* Take note if we take the last one */
+ i = st_ptr->stock_num;
- if (cur_store_num == STORE_BLACK) /* The black market is illegal! */
- chg_virtue(player_ptr, V_JUSTICE, -1);
- if((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME))
- chg_virtue(player_ptr, V_NATURE, -1);
+ /* Remove the items from the home */
+ store_item_increase(item, -amt);
+ store_item_optimize(item);
- /* Make a sound */
- sound(SOUND_BUY);
+ combined_or_reordered = combine_and_reorder_home(STORE_HOME);
- /* Be happy */
- decrease_insults();
+ /* Hack -- Item is still here */
+ if (i == st_ptr->stock_num)
+ {
+ if (combined_or_reordered) display_inventory(player_ptr);
- /* Spend the money */
- player_ptr->au -= price;
+ /* Redraw the item */
+ else display_entry(player_ptr, item);
+ }
- /* Update the display */
- store_prt_gold(player_ptr);
+ /* The item is gone */
+ else
+ {
+ /* Nothing left */
+ if (st_ptr->stock_num == 0) store_top = 0;
- /* Hack -- buying an item makes you aware of it */
- object_aware(player_ptr, j_ptr);
+ /* Nothing left on that screen */
+ else if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
+ display_inventory(player_ptr);
- /* Hack -- clear the "fixed" flag from the item */
- j_ptr->ident &= ~(IDENT_FIXED);
+ chg_virtue(player_ptr, V_SACRIFICE, 1);
+ }
- /* Describe the transaction */
- object_desc(o_name, j_ptr, 0);
+ return;
+ }
- msg_format(_("%sを $%ldで購入しました。", "You bought %s for %ld gold."), o_name, (long)price);
+ /* Fixed price, quick buy */
+ if (o_ptr->ident & (IDENT_FIXED))
+ {
+ /* Assume accept */
+ choice = 0;
- strcpy(record_o_name, o_name);
- record_turn = current_world_ptr->game_turn;
+ /* Go directly to the "best" deal */
+ price = (best * j_ptr->number);
+ }
- if (record_buy) exe_write_diary(player_ptr, NIKKI_BUY, 0, o_name);
- object_desc(o_name, o_ptr, OD_NAME_ONLY);
- if(record_rand_art && o_ptr->art_name)
- exe_write_diary(player_ptr, NIKKI_ART, 0, o_name);
+ /* Haggle for it */
+ else
+ {
+ /* Describe the object (fully) */
+ GAME_TEXT o_name[MAX_NLEN];
+ object_desc(o_name, j_ptr, 0);
+ msg_format(_("%s(%c)を購入する。", "Buying %s (%c)."), o_name, I2A(item));
+ msg_print(NULL);
- /* Erase the inscription */
- j_ptr->inscription = 0;
+ /* Haggle for a final price */
+ choice = purchase_haggle(player_ptr, j_ptr, &price);
- /* Erase the "feeling" */
- j_ptr->feeling = FEEL_NONE;
- j_ptr->ident &= ~(IDENT_STORE);
- /* Give it to the player */
- item_new = inven_carry(player_ptr, j_ptr);
+ /* Hack -- Got kicked out */
+ if (st_ptr->store_open >= current_world_ptr->game_turn) return;
+ }
- /* Describe the final result */
- object_desc(o_name, &player_ptr->inventory_list[item_new], 0);
- msg_format(_("%s(%c)を手に入れた。", "You have %s (%c)."), o_name, index_to_label(item_new));
+ /* Player wants it */
+ if (choice != 0) return;
+
+ /* Fix the item price (if "correctly" haggled) */
+ if (price == (best * j_ptr->number)) o_ptr->ident |= (IDENT_FIXED);
- /* Auto-inscription */
- autopick_alter_item(player_ptr, item_new, FALSE);
+ /* Player can afford it */
+ if (player_ptr->au < price)
+ {
+ msg_print(_("お金が足りません。", "You do not have enough gold."));
+ return;
+ }
+
+ /* Say "okay" */
+ say_comment_1(player_ptr);
- /* Now, reduce the original stack's pval. */
- if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
- {
- o_ptr->pval -= j_ptr->pval;
- }
+ if (cur_store_num == STORE_BLACK) /* The black market is illegal! */
+ chg_virtue(player_ptr, V_JUSTICE, -1);
+ if ((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME))
+ chg_virtue(player_ptr, V_NATURE, -1);
- handle_stuff(player_ptr);
+ /* Make a sound */
+ sound(SOUND_BUY);
- /* Note how many slots the store used to have */
- i = st_ptr->stock_num;
+ /* Be happy */
+ decrease_insults();
- /* Remove the bought items from the store */
- store_item_increase(item, -amt);
- store_item_optimize(item);
+ /* Spend the money */
+ player_ptr->au -= price;
- /* Store is empty */
- if (st_ptr->stock_num == 0)
- {
- /* Shuffle */
- if (one_in_(STORE_SHUFFLE))
- {
- char buf[80];
- msg_print(_("店主は引退した。", "The shopkeeper retires."));
-
- /* Shuffle the store */
- store_shuffle(player_ptr, cur_store_num);
-
- prt("",3,0);
- sprintf(buf, "%s (%s)",
- ot_ptr->owner_name, race_info[ot_ptr->owner_race].title);
- put_str(buf, 3, 10);
- sprintf(buf, "%s (%ld)",
- (f_name + f_info[cur_store_feat].name), (long)(ot_ptr->max_cost));
- prt(buf, 3, 50);
- }
+ /* Update the display */
+ store_prt_gold(player_ptr);
- /* Maintain */
- else
- {
- msg_print(_("店主は新たな在庫を取り出した。", "The shopkeeper brings out some new stock."));
- }
+ /* Hack -- buying an item makes you aware of it */
+ object_aware(player_ptr, j_ptr);
- for (i = 0; i < 10; i++)
- {
- /* Maintain the store */
- store_maint(player_ptr, player_ptr->town_num, cur_store_num);
- }
+ /* Hack -- clear the "fixed" flag from the item */
+ j_ptr->ident &= ~(IDENT_FIXED);
- /* Start over */
- store_top = 0;
- display_inventory(player_ptr);
- }
+ /* Describe the transaction */
+ GAME_TEXT o_name[MAX_NLEN];
+ object_desc(o_name, j_ptr, 0);
- /* The item is gone */
- else if (st_ptr->stock_num != i)
- {
- /* Pick the correct screen */
- if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
- display_inventory(player_ptr);
- }
+ msg_format(_("%sを $%ldで購入しました。", "You bought %s for %ld gold."), o_name, (long)price);
- /* Item is still here */
- else
- {
- /* Redraw the item */
- display_entry(player_ptr, item);
- }
- }
+ strcpy(record_o_name, o_name);
+ record_turn = current_world_ptr->game_turn;
- /* Player cannot afford it */
- else
- {
- /* Simple message (no insult) */
- msg_print(_("お金が足りません。", "You do not have enough gold."));
- }
- }
- }
+ if (record_buy) exe_write_diary(player_ptr, NIKKI_BUY, 0, o_name);
+ object_desc(o_name, o_ptr, OD_NAME_ONLY);
+ if (record_rand_art && o_ptr->art_name)
+ exe_write_diary(player_ptr, NIKKI_ART, 0, o_name);
- /* Home is much easier */
- else
- {
- bool combined_or_reordered;
+ /* Erase the inscription */
+ j_ptr->inscription = 0;
- /* Distribute charges of wands/rods */
- distribute_charges(o_ptr, j_ptr, amt);
+ /* Erase the "feeling" */
+ j_ptr->feeling = FEEL_NONE;
+ j_ptr->ident &= ~(IDENT_STORE);
+ /* Give it to the player */
+ item_new = inven_carry(player_ptr, j_ptr);
- /* Give it to the player */
- item_new = inven_carry(player_ptr, j_ptr);
+ /* Describe the final result */
+ object_desc(o_name, &player_ptr->inventory_list[item_new], 0);
+ msg_format(_("%s(%c)を手に入れた。", "You have %s (%c)."), o_name, index_to_label(item_new));
- /* Describe just the result */
- object_desc(o_name, &player_ptr->inventory_list[item_new], 0);
+ /* Auto-inscription */
+ autopick_alter_item(player_ptr, item_new, FALSE);
- msg_format(_("%s(%c)を取った。", "You have %s (%c)."), o_name, index_to_label(item_new));
- handle_stuff(player_ptr);
+ /* Now, reduce the original stack's pval. */
+ if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
+ {
+ o_ptr->pval -= j_ptr->pval;
+ }
- /* Take note if we take the last one */
- i = st_ptr->stock_num;
+ handle_stuff(player_ptr);
- /* Remove the items from the home */
- store_item_increase(item, -amt);
- store_item_optimize(item);
+ /* Note how many slots the store used to have */
+ i = st_ptr->stock_num;
- combined_or_reordered = combine_and_reorder_home(STORE_HOME);
+ /* Remove the bought items from the store */
+ store_item_increase(item, -amt);
+ store_item_optimize(item);
- /* Hack -- Item is still here */
- if (i == st_ptr->stock_num)
+ /* Store is empty */
+ if (st_ptr->stock_num == 0)
+ {
+ /* Shuffle */
+ if (one_in_(STORE_SHUFFLE))
{
- if (combined_or_reordered) display_inventory(player_ptr);
-
- /* Redraw the item */
- else display_entry(player_ptr, item);
+ char buf[80];
+ msg_print(_("店主は引退した。", "The shopkeeper retires."));
+
+ /* Shuffle the store */
+ store_shuffle(player_ptr, cur_store_num);
+
+ prt("", 3, 0);
+ sprintf(buf, "%s (%s)",
+ ot_ptr->owner_name, race_info[ot_ptr->owner_race].title);
+ put_str(buf, 3, 10);
+ sprintf(buf, "%s (%ld)",
+ (f_name + f_info[cur_store_feat].name), (long)(ot_ptr->max_cost));
+ prt(buf, 3, 50);
}
- /* The item is gone */
+ /* Maintain */
else
{
- /* Nothing left */
- if (st_ptr->stock_num == 0) store_top = 0;
-
- /* Nothing left on that screen */
- else if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
- display_inventory(player_ptr);
+ msg_print(_("店主は新たな在庫を取り出した。", "The shopkeeper brings out some new stock."));
+ }
- chg_virtue(player_ptr, V_SACRIFICE, 1);
+ for (i = 0; i < 10; i++)
+ {
+ /* Maintain the store */
+ store_maint(player_ptr, player_ptr->town_num, cur_store_num);
}
+
+ /* Start over */
+ store_top = 0;
+ display_inventory(player_ptr);
+ }
+
+ /* The item is gone */
+ else if (st_ptr->stock_num != i)
+ {
+ /* Pick the correct screen */
+ if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
+ display_inventory(player_ptr);
+ }
+
+ /* Item is still here */
+ else
+ {
+ /* Redraw the item */
+ display_entry(player_ptr, item);
}
}
*/
static void store_sell(player_type *owner_ptr)
{
- int choice;
- OBJECT_IDX item;
- int item_pos;
- int amt;
-
- PRICE price, value, dummy;
-
- object_type forge;
- object_type *q_ptr;
- object_type *o_ptr;
-
- concptr q, s;
-
- GAME_TEXT o_name[MAX_NLEN];
-
-
/* Prepare a prompt */
+ concptr q;
if (cur_store_num == STORE_HOME)
q = _("どのアイテムを置きますか? ", "Drop which item? ");
item_tester_hook = store_will_buy;
/* 我が家でおかしなメッセージが出るオリジナルのバグを修正 */
+ concptr s;
if (cur_store_num == STORE_HOME)
{
s = _("置けるアイテムを持っていません。", "You don't have any item to drop.");
s = _("欲しい物がないですねえ。", "You have nothing that I want.");
}
+ OBJECT_IDX item;
+ object_type *o_ptr;
o_ptr = choose_object(owner_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
if (!o_ptr) return;
}
/* Assume one item */
- amt = 1;
+ int amt = 1;
if (o_ptr->number > 1)
{
amt = get_quantity(NULL, o_ptr->number);
if (amt <= 0) return;
}
+
+ object_type forge;
+ object_type *q_ptr;
q_ptr = &forge;
/* Get a copy of the object */
}
/* Get a full description */
+ GAME_TEXT o_name[MAX_NLEN];
object_desc(o_name, q_ptr, 0);
/* Remove any inscription, feeling for stores */
}
/* Real store */
+ int choice;
+ PRICE price, value, dummy;
if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM))
{
/* Describe the transaction */
handle_stuff(owner_ptr);
/* The store gets that (known) item */
- item_pos = store_carry(q_ptr);
+ int item_pos = store_carry(q_ptr);
/* Re-display if item is now in store */
if (item_pos >= 0)
handle_stuff(owner_ptr);
/* Let the home carry it */
- item_pos = home_carry(owner_ptr, q_ptr);
+ int item_pos = home_carry(owner_ptr, q_ptr);
/* Update store display */
if (item_pos >= 0)
handle_stuff(owner_ptr);
/* Let the home carry it */
- item_pos = home_carry(owner_ptr, q_ptr);
+ int item_pos = home_carry(owner_ptr, q_ptr);
/* Update store display */
if (item_pos >= 0)
*/
static void store_examine(void)
{
- int i;
- COMMAND_CODE item;
- object_type *o_ptr;
- GAME_TEXT o_name[MAX_NLEN];
- char out_val[160];
-
/* Empty? */
if (st_ptr->stock_num <= 0)
{
}
/* Find the number of objects on this and following pages */
- i = (st_ptr->stock_num - store_top);
+ int i = (st_ptr->stock_num - store_top);
/* And then restrict it to the current page */
if (i > store_bottom) i = store_bottom;
/* Prompt */
+ char out_val[160];
sprintf(out_val, _("どれを調べますか?", "Which item do you want to examine? "));
/* Get the item number to be examined */
+ COMMAND_CODE item;
if (!get_stock(&item, out_val, 0, i - 1)) return;
/* Get the actual index */
item = item + store_top;
/* Get the actual item */
+ object_type *o_ptr;
o_ptr = &st_ptr->stock[item];
/* Require full knowledge */
return;
}
+ GAME_TEXT o_name[MAX_NLEN];
object_desc(o_name, o_ptr, 0);
msg_format(_("%sを調べている...", "Examining %s..."), o_name);
*/
static void museum_remove_object(player_type *player_ptr)
{
- int i;
- COMMAND_CODE item;
- object_type *o_ptr;
- GAME_TEXT o_name[MAX_NLEN];
- char out_val[160];
-
- /* Empty? */
if (st_ptr->stock_num <= 0)
{
msg_print(_("博物館には何も置いてありません。", "Museum is empty."));
}
/* Find the number of objects on this and following pages */
- i = st_ptr->stock_num - store_top;
+ int i = st_ptr->stock_num - store_top;
/* And then restrict it to the current page */
if (i > store_bottom) i = store_bottom;
/* Prompt */
+ char out_val[160];
sprintf(out_val, _("どのアイテムの展示をやめさせますか?", "Which item do you want to order to remove? "));
/* Get the item number to be removed */
+ COMMAND_CODE item;
if (!get_stock(&item, out_val, 0, i - 1)) return;
/* Get the actual index */
item = item + store_top;
/* Get the actual item */
+ object_type *o_ptr;
o_ptr = &st_ptr->stock[item];
+ GAME_TEXT o_name[MAX_NLEN];
object_desc(o_name, o_ptr, 0);
msg_print(_("展示をやめさせたアイテムは二度と見ることはできません!", "You cannot see items which is removed from the Museum!"));
/* Nothing left on that screen */
else if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
display_inventory(player_ptr);
-
- return;
}
if ( store_top >= store_bottom ) store_top = store_bottom;
display_inventory(client_ptr);
}
+
break;
}
display_inventory(client_ptr);
}
+
break;
}
{
msg_print(_("そのコマンドは店の中では使えません。", "That command does not work in stores."));
}
+
break;
}
}
*/
void do_cmd_store(player_type *player_ptr)
{
- int which;
- int maintain_num;
- int i;
- grid_type *g_ptr;
- bool need_redraw_store_inv; /* To redraw missiles damage and prices in store */
- TERM_LEN w, h;
-
if(player_ptr->wild_mode) return;
+ TERM_LEN w, h;
Term_get_size(&w, &h);
/* Calculate stocks per 1 page */
store_bottom = MIN_STOCK + xtra_stock;
/* Access the player grid */
+ grid_type *g_ptr;
g_ptr = &player_ptr->current_floor_ptr->grid_array[player_ptr->y][player_ptr->x];
/* Verify a store */
}
/* Extract the store code */
- which = f_info[g_ptr->feat].subtype;
+ int which = f_info[g_ptr->feat].subtype;
old_town_num = player_ptr->town_num;
if ((which == STORE_HOME) || (which == STORE_MUSEUM)) player_ptr->town_num = 1;
}
/* Calculate the number of store maintainances since the last visit */
- maintain_num = (current_world_ptr->game_turn - town_info[player_ptr->town_num].store[which].last_visit) / (TURNS_PER_TICK * STORE_TICKS);
+ int maintain_num = (current_world_ptr->game_turn - town_info[player_ptr->town_num].store[which].last_visit) / (TURNS_PER_TICK * STORE_TICKS);
/* Maintain the store max. 10 times */
if (maintain_num > 10) maintain_num = 10;
if (maintain_num)
{
/* Maintain the store */
- for (i = 0; i < maintain_num; i++)
+ for (int i = 0; i < maintain_num; i++)
store_maint(player_ptr, player_ptr->town_num, which);
/* Save the visit */
* Hack -- To redraw missiles damage and prices in store
* If player's charisma changes, or if player changes a bow, PU_BONUS is set
*/
- need_redraw_store_inv = (player_ptr->update & PU_BONUS) ? TRUE : FALSE;
+ bool need_redraw_store_inv = (player_ptr->update & PU_BONUS) ? TRUE : FALSE;
/* Hack -- Character is still in "icky" mode */
current_world_ptr->character_icky = TRUE;
}
-
/*!
* @brief 現在の町の店主を交代させる /
* Shuffle one of the stores.
*/
void store_shuffle(player_type *player_ptr, int which)
{
- int i, j;
-
-
/* Ignore home */
if (which == STORE_HOME) return;
if (which == STORE_MUSEUM) return;
/* Activate that store */
st_ptr = &town_info[player_ptr->town_num].store[cur_store_num];
- j = st_ptr->owner;
+ int j = st_ptr->owner;
/* Pick a new owner */
- while(1)
+ while (TRUE)
{
st_ptr->owner = (byte)randint0(MAX_OWNERS);
if (j == st_ptr->owner) continue;
+ int i;
for (i = 1;i < max_towns; i++)
{
if (i == player_ptr->town_num) continue;
if (st_ptr->owner == town_info[i].store[cur_store_num].owner) break;
}
+
if (i == max_towns) break;
}
/* Activate the new owner */
ot_ptr = &owners[cur_store_num][st_ptr->owner];
-
/* Reset the owner data */
st_ptr->insult_cur = 0;
st_ptr->store_open = 0;
st_ptr->good_buy = 0;
st_ptr->bad_buy = 0;
-
/* Hack -- discount all the items */
- for (i = 0; i < st_ptr->stock_num; i++)
+ for (int i = 0; i < st_ptr->stock_num; i++)
{
object_type *o_ptr;
-
o_ptr = &st_ptr->stock[i];
+ if (object_is_artifact(o_ptr)) continue;
- if (!object_is_artifact(o_ptr))
- {
- /* Hack -- Sell all non-artifact old items for "half price" */
- o_ptr->discount = 50;
+ /* Hack -- Sell all non-artifact old items for "half price" */
+ o_ptr->discount = 50;
- /* Hack -- Items are no longer "fixed price" */
- o_ptr->ident &= ~(IDENT_FIXED);
+ /* Hack -- Items are no longer "fixed price" */
+ o_ptr->ident &= ~(IDENT_FIXED);
- /* Mega-Hack -- Note that the item is "on sale" */
- o_ptr->inscription = quark_add(_("売出中", "on sale"));
- }
+ /* Mega-Hack -- Note that the item is "on sale" */
+ o_ptr->inscription = quark_add(_("売出中", "on sale"));
}
}
*/
void store_maint(player_type *player_ptr, int town_num, int store_num)
{
- INVENTORY_IDX j;
-
cur_store_num = store_num;
/* Ignore home */
if (store_num == STORE_BLACK)
{
/* Destroy crappy black market items */
- for (j = st_ptr->stock_num - 1; j >= 0; j--)
+ for (INVENTORY_IDX j = st_ptr->stock_num - 1; j >= 0; j--)
{
object_type *o_ptr = &st_ptr->stock[j];
}
/* Choose the number of slots to keep */
- j = st_ptr->stock_num;
+ INVENTORY_IDX j = st_ptr->stock_num;
/* Sell a few items */
j = j - randint1(STORE_TURNOVER);
/* Destroy objects until only "j" slots are left */
while (st_ptr->stock_num > j) store_delete();
-
/* Choose the number of slots to fill */
j = st_ptr->stock_num;
*/
void store_init(int town_num, int store_num)
{
- int k;
cur_store_num = store_num;
/* Activate that store */
st_ptr = &town_info[town_num].store[store_num];
-
/* Pick an owner */
- while(1)
+ while (TRUE)
{
- int i;
-
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) break;
}
+
if (i == max_towns) break;
}
st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
/* Clear any old items */
- for (k = 0; k < st_ptr->stock_size; k++)
+ for (int k = 0; k < st_ptr->stock_size; k++)
{
object_wipe(&st_ptr->stock[k]);
}
object_wipe(o_ptr); /* Don't leave a bogus object behind... */
}
-