constructbuildingcommand.h

Go to the documentation of this file.
00001 /*
00002      This file is part of Advanced Strategic Command; http://www.asc-hq.de
00003      Copyright (C) 1994-2010  Martin Bickel  and  Marc Schellenberger
00004  
00005      This program is free software; you can redistribute it and/or modify
00006      it under the terms of the GNU General Public License as published by
00007      the Free Software Foundation; either version 2 of the License, or
00008      (at your option) any later version.
00009  
00010      This program is distributed in the hope that it will be useful,
00011      but WITHOUT ANY WARRANTY; without even the implied warranty of
00012      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013      GNU General Public License for more details.
00014  
00015      You should have received a copy of the GNU General Public License
00016      along with this program; see the file COPYING. If not, write to the 
00017      Free Software Foundation, Inc., 59 Temple Place, Suite 330, 
00018      Boston, MA  02111-1307  USA
00019 */
00020 
00021 
00022 #ifndef ConstructBuildingCommandH
00023 #define ConstructBuildingCommandH
00024 
00025 #include "unitcommand.h"
00026 
00027 #include "../typen.h"
00028 #include "../objects.h"
00029 #include "../mapfield.h"
00030 
00031 
00032 class ConstructBuildingCommand : public UnitCommand {
00033    
00034    public:
00035       static bool avail ( const Vehicle* eht );
00036    private:
00037       MapCoordinate target;
00038       int buildingTypeID;
00039       
00040       void fieldChecker( const MapCoordinate& pos );
00041       
00042       ConstructBuildingCommand( GameMap* map ) : UnitCommand( map ) {};
00043       template<class Child> friend GameAction* GameActionCreator( GameMap* map);
00044       
00045       Resources getProductionCost( const BuildingType* bld ) const;
00046       
00047    protected:
00048       void readData ( tnstream& stream );
00049       void writeData ( tnstream& stream ) const;
00050       
00051       GameActionID getID() const;
00052       ASCString getDescription() const;
00053       
00054       bool buildingFits( const MapCoordinate& entry );
00055       
00056    public:
00057       ConstructBuildingCommand ( Vehicle* unit );
00058       
00059       ActionResult go ( const Context& context ); 
00060       ASCString getCommandString() const;
00061       
00062       
00063       class Lack {
00064           int value;
00065          public:
00066             Lack() : value(0) {};
00067             Lack( int value ) { this->value = value; };
00068             enum Prerequisites { Energy = 1, Material = 2, Fuel = 4, Research = 8, Level = 0x10 };
00069             bool ok() const { return value == 0 ; };
00070             int getValue() const { return value; };
00071       };
00072       
00073       class ProductionEntry {
00074          public:
00075             const BuildingType* type;
00076             Resources cost;
00077             ConstructBuildingCommand::Lack prerequisites;
00078             ProductionEntry() : type(NULL) {};
00079             ProductionEntry(const BuildingType* type, const Resources& cost, ConstructBuildingCommand::Lack prerequisites ) {
00080                this->type = type;
00081                this->cost = cost;
00082                this->prerequisites = prerequisites;
00083             }
00084       };
00085       
00086       typedef vector<ConstructBuildingCommand::ProductionEntry> Producables;
00087       Lack buildingProductionPrerequisites( const BuildingType* type ) const;
00088       Producables getProduceableBuildings();
00089       
00090       
00091       
00092       void setBuildingType( const BuildingType* type );
00093       
00094       
00095       vector<MapCoordinate> getFields();
00096       bool isFieldUsable( const MapCoordinate& pos );
00097       
00098       Building* getProducedBuilding();
00099       
00100       void setTargetPosition( const MapCoordinate& pos );
00101 };
00102 
00103 #endif
00104 

Generated on Mon May 21 01:26:30 2012 for Advanced Strategic Command by  doxygen 1.5.1