b1NavyPerson Class Reference

#include <b1-navy-person.hpp>

Inheritance diagram for b1NavyPerson:

Inheritance graph
[legend]
Collaboration diagram for b1NavyPerson:

Collaboration graph
[legend]
List of all members.

Detailed Description

This is an implementation of a Navy service character from book 1 of the original boxed set of the Traveller series.
See also:
personObj

book1Person

Definition at line 37 of file b1-navy-person.hpp.

Public Member Functions

 b1NavyPerson ()
void enlist ()
void skillTables (int n)


Constructor & Destructor Documentation

b1NavyPerson::b1NavyPerson (  ) 

Non paramtized constructor.

Definition at line 46 of file b1-navy-person.cpp.

References enlist().

00046                           :book1Person(){
00047                 
00048                 
00049                 
00050                 this->enlist();
00051 };

Here is the call graph for this function:


Member Function Documentation

void b1NavyPerson::enlist (  ) 

Enlist this character, and run them through the paces.

Definition at line 56 of file b1-navy-person.cpp.

References personObj::getEducation(), personObj::getSocialStanding(), personObj::incrementSocialStanding(), personObj::setAccepted(), personObj::setAge(), personObj::setAlive(), personObj::setCommissioned(), personObj::setRank(), personObj::setService(), personObj::setTerms(), and skillTables().

Referenced by b1NavyPerson().

00056                          {
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 }

Here is the call graph for this function:

Here is the caller graph for this function:

void b1NavyPerson::skillTables ( int  n  ) 

Invoke one several skill tables.

Parameters:
n number of rolls to run against the skill tables for a given term.

Definition at line 155 of file b1-navy-person.cpp.

Referenced by enlist().

00155                                         {
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 }

Here is the caller graph for this function:


The documentation for this class was generated from the following files:
Generated on Fri Mar 7 16:41:07 2008 for frpuniverse by  doxygen 1.4.7