src/b1-navy-person.cpp

00001 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
00002 /*
00003  * 
00004  * $Id: b1-navy-person.cpp,v 1.4 2008/02/21 21:33:58 plankowner Exp $
00005  * 
00006  * $Log: b1-navy-person.cpp,v $
00007  * Revision 1.4  2008/02/21 21:33:58  plankowner
00008  * checkpoint, mega-stuff added
00009  *
00010  * Revision 1.3  2008/02/16 04:21:18  plankowner
00011  * Fleshed out book 1 army and marine characters
00012  *
00013  * Revision 1.2  2008/02/14 21:37:25  plankowner
00014  * Added more skeleton structure to this project. Corrected some issues
00015  * with string handling in a couple of the modules.
00016  *
00017  * Revision 1.1  2008/01/31 19:41:23  plankowner
00018  * Book 1 style people started with Navy characters first.
00019  *
00020  * 
00021  * frpuniverse
00022  * Copyright (C) Peter L. Berghold 2008 <Peter@Berghold.net>
00023  * 
00024  * frpuniverse is free software.
00025  * 
00026  * You may redistribute it and/or modify it under the terms of the
00027  * GNU General Public License, as published by the Free Software
00028  * Foundation; either version 2 of the License, or (at your option)
00029  * any later version.
00030  * 
00031  * frpuniverse is distributed in the hope that it will be useful,
00032  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00033  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00034  * See the GNU General Public License for more details.
00035  * 
00036  * You should have received a copy of the GNU General Public License
00037  * along with frpuniverse.  If not, write to:
00038  *      The Free Software Foundation, Inc.,
00039  *      51 Franklin Street, Fifth Floor
00040  *      Boston, MA  02110-1301, USA.
00041  */
00042 
00043 #include "b1-navy-person.hpp"
00044 #include "dice.hpp"
00045 
00046 b1NavyPerson::b1NavyPerson():book1Person(){
00047                 
00048                 
00049                 
00050                 this->enlist();
00051 };
00052 
00053 
00054 
00055 
00056 void b1NavyPerson::enlist(){
00057         int dm=0;
00058         int skill_rolls=0;
00059         this->setService("Navy");
00060         
00061         if ( this->getIntelligence() > 7 ) 
00062                 dm = 1; 
00063         if ( this->getEducation() > 8 ) 
00064                 dm = dm + 2;
00065         if ( (d2d6()+dm) > 7 ) {
00066                 this->setAccepted(1);
00067         } else {
00068                 this->setAccepted(0);
00069                 return ;
00070         }
00071         this->setTerms(1);
00072         while(1){ // while 
00073                 if ( this->getTerms() == 1 ) { // if
00074                         skill_rolls=2;
00075                 } else {
00076                         skill_rolls=1;
00077                 } //end-if
00078                 
00079                 // Determine Survival
00080                 //
00081                 dm=0;
00082                 if ( this->getIntelligence() > 6) 
00083                         dm = 2;
00084                 if ( (d2d6()+dm) > 4 ) {
00085                         // this->setTerms(this->getTerms()+1);
00086                         this->setAge( this->getAge()+4);
00087                 } else {
00088                         this->setAlive(0);
00089                         return;
00090                 }
00091                 
00092                 // Check to see if commissioned either already or now.
00093                 // if already commissioned check for promotion.
00094                 
00095                 if ( this->getCommissioned() == 1 ) {
00096                         dm = ( this->getEducation() > 7 ? 1:0);
00097                         if ( (d2d6()+dm) > 7 ) {
00098                                 this->setRank(this->getRank()+1);  // promotion of an officer.
00099                                 if ( (this->getRank() == 5) || 
00100                                         (this->getRank() == 6 ) ) {
00101                                                 this->incrementSocialStanding(1);
00102                                         }
00103                                 
00104                                         
00105                                 skill_rolls++;
00106                         }
00107                 } else {
00108                         dm = ( this->getSocialStanding() > 8 ? 1 : 0 ) ;
00109                         // Roll to see if they get commissioned. 
00110                         if ( (d2d6()+dm)>9 ){
00111                                 this->setCommissioned(1);
00112                                 this->setRank(1);
00113                                 dm = ( this->getEducation() > 7 ? 1:0);
00114                                 skill_rolls++;
00115                         
00116                                 if ( (d2d6()+dm) > 7 ) {
00117                                         this->setRank(this->getRank()+1);  // promotion of an officer. 
00118                                         skill_rolls++;
00119                                 }
00120                         }
00121                         
00122                 }
00123                 
00124                 this->skillTables(skill_rolls);
00125                 
00126                 // I've imposed my own DMS for sanity sake since I don't want people
00127                 // managing to be in for 60 terms like some trial runs had. 
00128                 dm=0;
00129                 if ( this->getTerms() > 5 ) {
00130                         dm = this->getTerms() - 5; 
00131                 }
00132                 if ( this->getAge() > 50 ) {
00133                         dm = dm + (this->getAge()/10);
00134                 }
00135                 int re_enlisted=0;
00136                 
00137                 if ( (d2d6() - dm) > 5 ) {
00138                         this->setTerms(this->getTerms()+1);
00139                         re_enlisted=1;
00140                 }
00141                         
00142                 // A couple of sanity checks:
00143                 if ( this->getRank() > 6) this->setRank(6);
00144                 if ( re_enlisted != 1 ) {
00145                         this->musterOut();
00146                         return;
00147                 }
00148                 
00149                         
00150         }
00151         
00152 }
00153 
00154 
00155 void b1NavyPerson::skillTables(int nrolls){
00156         // There are 4 different skill tables to deal with here...
00157         // 3 of which are in play when education < 8 and all 4 are 
00158         // in play for education >= 8 
00159         
00160 
00161         int roll;
00162         for(roll=1;roll<=nrolls;roll++){
00163                 if ( this->getEducation() < 8 ) {
00164                         switch(d1d6()){
00165                                 case 1:
00166                                 case 2:
00167                                         this->skillTable1();
00168                                         break;
00169                                 case 3:
00170                                 case 4:
00171                                         this->skillTable2();
00172                                         break;
00173                                 case 5:
00174                                 case 6:
00175                                         this->skillTable3();
00176                                         break;
00177                         };
00178                 } else {
00179                         switch(d2d6()){
00180                                 case 1:
00181                                         this->skillTable1();
00182                                         break;
00183                                 case 2:
00184                                 case 3:
00185                                         this->skillTable2();
00186                                         break;
00187                                 case 4: 
00188                                 case 5:
00189                                         this->skillTable3();
00190                                         break;
00191                                 case 6:
00192                                         this->skillTable4();
00193                                         break;
00194                         };
00195                         
00196                 }
00197                 
00198         }
00199         
00200         
00201 }
00202 
00203 void b1NavyPerson::skillTable1(){
00204         this->incrementAttribute(d1d6()-1,1);
00205 }
00206 
00207 void b1NavyPerson::skillTable2(){
00208         switch(d1d6()){
00209                 case 1:
00210                         this->addSkill(SHIP_S_BOAT,1);
00211                         break;
00212                 case 2:
00213                         this->addSkill(VACC_SUIT,1);
00214                         break;
00215                 case 3:
00216                         this->addSkill(FORWARD_OBSERVER,1);
00217                         break;
00218                 case 4:
00219                         this->addSkill(GUNNERY,1);
00220                         break;
00221                 case 5:
00222                         this->addSkill(BLADE_COMBAT,1);
00223                         break;
00224                 case 6:
00225                         this->addSkill(GUN_COMBAT,1);
00226                         break;
00227         }
00228         
00229 }
00230 
00231 void b1NavyPerson::skillTable3(){
00232         switch(d1d6()){
00233                 case 1:
00234                         this->addSkill(VACC_SUIT,1);
00235                         break;
00236                 case 2:
00237                         this->addSkill(MECHANICAL,1);
00238                         break;
00239                 case 3:
00240                         this->addSkill(ELECTRONICS,1);
00241                         break;
00242                 case 4:
00243                         this->addSkill(ENGINEERING,1);
00244                         break;
00245                 case 5:
00246                         this->addSkill(GUNNERY,1);
00247                         break;
00248                 case 6:
00249                         this->addSkill(JACK_OF_ALL_TRADES,1);
00250                         break;
00251         }
00252 }
00253 
00254 void b1NavyPerson::skillTable4(){
00255         switch(d1d6()){
00256                 case 1:
00257                         this->addSkill(MEDICAL,1);
00258                         break;
00259                 case 2:
00260                         this->addSkill(NAVIGATION,1);
00261                         break;
00262                 case 3:
00263                         this->addSkill(ENGINEERING,1);
00264                         break;
00265                 case 4:
00266                         this->addSkill(COMPUTER,1);
00267                         break;
00268                 case 5:
00269                         this->addSkill(PILOT,1);
00270                         break;
00271                 case 6:
00272                         this->addSkill(ADMIN,1);
00273                         break;
00274         }
00275         
00276 }
00277 
00278 static int cashRolls=0;
00279 static int materialRolls=0;
00280 
00281 void b1NavyPerson::musterOut(){
00282         int ix;
00283         
00284         if ( this->getTerms() > 3 ) {
00285                 cashRolls=3;
00286         } else { 
00287                 cashRolls = randxInRange(1,this->getTerms());
00288         }
00289         
00290         materialRolls = this->getTerms() - cashRolls;
00291         
00292         for(ix=1;ix<=cashRolls;ix++)
00293                 this->cashTable();
00294         
00295         for(ix=1;ix<=materialRolls;ix++)
00296                 this->materialTable();
00297         
00298 }
00299 
00300 void b1NavyPerson::cashTable(){
00301         int dm = ( this->getRank() > 4 ? 1 : 0 );
00302         double amount;
00303         
00304         switch(d1d6()+dm){
00305                 case 1:
00306                         amount=1000;
00307                         break;
00308                 case 2:
00309                 case 3:
00310                         amount=5000;
00311                         break;
00312                 case 4:
00313                         amount=10000;
00314                         break;
00315                 case 5:
00316                         amount=20000;
00317                         break;
00318                 default:
00319                         amount=50000;
00320                         break;
00321         }
00322         
00323         this->setCash(this->getCash()+amount);
00324 }
00325 void b1NavyPerson::materialTable(){
00326         int dm = ( this->getRank() > 4 ? 1 : 0 ) + d1d6();
00327 #ifdef DEBUG_ON
00328         FILE* diaglog = fopen("diaglog.log","a+");
00329         
00330         fprintf(diaglog,"b1Army::materialTable() -- Dice roll %d \n",dm);
00331         
00332         fclose(diaglog);
00333 #endif
00334         
00335         switch(dm){
00336                 case 1:
00337                         this->addMaterialBenefit(new mbLowPassage());
00338                         break;
00339                 case 2:
00340                         this->incrementIntelligence(1);
00341                         break;
00342                 case 3:
00343                         this->incrementEducation(2);
00344                         break;
00345                 case 4:
00346                         this->addMaterialBenefit(new mbBlade());
00347                         break;
00348                 case 5:
00349                         this->addMaterialBenefit(new mbTAS());
00350                         break;
00351                 case 6:
00352                         
00353                         this->addMaterialBenefit(new mbHighPassage());
00354                         break;
00355                 default:
00356                         this->incrementSocialStanding(2);
00357                         break;
00358         };
00359 }
00360 
00361 

Generated on Fri Mar 7 16:40:53 2008 for frpuniverse by  doxygen 1.4.7