Advanced Strategic Command
constructbuildingcommand.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 ConstructBuildingCommandH
23 #define ConstructBuildingCommandH
24 
25 #include "unitcommand.h"
26 
27 #include "../typen.h"
28 #include "../objects.h"
29 #include "../mapfield.h"
30 
31 
33 
34  public:
35  static bool avail ( const Vehicle* eht );
36  private:
37  MapCoordinate target;
38  int buildingTypeID;
39 
40  void fieldChecker( const MapCoordinate& pos );
41 
42  ConstructBuildingCommand( GameMap* map ) : UnitCommand( map ) {};
43  template<class Child> friend GameAction* GameActionCreator( GameMap* map);
44 
45  Resources getProductionCost( const BuildingType* bld ) const;
46 
47  protected:
48  void readData ( tnstream& stream );
49  void writeData ( tnstream& stream ) const;
50 
51  GameActionID getID() const;
52  ASCString getDescription() const;
53 
54  bool buildingFits( const MapCoordinate& entry );
55 
56  public:
58 
59  ActionResult go ( const Context& context );
61 
62 
63  class Lack {
64  int value;
65  public:
66  Lack() : value(0) {};
67  Lack( int value ) { this->value = value; };
68  enum Prerequisites { Energy = 1, Material = 2, Fuel = 4, Research = 8, Level = 0x10 };
69  bool ok() const { return value == 0 ; };
70  int getValue() const { return value; };
71  };
72 
74  public:
78  ProductionEntry() : type(NULL) {};
80  this->type = type;
81  this->cost = cost;
82  this->prerequisites = prerequisites;
83  }
84  };
85 
86  typedef vector<ConstructBuildingCommand::ProductionEntry> Producables;
89 
90 
91 
92  void setBuildingType( const BuildingType* type );
93 
94 
95  vector<MapCoordinate> getFields();
96  bool isFieldUsable( const MapCoordinate& pos );
97 
99 
100  void setTargetPosition( const MapCoordinate& pos );
101 };
102 
103 #endif
104 
ProductionEntry()
friend GameAction * GameActionCreator(GameMap *map)
Definition: action.h:114
vector< MapCoordinate > getFields()
int GameActionID
Definition: action.h:35
static bool avail(const Vehicle *eht)
bool buildingFits(const MapCoordinate &entry)
void setBuildingType(const BuildingType *type)
The interface for all kinds of IO stream.
UnitCommand(GameMap *map)
Definition: unitcommand.cpp:44
The ASCString class provides an abstract way to manipulate strings.
Definition: ascstring.h:14
ProductionEntry(const BuildingType *type, const Resources &cost, ConstructBuildingCommand::Lack prerequisites)
const BuildingType * type
ActionResult go(const Context &context)
The class describing properties that are common to all buildings of a certain kind.
Definition: buildingtype.h:35
vector< ConstructBuildingCommand::ProductionEntry > Producables
Coordinate on the twodimensional map.
Definition: typen.h:202
ConstructBuildingCommand::Lack prerequisites
bool isFieldUsable(const MapCoordinate &pos)
Resources cost
Lack buildingProductionPrerequisites(const BuildingType *type) const
An actual building on the map, which references a BuildingType Buildings have an owner,.
Definition: buildings.h:38
A GameAction is an modification of something on a map.
Definition: action.h:45
Resources are basically the currency of ASC.
Definition: typen.h:97
void setTargetPosition(const MapCoordinate &pos)
The map. THE central structure of ASC, which holds everything not globally available together...
Definition: gamemap.h:182
void writeData(tnstream &stream) const