2
2
3
3
#include " building/building_menu.h"
4
4
#include " building/maintenance.h"
5
+ #include " building/building_granary.h"
5
6
#include " city/buildings.h"
6
7
#include " city/city.h"
7
8
#include " city/message.h"
@@ -181,12 +182,12 @@ void tutorial1_handle_fire(event_fire_damage) {
181
182
post_message (MESSAGE_TUTORIAL_FIRE_IN_THE_VILLAGE);
182
183
}
183
184
184
- void tutorial1_handle_population_changed (event_population_changed ev) {
185
+ void tutorial1_handle_population_150 (event_population_changed ev) {
185
186
if (g_tutorials_flags.tutorial_1 .population_150_reached || ev.value < 150 ) {
186
187
return ;
187
188
}
188
189
189
- g_city_events.removeListener (typeid (event_population_changed), &tutorial1_handle_population_changed );
190
+ g_city_events.removeListener (typeid (event_population_changed), &tutorial1_handle_population_150 );
190
191
191
192
g_tutorials_flags.tutorial_1 .population_150_reached = true ;
192
193
building_menu_update (tutorial_stage.tutorial_food );
@@ -205,6 +206,45 @@ void tutorial1_handle_collapse(event_collase_damage) {
205
206
post_message (MESSAGE_TUTORIAL_COLLAPSED_BUILDING);
206
207
}
207
208
209
+ void tutorial1_on_filled_granary (event_granary_filled ev) {
210
+ if (g_tutorials_flags.tutorial_1 .gamemeat_400_stored ) {
211
+ return ;
212
+ }
213
+
214
+ if (ev.amount <= 400 ) {
215
+ return ;
216
+ }
217
+
218
+ g_city_events.removeListener (typeid (event_granary_filled), &tutorial1_on_filled_granary);
219
+
220
+ g_tutorials_flags.tutorial_1 .gamemeat_400_stored = true ;
221
+ building_menu_update (tutorial_stage.tutorial_water );
222
+ post_message (MESSAGE_TUTORIAL_CLEAN_WATER);
223
+ }
224
+
225
+ void tutorial3_on_filled_granary (event_granary_filled ev) {
226
+ if (g_tutorials_flags.tutorial_3 .figs_800_stored ) {
227
+ return ;
228
+ }
229
+
230
+ if (ev.amount < 800 ) {
231
+ return ;
232
+ }
233
+
234
+ auto granary = building_get (ev.bid )->dcast_granary ();
235
+ const int figs_stored = granary ? granary->amount (RESOURCE_FIGS) : 0 ;
236
+
237
+ if (figs_stored < 800 ) {
238
+ return ;
239
+ }
240
+
241
+ g_city_events.removeListener (typeid (event_granary_filled), &tutorial3_on_filled_granary);
242
+
243
+ g_tutorials_flags.tutorial_3 .figs_800_stored = true ;
244
+ building_menu_update (tutorial_stage.tutorial_industry );
245
+ post_message (MESSAGE_TUTORIAL_INDUSTRY);
246
+ }
247
+
208
248
bool tutorial1_is_success () {
209
249
auto &tut = g_tutorials_flags.tutorial_1 ;
210
250
return tut.fire && tut.collapse && tut.population_150_reached && tut.gamemeat_400_stored ;
@@ -216,12 +256,17 @@ bool tutorial_menu_update(int tut) {
216
256
else g_city_events.appendListener (typeid (event_fire_damage), &tutorial1_handle_fire);
217
257
218
258
if (g_tutorials_flags.tutorial_1 .population_150_reached ) building_menu_update (tutorial_stage.tutorial_food );
219
- else g_city_events.appendListener (typeid (event_population_changed), &tutorial1_handle_population_changed);
259
+ else g_city_events.appendListener (typeid (event_population_changed), &tutorial1_handle_population_150);
260
+
261
+ // if (!g_tutorials_flags.tutorial_1.architector_built) {
262
+ // g_city_events.appendListener(typeid(event_building_create), &tutorial1_handle_building_create);
263
+ // }
220
264
221
265
if (g_tutorials_flags.tutorial_1 .collapse ) building_menu_update (tutorial_stage.tutorial_collapse );
222
266
else g_city_events.appendListener (typeid (event_collase_damage), &tutorial1_handle_collapse);
223
267
224
268
if (g_tutorials_flags.tutorial_1 .gamemeat_400_stored ) building_menu_update (tutorial_stage.tutorial_water );
269
+ else g_city_events.appendListener (typeid (event_granary_filled), &tutorial1_on_filled_granary);
225
270
226
271
g_city.victory_state .add_condition (&tutorial1_is_success);
227
272
@@ -237,6 +282,8 @@ bool tutorial_menu_update(int tut) {
237
282
238
283
if (tut == 3 ) {
239
284
if (g_tutorials_flags.tutorial_3 .figs_800_stored ) building_menu_update (tutorial_stage.tutorial_industry );
285
+ else g_city_events.appendListener (typeid (event_granary_filled), &tutorial3_on_filled_granary);
286
+
240
287
if (g_tutorials_flags.tutorial_3 .pottery_made ) building_menu_update (tutorial_stage.tutorial_industry );
241
288
if (g_tutorials_flags.tutorial_3 .disease ) building_menu_update (tutorial_stage.tutorial_health );
242
289
if (g_tutorials_flags.tutorial_3 .pottery_made ) building_menu_update (tutorial_stage.tutorial_gardens );
@@ -370,20 +417,6 @@ void tutorial_on_disease() {
370
417
}
371
418
}
372
419
373
- void tutorial_on_filled_granary (int quantity) {
374
- if (scenario_is_mission_rank (1 ) && !g_tutorials_flags.tutorial_1 .gamemeat_400_stored && quantity >= 400 ) {
375
- g_tutorials_flags.tutorial_1 .gamemeat_400_stored = 1 ;
376
- building_menu_update (tutorial_stage.tutorial_water );
377
- post_message (MESSAGE_TUTORIAL_CLEAN_WATER);
378
- }
379
-
380
- if (scenario_is_mission_rank (3 ) && !g_tutorials_flags.tutorial_3 .figs_800_stored && quantity >= 800 ) {
381
- g_tutorials_flags.tutorial_3 .figs_800_stored = 1 ;
382
- building_menu_update (tutorial_stage.tutorial_industry );
383
- post_message (MESSAGE_TUTORIAL_INDUSTRY);
384
- }
385
- }
386
-
387
420
void tutorial_check_resources_on_storageyard () {
388
421
if (!g_tutorials_flags.tutorial_3 .pottery_made && city_resource_warehouse_stored (RESOURCE_POTTERY) >= 1 ) {
389
422
g_tutorials_flags.tutorial_3 .pottery_made = true ;
@@ -535,6 +568,7 @@ io_buffer* iob_tutorial_flags = new io_buffer([](io_buffer* iob, size_t version)
535
568
iob->bind (BIND_SIGNATURE_UINT8, &g_tutorials_flags.tutorial_1 .population_150_reached );
536
569
iob->bind (BIND_SIGNATURE_UINT8, &g_tutorials_flags.tutorial_1 .gamemeat_400_stored );
537
570
iob->bind (BIND_SIGNATURE_UINT8, &g_tutorials_flags.tutorial_1 .collapse );
571
+ iob->bind (BIND_SIGNATURE_UINT8, &g_tutorials_flags.tutorial_1 .architector_built );
538
572
// tut 2
539
573
iob->bind (BIND_SIGNATURE_UINT8, &g_tutorials_flags.tutorial_2 .gold_mined_500 );
540
574
iob->bind (BIND_SIGNATURE_UINT8, &g_tutorials_flags.tutorial_2 .temples_built );
@@ -577,5 +611,4 @@ io_buffer* iob_tutorial_flags = new io_buffer([](io_buffer* iob, size_t version)
577
611
iob->bind (BIND_SIGNATURE_UINT8, &g_tutorials_flags.pharaoh .flags [37 ]); // goal: temples
578
612
iob->bind (BIND_SIGNATURE_UINT8, &g_tutorials_flags.pharaoh .flags [38 ]);
579
613
iob->bind (BIND_SIGNATURE_UINT8, &g_tutorials_flags.pharaoh .flags [39 ]);
580
- iob->bind (BIND_SIGNATURE_UINT8, &g_tutorials_flags.pharaoh .flags [40 ]);
581
614
});
0 commit comments