1 // -------------------------------------------------------------------------
2 // AAI
3 //
4 // A skirmish AI for the Spring engine.
5 // Copyright Alexander Seizinger
6 //
7 // Released under GPL license: see LICENSE.html for more information.
8 // -------------------------------------------------------------------------
9 
10 #ifndef AAI_ATTACKMANAGER_H
11 #define AAI_ATTACKMANAGER_H
12 
13 #include "aidef.h"
14 #include <set>
15 #include <list>
16 #include <vector>
17 
18 using namespace std;
19 
20 class AAI;
21 class AAIBrain;
22 class AAIBuildTable;
23 class AAIMap;
24 class AAIAttack;
25 class AAISector;
26 
27 
28 class AAIAttackManager
29 {
30 public:
31 	AAIAttackManager(AAI *ai, int continents);
32 	~AAIAttackManager(void);
33 
34 	void CheckAttack(AAIAttack *attack);
35 
36 	// true if units have sufficient combat power to face mobile units in dest
37 	bool SufficientCombatPowerAt(AAISector *dest, set<AAIGroup*> *combat_groups, float aggressiveness);
38 
39 	// true if combat groups have suffiecient attack power to face stationary defences
40 	bool SufficientAttackPowerVS(AAISector *dest, set<AAIGroup*> *combat_groups, float aggressiveness);
41 
42 	// true if defences have sufficient combat power to push back mobile units in dest
43 	bool SufficientDefencePowerAt(AAISector *dest, float aggressiveness);
44 
45 	void GetNextDest(AAIAttack *attack);
46 
47 	void Update();
48 private:
49 
50 	void LaunchAttack();
51 	void StopAttack(AAIAttack *attack);
52 
53 	// sends all groups to a rallypoint
54 	void RallyGroups(AAIAttack *attack);
55 
56 	list<AAIAttack*> attacks;
57 
58 	// array stores number of combat groups per category (for SufficientAttackPowerVS(..) )
59 	vector<int> available_combat_cat;
60 
61 	vector< list<AAIGroup*> > available_combat_groups_continent;
62 	vector< list<AAIGroup*> > available_aa_groups_continent;
63 
64 	list<AAIGroup*> available_combat_groups_global;
65 	list<AAIGroup*> available_aa_groups_global;
66 
67 	// stores total attack power for different unit types on each continent
68 	vector< vector<float> > attack_power_continent;
69 	vector<float> attack_power_global;
70 
71 	AAI *ai;
72 };
73 
74 #endif
75