Advanced Strategic Command
discoverresources.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 DiscoverResourcesH
23 #define DiscoverResourcesH
24 
25 
26 #include "unitaction.h"
27 
28 #include "../typen.h"
29 #include "../mapfield.h"
30 
31 class DiscoverResources : public UnitAction {
32  public:
34  public:
36  ResourceViewState( const MapField* fld, int player ) { initFromField( fld, player ); };
38  int fuel;
39  int material;
40  bool visible;
41  int player;
42  void read ( tnstream& stream ) ;
43  void write ( tnstream& stream ) const;
44  void initFromField( const MapField* fld, int player );
45  void writeToField( MapField* fld );
46  };
47  typedef vector<ResourceViewState> ViewState;
48  DiscoverResources( Vehicle* unit );
49 
50 
51  ASCString getDescription() const;
52  private:
53  ViewState newState;
54  ViewState oldState;
55  int shareview;
56 
57  void testField( const MapCoordinate& pos );
58 
59  DiscoverResources( GameMap* map ) : UnitAction( map ) {};
60  template<class Child> friend GameAction* GameActionCreator( GameMap* map);
61 
62  protected:
63  virtual GameActionID getID() const;
64 
65  virtual ActionResult runAction( const Context& context );
66  virtual ActionResult undoAction( const Context& context );
67 
68  virtual void readData ( tnstream& stream );
69  virtual void writeData ( tnstream& stream ) const;
70 
71 };
72 
73 #endif
74 
virtual GameActionID getID() const
void initFromField(const MapField *fld, int player)
int GameActionID
Definition: action.h:35
virtual ActionResult runAction(const Context &context)
ASCString getDescription() const
virtual void writeData(tnstream &stream) const
The interface for all kinds of IO stream.
a single field of the map
Definition: mapfield.h:26
virtual void readData(tnstream &stream)
The ASCString class provides an abstract way to manipulate strings.
Definition: ascstring.h:14
ResourceViewState(const MapField *fld, int player)
Coordinate on the twodimensional map.
Definition: typen.h:202
friend GameAction * GameActionCreator(GameMap *map)
Definition: action.h:114
virtual ActionResult undoAction(const Context &context)
A GameAction is an modification of something on a map.
Definition: action.h:45
DiscoverResources(Vehicle *unit)
void write(tnstream &stream) const
vector< ResourceViewState > ViewState
The map. THE central structure of ASC, which holds everything not globally available together...
Definition: gamemap.h:182