Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals

parameters.h

Go to the documentation of this file.
00001 /*
00002          _/_/_/     _/_/_/   _/_/_/_/    _/_/_/    _/    _/  _/_/_/_/ _/_/_/_/    _/_/_/   _/_/_/_/
00003         _/    _/  _/    _/  _/     _/  _/     _/  _/    _/  _/       _/     _/  _/    _/  _/     _/
00004        _/    _/  _/    _/  _/     _/  _/     _/  _/    _/  _/       _/     _/  _/    _/  _/     _/
00005       _/_/_/    _/    _/  _/_/_/_/   _/     _/  _/    _/  _/_/_/   _/_/_/_/   _/    _/  _/_/_/_/
00006      _/     _/ _/    _/  _/  _/     _/     _/  _/    _/  _/       _/  _/     _/    _/  _/  _/
00007     _/     _/ _/    _/  _/   _/    _/   _/_/  _/    _/  _/       _/   _/    _/    _/  _/   _/
00008    _/     _/ _/    _/  _/    _/     _/_/_/   _/    _/  _/       _/    _/   _/    _/  _/    _/
00009   _/_/_/_/   _/_/_/   _/     _/         _/   _/_/_/   _/_/_/_/ _/     _/   _/_/_/   _/     _/
00010 
00011   \author Hannosset Christophe
00012   \date 2 - Nov - 2003
00013 */
00014 
00015 #if !defined( __PARAMETERS_H__ )
00016 #define __PARAMETERS_H__
00017 
00018 class Random;
00019 
00020 class PDiscrete : public vector<DiscreteProba *>        {
00021 public:
00022         void Setup( icstring s , const int qte = 1000 )
00023         {
00024                 vector<double>  vect;
00025                 double  sum = 0.0;
00026                 while( !s.empty() )
00027                 {
00028                         double  d = Rsrc::GetDbl( s );
00029                         sum += d;
00030                         vect.push_back( d );
00031                 }
00032                 if( sum > 0 && sum != 1.0 )
00033                         for( vector<double>::iterator it = vect.begin() ; it != vect.end() ; ++it )
00034                                 *it /= sum;
00035                 DiscreteProba   *p = new DiscreteProba;
00036                 if( sum > 0 )
00037                         p->Setup( vect , vect.size() , qte );
00038                 push_back( p );
00039         }
00040 
00041         ~PDiscrete( void )
00042         {
00043                 for( vector<DiscreteProba *>::iterator it = begin() ; it != end() ; ++it )
00044                         delete (*it);
00045                 clear();
00046         }
00047 };
00048 
00049 class StarInfo : public PDiscrete       {
00050 public:
00051 
00052         string  name;
00053         int     sid;
00054         int     temperature;
00055         int     age;
00056         int     ssize;
00057         
00058         string  classInf , ageInf , temInf , exInf , descrInf;
00059         int     ageSection;
00060         ProbaHolder     *nrPlanets;
00061         
00062         StarInfo( void )
00063         : nrPlanets( 0 )
00064         {}
00065 
00066         ~StarInfo( void )
00067         {
00068                 if( nrPlanets )
00069                         delete nrPlanets;
00070                 nrPlanets = 0;
00071         }
00072 
00073         inline const bool IsId( const int *aId )        {       return (sid << 8 | ssize) == *aId;      }
00074 };
00075 
00076 class PlanetInfo : public vector<int>   {
00077 public:
00078 
00079         int     id;
00080         string  surface , type , athmosphere , lifeForm , Description , example;
00081         int     sizeMin , sizeMax;
00082         int     ageMin , ageMax;
00083         int     tempMin , tempMax;
00084         vector<int>     become;
00085         ProbaHolder     *delta;
00086         int     soil[2] , humidity[2] , surfaceTemperature[2] , atmPressure[2] , ore[2] , energy[2] , fauna[2] , flora[2] , lithium[2] , deuterium[2] , water[2];
00087         
00088         PlanetInfo( void )  : delta( 0 )        {}
00089 
00090         ~PlanetInfo( void )     
00091         {
00092                 if( delta )
00093                         delete delta;
00094                 delta = 0;
00095         }
00096 
00097         double GetAbsValueOf( const int arr[2] )        {       return max( 0.0 , GetValueOf( arr ) );  }
00098         double GetValueOf( const int arr[2] )   {       return arr[0] + delta->Next( arr[1] ) - arr[1] / 2.0;   }
00099 };
00100 
00101 class EcoZone : public vector<int>      {
00102 public:
00103         int     sunTemp;
00104 };
00105 
00106 class Planet;
00107 
00108 class SpeciesInfo       {
00109 public:
00110 
00111         icstring        name;
00112         RGBColor        color;
00114         int     humidity , surfaceTemperature , atmPressure;
00115 
00117         int     powerPotential , industryPotential , farmingPotential , medicalPotential;
00118 
00123         int     combatTactic , combatNavigation , combatCommunication;
00124 
00126         int     economy;
00127         int transfertEffisciency;
00128         int     diplomacy;
00129         int     research;
00130         int     sociology;      
00131 
00132         double  residue;
00133         Planet  *hwPlanet;
00134         SpeciesInfo( void ) : hwPlanet( 0 ) , residue( 1000 ) , color( 0 , 0 , 0 )      {}
00135 
00136         const bool IsSpecies( const char *aSpecies ) const {    return name == aSpecies;        }
00137 };
00138 
00139 class Parameters : public BqBase        {
00140 private:
00141         
00142         Rsrc    res;
00143 
00144         vector<string>  img2Size , img2Shape , img2Age;
00145         set<string>     xstNames;
00146         int     ans;
00147 
00148         vector<pair<XPoint, bool> >     xy4Shape;
00149 public:
00150 
00151         unsigned int    parSize , parShape , parAge , nrAliens;
00152 
00153         Parameters( Window *aParent );
00154 
00155         ~Parameters( void );
00156 
00157         static double   ratio;
00158 
00159         static vector<StarInfo *>       starInfo;
00160         static map<int,int>     SIFromSunSize;
00161         static void SetupStarInfo( void );
00162         static void ResetInfo( void );
00163 
00165         static vector<PlanetInfo *> planetInfo;
00166         static map<int,PlanetInfo *> plIndice;
00167         static void SetupPlanetInfo( void );
00168 
00169         static vector<string>   starName;
00170         static void LoadStarsName( void );
00171 
00172         static vector<pair<int , int> > planetSize;
00173         static map<int,string>  sizeStr;
00174         static map<icstring , vector<double> >  compensator;
00175         static void SetupPlanetSize( void );
00176 
00177         static vector<EcoZone *>        ecoZones;
00178         static void SetupEcoZones( void );
00179 
00180         static map<icstring,SpeciesInfo *>      species;
00181         static vector<SpeciesInfo *> allSpecies;
00182         static void SetupSpecies( void );
00183 
00184         static string GetDenomination( const XPoint &p2 , const int StarType , const int StarSize , const int nrPlanets , const int gx , const int gy );
00185 
00186 private:
00187 
00188         void UpdateParameters( void );
00189 
00190         void CreateGalaxy( void );
00191 
00192         void GetStarName( const double sqSize , const XPoint &p , string &starName , string &StarDescr );
00193 
00194         int GenPosition( void );
00195 
00196         EcoZone *GetEcoZone( const int sunTemperature );
00197         const int RestrictWithSize( const int atSize , vector<PlanetInfo *> &v );
00198         const int RestrictToZone( const int ez , vector<PlanetInfo *> &v );
00199         const int RestrictWithAge( const int sunAge , vector<PlanetInfo *> &v );
00200 
00201 protected:
00202 
00203         virtual void InitDialog( void );
00204 
00205         virtual const bool SetupWindow( const Message &msg );
00206 
00208         virtual const bool MainLoop( void );
00209 
00210         virtual const bool evMouseLClick( const CtrlMessage &msg );
00211 
00212         virtual const bool evValueChange( const CtrlMessage &msg );
00213         virtual const bool evValueChanging( const CtrlMessage &msg );
00214 };
00215 
00216 #endif

Generated on Fri Dec 5 04:06:00 2003 for Borqueror by doxygen 1.3.3