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 #include "b1-army-person.hpp"
00026 #include "dice.hpp"
00027 #include "skill-obj.hpp"
00028 #include "stdio.h"
00029
00030 b1ArmyPerson::b1ArmyPerson() : book1Person() {
00031 this->setService("Army");
00032 this->enlist();
00033 }
00034
00035 void b1ArmyPerson::enlist(){
00036 int dm=0;
00037 int skill_rolls=0;
00038
00039 if ( this->getDexterity() > 5)
00040 dm = 1;
00041 if ( this->getEndurance() > 4 )
00042 dm = dm + 2;
00043 if ( (d2d6()+dm) > 4 ) {
00044 this->setAccepted(1);
00045 this->addSkill(RIFLE,1);
00046 } else {
00047 this->setAccepted(0);
00048 return ;
00049 }
00050 this->setTerms(1);
00051 while(1){
00052 if ( this->getTerms() == 1 ) {
00053 skill_rolls=2;
00054 } else {
00055 skill_rolls=1;
00056 }
00057
00058
00059
00060 dm=0;
00061 if ( this->getEducation() > 5)
00062 dm = 2;
00063 if ( (d2d6()+dm) > 4 ) {
00064
00065 this->setAge( this->getAge()+4);
00066 } else {
00067 this->setAlive(0);
00068 return;
00069 }
00070
00071
00072
00073
00074 if ( this->getCommissioned() == 1 ) {
00075 dm = ( this->getEducation() > 6 ? 1:0);
00076 if ( (d2d6()+dm) > 5 ) {
00077 this->setRank(this->getRank()+1);
00078 skill_rolls++;
00079 }
00080 } else {
00081 dm = ( this->getEndurance() > 6 ? 1 : 0 ) ;
00082
00083 if ( (d2d6()+dm)>5 ){
00084 this->setCommissioned(1);
00085 this->setRank(1);
00086 this->addSkill(SUBMACHINEGUN,1);
00087
00088 dm = ( this->getEducation() > 6 ? 1:0);
00089 skill_rolls++;
00090
00091 if ( (d2d6()+dm) > 7 ) {
00092 this->setRank(this->getRank()+1);
00093 skill_rolls++;
00094 }
00095 }
00096 }
00097
00098 this->skillTables(skill_rolls);
00099
00100
00101
00102 dm=0;
00103 if ( this->getTerms() > 5 ) {
00104 dm = this->getTerms() - 5;
00105 }
00106 if ( this->getAge() > 50 ) {
00107 dm = dm + (this->getAge()/10);
00108 }
00109 int re_enlisted=0;
00110
00111 if ( (d2d6() - dm) > 5 ) {
00112 this->setTerms(this->getTerms()+1);
00113 re_enlisted=1;
00114 }
00115
00116
00117 if ( this->getRank() > 6) this->setRank(6);
00118 if ( re_enlisted != 1 ) {
00119
00120 this->musterOut();
00121 return;
00122 }
00123
00124 }
00125 }
00126
00127 void b1ArmyPerson::skillTables(int nrolls){
00128
00129
00130
00131
00132
00133 int roll;
00134 for(roll=1;roll<=nrolls;roll++){
00135 if ( this->getEducation() < 8 ) {
00136 switch(d1d6()){
00137 case 1:
00138 case 2:
00139 this->skillTable1();
00140 break;
00141 case 3:
00142 case 4:
00143 this->skillTable2();
00144 break;
00145 case 5:
00146 case 6:
00147 this->skillTable3();
00148 break;
00149 };
00150 } else {
00151 switch(d2d6()){
00152 case 1:
00153 this->skillTable1();
00154 break;
00155 case 2:
00156 case 3:
00157 this->skillTable2();
00158 break;
00159 case 4:
00160 case 5:
00161 this->skillTable3();
00162 break;
00163 case 6:
00164 this->skillTable4();
00165 break;
00166 };
00167
00168 }
00169
00170 }
00171 }
00172
00173 void b1ArmyPerson::skillTable1(){
00174 switch(d1d6()){
00175 case 1:
00176 this->incrementStrength(1);
00177 break;
00178 case 2:
00179 this->incrementDexterity(1);
00180 break;
00181 case 3:
00182 this->incrementEndurance(1);
00183 break;
00184 case 4:
00185 this->addSkill(GAMBLING,1);
00186 break;
00187 case 5:
00188 this->incrementEducation(1);
00189 break;
00190 case 6:
00191 this->addSkill(BRAWLING,1);
00192 break;
00193
00194
00195 };
00196
00197 }
00198
00199 void b1ArmyPerson::skillTable2(){
00200 switch(d1d6()){
00201 case 1:
00202 this->addSkill(VEHICLE,1);
00203 break;
00204 case 2:
00205 this->addSkill(AIR_RAFT,1);
00206 break;
00207 case 3:
00208 this->addSkill(GUN_COMBAT,1);
00209 break;
00210 case 4:
00211 this->addSkill(FORWARD_OBSERVER,1);
00212 break;
00213 case 5:
00214 this->addSkill(BLADE_COMBAT,1);
00215 break;
00216 case 6:
00217 this->addSkill(GUN_COMBAT,1);
00218 break;
00219 }
00220
00221 }
00222
00223 void b1ArmyPerson::skillTable3(){
00224 switch(d1d6()){
00225 case 1:
00226 this->addSkill(VEHICLE,1);
00227 break;
00228 case 2:
00229 this->addSkill(MECHANICAL,1);
00230 break;
00231 case 3:
00232 this->addSkill(ELECTRONICS,1);
00233 break;
00234 case 4:
00235 this->addSkill(TACTICS,1);
00236 break;
00237 case 5:
00238 this->addSkill(BLADE_COMBAT,1);
00239 break;
00240 case 6:
00241 this->addSkill(GUN_COMBAT,1);
00242 break;
00243 };
00244
00245 }
00246
00247 void b1ArmyPerson::skillTable4(){
00248 switch(d1d6()){
00249 case 1:
00250 this->addSkill(MEDICAL,1);
00251 break;
00252 case 2:
00253 case 3:
00254 this->addSkill(TACTICS,1);
00255 break;
00256 case 4:
00257 this->addSkill(COMPUTER,1);
00258 break;
00259 case 5:
00260 this->addSkill(LEADER,1);
00261 break;
00262 case 6:
00263 this->addSkill(ADMIN,1);
00264 break;
00265
00266 };
00267 }
00268
00269 static int cashRolls=0;
00270 static int materialRolls=0;
00271
00272 void b1ArmyPerson::musterOut(){
00273 int ix;
00274 #ifdef DEBUG_ON
00275 FILE* diaglog = fopen("diaglog.log","a+");
00276
00277 fprintf(diaglog,"b1Army::musterOut() \n");
00278 #endif
00279
00280
00281
00282 if ( this->getTerms() > 3 ) {
00283 cashRolls=3;
00284 } else {
00285 cashRolls = randxInRange(1,this->getTerms());
00286 }
00287 materialRolls = this->getTerms() - cashRolls;
00288 #ifdef DEBUG_ON
00289 fprintf(diaglog,"%d cash rolls, %d material rolls\n",cashRolls,materialRolls);
00290
00291 fclose(diaglog);
00292 #endif
00293
00294 for(ix=1;ix<=cashRolls;ix++)
00295 this->cashTable();
00296 for(ix=1;ix<=materialRolls;ix++)
00297 this->materialTable();
00298
00299 }
00300
00301 void b1ArmyPerson::cashTable(){
00302 int dm = ( this->getRank() > 4 ? 1 : 0 );
00303 double amount;
00304
00305 switch(d1d6()+dm){
00306 case 1:
00307 amount=1000;
00308 break;
00309 case 2:
00310
00311 case 3:
00312 amount=5000;
00313 break;
00314 case 4:
00315 amount=10000;
00316 break;
00317 case 5:
00318 amount=20000;
00319 break;
00320
00321 default:
00322 amount=50000;
00323 break;
00324 }
00325
00326 this->setCash(this->getCash()+amount);
00327 }
00328
00329
00330
00331 void b1ArmyPerson::materialTable(){
00332 int dm = ( this->getRank() > 4 ? 1 : 0 ) + d1d6();
00333 #ifdef DEBUG_ON
00334 FILE* diaglog = fopen("diaglog.log","a+");
00335
00336 fprintf(diaglog,"b1Army::materialTable() -- Dice roll %d \n",dm);
00337
00338 fclose(diaglog);
00339 #endif
00340
00341 switch(dm){
00342 case 1:
00343 this->addMaterialBenefit(new mbLowPassage());
00344 break;
00345 case 2:
00346 this->incrementIntelligence(1);
00347 break;
00348 case 3:
00349 this->incrementEducation(2);
00350 break;
00351 case 4:
00352 this->addMaterialBenefit(new mbGun());
00353 break;
00354 case 5:
00355 this->addMaterialBenefit(new mbHighPassage());
00356 break;
00357 case 6:
00361 this->addMaterialBenefit(new mbHighPassage());
00362 break;
00363 default:
00364 this->incrementSocialStanding(2);
00365 break;
00366 };
00367 }
00368