forked from Whales/edigotia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresource.h
304 lines (247 loc) · 6.37 KB
/
resource.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
#ifndef _RESOURCE_H_
#define _RESOURCE_H_
#include "color.h"
#include <string>
#include <vector>
// INFINITE_RESOURCE is used e.g. when reporting how much stone is available in
// a mountain.
#define INFINITE_RESOURCE -99
/* HIDDEN_RESOURCE is used for Building::minerals_mined, which is of type
* std::vector<Mineral_amount>. When we open a new mine area, we look at the
* underlying terrain, and add a Mineral_amount with a type corresponding to
* each mineral available in the terrain, and a amount of HIDDEN_RESOURCE. This
* means that while the mineral is available, it isn't presented to the player
* until the mine happens to find the mineral - at which point the amount is
* changed from HIDDEN_RESOURCE to 0, meaning the player has the option to mine
* that mineral (further increasing the amount).
*/
#define HIDDEN_RESOURCE -999
enum Resource
{
RES_NULL = 0,
// The Big Four
RES_GOLD,
RES_FOOD,
RES_WOOD,
RES_STONE,
// Forged minerals
RES_TIN,
RES_COPPER,
RES_IRON,
// Component resources
RES_FIBER, // Anything than can become cloth; cotton, wool, etc
RES_FUR,
RES_LEATHER,
// Rare/monster resources
RES_UNICORN_HORN,
// Luxuries - these impart morale
// Spices
RES_SALT,
RES_PEPPER,
RES_CINNAMON,
RES_CUMIN,
RES_PAPRIKA,
// Smokeables
RES_TOBACCO,
RES_CANNABIS,
// Hallucinogens
RES_AMANITAS,
RES_AYAHUASCA,
RES_SPICEREED,
// Clothing
RES_CLOTHING,
RES_FUR_COATS,
RES_LEATHER_COATS,
// Housewares
RES_WOOD_HOUSEWARES,
RES_TIN_HOUSEWARES,
RES_COPPER_HOUSEWARES,
RES_IRON_HOUSEWARES,
// Misc
RES_FURNITURE,
RES_JEWELRY,
// Non-luxury produced goods
RES_BLANK_BOOK,
// Meta-resources
RES_FARMING, // Can be any available crop
RES_MINING, // Available minerals, decided by the terrain
RES_HUNTING, // Available game, decided by the terrain
RES_LOGGING, // Produces wood based on terrain
RES_MAX
};
Resource lookup_resource(std::string name);
enum Luxury_type
{
LUX_NULL = 0, // A valid option, if it's a unique luxury
LUX_SPICE, // Food spices.
LUX_SMOKABLE, // A smokable soft drug
LUX_HALLUCINOGEN,
LUX_COATS,
LUX_HOUSEWARES,
LUX_MAX
};
// See resource.cpp for this stuff
Luxury_type lookup_luxury_type(std::string name);
std::string luxury_type_name(Luxury_type type);
struct Resource_datum
{
Resource_datum(std::string N = "", nc_color C = c_white, int V = 0, int D = 0,
int M = 0, Luxury_type L = LUX_NULL, bool MT = false) :
name (N), color (C), value (V), demand (D), morale (M), luxury_type (L),
meta (MT) { }
std::string name;
nc_color color;
// The actual price we pay for a resource is determined by supply & demand, and
// the price a city sets for it. But the value property is a basic guide and
// helps AI cities determine what crops to grow, for instance.
int value;
int demand; // Standard demand each turn per 100 citizens
int morale; // Morale boost when the demand is met
Luxury_type luxury_type;
bool meta; // True if it's not real; farming, mining, etc
std::string description; // For help article
};
struct Resource_amount
{
Resource_amount(Resource R = RES_NULL, int A = 0) :
type (R),
amount (A)
{}
Resource type;
int amount;
bool is_infinite(); // True if amount == INFINITE_RESOURCE
};
enum Crop_type
{
CROPTYPE_NULL = 0,
CROPTYPE_FOOD,
CROPTYPE_SPICE,
CROPTYPE_DRUG,
CROPTYPE_POISON,
CROPTYPE_FIBER,
CROPTYPE_OTHER,
CROPTYPE_MAX
};
Crop_type lookup_crop_type(std::string name);
std::string crop_type_name(Crop_type type);
nc_color crop_type_color(Crop_type type);
enum Crop
{
CROP_NULL = 0,
// Food
CROP_WHEAT,
CROP_CABBAGE,
CROP_GRAPES,
CROP_MELON,
CROP_RICE,
CROP_CACTUS,
// Spices
CROP_PEPPER,
CROP_CINNAMON,
CROP_CUMIN,
CROP_PAPRIKA,
// Drugs
CROP_TOBACCO,
CROP_AMANITAS,
CROP_AYAHUASCA,
CROP_SPICEREED,
// Poisons
CROP_DEATHCAP,
CROP_VIPERVINE,
CROP_SCORPICON,
// Materials
CROP_COTTON,
CROP_HEMP,
CROP_MAX
};
enum Mineral
{
MINERAL_NULL = 0,
// Building materials
MINERAL_STONE,
// Crafting metals
MINERAL_TIN,
MINERAL_COPPER,
MINERAL_IRON,
// Rare valuables
MINERAL_SALT,
MINERAL_GEMS, // TODO: Should this be broken out into different TYPES of gems?
MINERAL_GOLD,
// Fuels
MINERAL_COAL,
MINERAL_MAX
};
struct Crop_datum
{
Crop_datum()
{
food = 0;
percentage = 0;
type = CROPTYPE_NULL;
min_temp = 0;
max_temp = 100;
min_altitude = 0;
max_altitude = 100;
min_rainfall = 0;
max_rainfall = 100;
}
nc_color get_color();
std::string name;
int food;
int percentage;
int min_temp, max_temp; // Range of temperature we grow in
int min_altitude, max_altitude; // Range of altitude we grow in
int min_rainfall, max_rainfall; // Range of rainfall we grow in
Crop_type type;
std::vector<Resource_amount> bonus_resources;
std::string description;
};
struct Mineral_datum
{
Mineral_datum() { percentage = 0; value = 0; color = c_ltgray; hidden = false;
}
std::string name;
int percentage;
int value; // Per 100 units
nc_color color;
bool hidden;
std::string description;
};
// These search for the name (trimmed & non-case-sensitive) in the data pools;
// partial matches work (e.g. a search for " Eat " returns CROP_WHEAT)
Crop search_for_crop (std::string name);
Mineral search_for_mineral(std::string name);
struct Crop_amount
{
Crop_amount(Crop T = CROP_NULL, int A = 0) :
type (T),
amount (A)
{}
Crop type;
int amount;
bool is_infinite(); // True if amount == INFINITE_RESOURCE
};
struct Mineral_amount
{
Mineral_amount(Mineral T = MINERAL_NULL, int A = 0) :
type (T),
amount (A)
{}
Mineral type;
int amount;
bool is_infinite(); // True if amount == INFINITE_RESOURCE
// Returns this, with the amount set to 10%- 20% of the original.
Mineral_amount make_small();
// Returns this, with the amount set to 80%-120% of the original.
Mineral_amount randomize();
};
// Returns a description of the amount of mineral there.
// E.g. "Trace ", "Little ", "Some ", "Lots of ", "Tons of ", etc
std::string mineral_amount_ranking(Mineral_amount min_amt);
std::string trees_amount_ranking(int wood);
// Defined in resource_data.cpp
extern Resource_datum* Resource_data [RES_MAX];
extern Crop_datum* Crop_data [CROP_MAX];
extern Mineral_datum* Mineral_data [MINERAL_MAX];
void init_resource_data();
#endif