00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include "planet.hpp"
00039 #include "dice.hpp"
00040
00047 static int correctedRoll(int dm,int j){
00048 int roll = ( d2d6() - dm ) + j ;
00049 return ( roll >= 0 ? roll : 0 ) ;
00050
00051 }
00052
00053 void planet::setPhysicalElements(){
00054 int ix;
00055
00056 physicalElements.s.diameter = d2d6() - 2;
00057 if ( physicalElements.s.diameter == 0 ) {
00058 physicalElements.s.atmosphere = 0;
00059 } else {
00060 physicalElements.s.atmosphere =
00061 correctedRoll(7,physicalElements.s.diameter);
00062 }
00063
00064 if ( physicalElements.s.diameter <= 1 ) {
00065 physicalElements.s.hydrosphere = 0;
00066 } else {
00067 ix = correctedRoll(7,physicalElements.s.diameter);
00068 if ( (physicalElements.s.atmosphere <= 1 ) ||
00069 ( physicalElements.s.atmosphere >= 10 ) )
00070 ix = ix - 4;
00071 ix = ( ix < 0 ? 0 : ix) ;
00072 ix = ( ix > 10 ? 10 : ix) ;
00073 physicalElements.s.hydrosphere = ix;
00074 }
00075 }
00076
00077
00078 planet::planet():orbitPlace(){
00079 this->setPhysicalElements();
00080 this->setSignature("planet");
00081 }
00082
00083 planet::planet(char *s) : orbitPlace(){
00084 this->setSignature(s);
00085 this->setPhysicalElements();
00086 }
00087
00088
00089 void planet::setDiameter(int d){
00090 physicalElements.s.diameter = ( d>= 0? d : 0 );
00091 }
00092
00093 int planet::getDiameter(){
00094 return physicalElements.s.diameter;
00095 }
00096
00097 void planet::setAtmosphere(int a){
00098 physicalElements.s.atmosphere = a;
00099 }
00100
00101 int planet::getAtmosphere(){
00102 return physicalElements.s.atmosphere;
00103 }
00104
00105 void planet::setHydrosphere(int h){
00106 physicalElements.s.hydrosphere = h;
00107 }
00108
00109 int planet::getHydrosphere(){
00110 return physicalElements.s.hydrosphere;
00111 }
00112
00113 void planet::setPopulation(int p){
00114 peopleElements.s.population = p;
00115 }
00116
00117 int planet::getPopulation(){
00118 return peopleElements.s.population;
00119 }
00120
00121 void planet::setGovernment(int g){
00122 peopleElements.s.government = g;
00123 }
00124
00125 int planet::getGovernment(){
00126 return peopleElements.s.government;
00127 }
00128
00129
00130 int planet::getLawlevel(){
00131 return peopleElements.s.lawlevel;
00132 }
00133
00134 void planet::setLawlevel (int l){
00135 peopleElements.s.lawlevel=l;
00136 }
00137
00138 void planet::setTechlevel(int t){
00139 techlevel = t;
00140 techlevel = ( techlevel < 0 ? 0 : techlevel );
00141
00142 }
00143
00144 int planet::getTechlevel(){
00145 return techlevel;
00146 }
00147
00148 void planet::setScoutBase(int f){
00149 scoutBase = (f != 0 ? 1:0);
00150 }
00151
00152 int planet::getScoutBase(){
00153 return scoutBase;
00154 }
00155
00156 void planet::setNavalBase(int f){
00157 navalBase = ( f != 0 ? 1:0);
00158 }
00159
00160 int planet::getNavalBase(){
00161 return navalBase;
00162 }
00163
00164 void planet::setSignature(char *s){
00165 signature = s;
00166 }
00167
00168 char* planet::getSignature(){
00169 return signature;
00170 }
00171
00172 void planet::genWBHData(){
00173 }
00174
00175 void planet::setSizeModifier(int s){
00176 size_details.modifier = s;
00177
00178 }
00179
00180
00181 int planet::getSizeModifier(){
00182 return size_details.modifier;
00183 }
00184
00185 void planet::setPlanetDensityType(int d){
00186 size_details.density_type=d;
00187 }
00188
00189 int planet::getPlanetDensityType(){
00190 return size_details.density_type;
00191 }
00192
00193 void planet::determinePlanetDensityType(){
00194 int dm=0;
00195
00196 if ( this->getDiameter() < 5 ) dm = 1;
00197 if ( this->getDiameter() > 5) dm = dm-2;
00198
00199 if ( this->getAtmosphere() < 4 ) dm = dm+1;
00200 if ( this->getAtmosphere() > 5 ) dm = dm-2;
00201
00202 switch(d2d6()){
00203 case 1:
00204 this->setPlanetDensityType(HEAVY_CORE);
00205 break;
00206 case 2:
00207 case 3:
00208 case 4:
00209 case 5:
00210 case 6:
00211 case 7:
00212 case 8:
00213 case 9:
00214 case 10:
00215 this->setPlanetDensityType(MOLTEN_CORE);
00216 break;
00217 case 11:
00218 case 12:
00219 case 13:
00220 case 14:
00221 this->setPlanetDensityType(ROCKY_BODY);
00222 break;
00223 default:
00224 this->setPlanetDensityType(ICY_BODY);
00225 break;
00226 };
00227 }
00228
00229 void planet::setPlanetDensity(double d){
00230 size_details.density=d;
00231
00232 }
00233
00234 double planet::getPlanetDensity(){
00235 return size_details.density;
00236 }
00237
00238 double density_table[15][4];
00239
00240 static int density_table_initialized=0;
00241
00242 static void initializeDensityTable(){
00243 int ix;
00244 int iy;
00245 double start_values[4]={1.10,0.82,0.50,0.18};
00246
00247 for(ix=0;ix<15;ix++){
00248 for(iy=0;iy<4;iy++){
00249 density_table[ix][iy]=start_values[iy];
00250 }
00254 if ( ix <= 10 ) start_values[0] = start_values[0] + 0.05;
00255 else start_values[0] = start_values[0] + 0.10;
00256 if ( ix == 15 ) start_values[0] = 2.25;
00257
00261 start_values[1] = start_values[1] + 0.02;
00262
00266 start_values[2] = start_values[2] + 0.02;
00267
00271 start_values[3] = start_values[3] + 0.02;
00272 }
00273 density_table_initialized=1;
00274 }
00275
00276
00277 void planet::calculatePlanetDensity(){
00278 if ( density_table_initialized == 0 )
00279 initializeDensityTable ();
00280 int rx = d2d6() + d1d6() - 3;
00281 this->setPlanetDensity(density_table[rx][this->getPlanetDensityType()-1]);
00282
00283
00284 }
00285
00286 void planet::calculatePlanetMass(){
00287 double mass;
00288
00289 mass = ( ( this->getDiameter() == 0 ? 0.8 : (double) this->getDiameter()) / 8 ) ;
00290 mass = mass * mass * mass;
00291 mass = this->getPlanetDensity() * mass;
00292
00293 size_details.mass = mass;
00294
00295 }