Angband
Data Structures | Enumerations | Functions | Variables
store.h File Reference

Store stocking. More...

#include "cave.h"
#include "cmd-core.h"
#include "datafile.h"
#include "object.h"

Go to the source code of this file.

Data Structures

struct  object_buy
 
struct  owner
 
struct  store
 

Enumerations

enum  {
  STORE_NONE = -1, STORE_GENERAL = 0, STORE_ARMOR = 1, STORE_WEAPON = 2,
  STORE_TEMPLE = 3, STORE_ALCHEMY = 4, STORE_MAGIC = 5, STORE_B_MARKET = 6,
  STORE_HOME = 7, MAX_STORES = 8
}
 List of store indices. More...
 

Functions

struct storestore_at (struct chunk *c, int y, int x)
 Return the store instance at the given location. More...
 
void store_init (void)
 
void free_stores (void)
 
void store_stock_list (struct store *store, struct object **list, int n)
 Sort the store inventory into an ordered array. More...
 
void home_carry (struct object *obj)
 Add an object to the inventory of the Home. More...
 
struct objectstore_carry (struct store *store, struct object *obj)
 Add an object to a real stores inventory. More...
 
void store_reset (void)
 
void store_shuffle (struct store *store)
 Shuffle one of the stores. More...
 
void store_update (void)
 Update the stores on the return to town. More...
 
int price_item (struct store *store, const struct object *obj, bool store_buying, int qty)
 

Basics: pricing, generation, etc. More...

 
bool store_will_buy_tester (const struct object *obj)
 Determine if the current store will purchase the given object. More...
 
bool store_check_num (struct store *store, const struct object *obj)
 Check to see if the shop will be carrying too many objects. More...
 
int find_inven (const struct object *obj)
 

Higher-level code

More...
 
struct ownerstore_ownerbyidx (struct store *s, unsigned int idx)
 Owner stuff. More...
 
struct parserinit_parse_stores (void)
 
struct parserstore_parser_new (void)
 
struct parserstore_owner_parser_new (struct store *stores)
 
void do_cmd_sell (struct command *cmd)
 Sell an item to the current store. More...
 
void do_cmd_stash (struct command *cmd)
 Stash an item in the home. More...
 
void do_cmd_buy (struct command *cmd)
 Buy the item with the given index from the current store's inventory. More...
 
void do_cmd_retrieve (struct command *cmd)
 Retrieve the item with the given index from the home's inventory. More...
 

Variables

struct storestores
 

Constants and definitions

More...
 

Detailed Description

Store stocking.

Copyright (c) 1997 Robert A. Koeneke, James E. Wilson, Ben Harrison Copyright (c) 2007 Andi Sidwell

This work is free software; you can redistribute it and/or modify it under the terms of either:

a) the GNU General Public License as published by the Free Software Foundation, version 2, or

b) the "Angband licence": This software may be copied and distributed for educational, research, and not for profit purposes provided that this copyright and statement are included in all such copies. Other copyrights may also apply.

Enumeration Type Documentation

anonymous enum

List of store indices.

Enumerator
STORE_NONE 
STORE_GENERAL 
STORE_ARMOR 
STORE_WEAPON 
STORE_TEMPLE 
STORE_ALCHEMY 
STORE_MAGIC 
STORE_B_MARKET 
STORE_HOME 
MAX_STORES 

Function Documentation

void do_cmd_buy ( struct command cmd)
void do_cmd_retrieve ( struct command cmd)
void do_cmd_sell ( struct command cmd)
void do_cmd_stash ( struct command cmd)
int find_inven ( const struct object obj)
void free_stores ( void  )
void home_carry ( struct object obj)

Add an object to the inventory of the Home.

Also note that it may not correctly "adapt" to "knowledge" becoming known: the player may have to pick stuff up and drop it again.

References object::known, object::next, object_absorb(), object_similar(), OSTACK_PACK, pile_insert(), store::stock, store::stock_k, store::stock_num, store::stock_size, and STORE_HOME.

Referenced by do_cmd_stash(), and rd_stores_aux().

struct parser* init_parse_stores ( void  )
int price_item ( struct store store,
const struct object obj,
bool  store_buying,
int  qty 
)


