diff --git a/src/callbacks.c b/src/callbacks.c index b5941410..ce012293 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -34,6 +34,7 @@ #include "league.h" #include "load_save.h" #include "main.h" +#include "misc2_callback_func.h" #include "option.h" #include "player.h" #include "table.h" @@ -648,6 +649,14 @@ on_treeview_right_button_press_event (GtkWidget *widget, game_gui_show_job_offer(NULL, &g_array_index(jobs, Job, idx - 1), STATUS_JOB_EXCHANGE_SHOW_TEAM); + else if(event->button == 3) + if(misc2_callback_evaluate_job_application( + &g_array_index(jobs, Job, idx - 1), ¤t_user)) + { + stat0 = STATUS_MAIN; + game_gui_show_main(); + setsav0; + } break; } diff --git a/src/file.c b/src/file.c index c53f3ea6..b9498358 100644 --- a/src/file.c +++ b/src/file.c @@ -500,7 +500,8 @@ file_load_user_conf_file(User *user) !file_my_fopen(conf_file, "r", &fil, FALSE)) { g_free(conf_file); - conf_file = file_find_support_file(opt_str("string_opt_default_user_conf_file"), TRUE); + conf_file = + file_find_support_file(opt_str("string_opt_default_user_conf_file"), TRUE); } file_load_opt_file(conf_file, &user->options); diff --git a/src/job.c b/src/job.c index c9adbb7c..62252c17 100644 --- a/src/job.c +++ b/src/job.c @@ -334,7 +334,11 @@ query_job_application_successful(const Job *job, const User *user) } /*d*/ - printf("%s %.0f\n", tm->name, success_needed); + printf("%s avd %.1f ld %d crd %d %.0f\n", tm->name, + job_av_skill - user_av_skill, + job->league_layer - league_from_clid(user->tm->clid)->layer, + job->country_rating - country.rating, + success_needed); return (user->counters[COUNT_USER_SUCCESS] >= success_needed); } diff --git a/src/misc2_callback_func.c b/src/misc2_callback_func.c index 1a8b0e60..e22dcde1 100644 --- a/src/misc2_callback_func.c +++ b/src/misc2_callback_func.c @@ -29,6 +29,7 @@ #include "finance.h" #include "free.h" #include "game_gui.h" +#include "job.h" #include "league.h" #include "maths.h" #include "misc.h" @@ -217,7 +218,8 @@ void misc2_callback_add_user(void) { GtkTreeView *treeview_user_management_teams = - GTK_TREE_VIEW(lookup_widget(window.user_management, "treeview_user_management_teams")); + GTK_TREE_VIEW(lookup_widget(window.user_management, + "treeview_user_management_teams")); GtkEntry *entry_user_management = GTK_ENTRY(lookup_widget(window.user_management, "entry_user_management")); const gchar *user_name = gtk_entry_get_text(entry_user_management); @@ -225,9 +227,10 @@ misc2_callback_add_user(void) Team *tm = (Team*)treeview_helper_get_pointer(treeview_user_management_teams, 2); if(strlen(user_name) > 0) - misc_string_assign(&new_user.name, user_name); - - gtk_entry_set_text(entry_user_management, ""); + { + misc_string_assign(&new_user.name, user_name); + gtk_entry_set_text(entry_user_management, ""); + } new_user.tm = tm; new_user.team_id = tm->id; @@ -238,11 +241,13 @@ misc2_callback_add_user(void) g_array_append_val(users, new_user); - user_set_up_team(&usr(users->len - 1)); - file_load_user_conf_file(&usr(users->len - 1)); - treeview_show_users(GTK_TREE_VIEW(lookup_widget(window.user_management, "treeview_user_management_users"))); + user_set_up_team(&usr(users->len - 1)); + + treeview_show_users( + GTK_TREE_VIEW(lookup_widget(window.user_management, + "treeview_user_management_users"))); treeview_show_team_list(treeview_user_management_teams, FALSE, FALSE); setsav0; @@ -293,3 +298,45 @@ misc2_callback_mmatches_button_press(GtkWidget *widget, gint row_num, gint col_n treeview2_show_mmatches(); } } + +/** Find out whether the user's application for the job + is accepted and show the appropriate popups. + @return TRUE if accepted, FALSE otherwise. */ +gboolean +misc2_callback_evaluate_job_application(Job *job, User *user) +{ + if(!query_job_application_successful(job, user)) + { + game_gui_show_warning( + _("The owners of %s politely reject your application. You're not successful enough in their eyes."), + job_get_team(job)->name); + return FALSE; + } + + if(job->type != JOB_TYPE_NATIONAL) + { + game_gui_show_warning( + _("The owners of %s accept your application. Since %s don't want to get stuck with a lame duck, you get fired instantly and spend the rest of the current season tending your garden."), + job_get_team(job)->name, user->tm->name); + job_change_country(job); + } + else + game_gui_show_warning( + _("The owners of %s accept your application."), + current_user.tm->name); + + printf("misc2 1\n"); + user_change_team(user, team_of_id(job->team_id)); + + printf("misc2 2\n"); + if(job->type == JOB_TYPE_NATIONAL) + job_remove(job, TRUE); + else + { + job_remove(job, FALSE); + job_remove_national(); + } + printf("misc2 3\n"); + + return TRUE; +} diff --git a/src/misc2_callback_func.h b/src/misc2_callback_func.h index 1790bb50..dcc0763b 100644 --- a/src/misc2_callback_func.h +++ b/src/misc2_callback_func.h @@ -46,5 +46,8 @@ misc2_callback_add_user(void); void misc2_callback_mmatches_button_press(GtkWidget *widget, gint row_num, gint col_num); +gboolean +misc2_callback_evaluate_job_application(Job *job, User *user); + #endif diff --git a/src/misc2_callbacks.c b/src/misc2_callbacks.c index f9262ae5..c5560b1d 100644 --- a/src/misc2_callbacks.c +++ b/src/misc2_callbacks.c @@ -55,43 +55,8 @@ on_button_offer_ok_clicked (GtkButton *button, gchar *team_name = g_strdup(current_user.tm->name); if(stat2 == STATUS_JOB_EXCHANGE_SHOW_TEAM) - { - if(query_job_application_successful((Job*)statp, ¤t_user)) - { - if(((Job*)statp)->type != JOB_TYPE_NATIONAL) - { - game_gui_show_warning( - _("The owners of %s accept your application. Since %s don't want to get stuck with a lame duck, you get fired instantly and spend the rest of the current season tending your garden."), - job_get_team((Job*)statp)->name, current_user.tm->name); - job_change_country((Job*)statp); - } - else - game_gui_show_warning( - _("The owners of %s accept your application."), - current_user.tm->name); - - printf("misc2 1\n"); - user_change_team(¤t_user, team_of_id(((Job*)statp)->team_id)); - - printf("misc2 2\n"); - if(((Job*)statp)->type == JOB_TYPE_NATIONAL) - job_remove((Job*)statp, TRUE); - else - { - job_remove((Job*)statp, FALSE); - job_remove_national(); - } - printf("misc2 3\n"); - - } - else - { - game_gui_show_warning( - _("The owners of %s politely reject your application. You're not successful enough in their eyes."), - job_get_team((Job*)statp)->name); - changed = FALSE; - } - } + changed = + misc2_callback_evaluate_job_application((Job*)statp, ¤t_user); else user_change_team(¤t_user, (Team*)statp); @@ -247,10 +212,12 @@ on_button_yesno_yes_clicked (GtkButton *button, break; case STATUS_USER_MANAGEMENT: user_remove(stat2, TRUE); - treeview_show_users(GTK_TREE_VIEW(lookup_widget(window.user_management, - "treeview_user_management_users"))); - treeview_show_team_list(GTK_TREE_VIEW(lookup_widget(window.user_management, - "treeview_user_management_teams")), + treeview_show_users( + GTK_TREE_VIEW(lookup_widget(window.user_management, + "treeview_user_management_users"))); + treeview_show_team_list( + GTK_TREE_VIEW(lookup_widget(window.user_management, + "treeview_user_management_teams")), FALSE, FALSE); break; case STATUS_QUERY_UNFIT: diff --git a/support_files/bygfoot_constants b/support_files/bygfoot_constants index bff5b236..2710a75c 100644 --- a/support_files/bygfoot_constants +++ b/support_files/bygfoot_constants @@ -898,26 +898,26 @@ int_bet_wager_max 25000 # lower and upper bounds for the number # of new job offers when the job exchange gets updated -int_job_new_offers_lower 3 -int_job_new_offers_upper 6 +int_job_new_offers_lower 4 +int_job_new_offers_upper 8 # how often (in weeks) an update occurs int_job_update_interval 5 # percentage of international offers -float_job_international_perc 50000 +float_job_international_perc 70000 # number of success points per average skill # difference unit (needed when finding out whether # a user's application for a job is successful) -int_job_application_points_per_av_skill 40 +int_job_application_points_per_av_skill 20 # how many points a league layer difference is worth int_job_application_points_per_layer 30 # how many points more are needed for an international # application -int_job_application_points_international 150 +int_job_application_points_international 200 # how many points a country rating difference is worth int_job_application_points_per_rating 80