diff --git a/po/Makefile.in.in b/po/Makefile.in.in
index 7c26df4c..e91e8387 100644
--- a/po/Makefile.in.in
+++ b/po/Makefile.in.in
@@ -28,7 +28,7 @@ exec_prefix = @exec_prefix@
datarootdir = @datarootdir@
datadir = @datadir@
libdir = @libdir@
-localedir = $(libdir)/locale
+localedir = $(datadir)/locale
gnulocaledir = $(datadir)/locale
gettextsrcdir = $(datadir)/glib-2.0/gettext/po
subdir = po
diff --git a/src/debug.c b/src/debug.c
index 2e22f7b0..a9890bf3 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -42,6 +42,8 @@ debug_action(const gchar *text)
gchar buf[SMALL];
gint value = -1;
+ printf("debact: %s\n", text);
+
sscanf(text, "%[^-0-9]%d", buf, &value);
if(g_str_has_prefix(text, "deb"))
diff --git a/src/finance.c b/src/finance.c
index 5784d278..6b019848 100644
--- a/src/finance.c
+++ b/src/finance.c
@@ -121,7 +121,7 @@ finance_update_user_weekly(User *user)
user->money -= (gint)(finance_wage_unit(tm) * yc_factor[user->youth_academy.coach % 10]);
}
- user->debt = (gint)rint((gfloat)user->debt * (1 + const_float("float_finance_interest")));
+ user->debt = (gint)rint((gfloat)user->debt * (1 + user->debt_interest));
if(user->money < -finance_team_drawing_credit_loan(user->tm, FALSE) &&
user->counters[COUNT_USER_POSITIVE] == -1 && debug < 50)
@@ -200,12 +200,25 @@ finance_team_drawing_credit_loan(const Team *tm, gboolean loan)
void
finance_get_loan(gint value)
{
+ gfloat debt_old = current_user.debt;
+ gfloat debt_new = -value;
+
current_user.money += value;
current_user.debt -= value;
- current_user.counters[COUNT_USER_LOAN] = (current_user.counters[COUNT_USER_LOAN] == -1) ?
- const_int("int_finance_payback_weeks") :
- current_user.counters[COUNT_USER_LOAN];
+ if(current_user.counters[COUNT_USER_LOAN] == -1)
+ {
+ current_user.counters[COUNT_USER_LOAN] = const_int("int_finance_payback_weeks");
+ current_user.debt_interest = current_interest;
+ }
+ else
+ {
+ /** Calculate new interest in a way that the user can't take unfair advantage of new market interest. */
+ current_user.debt_interest =
+ powf((debt_old * powf(1 + current_user.debt_interest, (gfloat)current_user.counters[COUNT_USER_LOAN]) +
+ debt_new * powf(1 + current_interest, (gfloat)current_user.counters[COUNT_USER_LOAN])) / (gfloat)current_user.debt,
+ 1 / (gfloat)current_user.counters[COUNT_USER_LOAN]) - 1;
+ }
game_gui_print_message(_("You have %d weeks to pay back your loan."),
current_user.counters[COUNT_USER_LOAN]);
@@ -356,3 +369,15 @@ finance_assign_game_money(const Fixture *fix)
}
}
}
+
+/** Change the current interest on the market (random walk with three possibilities). */
+void
+finance_update_current_interest(void)
+{
+ current_interest += math_rndi(-1, 1) * const_float("float_finance_interest_step");
+
+ if(current_interest < const_float("float_finance_interest_lower"))
+ current_interest = const_float("float_finance_interest_lower");
+ else if(current_interest > const_float("float_finance_interest_upper"))
+ current_interest = const_float("float_finance_interest_upper");
+}
diff --git a/src/finance.h b/src/finance.h
index 1a73ce8c..9b45761d 100644
--- a/src/finance.h
+++ b/src/finance.h
@@ -56,4 +56,7 @@ finance_get_stadium_improvement_duration(gfloat value, gboolean capacity);
void
finance_assign_game_money(const Fixture *fix);
+void
+finance_update_current_interest(void);
+
#endif
diff --git a/src/main.c b/src/main.c
index 8ad2341a..b4072053 100644
--- a/src/main.c
+++ b/src/main.c
@@ -41,6 +41,7 @@
#include "live_game.h"
#include "load_save.h"
#include "main.h"
+#include "maths.h"
#include "misc.h"
#include "misc_callbacks.h"
#include "name_struct.h"
@@ -205,7 +206,6 @@ main_init_variables(void)
bets[1] = g_array_new(FALSE, FALSE, sizeof(BetMatch));
jobs = g_array_new(FALSE, FALSE, sizeof(Job));
job_teams = g_array_new(FALSE, FALSE, sizeof(Team));
-
save_file = NULL;
constants_app.list = settings.list =
@@ -224,7 +224,11 @@ main_init_variables(void)
file_load_conf_files();
xml_strategy_load_strategies();
-
+
+ current_interest = rint(math_rnd(const_float("float_finance_interest_lower"),
+ const_float("float_finance_interest_upper")) /
+ const_float("float_finance_interest_step")) * const_float("float_finance_interest_step");
+
language_set(language_get_code_index(opt_str("string_opt_language_code")) + 1);
option_add(&options, "int_opt_calodds", 0, NULL);
diff --git a/src/start_end.c b/src/start_end.c
index c9942d29..83295881 100644
--- a/src/start_end.c
+++ b/src/start_end.c
@@ -71,7 +71,8 @@ WeekFunc start_week_round_funcs[] =
WeekFunc start_week_funcs[] =
{start_week_add_cups, start_week_update_users,
start_week_update_teams, start_week_update_user_finances,
- youth_academy_update_weekly, transfer_update, job_update, NULL};
+ youth_academy_update_weekly, transfer_update, job_update,
+ finance_update_current_interest, NULL};
WeekFunc end_week_funcs[] = {stat_update_leagues, end_week_hide_cups, NULL};
diff --git a/src/treeview.c b/src/treeview.c
index fd5572ca..6643896f 100644
--- a/src/treeview.c
+++ b/src/treeview.c
@@ -1473,12 +1473,17 @@ treeview_create_finances(const User* user)
misc_print_grouped_int(finance_team_drawing_credit_loan(user->tm, FALSE), buf);
gtk_list_store_append(ls, &iter);
gtk_list_store_set(ls, &iter, 0, _("Drawing credit"), 1, buf, 2, "", -1);
+
+ sprintf(buf, "%.2f%%", current_interest * 100);
+ gtk_list_store_append(ls, &iter);
+ gtk_list_store_set(ls, &iter, 0, _("Current market interest"), 1, buf, 2, "", -1);
if(user->debt != 0)
{
misc_print_grouped_int(user->debt, buf);
- sprintf(buf2, "%s",
- const_app("string_treeview_finances_expenses_fg"), buf);
+ sprintf(buf2, "%s (%.2f%% %s)",
+ const_app("string_treeview_finances_expenses_fg"), buf,
+ user->debt_interest * 100, _("interest rate"));
sprintf(buf, _("Debt (repay in %d weeks)"), user->counters[COUNT_USER_LOAN]);
gtk_list_store_append(ls, &iter);
gtk_list_store_set(ls, &iter, 0, buf, 1, "", 2, buf2, -1);
diff --git a/src/user_struct.h b/src/user_struct.h
index 1a81b94b..b4a5b593 100644
--- a/src/user_struct.h
+++ b/src/user_struct.h
@@ -165,7 +165,9 @@ typedef struct
We have double arrays to store information about
the current and the past week. */
gint money, debt, money_in[2][MON_IN_END],
- money_out[2][MON_OUT_END];
+ money_out[2][MON_OUT_END];
+ /** Interest the debt was taken at. */
+ gfloat debt_interest;
/** The user's scout and physio qualities.
@see #Quality */
gint scout, physio;
diff --git a/src/variables.h b/src/variables.h
index 2879bb0f..8f9a15a3 100644
--- a/src/variables.h
+++ b/src/variables.h
@@ -72,6 +72,9 @@ GArray *strategies;
/** Array of current and recent bets. */
GArray *bets[2];
+/** Loan interest for the current week. */
+gfloat current_interest;
+
/** Array of jobs in the job exchange and
teams going with the international jobs. */
GArray *jobs, *job_teams;
diff --git a/src/xml_loadsave_misc.c b/src/xml_loadsave_misc.c
index 5d279928..29eadcc0 100644
--- a/src/xml_loadsave_misc.c
+++ b/src/xml_loadsave_misc.c
@@ -49,6 +49,7 @@ enum XmlLoadSaveCountryTags
TAG_MISC_BET_FIX_ID,
TAG_MISC_BET_ODD,
TAG_MISC_VERSION,
+ TAG_MISC_CURRENT_INTEREST,
TAG_END
};
@@ -108,6 +109,7 @@ xml_loadsave_misc_end_element (GMarkupParseContext *context,
tag == TAG_SYMBOL ||
tag == TAG_SID ||
tag == TAG_MISC_VERSION ||
+ tag == TAG_MISC_CURRENT_INTEREST ||
tag == TAG_MISC_RATING ||
tag == TAG_MISC_ALLCUP ||
tag == TAG_MISC_COUNTER ||
@@ -175,6 +177,8 @@ xml_loadsave_misc_text (GMarkupParseContext *context,
new_bet.odds[oddidx] = float_value;
else if(state == TAG_MISC_BET_FIX_ID)
new_bet.fix_id = int_value;
+ else if(state == TAG_MISC_CURRENT_INTEREST)
+ current_interest = float_value;
}
@@ -235,6 +239,7 @@ xml_loadsave_misc_write(const gchar *prefix)
fprintf(fil, "<_%d>\n", TAG_MISC);
xml_write_string(fil, VERS, TAG_MISC_VERSION, I0);
+ xml_write_float(fil, current_interest, TAG_MISC_CURRENT_INTEREST, I0);
xml_write_string(fil, country.name, TAG_NAME, I0);
xml_write_string(fil, country.symbol, TAG_SYMBOL, I0);
xml_write_string(fil, country.sid, TAG_SID, I0);
diff --git a/src/xml_loadsave_users.c b/src/xml_loadsave_users.c
index 34bdd572..2de261e1 100644
--- a/src/xml_loadsave_users.c
+++ b/src/xml_loadsave_users.c
@@ -42,6 +42,7 @@ enum
TAG_USER_COUNTER,
TAG_USER_MONEY,
TAG_USER_DEBT,
+ TAG_USER_DEBT_INTEREST,
TAG_USER_MONEY_INS,
TAG_USER_MONEY_IN,
TAG_USER_MONEY_OUTS,
@@ -163,6 +164,7 @@ xml_loadsave_users_end_element (GMarkupParseContext *context,
else if(tag == TAG_USER_COUNTER ||
tag == TAG_USER_MONEY ||
tag == TAG_USER_DEBT ||
+ tag == TAG_USER_DEBT_INTEREST ||
tag == TAG_USER_MONEY_INS ||
tag == TAG_USER_MONEY_OUTS ||
tag == TAG_USER_SCOUT ||
@@ -268,6 +270,8 @@ xml_loadsave_users_text (GMarkupParseContext *context,
new_user.money = int_value;
else if(state == TAG_USER_DEBT)
new_user.debt = int_value;
+ else if(state == TAG_USER_DEBT_INTEREST)
+ new_user.debt_interest = float_value;
else if(state == TAG_USER_SCOUT)
new_user.scout = int_value;
else if(state == TAG_USER_PHYSIO)
@@ -392,6 +396,7 @@ xml_loadsave_users_write(const gchar *prefix)
xml_write_int(fil, usr(i).team_id, TAG_TEAM_ID, I1);
xml_write_int(fil, usr(i).money, TAG_USER_MONEY, I1);
xml_write_int(fil, usr(i).debt, TAG_USER_DEBT, I1);
+ xml_write_float(fil, usr(i).debt_interest, TAG_USER_DEBT_INTEREST, I1);
xml_write_int(fil, usr(i).scout, TAG_USER_SCOUT, I1);
xml_write_int(fil, usr(i).physio, TAG_USER_PHYSIO, I1);
diff --git a/support_files/bygfoot_constants b/support_files/bygfoot_constants
index facd4d80..c2862e50 100644
--- a/support_files/bygfoot_constants
+++ b/support_files/bygfoot_constants
@@ -338,6 +338,12 @@ float_finance_credit_factor_loan 70000
# number of weeks to pay back a loan
int_finance_payback_weeks 15
+# lower and upper limit for the current interest
+# and the change step between weeks
+float_finance_interest_lower 500
+float_finance_interest_upper 6000
+float_finance_interest_step 250
+
# live game scale configuration
float_game_gui_live_game_scale_attack 30000
float_game_gui_live_game_scale_chance 45000
diff --git a/support_files/bygfoot_user.conf b/support_files/bygfoot_user.conf
index 88dbec7a..4ec03d8a 100644
--- a/support_files/bygfoot_user.conf
+++ b/support_files/bygfoot_user.conf
@@ -1,13 +1,6 @@
-# Bygfoot Football Manager
-# Default user configuration file
-
-# Most of these options are uncommented because their meaning
-# is rather clear if you take a look at the options window in the game.
-
int_opt_user_confirm_youth 1
-
-int_opt_user_show_live_game 1
-int_opt_user_live_game_speed 20
+int_opt_user_show_live_game 0
+int_opt_user_live_game_speed 40
int_opt_user_live_game_verbosity 5
int_opt_user_show_tendency_bar 1
int_opt_user_pause_injury 1
@@ -19,20 +12,13 @@ int_opt_user_swap_adapts 1
int_opt_user_show_overall 0
int_opt_user_show_all_leagues 0
int_opt_user_contract_limit 12
-
int_opt_user_penalty_shooter -1
-
int_opt_user_bet_show_all_leagues 0
int_opt_user_bet_show_cups 1
int_opt_user_bet_show_my_recent 1
int_opt_user_bet_default_wager 5000
-
-# default training camp hotel
int_opt_user_training_camp_hotel 1
int_opt_user_training_camp_recreation 5
-
-# the order of these attributes is important
-# don't change it, only the values
int_opt_user_pl1_att_name 1
int_opt_user_pl1_att_cpos 1
int_opt_user_pl1_att_pos 1
@@ -51,9 +37,6 @@ int_opt_user_pl1_att_wage 0
int_opt_user_pl1_att_contract 0
int_opt_user_pl1_att_team 0
int_opt_user_pl1_att_league_cup 0
-
-# the order of these attributes is important
-# don't change it, only the values
int_opt_user_pl2_att_name 1
int_opt_user_pl2_att_cpos 0
int_opt_user_pl2_att_pos 1