Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

resourcenet.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                           resourcenet.cpp  -  description
00003                              -------------------
00004     begin                : Tue Jan 28 2001
00005     copyright            : (C) 2001 by Martin Bickel
00006     email                : bickel@asc-hq.org
00007  ***************************************************************************/
00008 
00013 /***************************************************************************
00014  *                                                                         *
00015  *   This program is free software; you can redistribute it and/or modify  *
00016  *   it under the terms of the GNU General Public License as published by  *
00017  *   the Free Software Foundation; either version 2 of the License, or     *
00018  *   (at your option) any later version.                                   *
00019  *                                                                         *
00020  ***************************************************************************/
00021 
00022 
00023 #ifndef resourcenetH
00024  #define resourcenetH
00025 
00026 #include "gamemap.h"
00027 
00029 class MapNetwork {
00030                 static int instancesrunning;
00031              protected:
00032                 GameMap* actmap;
00033                 int pass;
00034 
00035                 MapCoordinate startposition;
00036 
00037                 virtual int fieldavail ( int x, int y ) = 0;
00038                 virtual int searchfinished ( void ) = 0;
00039                 virtual void checkvehicle ( Vehicle* v ) = 0;
00040                 virtual void checkbuilding ( Building* b ) = 0;
00041                 virtual int globalsearch ( void ) = 0;
00042 
00043                 virtual void searchbuilding ( int x, int y );
00044                 virtual void searchvehicle  ( int x, int y );
00045                 virtual void searchfield ( int x, int y, int dir );
00046                 void searchAllVehiclesNextToBuildings ( int player );
00047              public:
00048                 enum Scope { singleField, net, wholeMap, globalPool };
00049                 virtual void start ( int x, int y );
00050                 MapNetwork ( GameMap* gamemap, int checkInstances = 1 );
00051                 virtual ~MapNetwork();
00052            };
00053 
00054 class ResourceNet : public MapNetwork {
00055                public:
00056                   ResourceNet ( GameMap* gamemap, int _scope = -1 ) : MapNetwork ( gamemap, _scope != 0 ), resourcetype(-1), scope(_scope) {};
00057                protected:
00058                   int resourcetype;
00059                   int scope;
00060 
00061                   virtual int fieldavail ( int x, int y );
00062                   virtual int globalsearch ( void ) { return scope; };
00063              };
00064 
00065 class GetConnectedBuildings : public ResourceNet {
00066                 protected:
00067                    void checkvehicle ( Vehicle* v ) {};
00068                    void checkbuilding ( Building* b ) { buildingContainer.push_back ( b ); };
00069                    int searchfinished ( void ) { return false; };
00070 
00071                 public:
00072                    typedef vector<Building*> BuildingContainer;
00073                    BuildingContainer& buildingContainer;
00074                    GetConnectedBuildings ( BuildingContainer& buildingContainer_, GameMap* gamemap, int resourceType ) : ResourceNet ( gamemap, gamemap->isResourceGlobal(resourceType)?2:1), buildingContainer ( buildingContainer_) { resourcetype = 0; };
00075 };
00076 
00077 class StaticResourceNet : public ResourceNet {
00078                protected:
00079                   int need;
00080                   int got;
00081                   int queryonly;
00082                   int player;
00083 
00084                   virtual int searchfinished ( void );
00085 
00086               public:
00087                   StaticResourceNet ( GameMap* gamemap, int scope = -1 ) : ResourceNet ( gamemap, scope ) {};
00088                   int getresource ( int x, int y, int resource, int _need, int _queryonly, int _player, int _scope );
00089                        /* _scope:  0 : only this field
00090                                    1 : net
00091                                    2 : global
00092                        */
00093        };
00094 
00095 class GetResource : public StaticResourceNet {
00096               protected:
00097                   int tributegot[3][8];
00098                   virtual void checkvehicle ( Vehicle* v );
00099                   virtual void checkbuilding ( Building* b );
00100                   virtual void start ( int x, int y );
00101               public:
00102                   GetResource ( GameMap* gamemap, int scope = -1 );
00103    };
00104 
00105 class PutResource : public StaticResourceNet {
00106               protected:
00107                   virtual void checkbuilding ( Building* b );
00108                   virtual void checkvehicle ( Vehicle* v ) {};
00109                   virtual void start ( int x, int y );
00110                public:
00111                    PutResource ( GameMap* gamemap, int scope = -1 ) : StaticResourceNet ( gamemap, scope ) {};
00112    };
00113 
00114 class PutTribute : public StaticResourceNet {
00115               protected:
00116                   int targplayer;
00117                   Building* startbuilding;
00118                   virtual void checkbuilding ( Building* b );
00119                   virtual void checkvehicle ( Vehicle* v ) {};
00120                   virtual void start ( int x, int y );
00121               public:
00122                   PutTribute ( GameMap* gamemap ) : StaticResourceNet( gamemap ) {};
00123                   int puttribute ( Building* start, int resource, int _queryonly, int _forplayer, int _fromplayer, int _scope );
00124    };
00125 
00126 
00127 class GetResourceCapacity : public StaticResourceNet {
00128               protected:
00129                   virtual void checkbuilding ( Building* b );
00130                   virtual void checkvehicle ( Vehicle* v ) {};
00131                   virtual void start ( int x, int y );
00132                   virtual int searchfinished ( void ) { return 0; };
00133               public:
00134                   GetResourceCapacity( GameMap* gamemap ) : StaticResourceNet ( gamemap ) {};
00135    };
00136 
00137 class ResourceChangeNet : public ResourceNet {
00138                protected:
00139                   int got;
00140                   int player;
00141 
00142                   virtual int searchfinished ( void ) { return 0; };
00143 
00144               public:
00145                   int getresource ( int x, int y, int resource, int _player, int _scope );
00146                        /* _scope:  0 : only this field
00147                                    1 : net
00148                                    2 : global
00149                        */
00150                   ResourceChangeNet ( GameMap* gamemap ) : ResourceNet ( gamemap ) {};
00151 
00152        };
00153 
00154 
00155 class GetResourcePlus : public ResourceChangeNet {
00156               protected:
00157                   virtual void checkbuilding ( Building* b );
00158                   virtual void checkvehicle ( Vehicle* v );
00159               public:
00160                   GetResourcePlus ( GameMap* gamemap ) : ResourceChangeNet ( gamemap ) {};
00161    };
00162 
00163 class GetResourceUsage : public ResourceChangeNet {
00164               protected:
00165                   virtual void checkbuilding ( Building* b );
00166                   virtual void checkvehicle ( Vehicle* v ) {};
00167               public:
00168                   GetResourceUsage ( GameMap* gamemap ) : ResourceChangeNet ( gamemap ) {};
00169    };
00170 
00171 extern void transfer_all_outstanding_tribute( Player& player );
00172 
00173 extern SigC::Signal0<void> tributeTransferred;
00174 
00175 extern bool compareMapResources( GameMap* currentMap, GameMap* replaymap, int player, ASCString* log );
00176 
00177 
00178 #endif

Generated on Tue Jun 24 01:27:51 2008 for Advanced Strategic Command by  doxygen 1.4.2