31
31
#define ANON_PLAYER_NAME "noname"
32
32
#define ANON_USER_NAME "Unassigned"
35
* pplayer->ai.barbarian_type uses this enum. Note that the values
36
* have to stay since they are used in savegames.
44
34
enum handicap_type {
45
H_NONE = 0, /* No handicaps */
46
H_DIPLOMAT = 1, /* Can't build offensive diplomats */
47
H_AWAY = 2, /* Away mode */
48
H_LIMITEDHUTS = 4, /* Can get only 25 gold and barbs from huts */
49
H_DEFENSIVE = 8, /* Build defensive buildings without calculating need */
50
H_EXPERIMENTAL = 16,/* Enable experimental AI features (for testing) */
51
H_RATES = 32, /* Can't set its rates beyond government limits */
52
H_TARGETS = 64, /* Can't target anything it doesn't know exists */
53
H_HUTS = 128, /* Doesn't know which unseen tiles have huts on them */
54
H_FOG = 256, /* Can't see through fog of war */
55
H_NOPLANES = 512, /* Doesn't build air units */
56
H_MAP = 1024, /* Only knows map_is_known tiles */
57
H_DIPLOMACY = 2048, /* Not very good at diplomacy */
58
H_REVOLUTION = 4096, /* Cannot skip anarchy */
59
H_EXPANSION = 8192, /* Don't like being much larger than human */
60
H_DANGER = 16384 /* Always thinks its city is in danger */
35
H_DIPLOMAT = 0, /* Can't build offensive diplomats */
36
H_AWAY, /* Away mode */
37
H_LIMITEDHUTS, /* Can get only 25 gold and barbs from huts */
38
H_DEFENSIVE, /* Build defensive buildings without calculating need */
39
H_EXPERIMENTAL, /* Enable experimental AI features (for testing) */
40
H_RATES, /* Can't set its rates beyond government limits */
41
H_TARGETS, /* Can't target anything it doesn't know exists */
42
H_HUTS, /* Doesn't know which unseen tiles have huts on them */
43
H_FOG, /* Can't see through fog of war */
44
H_NOPLANES, /* Doesn't build air units */
45
H_MAP, /* Only knows map_is_known tiles */
46
H_DIPLOMACY, /* Not very good at diplomacy */
47
H_REVOLUTION, /* Cannot skip anarchy */
48
H_EXPANSION, /* Don't like being much larger than human */
49
H_DANGER, /* Always thinks its city is in danger */
63
53
BV_DEFINE(bv_player, MAX_NUM_PLAYERS + MAX_NUM_BARBARIANS);
55
BV_DEFINE(bv_handicap, H_LAST);
65
57
struct player_economic {
104
96
int est_upkeep; /* estimated upkeep of buildings in cities */
105
97
/* The units of tech_want seem to be shields */
106
98
int tech_want[A_LAST+1];
107
int handicap; /* sum of enum handicap_type */
108
int skill_level; /* 0-10 value for save/load/display */
99
bv_handicap handicaps; /* sum of enum handicap_type */
100
enum ai_level skill_level; /* 0-10 value for save/load/display */
109
101
int fuzzy; /* chance in 1000 to mis-decide */
110
102
int expand; /* percentage factor to value new cities */
111
103
int science_cost; /* Cost in bulbs to get new tech, relative
181
175
bool is_dying; /* set once the player is in the process of dying */
176
bool is_winner; /* This player is winner in scenario game */
182
177
bool surrendered; /* has indicated willingness to surrender */
184
179
/* Turn in which the player's revolution is over; see update_revolution. */
185
180
int revolution_finishes;
187
182
bool capital; /* used to give player init_buildings in first city. */
183
bv_player real_embassy;
189
184
struct player_diplstate diplstates[MAX_NUM_PLAYERS + MAX_NUM_BARBARIANS];
186
struct city_list *cities;
191
187
struct unit_list *units;
192
struct city_list *cities;
193
188
struct player_score score;
194
189
struct player_economic economic;
196
191
int bulbs_last_turn; /* # bulbs researched last turn only */
197
192
struct player_spaceship spaceship;
193
struct player_ai ai_data;
199
195
bool was_created; /* if the player was /created */
200
196
bool is_connected;
201
197
struct connection *current_conn; /* non-null while handling packet */
202
198
struct conn_list *connections; /* will replace conn */
203
struct worklist worklists[MAX_NUM_WORKLISTS];
204
199
struct player_tile *private_map;
205
200
unsigned int gives_shared_vision; /* bitvector those that give you shared vision */
206
201
unsigned int really_gives_vision; /* takes into account that p3 may see what p1 has via p2 */
207
int small_wonders[B_LAST]; /* contains city id's */
208
/* wonders[] may also be (-1), or the id of a city
209
which no longer exists, if the wonder has been destroyed */
202
int wonders[B_LAST]; /* contains city id's or WONDER_NOT_BUILT */
211
203
struct attribute_block_s attribute_block;
212
204
struct attribute_block_s attribute_block_buffer;
208
/* A slot is a possibly uninitialized player. */
209
int player_slot_count(void);
210
bool player_slot_is_used(const struct player *pslot);
211
void player_slot_set_used(struct player *pslot, bool used);
212
struct player *player_slot_by_number(int player_id);
216
214
/* General player accessor functions. */
217
215
int player_count(void);
216
void set_player_count(int count);
218
218
int player_index(const struct player *pplayer);
219
219
int player_number(const struct player *pplayer);
230
230
bool player_set_nation(struct player *pplayer, struct nation_type *pnation);
231
231
void player_set_unit_focus_status(struct player *pplayer);
232
233
bool player_has_embassy(const struct player *pplayer,
233
const struct player *pplayer2);
234
const struct player *pplayer2);
235
bool player_has_real_embassy(const struct player *pplayer,
236
const struct player *pplayer2);
237
bool player_has_embassy_from_effect(const struct player *pplayer,
238
const struct player *pplayer2);
235
240
bool can_player_see_unit(const struct player *pplayer,
236
241
const struct unit *punit);
304
309
struct player_research *get_player_research(const struct player *p1);
311
void player_set_winner(struct player *plr);
306
313
/* Initialization and iteration */
307
314
void player_init(struct player *plr);
309
#define players_iterate(PI_player) \
311
struct player *PI_player; \
313
for (PI_p_itr = 0; PI_p_itr < game.info.nplayers; PI_p_itr++) { \
314
PI_player = get_player(PI_p_itr);
316
#define players_iterate_end \
316
#define player_slots_iterate(NAME_pslot)\
318
struct player *NAME_pslot;\
320
for (MY_i = 0; MY_i < player_slot_count(); MY_i++) {\
321
NAME_pslot = player_slot_by_number(MY_i);\
322
if (NAME_pslot != NULL) {\
324
#define player_slots_iterate_end\
329
/* NB!!! This will only iterate over players for
330
* which player_slot_is_used() returns TRUE. */
331
#define players_iterate(NAME_pplayer)\
333
player_slots_iterate(NAME_pplayer) {\
334
if (player_slot_is_used(NAME_pplayer)) {
336
#define players_iterate_end\
338
} player_slots_iterate_end;\
320
341
/* ai love values should be in range [-MAX_AI_LOVE..MAX_AI_LOVE] */
321
342
#define MAX_AI_LOVE 1000
324
345
/* User functions. */
325
346
bool is_valid_username(const char *name);
348
enum ai_level find_ai_level_by_name(const char *name);
349
const char *ai_level_name(enum ai_level level);
350
const char *ai_level_cmd(enum ai_level level);
351
bool is_settable_ai_level(enum ai_level level);
352
int number_of_ai_levels(void);
328
354
#endif /* FC__PLAYER_H */