File: unit.h

package info (click to toggle)
attal 1.0~rc2-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, squeeze, wheezy
  • size: 4,348 kB
  • ctags: 7,428
  • sloc: cpp: 55,101; sh: 267; ansic: 100; makefile: 54
file content (191 lines) | stat: -rw-r--r-- 4,363 bytes parent folder | download | duplicates (2)
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
/****************************************************************
**
** Attal : Lords of Doom
**
** unit.h
** manages unit (army)
**
** Version : $Id: unit.h,v 1.20 2007/10/07 13:11:00 lusum Exp $
**
** Author(s) : Pascal Audoux - Sardi Carlo
**
** Date : 09/08/2000
**
** Licence :    
**	This program is free software; you can redistribute it and/or modify
**   	it under the terms of the GNU General Public License as published by
**     	the Free Software Foundation; either version 2, or (at your option)
**      any later version.
**
**	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.
**
****************************************************************/


#ifndef UNIT_H
#define UNIT_H


// generic include files
// include files for QT
#include <QString>
// application specific includes

class Creature;
class GenericFightCell;
class GenericFightMap;

/*              ------------------------------
 *                         Unit
 *              ------------------------------ */

class GenericFightUnit
{

public:
	/** Constructor */
	GenericFightUnit();

	/** Destructor */	
	virtual ~GenericFightUnit();

	/** Set the fight map for unit */
	void setFightMap ( GenericFightMap* map );

	GenericFightMap* getFightMap () { return _map; }

	/** Set race of unit */
	void setCreature( QString name );

	void setCreature( uint race, uint level );

	void setCreature( Creature * creature );

	Creature * getCreature() { return _creature; }

	/** Return race of unit */
	uint getRace() { return _race; }

	/** Return race of unit */
	uint getLevel() { return _level; }

	/** Set nb of creatures */
	void setNumber( long int nb ) { _number = nb; }

	/** return nb of creatures */
	long int getNumber() { return _number; }

	/** Add nb of creatures */
	void addNumber( long int nb ) { _number += nb; }

	/** Set move points */
	void setMove( long int nb ) { _move = nb; }

	/** Return move points */
	long int getMove() { return _move; }

	void setMaxMove();

	/** Set health */
	void setHealth( long int nb ) { _health = nb; }

	/** Return health */
	long int getHealth() { return _health; }
	
	/** Set experience */
	void setExperience( long int nb ) { _experience = nb; }

	/** Return health */
	long int getExperience() { return _experience; }

	/** Display unit */
	void display();

	QString getUnitDescription();

	/** Calculate the damages made by the attack */
	int hit( long int nb );
	
	bool isAlive () { return (_number > 0); }

	/** Go to fight cell */
	void goTo( GenericFightCell * cell );

	/** Get the second cell of a 2 size unit */
	GenericFightCell * getNeighbour( GenericFightCell * cell );
	
	/** Return cell of the unit */
	GenericFightCell * getCell() {
		return _currentFightCell;
	}
	
	/** Return second cell of the unit (if exist)*/
	GenericFightCell * getNeibCell() {
		return _currentNeibCell;
	}
	
	/** buggy, don't use */
	void setCell(GenericFightCell * cell) {
		_currentFightCell = cell;
	}

	/** Return attack points of creature */
	int getAttack();

	/** Return defense points of creature */
	int getDefense();

	/** Return dist attack points of creature */
	int getDistAttack();

	/** Tell if dist attack is allowed for creature  */
	bool isDistAttack();

	/** Return max health points of creature */
	int getMaxHealth();

	/** Return max move points of creature */
	int getMaxMove();

	/** Return morale of creature */
	int getMorale();

	/** Return luck of creature */
	int getLuck();

	/** Return min damages points of creature */
	int getMinDamages();

	/** Return max damages points of creature */
	int getMaxDamages();

	/** Return maintenance cost of creature */
	int getMantCost(int ress);

	/** Is this unit looking to right (important for 2-cells units)*/
	bool isLookingToRight ();
	
	void setLookingToRight ( bool mirror );
	
	bool canAttack () {return _hasAttack;}
	
	void finishAttack () { _hasAttack = false;}
	
	void activateAttack () { _hasAttack = true;}


protected:
	long int _number, _move, _health, _experience;
	uint _race, _level;
	GenericFightCell * _currentFightCell, *  _currentNeibCell;
	Creature * _creature;
	GenericFightMap* _map;
	bool _lookingToRight;
	bool _hasAttack;

};
 
#endif // UNIT_H