src/b1-scout-person.cpp

00001 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
00002 /*
00003  * frpuniverse
00004  * Copyright (C) Peter L. Berghold 2008 <Peter@Berghold.net>
00005  * 
00006  * frpuniverse is free software.
00007  * 
00008  * You may redistribute it and/or modify it under the terms of the
00009  * GNU General Public License, as published by the Free Software
00010  * Foundation; either version 2 of the License, or (at your option)
00011  * any later version.
00012  * 
00013  * frpuniverse is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00016  * See the GNU General Public License for more details.
00017  * 
00018  * You should have received a copy of the GNU General Public License
00019  * along with frpuniverse.  If not, write to:
00020  *      The Free Software Foundation, Inc.,
00021  *      51 Franklin Street, Fifth Floor
00022  *      Boston, MA  02110-1301, USA.
00023  */
00024 
00025 #include "b1-scout-person.hpp"
00026 #include "dice.hpp"
00027 #include "skill-obj.hpp"
00028 
00029 b1ScoutPerson::b1ScoutPerson(): book1Person() {
00030         this->setService("Scout");
00031         this->enlist();
00032         
00033 }
00034 
00035 void b1ScoutPerson::enlist(){
00036         int dm=0;
00037         int skill_rolls=0;
00038         
00039         if ( this->getIntelligence() > 5 ) 
00040                 dm = 1; 
00041         if ( this->getStrength() > 7 ) 
00042                 dm = dm + 2;
00043         if ( (d2d6()+dm) > 6 ) {
00044                 this->setAccepted(1);
00045         } else {
00046                 this->setAccepted(0);
00047                 return ;
00048         }
00049         this->setTerms(1);
00050         while(1){ // while 
00051                 if ( this->getTerms() == 1 ) { // if
00052                         skill_rolls=2;
00053                 } else {
00054                         skill_rolls=1;
00055                 } //end-if
00056                 
00057                 // Determine Survival
00058                 //
00059                 dm=0;
00060                 if ( this->getEndurance() > 8) 
00061                         dm = 2;
00062                 if ( (d2d6()+dm) > 6 ) {
00063                         // this->setTerms(this->getTerms()+1);
00064                         this->setAge( this->getAge()+4);
00065                 } else {
00066                         this->setAlive(0);
00067                         return;
00068                 }
00069                 
00070 
00071                 
00072                 this->skillTables(skill_rolls);
00073                 
00074                 // I've imposed my own DMS for sanity sake since I don't want people
00075                 // managing to be in for 60 terms like some trial runs had. 
00076                 dm=0;
00077                 if ( this->getTerms() > 5 ) {
00078                         dm = this->getTerms() - 5; 
00079                 }
00080                 if ( this->getAge() > 50 ) {
00081                         dm = dm + (this->getAge()/10);
00082                 }
00083                 int re_enlisted=0;
00084                 
00085                 if ( (d2d6() - dm) > 3 ) {
00086                         this->setTerms(this->getTerms()+1);
00087                         re_enlisted=1;
00088                 }
00089                         
00090                 // A couple of sanity checks:
00091                 if ( this->getRank() > 5) this->setRank(5);
00092                 if ( re_enlisted != 1 ) {
00093                         this->musterOut();
00094                         return;
00095                 }
00096                 
00097                         
00098         }
00099         
00100 }
00101 
00102 
00103 void b1ScoutPerson::skillTables(int nrolls){
00104         // There are 4 different skill tables to deal with here...
00105         // 3 of which are in play when education < 8 and all 4 are 
00106         // in play for education >= 8 
00107         
00108 
00109         int roll;
00110         for(roll=1;roll<=nrolls;roll++){
00111                 if ( this->getEducation() < 8 ) {
00112                         switch(d1d6()){
00113                                 case 1:
00114                                 case 2:
00115                                         this->skillTable1();
00116                                         break;
00117                                 case 3:
00118                                 case 4:
00119                                         this->skillTable2();
00120                                         break;
00121                                 case 5:
00122                                 case 6:
00123                                         this->skillTable3();
00124                                         break;
00125                         };
00126                 } else {
00127                         switch(d2d6()){
00128                                 case 1:
00129                                         this->skillTable1();
00130                                         break;
00131                                 case 2:
00132                                 case 3:
00133                                         this->skillTable2();
00134                                         break;
00135                                 case 4: 
00136                                 case 5:
00137                                         this->skillTable3();
00138                                         break;
00139                                 case 6:
00140                                         this->skillTable4();
00141                                         break;
00142                         };
00143                         
00144                 }
00145                 
00146         }
00147         
00148         
00149 }
00150 
00151 void b1ScoutPerson::skillTable1(){
00152         switch(d1d6()){
00153                 case 1:
00154                         this->incrementStrength(1);
00155                         break;
00156                 case 2:
00157                         this->incrementDexterity(1);
00158                         break;
00159                 case 3:
00160                         this->incrementEndurance(1);
00161                         break;
00162                 case 4:
00163                         this->incrementIntelligence(1);
00164                         break;
00165                 case 5:
00166                         this->incrementEducation(1);
00167                         break;
00168                 case 6:
00169                         this->addSkill(GUN_COMBAT,1);
00170                         break;
00171         }
00172         
00173 }
00174 
00175 void b1ScoutPerson::skillTable2(){
00176         switch(d1d6()){
00177                 case 1:
00178                         this->addSkill(VEHICLE,1);
00179                         break;
00180                 case 2:
00181                         this->addSkill(VACC_SUIT,1);
00182                         break;
00183                 case 3:
00184                         this->addSkill(MECHANICAL,1);
00185                         break;
00186                 case 4:
00187                         this->addSkill(NAVIGATION,1);
00188                         break;
00189                 case 5:
00190                         this->addSkill(ELECTRONICS,1);
00191                         break;
00192                 case 6:
00193                         this->addSkill(JACK_OF_ALL_TRADES,1);
00194                         break;
00195         }
00196 }
00197 
00198 void b1ScoutPerson::skillTable3(){
00199         switch(d1d6()){
00200                 case 1:
00201                         this->addSkill(VEHICLE,1);
00202                         break;
00203                 case 2:
00204                         this->addSkill(MECHANICAL,1);
00205                         break;
00206                 case 3:
00207                         this->addSkill(ELECTRONICS,1);
00208                         break;
00209                 case 4:
00210                         this->addSkill(JACK_OF_ALL_TRADES,1);
00211                         break;
00212                 case 5:
00213                         this->addSkill(GUNNERY,1);
00214                         break;
00215                 case 6:
00216                         this->addSkill(MEDICAL,1);
00217                         break;
00218         };
00219         
00220 }
00221 
00222 void b1ScoutPerson::skillTable4(){
00223         switch(d1d6()){
00224                 case 1:
00225                         this->addSkill(MEDICAL,1);
00226                         break;
00227                 case 2:
00228                         this->addSkill(NAVIGATION,1);
00229                         break;
00230                 case 3:
00231                         this->addSkill(ENGINEERING,1);
00232                         break;
00233                 case 4:
00234                         this->addSkill(COMPUTER,1);
00235                         break;
00236                 case 5:
00237                         this->addSkill(PILOT,1);
00238                         break;
00239                 case 6:
00240                         this->addSkill(JACK_OF_ALL_TRADES,1);
00241                         break;
00242         }
00243 }
00244 
00245 static int cashRolls=0;
00246 static int materialRolls=0;
00247 
00248 void b1ScoutPerson::musterOut(){
00249         int ix;
00250         if ( this->getTerms() > 3 ) {
00251                 cashRolls=3;
00252         } else { 
00253                 cashRolls = randxInRange(1,this->getTerms());
00254         }
00255         materialRolls=this->getTerms() - cashRolls;
00256         
00257         for(ix=1;ix<=cashRolls;ix++)
00258                 this->cashTable();
00259         
00260         for(ix=1;ix<=materialRolls;ix++)
00261                 this->materialTable();
00262         
00263         
00264 }
00265 
00266 void b1ScoutPerson::cashTable(){
00267         double table[6]={20000,20000,30000,30000,50000,50000};
00268         this->setCash(this->getCash()+ table[d1d6()-1]);
00269 }
00270 
00271                 
00272 void b1ScoutPerson::materialTable(){
00273         switch(d1d6()){
00274                 case 1:
00275                         this->addMaterialBenefit(new mbLowPassage());
00276                         break;
00277                 case 2:
00278                         this->incrementIntelligence(2);
00279                         break;
00280                 case 3:
00281                         this->incrementEducation(2);
00282                         break;
00283                 case 4:
00284                         this->addMaterialBenefit(new mbBlade());
00285                         break;
00286                 case 5:
00287                         this->addMaterialBenefit(new mbGun());
00288                         break;
00289                 case 6:
00290                         this->addMaterialBenefit(new mbb2Scout());
00291                         break;
00292         };
00293         
00294 }
00295 
00296 
00297 

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