src/b1-merchant-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  * $Id: b1-merchant-person.cpp,v 1.5 2008/02/21 21:33:58 plankowner Exp $
00025  * 
00026  * $Log: b1-merchant-person.cpp,v $
00027  * Revision 1.5  2008/02/21 21:33:58  plankowner
00028  * checkpoint, mega-stuff added
00029  *
00030  * Revision 1.4  2008/02/20 03:04:56  plankowner
00031  * Finished character generation for Book 1 of the original Traveller boxed set. HURRAH!!
00032  *
00033  * Fixed autoskills for b1MerchantPerson
00034  *
00035  * Revision 1.3  2008/02/19 19:31:21  plankowner
00036  * Reorganized the source files and headers for this project
00037  *
00038  * Changed the personObj attribute "constitution" to "endurance" (DOH!)
00039  * since endurance is the Traveller gaming system not the D&D system. :-)
00040  *
00041  *
00042  */
00043 
00044 #include "b1-merchant-person.hpp"
00045 #include "skill-obj.hpp"
00046 #include "dice.hpp"
00047 #ifdef DEBUG_ON
00048 #include <stdio.h>
00049 #endif
00050 
00051 b1MerchantPerson::b1MerchantPerson() : book1Person() {
00052 #ifdef DEBUG_ON
00053         fprintf(stderr,"Entering b1MerchantPerson::b1MerchantPerson()\n");
00054 #endif
00055         this->setService("Merchant");
00056         this->enlist();
00057 #ifdef DEBUG_ON
00058         fprintf(stderr,"Exiting b1MerchantPeson::b1MerchantPerson()\n");
00059 #endif
00060 
00061 }
00062 
00063 
00064 void b1MerchantPerson::enlist(){
00065         int dm=0;
00066         int skill_rolls=0;
00067         
00068         if ( this->getStrength() > 6 ) 
00069                 dm = 1; 
00070         if ( this->getIntelligence() > 5 ) 
00071                 dm = dm + 2;
00072         if ( (d2d6()+dm) > 6 ) {
00073                 this->setAccepted(1);
00074         } else {
00075                 this->setAccepted(0);
00076                 return ;
00077         }
00078         this->setTerms(1);
00079         while(1){ // while 
00080                 if ( this->getTerms() == 1 ) { // if
00081                         skill_rolls=2;
00082                 } else {
00083                         skill_rolls=1;
00084                 } //end-if
00085                 
00086                 // Determine Survival
00087                 //
00088                 dm=0;
00089                 if ( this->getIntelligence() > 6) 
00090                         dm = 2;
00091                 if ( (d2d6()+dm) > 4 ) {
00092                         // this->setTerms(this->getTerms()+1);
00093                         this->setAge( this->getAge()+4);
00094                 } else {
00095                         this->setAlive(0);
00096                         return;
00097                 }
00098                 
00099                 // Check to see if commissioned either already or now.
00100                 // if already commissioned check for promotion.
00101                 
00102                 if ( this->getCommissioned() == 1 ) {
00103                         dm = ( this->getIntelligence() > 8 ? 1:0);
00104                         if ( (d2d6()+dm) > 9 ) {
00105                                 this->setRank(this->getRank()+1);  // promotion of an officer.
00106                                 if ( this->getRank() == 4)  {
00107                                                 this->addSkill(PILOT,1);
00108                                         }
00109                                 
00110                                         
00111                                 skill_rolls++;
00112                         }
00113                 } else {
00114                         dm = ( this->getIntelligence() > 6 ? 1 : 0 ) ;
00115                         // Roll to see if they get commissioned. 
00116                         if ( (d2d6()+dm)>3 ){
00117                                 this->setCommissioned(1);
00118                                 this->setRank(1);
00119                                 dm = ( this->getIntelligence() > 8 ? 1:0);
00120                                 skill_rolls++;
00121                         
00122                                 if ( (d2d6()+dm) > 9 ) {
00123                                         this->setRank(this->getRank()+1);  // promotion of an officer. 
00124                                         skill_rolls++;
00125                                 }
00126                         }
00127                         
00128                 }
00129                 
00130                 this->skillTables(skill_rolls);
00131                 
00132                 // I've imposed my own DMS for sanity sake since I don't want people
00133                 // managing to be in for 60 terms like some trial runs had. 
00134                 dm=0;
00135                 if ( this->getTerms() > 5 ) {
00136                         dm = this->getTerms() - 5; 
00137                 }
00138                 if ( this->getAge() > 50 ) {
00139                         dm = dm + (this->getAge()/10);
00140                 }
00141                 int re_enlisted=0;
00142                 
00143                 if ( (d2d6() - dm) > 3 ) {
00144                         this->setTerms(this->getTerms()+1);
00145                         re_enlisted=1;
00146                 }
00147                         
00148                 // A couple of sanity checks:
00149                 if ( this->getRank() > 5) this->setRank(5);
00150                 if ( re_enlisted != 1 ) return;
00151                         
00152         }
00153         
00154 }
00155 
00156 
00157 void b1MerchantPerson::skillTables(int nrolls){
00158         // There are 4 different skill tables to deal with here...
00159         // 3 of which are in play when education < 8 and all 4 are 
00160         // in play for education >= 8 
00161         
00162 
00163         int roll;
00164         for(roll=1;roll<=nrolls;roll++){
00165                 if ( this->getEducation() < 8 ) {
00166                         switch(d1d6()){
00167                                 case 1:
00168                                 case 2:
00169                                         this->skillTable1();
00170                                         break;
00171                                 case 3:
00172                                 case 4:
00173                                         this->skillTable2();
00174                                         break;
00175                                 case 5:
00176                                 case 6:
00177                                         this->skillTable3();
00178                                         break;
00179                         };
00180                 } else {
00181                         switch(d2d6()){
00182                                 case 1:
00183                                         this->skillTable1();
00184                                         break;
00185                                 case 2:
00186                                 case 3:
00187                                         this->skillTable2();
00188                                         break;
00189                                 case 4: 
00190                                 case 5:
00191                                         this->skillTable3();
00192                                         break;
00193                                 case 6:
00194                                         this->skillTable4();
00195                                         break;
00196                         };
00197                         
00198                 }
00199                 
00200         }
00201         
00202         
00203 }
00204 void b1MerchantPerson::skillTable1(){
00205         switch(d1d6()){
00206                 case 1:
00207                 case 4:
00208                         this->incrementStrength(1);
00209                         break;
00210                 case 2:
00211                         this->incrementDexterity(1);
00212                         break;
00213                 case 3:
00214                         this->incrementEndurance(1);
00215                         break;
00216                 case 5:
00217                         this->addSkill(BLADE_COMBAT,1);
00218                         break;
00219                 default:
00220                         this->addSkill(BRIBERY,1);
00221                         break;
00222                 
00223         };
00224         
00225 }
00226 
00227 void b1MerchantPerson::skillTable2(){
00228         switch(d1d6()){
00229                 case 1:
00230                         this->addSkill(VEHICLE,1);
00231                         break;
00232                 case 2:
00233                         this->addSkill(VACC_SUIT,1);
00234                         break;
00235                 case 3:
00236                         this->addSkill(JACK_OF_ALL_TRADES,1);
00237                         break;
00238                 case 4:
00239                         this->addSkill(STEWARD,1);
00240                         break;
00241                 case 5:
00242                         this->addSkill(ELECTRONICS,1);
00243                         break;
00244                 case 6:
00245                         this->addSkill(GUN_COMBAT,1);
00246                         break;
00247         };
00248         
00249 }
00250 
00251 void b1MerchantPerson::skillTable3(){
00252         switch(d1d6()){
00253                 case 1:
00254                         this->addSkill(STREETWISE,1);
00255                         break;
00256                 case 2:
00257                         this->addSkill(MECHANICAL,1);
00258                         break;
00259                 case 3:
00260                         this->addSkill(ELECTRONICS,1);
00261                         break;
00262                 case 4:
00263                         this->addSkill(NAVIGATION,1);
00264                         break;
00265                 case 5:
00266                         this->addSkill(GUNNERY,1);
00267                         break;
00268                 case 6:
00269                         this->addSkill(MEDICAL,1);
00270                         break;
00271         };
00272         
00273 }
00274 
00275 void b1MerchantPerson::skillTable4(){
00276         switch(d1d6()){
00277                 case 1:
00278                         this->addSkill(MEDICAL,1);
00279                         break;
00280                 case 2:
00281                         this->addSkill(NAVIGATION,1);
00282                         break;
00283                 case 3:
00284                         this->addSkill(ENGINEERING,1);
00285                         break;
00286                 case 4:
00287                         this->addSkill(COMPUTER,1);
00288                         break;
00289                 case 5:
00290                         this->addSkill(PILOT,1);
00291                         break;
00292                 case 6:
00293                         this->addSkill(ADMIN,1);
00294                         break;
00295         };
00296         
00297 }
00298 
00299 
00300 static int cashRolls;
00301 
00302 void b1MerchantPerson::musterOut(){
00303         int ix;
00304         
00305         if ( this->getTerms() > 3 ) {
00306                 cashRolls=3;
00307         } else { 
00308                 cashRolls = randxInRange(1,this->getTerms());
00309         }
00310         
00311         for(ix=1;ix<=cashRolls;ix++)
00312                 this->cashTable();
00313         
00314 }
00315 
00316 void b1MerchantPerson::cashTable(){
00317         int dm = ( this->getRank() > 4 ? 1 : 0 );
00318         double amount;
00319         
00320         switch(d1d6()+dm){
00321                 case 1:
00322                         amount=2000;
00323                         break;
00324                 case 2:
00325                         amount=5000;
00326                         break;
00327                 case 3:
00328                 case 4:
00329                 case 5:
00330                         amount=10000;
00331                         break;
00332                 
00333                 case 6:
00334                         amount=20000;
00335                         break;
00336                 default:
00337                         amount=30000;
00338                         break;
00339         }
00340         
00341         this->setCash(this->getCash()+amount);
00342 }
00343 
00344 
00345 
00346 

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