initial commit, lordsawar source, slightly modified
[lordsawar] / src / AICityInfo.h
1 // Copyright (C) 2004 John Farrell
2 // Copyright (C) 2004, 2005 Ulf Lorenz
3 //
4 //  This program is free software; you can redistribute it and/or modify
5 //  it under the terms of the GNU General Public License as published by
6 //  the Free Software Foundation; either version 3 of the License, or
7 //  (at your option) any later version.
8 //
9 //  This program is distributed in the hope that it will be useful,
10 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 //  GNU Library General Public License for more details.
13 //
14 //  You should have received a copy of the GNU General Public License
15 //  along with this program; if not, write to the Free Software
16 //  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
17 //  02110-1301, USA.
18
19 #ifndef AICITYINFO_H
20 #define AICITYINFO_H
21
22 #include <string>
23 #include "city.h"
24 class Threatlist;
25 class Threat;
26
27 /** Class which contains some threat-related information about a city. It is
28   * used by the smart AI.
29   * 
30   * There are three important values:
31   * - danger is a rough estimate of the strength of the stacks that are close
32   *   to the city
33   * - reinforcements is an indicator of the strength of the troops that have
34   *   been assigned to protect the city
35   * - the Threatlist contains a list of all threats (usually stacks) that
36   *   endanger the city
37   *
38   *   See ai_smart.h for a comment about the smart AI.
39   */
40 class AICityInfo
41 {
42     public:
43         // CREATORS
44         AICityInfo(City *c);
45         ~AICityInfo();
46
47         //! record this threat as threatening this city
48         void addThreat(float dangerFromThisThreat, Threat *threat);
49
50         //! return the total danger to this city
51         float getDanger() const { return d_danger; }
52
53         //! return the total reinforcements allocated to this city
54         float getReinforcements() const { return d_reinforcements; }
55
56         //! advise that reinforcements have been sent to the city
57         void addReinforcements(float reinforcements) { d_reinforcements += reinforcements; }
58
59         //! return the threats to this city
60         Threatlist *getThreats() const { return d_threats; }
61
62         //! Returns the location of the city
63         Vector<int> getPos() const { return d_city->getPos(); }
64         
65         //! Get the number of armies in the city
66         int getDefenderCount() const { return d_num_defenders; }
67     private:
68         float d_danger;
69         float d_reinforcements;
70         Threatlist *d_threats;
71         City *d_city;
72         int d_num_defenders;
73 };
74
75 #endif // AICITYINFO_H
76
77 // End of file