Virtual U.org
Get Personal Training on VU Today
    
Top shadow
 
 register/help
User Name:

Password:

Otaskend.cpp Source File
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

Otaskend.cpp

Go to the documentation of this file.
00001 //Filename    : OTASKEND.CPP
00002 //Description : Object TaskArray; related functions.
00003 //Owner                 :Fred
00004 
00005 #include <OSYS.H>
00006 
00007 #include <OINFO.H>
00008 #include <ODEPT.H>
00009 #include <OPSCHOOL.H>
00010 #include <OTASK.H>
00011 #include <ODATE.H>
00012 #include <OSTR.H>
00013 #include <OCHANCE.H>
00014 
00015 //--------- Define variable type ----------//
00016 
00017 typedef bool (Task::*TaskFP)();                   // message functions are placed in class News for easy access
00018 
00019 //-------- Define struct TaskInfo -------//
00020 
00023 struct TaskInfo {
00024     TaskFP is_completed_func;                       //[TASK_MSG_SUBTYPE_COUNT];
00025     TaskFP is_expired_func;
00026 };
00027 
00028 //------- Define static variables --------//
00029 
00030 static String str;
00031 
00032 static TaskInfo task_info_array[TASK_COUNT] = {
00033     { Task::is_completed_rise_performance, Task::is_expired }, {
00034         //## chea 220999 is_expired is for all task type
00035         Task::is_completed_rise_educational_quality, Task::is_expired
00036     },
00037     { Task::is_completed_rise_student_morale, Task::is_expired },
00038     { Task::is_completed_rise_department_morale, Task::is_expired },
00039     { Task::is_completed_rise_faculty_research_Per, Task::is_expired },
00040     { Task::is_completed_rise_faculty_diversity_index, Task::is_expired },
00041     { Task::is_completed_rise_use_of_IT, Task::is_expired },
00042     { Task::is_completed_rise_staff_morale, Task::is_expired },
00043 
00044 };
00045 
00046 //------- Begin of function TaskArray::next_day -----//
00047 void TaskArray::next_day() {
00048 
00049     // - will be removed from the objective/task section after the task offer expires or the task is completed
00050     // - checked monthly the success of the task; add bonus if task is completed
00051 
00052     Task* taskPtr;
00053 
00054     // return if not start of a month
00055     if ( info.game_day != 1) {                      //## chea 210899 BUGHERE the news date will not match
00056         return;
00057     }
00058 
00059     //--------------------//
00060 
00061     for( int i=size() ; i>0 ; i-- ) {
00062         taskPtr = operator[](i);
00063 
00064         // already completed
00065         if ( taskPtr->task_msg_subtype == TASK_COMPLETED )
00066             continue;
00067 
00068         if ( (taskPtr->*(task_info_array[taskPtr->id-1].is_completed_func))() == true ) {
00069             // add msg to news array
00070             news_array.new_task(taskPtr, TASK_COMPLETED);
00071 
00072             // 1126 don't remove if complete // remove(i);
00073             taskPtr->set_completed();
00074         }
00075         //else if ( (*taskPtr->expiry_func)() == true )
00076         else if ( (taskPtr->*(task_info_array[taskPtr->id-1].is_expired_func))() == true ) {
00077             news_array.new_task(taskPtr, TASK_EXPIRED); // add msg to news array
00078 
00079             //------- set for newspaper display --------//
00080 
00081             News* newsPtr = news_array[news_array.size()];
00082             chance_event.news_str=newsPtr->msg();
00083             chance_event.news_news_str=chance_event.news_str;
00084             //                  memcpy(chance_event.news_date_str,date.date_str(newsPtr->news_date),55);
00085             strncpy(chance_event.news_date_str, info.date_str_julian(newsPtr->news_date), 55 );
00086             chance_event.news_date_str[55-1] = '\0';
00087             //             chance_event.date_str=date.date_str( newsPtr->news_date, 1, 0 );
00088             chance_event.date_str=info.date_str_julian(newsPtr->news_date, INFO_DATE_DEFAULT|INFO_DATE_SHORT_MONTH|INFO_DATE_NO_DAY);
00089 
00090             remove(i);
00091         }
00092 
00093         sys.yield();
00094     }
00095 }
00096 
00097 //------- End of function TaskArray::next_day -----//
00098 
00099 //------ Begin of function Task::is_expired -----//
00105 bool Task::is_expired() {
00106     /*
00107       static  String expire_str; // for msg
00108 
00109       //## chea 220999 added to tell player time has expire.
00110       if(this->id == TASK_RISE_PERFORMANCE_RATING)
00111       expire_str = "departmental prestige expired";
00112       else if(this->id == RISE_EDUCATIONAL_QUALITY)
00113       expire_str = "educational quality expired";
00114       else if(this->id == RISE_STUDENT_MORALE)
00115       expire_str = "RISE STUDENT MORALE expired";
00116       else if(this->id == RISE_DEPARTMENT_MORALE)
00117       expire_str = "RISE DEPARTMENT MORALE expired";
00118       else if(this->id == RISE_FACULTY_RESEARCH)
00119       expire_str = "RISE FACULTY RESEARCH expired";
00120       else if(this->id == RISE_FACULTY_DIVERSITY_INDEX)
00121       expire_str = "RISE_FACULTY_DIVERSITY_INDEX expired";
00122       else if(this->id == RISE_USE_OF_IT)
00123       expire_str = "RISE USE OF IT expired";
00124       else if(this->id == RISE_STAFF_MORALE)
00125       expire_str = "RISE STAFF MORALE expired";
00126     */
00127     // #### begin Gilbert 07/09/2001 ######//
00128     // if ( info.game_month >= short_para5 && info.game_year >= short_para6 )
00129     if ( info.game_year > short_para6
00130          || info.game_year == short_para6 && info.game_month >= short_para5 ) {
00131         // #### end Gilbert 07/09/2001 ######//
00132         sys.set_news_pop_up();
00133         //              chance_event.news_news_str=expire_str;
00134 
00135         // display date in 200? format
00136         long endDay = date.julian(info.game_year, info.game_month, info.game_day);
00137         //              memcpy(chance_event.news_date_str,date.date_str(endDay),55);
00138         strncpy(chance_event.news_date_str, info.date_str_julian(endDay), 55 );
00139         chance_event.news_date_str[55-1] = '\0';
00140         //              chance_event.date_str=date.date_str(endDay,1,0);
00141         chance_event.date_str=info.date_str_julian(endDay, INFO_DATE_DEFAULT|INFO_DATE_SHORT_MONTH|INFO_DATE_NO_DAY);
00142 
00143         return true;
00144     }
00145     else
00146         return false;
00147 }
00148 
00149 //------ End of function Task::is_expired -----//
00150 
00151 //------ Begin of function Task::set_completed -----//
00157 void Task::set_completed() {                      // 990503
00158     task_msg_subtype = TASK_COMPLETED;
00159     news_date = info.game_date;
00160 
00161     task_array.total_bonus_pt += short_para7;
00162 }
00163 
00164 //------ End of function Task::set_completed -----//
00165 
00166 //------ Begin of function Task::is_completed_rise_performance -----//
00176 bool Task::is_completed_rise_performance() {
00177 
00178     //BUGHERE0 should depends on short_para2
00179     float curRating = department_array[short_para1]->p_academic_standing;
00180 
00181     return curRating >= short_para3;
00182 }
00183 
00184 //------ End of function Task::is_completed_rise_performance -----//
00185 
00186 //------ Begin of function Task::is_completed_rise_educational_quality -----//
00196 bool Task::is_completed_rise_educational_quality() {
00197     float curRating = department_array[short_para1]->p_educational_quality;
00198 
00199     return curRating >= short_para3;
00200 }
00201 
00202 //------ End of function Task::is_completed_rise_educational_quality -----//
00203 
00204 //------ Begin of function Task::is_completed_rise_student_morale -----//
00205 bool Task::is_completed_rise_student_morale() {
00206     float curRating = player_school.sub_score[S_STUDENT_MORALE][HISTORY_MONTH_COUNT-1];
00207 
00208     return curRating >= short_para3;
00209 }
00210 
00211 //------ End of function Task::is_completed_rise_student_morale -----//
00212 
00213 //------ Begin of function Task::is_completed_rise_department_morale -----//
00215 bool Task::is_completed_rise_department_morale() {
00216     float curRating = department_array.p_faculty_morale_history[47];
00217 
00218     return curRating >= short_para3;
00219 }
00220 
00221 //------ End of function Task::is_completed_rise_department_morale -----//
00222 
00223 //------ Begin of function Task::is_completed_rise_faculty_research_Per -----//
00224 bool Task::is_completed_rise_faculty_research_Per() {
00225     float curRating = department_array.p_faculty_research_history[47];
00226 
00227     return curRating >= short_para3;
00228 }
00229 
00230 //------ End of function Task::is_completed_rise_faculty_research_Per -----//
00231 
00232 //------ Begin of function Task::is_completed_rise_faculty_diversity_index -----//
00242 bool Task::is_completed_rise_faculty_diversity_index() {
00243     //value now
00244     float curRating = department_array[short_para1]->p_faculty_diversity_history[7];
00245 
00246     return curRating >= short_para3;
00247 }
00248 
00249 //------ End of function Task::is_completed_rise_faculty_diversity_index -----//
00250 
00251 //------ Begin of function Task::is_completed_rise_use_of_IT -----//
00261 bool Task::is_completed_rise_use_of_IT() {
00262 
00263     Department* cur_dept_ptr = department_array[short_para1];
00264     float curRating = cur_dept_ptr->var_educational_quality_history[4][23];
00265 
00266     return curRating >= short_para3;
00267 }
00268 
00269 //------ End of function Task::is_completed_rise_use_of_IT -----//
00270 
00271 //------ Begin of function Task::is_completed_rise_staff_morale -----//
00281 bool Task::is_completed_rise_staff_morale() {
00282     float curRating = player_school.sub_score[S_STAFF_MORALE][THIS_MONTH];
00283 
00284     return curRating >= short_para3;
00285 }
00286 
00287 //------ End of function Task::is_completed_rise_staff_morale -----//

Generated on Fri Aug 23 01:38:30 2002 for VirtualU by doxygen1.2.17