Advanced Strategic Command
attackcommand.h
Go to the documentation of this file.
1 /*
2  This file is part of Advanced Strategic Command; http://www.asc-hq.de
3  Copyright (C) 1994-2010 Martin Bickel and Marc Schellenberger
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; see the file COPYING. If not, write to the
17  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18  Boston, MA 02111-1307 USA
19 */
20 
21 
22 #ifndef AttackCommandH
23 #define AttackCommandH
24 
25 #include "unitcommand.h"
26 
27 #include "../typen.h"
28 #include "../attack.h"
29 
30 class AttackCommand : public UnitCommand {
31 
32  public:
33  static bool avail ( Vehicle* eht );
34  typedef map<MapCoordinate,AttackWeap > FieldList;
35 
36  private:
37  MapCoordinate target;
38  int targetUnitID;
39  MapCoordinate targetBuilding;
40  int weapon;
41 
42  bool kamikaze;
43 
44  void fieldChecker( const MapCoordinate& pos );
45 
46  FieldList attackableUnits;
47  vector<MapCoordinate> attackableUnitsKamikaze;
48  FieldList attackableBuildings;
49  FieldList attackableObjects;
50 
51 
52  AttackCommand( GameMap* map ) : UnitCommand( map ) {};
53  template<class Child> friend GameAction* GameActionCreator( GameMap* map);
54 
55  protected:
56  void readData ( tnstream& stream );
57  void writeData ( tnstream& stream ) const;
58 
59  GameActionID getID() const;
60  ASCString getDescription() const;
61 
62  public:
63  AttackCommand ( Vehicle* unit );
65 
66  Vehicle* getAttacker() { return getUnit(); };
67 
68  void setTarget( const MapCoordinate& target, int weapon = -1 );
69  ActionResult go ( const Context& context );
71 
72  const FieldList& getAttackableUnits() { return attackableUnits; };
73  const FieldList& getAttackableBuildings() { return attackableBuildings; };
74  const FieldList& getAttackableObjects() { return attackableObjects; };
75 
76 };
77 
78 #endif
79 
GameActionID getID() const
int GameActionID
Definition: action.h:35
map< MapCoordinate, AttackWeap > FieldList
Definition: attackcommand.h:34
void writeData(tnstream &stream) const
friend GameAction * GameActionCreator(GameMap *map)
Definition: action.h:114
The interface for all kinds of IO stream.
The ASCString class provides an abstract way to manipulate strings.
Definition: ascstring.h:14
const FieldList & getAttackableObjects()
Definition: attackcommand.h:74
ActionResult go(const Context &context)
void readData(tnstream &stream)
Coordinate on the twodimensional map.
Definition: typen.h:202
const FieldList & getAttackableBuildings()
Definition: attackcommand.h:73
ASCString getDescription() const
static bool avail(Vehicle *eht)
const FieldList & getAttackableUnits()
Definition: attackcommand.h:72
Vehicle * getAttacker()
Definition: attackcommand.h:66
ASCString getCommandString() const
A GameAction is an modification of something on a map.
Definition: action.h:45
ActionResult searchTargets()
void setTarget(const MapCoordinate &target, int weapon=-1)
const Vehicle * getUnit() const
Definition: unitcommand.cpp:26
The map. THE central structure of ASC, which holds everything not globally available together...
Definition: gamemap.h:182