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 "person-obj.hpp"
00026 #include "dice.hpp"
00027 #include "string.h"
00028 #include "numeric2string.hpp"
00029 #include "malloc.h"
00030 #include "stdio.h"
00031
00032
00033 personObj::personObj(){
00034 int ix;
00035 for(ix=0;ix<6;ix++){
00036 physical_stats.upp[ix]=d2d6();
00037 }
00038 age = 18;
00039 accepted=0;
00040 alive=1;
00041 terms=0;
00042 rank=0;
00043 commissioned=0;
00044 cash=0;
00045 skills = new skillList();
00046 musterOutBenefits = new materialBenefitList();
00047
00048 }
00049 int personObj::getCommissioned(){
00050 return commissioned;
00051 }
00052
00053 void personObj::setCommissioned(int c){
00054 commissioned=(c==0?0:1);
00055 }
00056 int personObj::getRank(){
00057 return rank;
00058 }
00059 void personObj::setRank(int r){
00060 rank = r;
00061 }
00062 int personObj::getTerms(){
00063 return terms;
00064 }
00065
00066 void personObj::setTerms(int t){
00067 terms=t;
00068 }
00069
00070 int personObj::getIndexedAttribute(int ix){
00071 return this->physical_stats.upp[ix];
00072 }
00073
00074 char* personObj::toString(){
00075 char *buffer;
00076 int ix;
00077 buffer=(char*)malloc(50);
00078 buffer[0]='\0';
00079
00080 sprintf(buffer,"%s: ","UPP");
00081 for(ix=0;ix<6;ix++){
00082 strcat(buffer,itohex(physical_stats.upp[ix]));
00083 }
00084 sprintf(buffer,"%s Age: %d",buffer,age);
00085 return buffer;
00086 }
00087
00088 char* personObj::UPPasString(){
00089 char *buffer;
00090 int ix;
00091 buffer=(char*)malloc(50);
00092 buffer[0]='\0';
00093
00094 sprintf(buffer,"%s: ","UPP");
00095 for(ix=0;ix<6;ix++){
00096 strcat(buffer,itohex(physical_stats.upp[ix]));
00097 }
00098 return buffer;
00099 }
00100
00101 void personObj::setService(char *s){
00102 service=s;
00103 }
00104 char* personObj::getService(){
00105 return service;
00106 }
00107
00108 void personObj::incrementAge(int ix){
00109 age = age + ix;
00110 }
00111
00112 void personObj::incrementStrength(int ix){
00113 this->incrementAttribute(STRENGTH,ix);
00114 }
00115
00116 void personObj::incrementDexterity(int ix){
00117 this->incrementAttribute(DEXTERITY,ix);
00118 }
00119
00120 void personObj::incrementEndurance(int ix){
00121 this->incrementAttribute(ENDURANCE,ix);
00122 }
00123
00124 void personObj::incrementIntelligence(int ix){
00125 this->incrementAttribute(INTELLIGENCE,ix);
00126 }
00127
00128 void personObj::incrementEducation(int ix){
00129 this->incrementAttribute(EDUCATION,ix);
00130 }
00131
00132 void personObj::incrementSocialStanding(int ix){
00133 this->incrementAttribute(SOCIALSTANDING,ix);
00134 }
00135
00136 int personObj::getStrength(){
00137 return physical_stats.a.strength;
00138 }
00139
00140 void personObj::setStrength(int s){
00141 physical_stats.a.strength=s;
00142 }
00143
00144 void personObj::setDexterity(int d) {
00145 physical_stats.a.dexterity=d;
00146 }
00147
00148 int personObj::getDexterity(){
00149 return physical_stats.a.dexterity;
00150 }
00151
00152 void personObj::setEndurance(int c){
00153 physical_stats.a.endurance=c;
00154 }
00155
00156 int personObj::getEndurance(){
00157 return physical_stats.a.endurance;
00158 }
00159
00160 int personObj::getIntelligence(){
00161 return physical_stats.a.intelligence;
00162 }
00163
00164 void personObj::setIntelligence(int i){
00165 physical_stats.a.intelligence=i;
00166 }
00167
00168 int personObj::getEducation(){
00169 return physical_stats.a.education;
00170 }
00171
00172 void personObj::setEducation(int e){
00173 physical_stats.a.education=e;
00174 }
00175
00176 void personObj::setSocialStanding(int s){
00177 physical_stats.a.social_standing=s;
00178 }
00179
00180 int personObj::getSocialStanding(){
00181 return physical_stats.a.social_standing;
00182 }
00183
00184 int personObj::getAge(){
00185 return age;
00186 }
00187
00188 void personObj::setAge(int a){
00189 age=a;
00190 }
00191
00192 void personObj::incrementAttribute(int attr,int incr){
00193 physical_stats.upp[attr] = physical_stats.upp[attr] + incr;
00194 if ( physical_stats.upp[attr] < 0 )
00195 physical_stats.upp[attr] = 0;
00196
00197 }
00198
00199 int personObj::getAccepted(){
00200 return accepted;
00201 }
00202 void personObj:: setAccepted(int a){
00203 accepted=(a!=0 ? 1 : 0 ) ;
00204 }
00205
00206 int personObj::survived(){
00207
00208
00209
00210
00211 if ( alive == 1 ) return 1;
00212 else return 0;
00213 }
00214
00215 int personObj::wasRejected(){
00216 if (accepted == 1) return 0;
00217 else return 1;
00218
00219 }
00220
00221 int personObj::getAlive(){
00222 return alive;
00223 }
00224 void personObj::setAlive(int a){
00225 alive=(a == 0 ? 0 : 1 ) ;
00226 }
00227
00228 int personObj::skillCount(){
00229 return skills->skillCount();
00230 }
00231
00232 char **personObj::listOfSkills(){
00233 return skills->listOfSkills();
00234 }
00235
00236
00237 void personObj::addSkill(int s,int l){
00238 skills->addSkill(new skillObj(this,s,l));
00239
00240 }
00241
00242
00243 char* personObj::listOfSkillString(){
00244 return skills->listOfSkillString();
00245 }
00246
00247 skillList* personObj::getSkillList(){
00248 return skills;
00249 }
00250
00251 double personObj::getCash(){
00252 return cash;
00253 }
00254
00255 void personObj::setCash(double c){
00256 cash=c;
00257 }
00258
00259 materialBenefitList* personObj::getBenefitList(){
00260 return musterOutBenefits;
00261 }
00262
00263 void personObj::addMaterialBenefit(materialBenefit *b){
00264 musterOutBenefits->addBenefit(b);
00265 }