From 9c03091c9b6c6e58f61f4cf16b5c3af7739469f7 Mon Sep 17 00:00:00 2001 From: Shadow15510 Date: Thu, 23 Jun 2022 14:26:38 +0200 Subject: [PATCH] First playable version --- src/core.c | 16 ++++++++++++---- src/display.c | 10 ++++++++-- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/core.c b/src/core.c index dbae000..8ebd81f 100644 --- a/src/core.c +++ b/src/core.c @@ -116,8 +116,9 @@ void next_step(struct calccity *calccity, struct map *map) if (calccity->disaster) { + int random_event = rand() % 10000; // Firehazard - if (calccity->stat[7] > 500 && rand() % 1000 == 0) + if (calccity->stat[7] > 500 && random_event == 0) { display_message("UN INCENDIE A RAVAGE VOTRE VILLE."); disaster(calccity, map, calccity->stat[7]); @@ -125,7 +126,7 @@ void next_step(struct calccity *calccity, struct map *map) } // Nuclear disaster - if (calccity->stat[8] >= 1 && rand() % 10000 == 0) + if (calccity->stat[8] >= 1 && random_event == 1) { display_message("UN ACCIDENT NUCLEAIRE A RAVAGE VOTRE VILLE."); disaster(calccity, map, calccity->stat[8] * 100); @@ -133,7 +134,7 @@ void next_step(struct calccity *calccity, struct map *map) } // Earthquake - if (rand() % 10000 == 0) + if (random_event == 2) { display_message("UN TREMBLEMENT DE TERRE A RAVAGE VOTRE VILLE."); disaster(calccity, map, rand() % 10); @@ -141,7 +142,7 @@ void next_step(struct calccity *calccity, struct map *map) } // Treasure - if (calccity->misc[0] > 1000 && rand() % 1000 == 0) + if (calccity->misc[0] > 1000 && random_event == 3) { if (rand() % 2) { @@ -156,6 +157,13 @@ void next_step(struct calccity *calccity, struct map *map) } } } + + // No money + if (calccity->misc[0] == 0) + { + display_message("DES MECENES PRIVES VOUS ONT FAIT UN DON DE 1000$."); + calccity->misc[0] += 1000; + } } diff --git a/src/display.c b/src/display.c index 42f89d1..fedec59 100644 --- a/src/display.c +++ b/src/display.c @@ -1,6 +1,7 @@ #include #include #include +#include #include "display.h" @@ -95,8 +96,13 @@ void display_around(struct calccity *calccity, struct camera *camera, const int { extern const bopti_image_t img_fn_keys; - // Date in the top-left corner - dprint_opt(5, 1, C_BLACK, C_WHITE, DTEXT_LEFT, DTEXT_TOP, "%d-%d", calccity->month, calccity->year); + // Date in the top-left corner and treasure + char up_data[25]; + sprintf(up_data, "%d-%d | %d$", calccity->month, calccity->year, calccity->misc[0]); + int width; + dsize(up_data, NULL, &width, NULL); + drect(4, 1, 5 + width, 6, C_WHITE); + dprint_opt(5, 1, C_BLACK, C_WHITE, DTEXT_LEFT, DTEXT_TOP, up_data); // Cursor if (disp_cursor)