From 80e16c93ffd5ac868aae42e32b5af29fdf956595 Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Sun, 1 Dec 2024 10:53:34 +0100 Subject: close #32 --- src/include/world.h | 4 ++-- src/scenes/place_detail.c | 4 ++-- src/world.c | 17 ++++++++++++++--- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/include/world.h b/src/include/world.h index 250e235..1efa553 100644 --- a/src/include/world.h +++ b/src/include/world.h @@ -144,7 +144,7 @@ typedef struct t_employee char name[MAX_EMPLOYEE_NAME_LENGTH]; u8 age; struct tm hire_date; - u8 experience; + float experience; float salary; float happiness; // 0-1 s16 days_below_happiness_treshold; @@ -264,7 +264,7 @@ typedef enum t_event_type EVENT_TYPE_MISSED_SHIPMENT_NO_ASSIGNEE, // go to schedule EVENT_TYPE_EMPLOYEE_QUIT, // go to schedule EVENT_TYPE_FINED, // go to employee detail - + EVENT_TYPE_INFO, // not clickable } event_type; diff --git a/src/scenes/place_detail.c b/src/scenes/place_detail.c index 01e7d71..d5c0790 100644 --- a/src/scenes/place_detail.c +++ b/src/scenes/place_detail.c @@ -839,7 +839,7 @@ static void place_detail_draw_selected_employee(platform_window* window) PUSH_INFO_TEXT("Name: %s", _active_employee->name); PUSH_INFO_TEXT("Age: %d", _active_employee->age); - PUSH_INFO_TEXT("Experience: %d years", _active_employee->experience); + PUSH_INFO_TEXT("Experience: %.0f years", _active_employee->experience); PUSH_INFO_TEXT("Salary: $%.2f/month", _active_employee->salary); // Happiness @@ -1434,7 +1434,7 @@ static void place_detail_draw_resumes(platform_window* window) renderer->render_text(fnt, text_x, text_y, buffer, t_shadow); text_y += fnt->px_h + 8*scale; - sprintf(buffer, "Experience: %d years", resume->employee->experience); + sprintf(buffer, "Experience: %.0f years", resume->employee->experience); renderer->render_text(fnt, text_x, text_y, buffer, t_shadow); text_y += fnt->px_h + 8*scale; diff --git a/src/world.c b/src/world.c index 963568a..7f7252c 100644 --- a/src/world.c +++ b/src/world.c @@ -218,7 +218,7 @@ static employee* create_employee(world* world, world_location* hired_at) employee1->age = get_random_number(18, 60); employee1->hire_date = world->current_time; employee1->days_below_happiness_treshold = 0; - employee1->experience = (u8)((employee1->age - 18) * (get_random_number(1, 100)/100.0f)); + employee1->experience = (float)((employee1->age - 18.0f) * (get_random_number(1, 100)/100.0f)); employee1->salary = BASE_PAY + (employee1->experience * RAISE_PER_YEAR); if (employee1->salary > MAX_PAY) employee1->salary = MAX_PAY; employee1->happiness = 1.0f; @@ -1079,6 +1079,17 @@ static void world_update_active_jobs(world* world) job->left_at = job->done_at; job->done_at = job->left_at + job->duration_sec; job->reversed = true; + + // Update experience of employee + world_location* orig_location = get_world_location_by_id(world, job->assignee.original_location_id); + employee* e = get_employee_by_id(orig_location, job->assignee.id); + + // 16k/month is max effective increase where 1 job = 0.05 years of experience. + float multiplier = 1.0f + (world->investments.training/100.0f) * 0.025f; + if (multiplier < 1.0f) multiplier = 1.0f; + if (multiplier > 5.0f) multiplier = 5.0f; + printf("%f\n", multiplier); + e->experience += 0.01f * multiplier; } } } @@ -1475,10 +1486,10 @@ void world_update(platform_window* window, world* world) { static float delta = 0; delta += frame_delta; - if (delta >= (1/60.0f)) { // tick runs at 60 ticks per second regardless of fps. + //if (delta >= (1/60.0f)) { // tick runs at 60 ticks per second regardless of fps. world_run_simulation_tick(world); delta = 0; - } + //} } static vec2f get_world_location_for_job(platform_window* window, world* world, active_job* job) -- cgit v1.2.3-70-g09d2