1 /**
2  * \file store.h
3  * \brief Store stocking
4  *
5  * Copyright (c) 1997 Robert A. Koeneke, James E. Wilson, Ben Harrison
6  * Copyright (c) 2007 Andi Sidwell
7  *
8  * This work is free software; you can redistribute it and/or modify it
9  * under the terms of either:
10  *
11  * a) the GNU General Public License as published by the Free Software
12  *    Foundation, version 2, or
13  *
14  * b) the "Angband licence":
15  *    This software may be copied and distributed for educational, research,
16  *    and not for profit purposes provided that this copyright and statement
17  *    are included in all such copies.  Other copyrights may also apply.
18  */
19 
20 #ifndef INCLUDED_STORE_H
21 #define INCLUDED_STORE_H
22 
23 #include "cave.h"
24 #include "cmd-core.h"
25 #include "datafile.h"
26 #include "object.h"
27 
28 /**
29  * List of store indices
30  */
31 enum {
32 	STORE_NONE      = -1,
33 	STORE_GENERAL	= 0,
34 	STORE_ARMOR	= 1,
35 	STORE_WEAPON	= 2,
36 	STORE_TEMPLE	= 3,
37 	STORE_ALCHEMY	= 4,
38 	STORE_MAGIC	= 5,
39 	STORE_B_MARKET	= 6,
40 	STORE_HOME	= 7,
41 	MAX_STORES	= 8
42 };
43 
44 struct object_buy {
45 	struct object_buy *next;
46 	size_t tval;
47 	size_t flag;
48 };
49 
50 struct owner {
51 	unsigned int oidx;
52 	struct owner *next;
53 	char *name;
54 	s32b max_cost;
55 };
56 
57 struct store {
58 	struct store *next;
59 	struct owner *owners;
60 	struct owner *owner;
61 	unsigned int sidx;
62 	const char *name;
63 
64 	byte stock_num;				/* Stock -- Number of entries */
65 	s16b stock_size;			/* Stock -- Total Size of Array */
66 	struct object *stock;		/* Stock -- Actual stock items */
67 	struct object *stock_k;		/* Stock -- Stock as known by the character */
68 
69 	/* Always stock these items */
70 	size_t always_size;
71 	size_t always_num;
72 	struct object_kind **always_table;
73 
74 	/* Select a number of these items to stock */
75 	size_t normal_size;
76 	size_t normal_num;
77 	struct object_kind **normal_table;
78 
79 	/* Buy these items */
80 	struct object_buy *buy;
81 
82 	int turnover;
83 	int normal_stock_min;
84 	int normal_stock_max;
85 };
86 
87 extern struct store *stores;
88 
89 struct store *store_at(struct chunk *c, struct loc grid);
90 void store_init(void);
91 void free_stores(void);
92 void store_stock_list(struct store *store, struct object **list, int n);
93 void home_carry(struct object *obj);
94 struct object *store_carry(struct store *store, struct object *obj);
95 void store_reset(void);
96 void store_shuffle(struct store *store);
97 void store_update(void);
98 int price_item(struct store *store, const struct object *obj,
99 			   bool store_buying, int qty);
100 
101 bool store_will_buy_tester(const struct object *obj);
102 bool store_check_num(struct store *store, const struct object *obj);
103 int find_inven(const struct object *obj);
104 
105 extern struct owner *store_ownerbyidx(struct store *s, unsigned int idx);
106 
107 struct parser *init_parse_stores(void);
108 extern struct parser *store_parser_new(void);
109 extern struct parser *store_owner_parser_new(struct store *stores);
110 
111 extern void do_cmd_sell(struct command *cmd);
112 extern void do_cmd_stash(struct command *cmd);
113 extern void do_cmd_buy(struct command *cmd);
114 extern void do_cmd_retrieve(struct command *cmd);
115 
116 #endif /* INCLUDED_STORE_H */
117