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


enum  {
 List of store indices. More...


struct storestore_at (struct chunk *c, struct loc grid)
 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

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...


struct storestores

Constants and definitions


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

anonymous enum

List of store indices.


Function Documentation

◆ do_cmd_buy()

void do_cmd_buy ( struct command cmd)

◆ do_cmd_retrieve()

void do_cmd_retrieve ( struct command cmd)

◆ do_cmd_sell()

void do_cmd_sell ( struct command cmd)

◆ do_cmd_stash()

void do_cmd_stash ( struct command cmd)

◆ find_inven()

int find_inven ( const struct object obj)

◆ free_stores()

void free_stores ( void  )

◆ home_carry()

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().

◆ init_parse_stores()

struct parser* init_parse_stores ( void  )

◆ price_item()

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, MIN, object_value(), 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().

◆ store_at()

struct store* store_at ( struct chunk c,
struct loc  grid 

Return the store instance at the given location.

References cave, 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().

◆ store_carry()

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::number, 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().

◆ store_check_num()

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().

◆ store_init()

void store_init ( void  )

◆ store_owner_parser_new()

struct parser* store_owner_parser_new ( struct store stores)

◆ store_ownerbyidx()

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().

◆ store_parser_new()

struct parser* store_parser_new ( void  )

◆ store_reset()

void store_reset ( void  )

◆ store_shuffle()

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().

◆ store_stock_list()

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, num, store::sidx, store::stock, and STORE_HOME.

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

◆ store_update()

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().

◆ store_will_buy_tester()

bool store_will_buy_tester ( const struct object obj)

Determine if the current store will purchase the given object.

References cave, player::grid, store_at(), and store_will_buy().

Referenced by context_menu_object(), and store_sell().

Variable Documentation

◆ stores

struct store* stores