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/world.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/world.c') 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