File: player.h

package info (click to toggle)
ale-clone 1.15pre16.3-1
  • links: PTS
  • area: contrib
  • in suites: potato
  • size: 2,432 kB
  • ctags: 3,217
  • sloc: ansic: 37,483; sh: 1,105; makefile: 343
file content (188 lines) | stat: -rw-r--r-- 6,415 bytes parent folder | download
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
/*
**	A clone of a famous game.
*/
/**@name player.h	-	The player headerfile. */
/*
**	(c) Copyright 1998,1999 by Lutz Sammer
**
**	$Id: player.h,v 1.23 1999/11/25 00:59:27 root Exp $
*/

#ifndef __PLAYER_H__
#define __PLAYER_H__

//@{

/*----------------------------------------------------------------------------
--	Includes
----------------------------------------------------------------------------*/

typedef struct _player_ Player;

#include "upgrade_structs.h"
#include "unittype.h"
#include "unit.h"

/*----------------------------------------------------------------------------
--	Player type
----------------------------------------------------------------------------*/

/**
**	Player structure
*/
struct _player_ {
    unsigned	Player;			/// player as number
    char*	Name;			/// name of non computer
    unsigned	Type;			/// type of player (human,computer,...)
    unsigned	Race;			/// race of player (orc,human,...)
    unsigned	Team;			/// team of player
    unsigned	Ai;			/// AI for computer

    unsigned	X;			/// map tile start X position
    unsigned	Y;			/// map tile start Y position

// FIXME: change to Resource[]
    unsigned	Gold;			/// resources of gold in store
    unsigned	Wood;			/// resources of wood in store
    unsigned	Oil;			/// resources of oil in store

// FIXME: change to Income[]
    unsigned	WoodPerChop;		/// how much gives a piece wood
    unsigned	GoldPerMine;		/// how much gives a piece gold
    unsigned	OilPerHaul;		/// how much gives an oil transport

//    unsigned	UnitFlags[
//	(UnitTypeInternalMax+BitsOf(unsigned)-1)
//	    /BitsOf(unsigned)];		/// flags what units are available
    unsigned    UnitTypesCount[MaxUnitTypes];       /// each type unit count

    unsigned	AiEnabled;		/// handle ai on this computer

    Unit**	Units;			/// units of this player
    unsigned	TotalNumUnits;		/// total # units for units' list.

    unsigned	Food;			/// food available/produced
    unsigned	NumUnits;		/// # units (need food)
    unsigned	NumBuildings;		/// # buildings (don't need food)

    unsigned	Score;			/// points for killing ...

    unsigned	Color;			/// color of units on minimap

    unsigned	UnitColor1;		/// Unit color 1 on map and icons
    unsigned	UnitColor2;		/// Unit color 2 on map and icons
    unsigned	UnitColor3;		/// Unit color 3 on map and icons
    unsigned	UnitColor4;		/// Unit color 4 on map and icons

//  Upgrades/Allows:

    Allow		Allow;		/// Allowed for player
    UpgradeTimers	UTimers;	/// Timer for the upgrades
};

/*
**	Races for the player
*/
#define PlayerRaceHuman		0	/// belongs to human
#define PlayerRaceOrc		1	/// belongs to orc
#define PlayerRaceNeutral	2	/// belongs to none

#define PlayerMaxRaces		2	/// maximal races supported

/*
**	Types for the player
*/
#define PlayerNeutral		2	/// neutral
#define PlayerNobody		3	/// unused slot
#define PlayerComputer		4	/// computer player
#define PlayerHuman		5	/// human player
#define PlayerRescuePassive	6	/// rescued passive
#define PlayerRescueActive	7	/// rescued  active

/*
**	Ai types for the player
*/
#define PlayerAiLand		0	/// attack at land
#define PlayerAiPassive		1
#define PlayerAiSea		0x19	/// attack at sea
#define PlayerAiAir		0x1A	/// attack at air

#define PlayerAiUniversal	0xFF	/// attack best

#define PlayerNumNeutral	15	/// this is the neutral player slot

#define PlayerMax		16	/// maximal players supported

#define GOLD_PER_MINE		100	/// default value for gold
#define WOOD_PER_CHOP		100	/// default value for wood
#define OIL_PER_HAUL		100	/// default value for oil

/*----------------------------------------------------------------------------
--	Variables
----------------------------------------------------------------------------*/

extern int NumPlayers;			/// Player in play
extern int NetPlayers;			/// Network players
extern Player Players[PlayerMax];	/// All players
extern Player* ThisPlayer;		/// Player on this computer

/*----------------------------------------------------------------------------
--	Functions
----------------------------------------------------------------------------*/

    /// FIXME: write short docu
extern void CreatePlayer(char* name,int type);
    /// FIXME: write short docu
extern void PlayerSetSide(Player* player,int side);
    /// FIXME: write short docu
extern void PlayerSetAiNum(Player* player,int ai);
    /// FIXME: write short docu
extern void PlayerSetGold(Player* player,int gold);
    /// FIXME: write short docu
extern void PlayerSetWood(Player* player,int wood);
    /// FIXME: write short docu
extern void PlayerSetOil(Player* player,int oil);

    /// Check if enough food is available for unit type
extern int PlayerCheckFood(const Player* player,const UnitType* type);
    /// Check if enough gold is available for unit type
extern int PlayerCheckGoldCost(const Player* player,const UnitType* type);
    /// Check if enough wood is available for unit type
extern int PlayerCheckWoodCost(const Player* player,const UnitType* type);
    /// Check if enough oil is available for unit type
extern int PlayerCheckOilCost(const Player* player,const UnitType* type);
    /// Check if enough resources are available
extern int PlayerCheckCosts(const Player* player,int gold,int wood,int oil);
    /// Check if enough resources are available for unit type
extern int PlayerCheckResources(const Player* player,const UnitType* type);

    /// FIXME: write short docu
extern void PlayerAddCosts(Player* player,int gold,int wood,int oil);
    /// FIXME: write short docu
extern void PlayerSubCosts(Player* player,int gold,int wood,int oil);
    /// FIXME: write short docu
extern void PlayerSubResources(Player* player,const UnitType* type);
    /// FIXME: write short docu
extern void PlayerAddResources(Player* player,const UnitType* type);

    /// Has the player units of that type
extern int HaveUnitTypeByType(const Player* player,const UnitType* type);
    /// Has the player units of that type
extern int HaveUnitTypeByIdent(const Player* player,const char* ident);

    /// FIXME: write short docu
extern void PlayersInitAi(void);
    /// FIXME: write short docu
extern void PlayersEachFrame(void);
    /// FIXME: write short docu
extern void PlayersEachSecond(void);

    /// Change current color set to new player.
extern void PlayerPixels(const Player* player);

    /// Output debug informations for players
extern void DebugPlayers(void);

//@}

#endif // !__PLAYER_H__