-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ogconfig.cpp
167 lines (125 loc) · 4.22 KB
/
Ogconfig.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
//File: OGCONFIG.CPP
//Description: GoalConfig
#include <ALL.H>
#include <OFILETXT.H>
#include <OGCONFIG.H>
//----- Begin of function GoalConfig::init --------//
void GoalConfig::init() {
memset( this, 0, sizeof(GoalConfig) );
read_goal_scen();
read_goal_task();
}
//------- End of function GoalConfig::init --------//
//----- Begin of function GoalConfig::deinit --------//
void GoalConfig::deinit() {
}
//------- End of function GoalConfig::deinit --------//
//----- Begin of function GoalConfig::read_goal_scen --------//
//!
//! GOALSCEN.RES format:
//!
//! 1: Balance The Budget
//! ---------------------
//! Gold Years: 9
//! Silver Years: 6
//! Bronze Years: 3
//! Gold value: 0, 30, 50
//! Silver value: 9000, 50, 100
//! Bronze value: 1000, 20, 300
//!
void GoalConfig::read_goal_scen() {
FileTxt fileTxt( DIR_RES"GOALSCEN.RES" );
while( !fileTxt.is_eof() ) {
int scenId = (int) fileTxt.get_num();
if( scenId < 1 || scenId > SCENARIO_COUNT )
continue;
//-------------------------------------//
fileTxt.next_line();
fileTxt.next_line();
GoalScen* goalScen = goal_scen_array+scenId-1;
//--- read scenario objective time limits ------//
for( int i=0 ; i<3 ; i++ ) {
fileTxt.get_token(); // bypass "Gold"
fileTxt.get_token(); // bypass "Years:"
goalScen->goal_year[i] = (short) fileTxt.get_num();
fileTxt.next_line();
}
//--- read scenario objective variables ------//
for( int i=0 ; i<3 ; i++ ) {
fileTxt.get_token(); // bypass "Gold"
fileTxt.get_token(); // bypass "Value:"
goalScen->goal_value[i] = (float) fileTxt.get_num();
fileTxt.next_line();
}
//------- if all scenario settings have been read -----//
if( scenId == SCENARIO_COUNT )
break;
}
}
//------- End of function GoalConfig::read_goal_scen --------//
//----- Begin of function GoalConfig::read_goal_task --------//
//!
//! GOALTASK.RES format:
//!
//! 1: TASK_RISE_PERFORMANCE_RATING
//! -------------------------------
//! Years Lower: 4
//! Years Upper: 6
//! Goal Lower: 30
//! Goal Upper: 40
//! Bonus : 100
//!
void GoalConfig::read_goal_task() {
FileTxt fileTxt( DIR_RES"GOALTASK.RES" );
while( !fileTxt.is_eof() ) {
int taskId = (int) fileTxt.get_num();
if( taskId < 1 || taskId > SCENARIO_COUNT )
continue;
//-------------------------------------//
fileTxt.next_line();
fileTxt.next_line();
GoalTask* goalTask = goal_task_array+taskId-1;
//--- read task time limits ------//
fileTxt.get_token(); // bypass "Year"
fileTxt.get_token(); // bypass "Lower"
goalTask->years_lower = (short) fileTxt.get_num();
fileTxt.next_line();
fileTxt.get_token(); // bypass "Year"
fileTxt.get_token(); // bypass "Upper"
goalTask->years_upper = (short) fileTxt.get_num();
fileTxt.next_line();
//--- read task values ------//
fileTxt.get_token(); // bypass "Value"
fileTxt.get_token(); // bypass "Lower"
goalTask->value_lower = (short) fileTxt.get_num();
fileTxt.next_line();
fileTxt.get_token(); // bypass "Value"
fileTxt.get_token(); // bypass "Upper"
goalTask->value_upper = (short) fileTxt.get_num();
fileTxt.next_line();
//-------- read bonus ---------//
fileTxt.get_token(); // bypass "Bonus"
goalTask->bonus = (short) fileTxt.get_num();
fileTxt.next_line();
//------- if all scenario settings have been read -----//
if( taskId == TASK_COUNT )
break;
}
}
//------- End of function GoalConfig::read_goal_task --------//
//----- Begin of function GoalTask::get_value -----//
//!
//! Get a random value between value_lower & value_upper.
//!
int GoalTask::get_value() {
return value_lower + m.random(value_upper-value_lower+1);
}
//------- End of function GoalTask::get_value --------//
//----- Begin of function GoalTask::get_years -----//
//!
//! Get a random year between year_lower & year_upper.
//!
int GoalTask::get_years() {
return years_lower + m.random(years_upper-years_lower+1);
}
//------- End of function GoalTask::get_years --------//