Basics: pricing, generation, etc.


Determine the price of an object (qty one) in a store.

store_buying == true means the shop is buying, player selling == false means the shop is selling, player buying

This function never lets a shop-keeper lose money in a transaction.

The "greed" value should exceed 100 when the player is "buying" the object, and should be less than 100 when the player is "selling" it.

Hack – the black market always charges twice as much as it should.

References owner::max_cost, object_value_real(), OPT, store::owner, store::sidx, STORE_B_MARKET, and tval_can_have_charges().

Referenced by do_cmd_buy(), do_cmd_sell(), show_obj(), store_display_entry(), store_purchase(), and store_sell().

struct store* store_at ( struct chunk c,
int  y,
int  x 
)

Return the store instance at the given location.

References cave, NULL, square_isshop(), and square_shopnum().

Referenced by do_cmd_buy(), do_cmd_retrieve(), do_cmd_sell(), do_cmd_stash(), show_obj(), store_will_buy_tester(), and use_store().

struct object* store_carry ( struct store store,
struct object obj 
)

Add an object to a real stores inventory.

If the object is "worthless", it is thrown away (except in the home).

If the object cannot be combined with an object already in the inventory, make a new slot for it, and calculate its "per item" price. Note that this price will be negative, since the price will not be "fixed" yet. Adding an object to a "fixed" price stack will not change the fixed price.

Returns the object inserted (for ease of use) or NULL if it disappears

References object_kind::charge, angband_constants::default_lamp, object::flags, angband_constants::fuel_torch, i, object::kind, object::known, object::next, object::note, object::notice, NULL, object::number, OBJ_NOTICE_ASSESSED, object_is_carried(), object_similar(), object_value(), object_value_real(), of_has, OSTACK_STORE, pile_insert(), object::pval, randcalc(), RANDOMISE, store::stock, store::stock_k, store::stock_num, store::stock_size, store_can_carry(), store_object_absorb(), object::timeout, tval_can_have_charges(), tval_can_have_timeout(), tval_is_launcher(), tval_is_light(), value, and z_info.

Referenced by do_cmd_sell(), rd_stores_aux(), store_create_item(), and store_create_random().

bool store_check_num ( struct store store,
const struct object obj 
)

Check to see if the shop will be carrying too many objects.

Note that the shop, just like a player, will not accept things it cannot hold. Before, one could "nuke" objects this way, by adding them to a pile which was already full.

References object::next, object_similar(), OSTACK_PACK, OSTACK_STORE, store::sidx, store::stock, store::stock_num, store::stock_size, and STORE_HOME.

Referenced by do_cmd_sell(), do_cmd_stash(), and store_sell().

void store_init ( void  )
struct parser* store_owner_parser_new ( struct store stores)
struct owner* store_ownerbyidx ( struct store s,
unsigned int  idx 
)

Owner stuff.

References owner::next, owner::oidx, store::owners, and quit_fmt().

Referenced by rd_stores_aux(), and store_choose_owner().

struct parser* store_parser_new ( void  )
void store_reset ( void  )
void store_shuffle ( struct store store)

Shuffle one of the stores.

References store::owner, and store_choose_owner().

Referenced by do_cmd_buy(), store_reset(), and store_update().

void store_stock_list ( struct store store,
struct object **  list,
int  n 
)

Sort the store inventory into an ordered array.

References earlier_object(), i, object::next, NULL, num, store::sidx, store::stock, and STORE_HOME.

Referenced by refresh_stock(), store_menu_init(), and write_character_dump().

void store_update ( void  )

Update the stores on the return to town.

References daycount, MAX_STORES, msg, one_in_, OPT, randint0, STORE_HOME, store_maint(), angband_constants::store_shuffle, store_shuffle(), and z_info.

Referenced by dungeon_change_level().

bool store_will_buy_tester ( const struct object obj)

Determine if the current store will purchase the given object.

References cave, object::kind, object_flavor_is_aware(), OPT, player::px, player::py, store_at(), store_can_carry(), store_will_buy(), and tval_can_have_charges().

Referenced by context_menu_object(), and store_sell().

Variable Documentation

struct store* stores