initial commit, lordsawar source, slightly modified
[lordsawar] / src / AICityInfo.cpp
1 // Copyright (C) 2004 John Farrell
2 //
3 //  This program is free software; you can redistribute it and/or modify
4 //  it under the terms of the GNU General Public License as published by
5 //  the Free Software Foundation; either version 3 of the License, or
6 //  (at your option) any later version.
7 //
8 //  This program is distributed in the hope that it will be useful,
9 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 //  GNU Library General Public License for more details.
12 //
13 //  You should have received a copy of the GNU General Public License
14 //  along with this program; if not, write to the Free Software
15 //  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
16 //  02110-1301, USA.
17
18 #include "AICityInfo.h"
19 #include "Threatlist.h"
20 #include "Threat.h"
21 #include "city.h"
22
23 using namespace std;
24
25 //#define debug(x) {cerr<<__FILE__<<": "<<__LINE__<<": "<<x<<flush<<endl;}
26 #define debug(x)
27
28 AICityInfo::AICityInfo(City *c)
29     :d_danger(0), d_reinforcements(0), d_city(c)
30 {
31     d_threats = new Threatlist();
32     d_num_defenders = d_city->countDefenders();
33 }
34
35 AICityInfo::~AICityInfo()
36 {
37     // the threats in the threatlist do not belong to us
38     d_threats->clear();
39     delete d_threats;
40 }
41
42 void AICityInfo::addThreat(float dangerFromThisThreat, Threat *threat)
43 {
44     this->d_danger += dangerFromThisThreat;
45     this->d_threats->push_back(threat);
46 }
47