-
Notifications
You must be signed in to change notification settings - Fork 0
/
game.h
319 lines (226 loc) · 6.54 KB
/
game.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
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
/*
GAME.H v0.22
Game-dependent data, simple version.
Copyright (c) 2004 Francesco Orsenigo <francesco.orsenigo@gmail.com>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
version 2 as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef H_FILE_GAME
#define H_FILE_GAME
//=============================================================================
#include "map.h"
#include "unit.h"
#include "race.h"
#include "random.h"
#define GAME_NAME_BF 32
#define GAME_MAX_BRAINS 8 // 8 players
#define GAME_MAX_UNITS 5000 // 150xPlayer on a 32-players game
#define GAME_MODELSxBRAIN 50
//#define BRAIN_LOCAL_BIT (1<<31) // used to locally select units
#define BRAIN_NEUTRAL (1<<30) // used for neutral units
#define BRAIN_UNUSED 0 // just what it says
#define BRAIN_INIT 1 // waiting for it to send his init data
#define BRAIN_ACTIVE 2 // up and playing!
#define BRAIN_DEAD 3 // useless?
#define PICKS_MAX_CHOICE 6
#define PICKS_MAX_RANDOM 7
//#define PICKS_MAX PICKS_MAX_RANDOM
#define PICK_FULL_RANDOM_LIMIT 1
#define GENCH_GAIAS_REIGN 0
#define GENCH_CRUSADE 1
#define GENCH_CHARM_OF_LIFE 2
#define GENCH_PLANAR_SEAL 3
#define GENCH_TRANQUILLITY 4
#define GENCH_LIFE_FORCE 5
#define GENCH_JUST_CAUSE 6
#define GENCH_ETERNAL_NIGHT 7
#define GENCH_HOLY_ARMS 8
#define GENCH_TOTAL 9
/*=============================================================================
* STRUCTURES
*/
class colorC;
class utypeC;
class raceC;
class realmC;
/*=============================================================================
* BRAIN (PLAYER)
*/
class pickC;
class spellC;
class spellLaunchC;
class brainC { public:
char ZeroStart[0]; //---------------------------------------------
brainC* Next; // dynamic list of active brains
// identity
char Name[GAME_NAME_BF];
raceC* Race;
colorC* Color;
unitC* PlayerMage;
cellC* SummoningCircle;
pickC* InitialPicks[PICKS_MAX_CHOICE];
// system
long Bit;
unsigned char Id;
unsigned char Status;
bool Ready;
// interface
cellC* Focus;
cellC* LocalFocus; // used to change between menues
// while the real focus routes through the net
long SelectedTeam; // No "Local" trick
// empire
long EngageMask;
long FriendMask;
unsigned char Taxes; // taxes for 2000 citizens
signed GoldReserve;
signed ManaReserve;
// allocation
char AllocateToSkill;
char AllocateToResearch;
signed AlchemyManaToGold;
// magic
spellC* ResearchedSpell;
unsigned Skill;
unsigned SkillPool;
unsigned SkillAvl;
unsigned SkillCommitted;
spellLaunchC* SpellQueue;
char ZeroEnd[0]; //-------------------------------------
//
brainC();
~brainC();
void Display(float h);
void InitGame();
bool IsThe(pickC& pick);
bool HasGEnch(int id);
//
int MinorBooks(realmC* r);
int TotalBooks(realmC* r);
bool CanResearch(spellC* s);
bool CanCast(spellC* s);
unsigned SpellCost();
unsigned SpellCost(spellLaunchC* spl);
void CheckCast();
void CheckCast(spellLaunchC* spl);
void ClearSpellQueue();
void QueueSpell(spellLaunchC* spl);
//
void Think();
signed DeltaRawMana();
signed DeltaSkill();
signed DeltaGold();
signed DeltaMana();
signed DeltaFood();
signed DeltaKnow();
//
int CountPicks();
char* CheckRequirementsFor(pickC* p);
};
/*=============================================================================
* PICK
*/
class brainC;
class cellC;
class bookC;
class pickC { public:
pickC* Next;
char* Id;
char* Name;
char* Desc;
bookC* Book; // books only! =)
brainC* Owner; // 0 if not owned
cellC* Location;
char ReqMask;
bool Desired;
//
pickC(char* Id, char* name, char* desc, char req_mask);
//
bool Is(brainC* b);
};
extern pickC* picksHook;
/*=============================================================================
* GAME
*/
class travelC;
class gameC { public:
mapC Map;
raceC Creatures;
unitC Units[GAME_MAX_UNITS], UnitsEnd[0];
brainC Brains[GAME_MAX_BRAINS], BrainsEnd[0];
brainC* BrainsHook;
randomC Rnd;
travelC* TravelsHook; // travels dynamic list
heroC* HerosHook;
cellC* ActiveBattle;
char ZeroStart[0]; //-------------------------------------
char Ench[GENCH_TOTAL];
long Turn;
long UnitTeam; // used to assign a unique team id
long Seed;
char ZeroEnd[0]; //-------------------------------------
//
gameC(int self_id, long seed, int mapw, int maph);
~gameC();
bool CheckReady();
void Think();
unsigned Roll(int str, int chance);
unsigned Roll(int str);
long GetNewTeam();
void Start();
char* Write(char* w);
int Read(char* bf, char* ebf);
bool IsPlayerColorAvailable(colorC* );
};
/*=============================================================================
* GAME
*/
extern brainC* self;
extern gameC* game;
void gameClose();
bool gameIsAvailable();
class cellC;
cellC* map(signed x, signed y, char z);
/*=============================================================================
* BRAIN
*/
class battleC;
void bdSquare(brainC* );
/*=============================================================================
* PICK
*/
extern pickC Myrran;
extern pickC Warlord;
extern pickC Sage;
extern pickC Lightlord;
extern pickC NodeMaster;
extern pickC ChaosMaster;
extern pickC NatureMaster;
extern pickC SorceryMaster;
extern pickC Famous;
extern pickC Darklord;
extern pickC Conjurer;
extern pickC Charismatic;
extern pickC Channeller;
extern pickC Destroyer;
extern pickC Artificier;
extern pickC Archmage;
extern pickC Alchemist;
void pickAssign();
/*=============================================================================
* UNIT
* (why here?)
*/
unitC* unitNew(utypeC* type, cellC *cell);
unitC* unitSpawnExCity(cityC* city, utypeC* type);
#endif
//EOF =========================================================================