Advanced Strategic Command
consumeammo.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 consumeAmmoH
23 #define consumeAmmoH
24 
25 
26 #include "containeraction.h"
27 
28 
29 class ConsumeAmmo : public ContainerAction {
30  int ammoType;
31  int slot;
32  int count;
33 
34  int resultingAmmount;
35 
36  bool produceAmmo;
37  int produced;
38 
39  ConsumeAmmo( GameMap* map ) : ContainerAction( map ), produceAmmo(false), produced(0) {};
40  template<class Child> friend GameAction* GameActionCreator( GameMap* map);
41 
46  int produce( int num, const Context& context, bool queryOnly );
47 
48  public:
49  ConsumeAmmo( ContainerBase* veh, int ammoType, int slot, int count );
50 
51  ASCString getDescription() const;
52 
55  void setAmmoProduction( bool prod );
56 
57  protected:
58  virtual GameActionID getID() const;
59 
60  virtual ActionResult runAction( const Context& context );
61  virtual ActionResult undoAction( const Context& context );
62  virtual ActionResult postCheck();
63 
64  virtual void readData ( tnstream& stream );
65  virtual void writeData ( tnstream& stream ) const;
66 
67 };
68 
69 #endif
70 
virtual void readData(tnstream &stream)
Definition: consumeammo.cpp:56
int GameActionID
Definition: action.h:35
virtual void writeData(tnstream &stream) const
Definition: consumeammo.cpp:82
The interface for all kinds of IO stream.
virtual GameActionID getID() const
The ASCString class provides an abstract way to manipulate strings.
Definition: ascstring.h:14
virtual ActionResult postCheck()
postCheck is called after an action has been redone and should check that the state of the map is exa...
void setAmmoProduction(bool prod)
specifies if ammo shall be produced if there is not enough ammo available and the container has ammo ...
Definition: consumeammo.cpp:94
virtual ActionResult runAction(const Context &context)
ContainerAction(ContainerBase *container)
virtual ActionResult undoAction(const Context &context)
The parent class of Vehicle and Building; The name Container originates from Battle Isle...
Definition: containerbase.h:40
A GameAction is an modification of something on a map.
Definition: action.h:45
friend GameAction * GameActionCreator(GameMap *map)
Definition: action.h:114
ASCString getDescription() const
Definition: consumeammo.cpp:43
The map. THE central structure of ASC, which holds everything not globally available together...
Definition: gamemap.h:182