mirror of
https://github.com/tstellar/bygfoot.git
synced 2025-06-05 21:49:20 +02:00
Some finances.
This commit is contained in:
@@ -98,7 +98,7 @@
|
||||
<signal name="activate" handler="on_start_editor_activate" last_modification_time="Sun, 30 May 2004 19:58:16 GMT"/>
|
||||
|
||||
<child internal-child="image">
|
||||
<widget class="GtkImage" id="image217">
|
||||
<widget class="GtkImage" id="image222">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock">gtk-preferences</property>
|
||||
<property name="icon_size">1</property>
|
||||
@@ -119,7 +119,7 @@
|
||||
<signal name="activate" handler="on_start_update_activate" last_modification_time="Mon, 13 Sep 2004 12:30:42 GMT"/>
|
||||
|
||||
<child internal-child="image">
|
||||
<widget class="GtkImage" id="image218">
|
||||
<widget class="GtkImage" id="image223">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock">gtk-refresh</property>
|
||||
<property name="icon_size">1</property>
|
||||
@@ -168,7 +168,7 @@
|
||||
<signal name="activate" handler="on_menu_preferences_activate" last_modification_time="Sun, 02 Jan 2005 15:30:45 GMT"/>
|
||||
|
||||
<child internal-child="image">
|
||||
<widget class="GtkImage" id="image219">
|
||||
<widget class="GtkImage" id="image224">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock">gtk-preferences</property>
|
||||
<property name="icon_size">1</property>
|
||||
@@ -654,7 +654,7 @@
|
||||
<accelerator key="F9" modifiers="0" signal="activate"/>
|
||||
|
||||
<child internal-child="image">
|
||||
<widget class="GtkImage" id="image220">
|
||||
<widget class="GtkImage" id="image225">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock">gtk-go-forward</property>
|
||||
<property name="icon_size">1</property>
|
||||
@@ -676,7 +676,7 @@
|
||||
<accelerator key="F8" modifiers="0" signal="activate"/>
|
||||
|
||||
<child internal-child="image">
|
||||
<widget class="GtkImage" id="image221">
|
||||
<widget class="GtkImage" id="image226">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock">gtk-go-back</property>
|
||||
<property name="icon_size">1</property>
|
||||
@@ -698,7 +698,7 @@
|
||||
<accelerator key="F12" modifiers="0" signal="activate"/>
|
||||
|
||||
<child internal-child="image">
|
||||
<widget class="GtkImage" id="image222">
|
||||
<widget class="GtkImage" id="image227">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock">gtk-justify-fill</property>
|
||||
<property name="icon_size">1</property>
|
||||
@@ -726,20 +726,12 @@
|
||||
<widget class="GtkMenu" id="menu_finances_stadium_menu">
|
||||
|
||||
<child>
|
||||
<widget class="GtkMenuItem" id="menu_increase_capacity">
|
||||
<widget class="GtkMenuItem" id="menu_show_finances">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Increase capacity</property>
|
||||
<property name="label" translatable="yes">Show finances</property>
|
||||
<property name="use_underline">True</property>
|
||||
<signal name="activate" handler="on_menu_increase_capacity_activate" last_modification_time="Mon, 03 Jan 2005 17:14:21 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkMenuItem" id="menu_increase_safety">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Increase safety</property>
|
||||
<property name="use_underline">True</property>
|
||||
<signal name="activate" handler="on_menu_increase_safety_activate" last_modification_time="Mon, 03 Jan 2005 17:14:21 GMT"/>
|
||||
<signal name="activate" handler="on_menu_show_finances_activate" last_modification_time="Wed, 16 Mar 2005 10:45:18 GMT"/>
|
||||
<accelerator key="f" modifiers="0" signal="activate"/>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
@@ -760,6 +752,16 @@
|
||||
<signal name="activate" handler="on_menu_pay_loan_activate" last_modification_time="Mon, 03 Jan 2005 20:14:41 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkMenuItem" id="menu_show_stadium">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Show stadium</property>
|
||||
<property name="use_underline">True</property>
|
||||
<signal name="activate" handler="on_menu_show_stadium_activate" last_modification_time="Wed, 16 Mar 2005 10:45:18 GMT"/>
|
||||
<accelerator key="f" modifiers="GDK_CONTROL_MASK" signal="activate"/>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
|
@@ -45,7 +45,10 @@ callback_show_next_live_game(void)
|
||||
if(g_array_index(cp(i).fixtures, Fixture, j).week_number == week &&
|
||||
g_array_index(cp(i).fixtures, Fixture, j).week_round_number == week_round &&
|
||||
fixture_user_team_involved(&g_array_index(cp(i).fixtures, Fixture, j)) != -1 &&
|
||||
g_array_index(cp(i).fixtures, Fixture, j).attendance == -1)
|
||||
g_array_index(cp(i).fixtures, Fixture, j).attendance == -1 &&
|
||||
option_int("int_opt_user_show_live_game",
|
||||
usr(fixture_user_team_involved(&g_array_index(cp(i).fixtures, Fixture, j))).
|
||||
options))
|
||||
{
|
||||
live_game_calculate_fixture(&g_array_index(cp(i).fixtures, Fixture, j));
|
||||
return;
|
||||
@@ -68,24 +71,6 @@ callback_show_next_live_game(void)
|
||||
void
|
||||
callback_player_clicked(gint idx, GdkEventButton *event)
|
||||
{
|
||||
/*d*/
|
||||
gint i,j,k, sum=0, cnt;
|
||||
|
||||
for(i=0;i<ligs->len;i++)
|
||||
{
|
||||
sum = cnt = 0;
|
||||
for(j=0;j<lig(i).teams->len;j++)
|
||||
{
|
||||
for(k=0;k<g_array_index(lig(i).teams, Team, j).players->len;k++)
|
||||
{
|
||||
sum += g_array_index(g_array_index(lig(i).teams, Team, j).players, Player, k).wage;
|
||||
}
|
||||
cnt++;
|
||||
}
|
||||
|
||||
printf("%s %d\n", lig(i).name->str, (gint)rint((gfloat)sum / (gfloat)cnt));
|
||||
}
|
||||
|
||||
/** Only accept single-clicks right now. */
|
||||
if(event->type != GDK_BUTTON_PRESS)
|
||||
return;
|
||||
|
@@ -512,22 +512,6 @@ on_menu_finances_stadium_activate (GtkMenuItem *menuitem,
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
on_menu_increase_capacity_activate (GtkMenuItem *menuitem,
|
||||
gpointer user_data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
on_menu_increase_safety_activate (GtkMenuItem *menuitem,
|
||||
gpointer user_data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
on_menu_get_loan_activate (GtkMenuItem *menuitem,
|
||||
gpointer user_data)
|
||||
@@ -674,3 +658,20 @@ on_eventbox_boost_button_press_event (GtkWidget *widget,
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
on_menu_show_finances_activate (GtkMenuItem *menuitem,
|
||||
gpointer user_data)
|
||||
{
|
||||
treeview_show_finances(GTK_TREE_VIEW(lookup_widget(window.main, "treeview_right")),
|
||||
&usr(current_user));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
on_menu_show_stadium_activate (GtkMenuItem *menuitem,
|
||||
gpointer user_data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
@@ -225,14 +225,6 @@ void
|
||||
on_menu_finances_stadium_activate (GtkMenuItem *menuitem,
|
||||
gpointer user_data);
|
||||
|
||||
void
|
||||
on_menu_increase_capacity_activate (GtkMenuItem *menuitem,
|
||||
gpointer user_data);
|
||||
|
||||
void
|
||||
on_menu_increase_safety_activate (GtkMenuItem *menuitem,
|
||||
gpointer user_data);
|
||||
|
||||
void
|
||||
on_menu_get_loan_activate (GtkMenuItem *menuitem,
|
||||
gpointer user_data);
|
||||
@@ -298,3 +290,11 @@ on_button_cl_back_clicked (GtkButton *button,
|
||||
void
|
||||
on_button_cl_forward_clicked (GtkButton *button,
|
||||
gpointer user_data);
|
||||
|
||||
void
|
||||
on_menu_show_finances_activate (GtkMenuItem *menuitem,
|
||||
gpointer user_data);
|
||||
|
||||
void
|
||||
on_menu_show_stadium_activate (GtkMenuItem *menuitem,
|
||||
gpointer user_data);
|
||||
|
@@ -0,0 +1,95 @@
|
||||
#include "finance.h"
|
||||
#include "maths.h"
|
||||
#include "option.h"
|
||||
#include "player.h"
|
||||
#include "user.h"
|
||||
|
||||
/** Weekly update of finances. */
|
||||
void
|
||||
finance_update_user_weekly(User *user)
|
||||
{
|
||||
gint i;
|
||||
Team *tm = user->tm;
|
||||
gfloat physio_factor[4] =
|
||||
{const_float("float_finance_physio_factor1"),
|
||||
const_float("float_finance_physio_factor2"),
|
||||
const_float("float_finance_physio_factor3"),
|
||||
const_float("float_finance_physio_factor4")};
|
||||
gfloat scout_factor[4] =
|
||||
{const_float("float_finance_scout_factor1"),
|
||||
const_float("float_finance_scout_factor2"),
|
||||
const_float("float_finance_scout_factor3"),
|
||||
const_float("float_finance_scout_factor4")};
|
||||
|
||||
if(week % 2 == 1)
|
||||
{
|
||||
for(i=0;i<MON_OUT_END;i++)
|
||||
{
|
||||
user->money_out[0][i] = user->money_out[1][i];
|
||||
user->money_out[1][i] = 0;
|
||||
}
|
||||
for(i=0;i<MON_IN_END;i++)
|
||||
{
|
||||
user->money_in[0][i] = user->money_in[1][i];
|
||||
user->money_in[1][i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
for(i=0;i<tm->players->len;i++)
|
||||
{
|
||||
user->money_out[1][MON_OUT_WAGE] -= player_of(tm, i)->wage;
|
||||
|
||||
if(player_of(tm, i)->health > 0)
|
||||
user->money_out[1][MON_OUT_PHYSIO] -=
|
||||
(gint)(finance_wage_unit(tm) * physio_factor[user->physio % 10]);
|
||||
}
|
||||
|
||||
user->money_out[1][MON_OUT_SCOUT] -= (gint)(finance_wage_unit(tm) * scout_factor[user->scout % 10]);
|
||||
|
||||
user->debt = (gint)rint((gfloat)user->debt * const_float("float_finance_interest"));
|
||||
|
||||
for(i=0;i<MON_OUT_END;i++)
|
||||
user->money += user->money_out[1][i];
|
||||
}
|
||||
|
||||
/** Return a base value for team finances.
|
||||
Scout wages etc. depend on this value. */
|
||||
gfloat
|
||||
finance_wage_unit(const Team *tm)
|
||||
{
|
||||
gint i;
|
||||
gfloat sum = 0;
|
||||
|
||||
for(i=0;i<tm->players->len;i++)
|
||||
sum += player_of(tm, i)->wage;
|
||||
|
||||
return sum / (gfloat)tm->players->len;
|
||||
}
|
||||
|
||||
/** Calculate the drawing credit or maximum loan of a team
|
||||
based on player values and stadium data. */
|
||||
gint
|
||||
finance_team_drawing_credit_loan(const Team *tm, gboolean loan)
|
||||
{
|
||||
gint i;
|
||||
gfloat sum = 0;
|
||||
|
||||
for(i=0;i<tm->players->len;i++)
|
||||
sum += player_of(tm, i)->value;
|
||||
|
||||
/* printf("pl %.0f stad %.0f\n", sum, */
|
||||
/* (gfloat)tm->stadium.capacity * powf(tm->stadium.safety, */
|
||||
/* const_float("float_finance_credit_stadium_safety_exponent"))); */
|
||||
|
||||
sum = (sum * const_float("float_finance_credit_player_value_weight")) +
|
||||
((gfloat)tm->stadium.capacity * powf(tm->stadium.safety,
|
||||
const_float("float_finance_credit_stadium_safety_exponent"))
|
||||
* (1 - const_float("float_finance_credit_player_value_weight")));
|
||||
|
||||
/* printf(" sum %.0f\n", sum); */
|
||||
|
||||
sum *= (loan) ? const_float("float_finance_credit_factor_loan") :
|
||||
const_float("float_finance_credit_factor_drawing");
|
||||
|
||||
return (gint)rint(sum);
|
||||
}
|
||||
|
@@ -0,0 +1,17 @@
|
||||
#ifndef FINANCE_H
|
||||
#define FINANCE_H
|
||||
|
||||
#include "bygfoot.h"
|
||||
#include "variables.h"
|
||||
#include "user_struct.h"
|
||||
|
||||
void
|
||||
finance_update_user_weekly(User *user);
|
||||
|
||||
gfloat
|
||||
finance_wage_unit(const Team *tm);
|
||||
|
||||
gint
|
||||
finance_team_drawing_credit_loan(const Team *tm, gboolean loan);
|
||||
|
||||
#endif
|
||||
|
@@ -725,8 +725,7 @@ fixture_get_week_round_list(gint clid, gint week_number, gint week_round_number)
|
||||
void
|
||||
fixture_result_to_buf(const Fixture *fix, gchar *buf)
|
||||
{
|
||||
gchar local_buf[SMALL],
|
||||
local_buf2[SMALL];
|
||||
gchar local_buf[SMALL];
|
||||
|
||||
if(fix->attendance < 0)
|
||||
strcpy(buf, "-- : --");
|
||||
@@ -740,10 +739,9 @@ fixture_result_to_buf(const Fixture *fix, gchar *buf)
|
||||
strcat(local_buf, " e.t.");
|
||||
|
||||
if(fix->second_leg)
|
||||
{
|
||||
fixture_result_to_buf(fixture_get_first_leg(fix), local_buf2);
|
||||
sprintf(buf, "%s\n(%s)", local_buf, local_buf2);
|
||||
}
|
||||
sprintf(buf, "%s (%d - %d)", local_buf,
|
||||
fixture_get_first_leg(fix)->result[1][0],
|
||||
fixture_get_first_leg(fix)->result[0][0]);
|
||||
else
|
||||
strcpy(buf, local_buf);
|
||||
}
|
||||
|
107
src/game.c
107
src/game.c
@@ -1,6 +1,9 @@
|
||||
#include "cup.h"
|
||||
#include "finance.h"
|
||||
#include "fixture.h"
|
||||
#include "game.h"
|
||||
#include "game_gui.h"
|
||||
#include "league.h"
|
||||
#include "live_game.h"
|
||||
#include "maths.h"
|
||||
#include "misc.h"
|
||||
@@ -236,11 +239,25 @@ void
|
||||
game_initialize(Fixture *fix)
|
||||
{
|
||||
gint i, j;
|
||||
gfloat journey_factor =
|
||||
(fix->clid < ID_CUP_START ||
|
||||
(fix->clid >= ID_CUP_START &&
|
||||
cup_from_clid(fix->clid)->type == CUP_TYPE_NATIONAL)) ?
|
||||
const_float("float_game_finance_journey_factor_national") :
|
||||
const_float("float_game_finance_journey_factor_international");
|
||||
gint user_idx = team_is_user(fix->teams[0]);
|
||||
|
||||
/*d*/
|
||||
fix->attendance = 1000;
|
||||
game_assign_attendance(fix);
|
||||
|
||||
if(user_idx != -1)
|
||||
{
|
||||
usr(user_idx).money += (fix->attendance * const_int("int_team_stadium_ticket_price"));
|
||||
usr(user_idx).money_in[1][MON_IN_TICKET] +=
|
||||
(fix->attendance * const_int("int_team_stadium_ticket_price"));
|
||||
}
|
||||
|
||||
for(i=0;i<2;i++)
|
||||
{
|
||||
for(j=0;j<fix->teams[i]->players->len;j++)
|
||||
{
|
||||
if(j < 11)
|
||||
@@ -253,6 +270,63 @@ game_initialize(Fixture *fix)
|
||||
player_of(fix->teams[i], j)->participation =
|
||||
(j < 11 && player_of(fix->teams[i], j)->cskill > 0);
|
||||
}
|
||||
|
||||
if(team_is_user(fix->teams[i]) != -1 &&
|
||||
(i == 1 || !fix->home_advantage))
|
||||
usr(team_is_user(fix->teams[i])).money_out[1][MON_OUT_JOURNEY] -=
|
||||
(gint)(finance_wage_unit(fix->teams[i]) * journey_factor);
|
||||
}
|
||||
|
||||
if(team_is_user(fix->teams[0]) != -1 && fix->home_advantage)
|
||||
{
|
||||
fix->teams[0]->stadium.safety -=
|
||||
math_rnd(const_float("float_game_stadium_safety_deterioration_lower"),
|
||||
const_float("float_game_stadium_safety_deterioration_upper"));
|
||||
fix->teams[0]->stadium.safety = CLAMP(fix->teams[0]->stadium.safety, 0, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Find out how many spectators there were,
|
||||
depending on safety of the stadium etc.
|
||||
@param fix The match we examine. */
|
||||
void
|
||||
game_assign_attendance(Fixture *fix)
|
||||
{
|
||||
Team *tm[2] = {fix->teams[0], fix->teams[1]};
|
||||
gfloat factor =
|
||||
math_rnd(const_float("float_game_stadium_attendance_percentage_lower"),
|
||||
const_float("float_game_stadium_attendance_percentage_upper")) *
|
||||
powf(tm[0]->stadium.safety,
|
||||
const_float("float_game_stadium_attendance_safety_exponent"));
|
||||
gint max_att = MIN((gint)rint((gfloat)league_cup_average_capacity(fix->clid) *
|
||||
const_float("float_game_stadium_attendance_average_exceed_factor")),
|
||||
tm[0]->stadium.capacity);
|
||||
|
||||
if(fix->clid < ID_CUP_START &&
|
||||
team_rank(tm[1], fix->clid) <
|
||||
(gint)rint((gfloat)league_from_clid(fix->clid)->teams->len *
|
||||
const_float("float_game_stadium_attendance_rank_percentage")))
|
||||
factor *= const_float("float_game_stadium_attendance_rank_factor");
|
||||
|
||||
if(fix->clid >= ID_CUP_START)
|
||||
{
|
||||
if(cup_from_clid(fix->clid)->rounds->len - fix->round <=
|
||||
const_int("int_game_stadium_attendance_cup_rounds_full_house"))
|
||||
factor = 1;
|
||||
else if(cup_from_clid(fix->clid)->type == CUP_TYPE_NATIONAL)
|
||||
factor *= const_float("float_game_stadium_attendance_cup_national_factor");
|
||||
else
|
||||
factor *= const_float("float_game_stadium_attendance_cup_international_factor");
|
||||
}
|
||||
|
||||
fix->attendance = MIN((gint)rint((gfloat)tm[0]->stadium.capacity * factor), max_att);
|
||||
|
||||
tm[0]->stadium.average_attendance =
|
||||
(gint)rint((gfloat)(tm[0]->stadium.average_attendance * tm[0]->stadium.games + fix->attendance) /
|
||||
(gfloat)(tm[0]->stadium.games + 1));
|
||||
tm[0]->stadium.possible_attendance += tm[0]->stadium.capacity;
|
||||
tm[0]->stadium.games++;
|
||||
}
|
||||
|
||||
/** Save the team states in the current live game
|
||||
@@ -986,3 +1060,32 @@ game_post_match(Fixture *fix)
|
||||
team_update_post_match(fix->teams[i], fix->clid);
|
||||
}
|
||||
}
|
||||
|
||||
/** Reduce stadium capacity and safety after a stadium event.
|
||||
@param user The user whose stadium we demolish.
|
||||
@param type The event type. */
|
||||
void
|
||||
game_stadium_event(Stadium *stadium, gint type)
|
||||
{
|
||||
gfloat reduce;
|
||||
gfloat reduce_factor[3][2] =
|
||||
{{const_float("float_game_stadium_safety_reduce_breakdown_lower"),
|
||||
const_float("float_game_stadium_safety_reduce_breakdown_upper")},
|
||||
{const_float("float_game_stadium_safety_reduce_riots_lower"),
|
||||
const_float("float_game_stadium_safety_reduce_riots_upper")},
|
||||
{const_float("float_game_stadium_safety_reduce_fire_lower"),
|
||||
const_float("float_game_stadium_safety_reduce_fire_upper")}};
|
||||
|
||||
reduce = math_rnd(reduce_factor[type - LIVE_GAME_EVENT_STADIUM_BREAKDOWN][0],
|
||||
reduce_factor[type - LIVE_GAME_EVENT_STADIUM_BREAKDOWN][1]);
|
||||
|
||||
printf("event %d saf %.2f cap %d\n",
|
||||
type - LIVE_GAME_EVENT_STADIUM_BREAKDOWN, stadium->safety, stadium->capacity);
|
||||
stadium->safety *= (1 - reduce);
|
||||
stadium->capacity = (gint)rint((gfloat)stadium->capacity *
|
||||
(1 - reduce *
|
||||
const_float("float_game_stadium_capacity_reduce_factor")));
|
||||
|
||||
printf("2 event %d saf %.2f cap %d\n",
|
||||
type - LIVE_GAME_EVENT_STADIUM_BREAKDOWN, stadium->safety, stadium->capacity);
|
||||
}
|
||||
|
@@ -92,4 +92,10 @@ game_update_stats_player(gpointer live_game, gconstpointer live_game_unit);
|
||||
void
|
||||
game_post_match(Fixture *fix);
|
||||
|
||||
void
|
||||
game_assign_attendance(Fixture *fix);
|
||||
|
||||
void
|
||||
game_stadium_event(Stadium *stadium, gint type);
|
||||
|
||||
#endif
|
||||
|
@@ -183,7 +183,7 @@ game_gui_set_main_window_header(void)
|
||||
gui_label_set_text_from_int(label_week, week, FALSE);
|
||||
gui_label_set_text_from_int(label_round, week_round, FALSE);
|
||||
gui_label_set_text_from_int(label_rank, week_round, FALSE);
|
||||
gui_label_set_text_from_int(label_money, usr(current_user).finances[FIN_MONEY], FALSE);
|
||||
gui_label_set_text_from_int(label_money, usr(current_user).money, FALSE);
|
||||
gui_label_set_text_from_int(label_rank,
|
||||
team_rank(usr(current_user).tm, usr(current_user).tm->clid), FALSE);
|
||||
|
||||
|
@@ -42,15 +42,15 @@ create_main_window (void)
|
||||
GtkWidget *trennlinie1;
|
||||
GtkWidget *separatormenuitem1;
|
||||
GtkWidget *start_editor;
|
||||
GtkWidget *image217;
|
||||
GtkWidget *image222;
|
||||
GtkWidget *start_update;
|
||||
GtkWidget *image218;
|
||||
GtkWidget *image223;
|
||||
GtkWidget *trennlinie2;
|
||||
GtkWidget *menu_quit;
|
||||
GtkWidget *menu_options;
|
||||
GtkWidget *menu_options_menu;
|
||||
GtkWidget *menu_preferences;
|
||||
GtkWidget *image219;
|
||||
GtkWidget *image224;
|
||||
GtkWidget *trennlinie7;
|
||||
GtkWidget *menu_notify;
|
||||
GtkWidget *menu_job_offers;
|
||||
@@ -109,17 +109,17 @@ create_main_window (void)
|
||||
GtkWidget *menu_user_show_last_stats;
|
||||
GtkWidget *trennlinie9;
|
||||
GtkWidget *menu_next_user;
|
||||
GtkWidget *image220;
|
||||
GtkWidget *image225;
|
||||
GtkWidget *menu_previous_user;
|
||||
GtkWidget *image221;
|
||||
GtkWidget *image226;
|
||||
GtkWidget *menu_manage_users;
|
||||
GtkWidget *image222;
|
||||
GtkWidget *image227;
|
||||
GtkWidget *menu_finances_stadium;
|
||||
GtkWidget *menu_finances_stadium_menu;
|
||||
GtkWidget *menu_increase_capacity;
|
||||
GtkWidget *menu_increase_safety;
|
||||
GtkWidget *menu_show_finances;
|
||||
GtkWidget *menu_get_loan;
|
||||
GtkWidget *menu_pay_loan;
|
||||
GtkWidget *menu_show_stadium;
|
||||
GtkWidget *menu_help;
|
||||
GtkWidget *menu_help_menu;
|
||||
GtkWidget *menu_about;
|
||||
@@ -263,17 +263,17 @@ create_main_window (void)
|
||||
gtk_widget_show (start_editor);
|
||||
gtk_container_add (GTK_CONTAINER (menu_file_menu), start_editor);
|
||||
|
||||
image217 = gtk_image_new_from_stock ("gtk-preferences", GTK_ICON_SIZE_MENU);
|
||||
gtk_widget_show (image217);
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (start_editor), image217);
|
||||
image222 = gtk_image_new_from_stock ("gtk-preferences", GTK_ICON_SIZE_MENU);
|
||||
gtk_widget_show (image222);
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (start_editor), image222);
|
||||
|
||||
start_update = gtk_image_menu_item_new_with_mnemonic (_("Start Bygfoot Online Update"));
|
||||
gtk_widget_show (start_update);
|
||||
gtk_container_add (GTK_CONTAINER (menu_file_menu), start_update);
|
||||
|
||||
image218 = gtk_image_new_from_stock ("gtk-refresh", GTK_ICON_SIZE_MENU);
|
||||
gtk_widget_show (image218);
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (start_update), image218);
|
||||
image223 = gtk_image_new_from_stock ("gtk-refresh", GTK_ICON_SIZE_MENU);
|
||||
gtk_widget_show (image223);
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (start_update), image223);
|
||||
|
||||
trennlinie2 = gtk_separator_menu_item_new ();
|
||||
gtk_widget_show (trennlinie2);
|
||||
@@ -295,9 +295,9 @@ create_main_window (void)
|
||||
gtk_widget_show (menu_preferences);
|
||||
gtk_container_add (GTK_CONTAINER (menu_options_menu), menu_preferences);
|
||||
|
||||
image219 = gtk_image_new_from_stock ("gtk-preferences", GTK_ICON_SIZE_MENU);
|
||||
gtk_widget_show (image219);
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_preferences), image219);
|
||||
image224 = gtk_image_new_from_stock ("gtk-preferences", GTK_ICON_SIZE_MENU);
|
||||
gtk_widget_show (image224);
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_preferences), image224);
|
||||
|
||||
trennlinie7 = gtk_separator_menu_item_new ();
|
||||
gtk_widget_show (trennlinie7);
|
||||
@@ -554,9 +554,9 @@ create_main_window (void)
|
||||
GDK_F9, 0,
|
||||
GTK_ACCEL_VISIBLE);
|
||||
|
||||
image220 = gtk_image_new_from_stock ("gtk-go-forward", GTK_ICON_SIZE_MENU);
|
||||
gtk_widget_show (image220);
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_next_user), image220);
|
||||
image225 = gtk_image_new_from_stock ("gtk-go-forward", GTK_ICON_SIZE_MENU);
|
||||
gtk_widget_show (image225);
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_next_user), image225);
|
||||
|
||||
menu_previous_user = gtk_image_menu_item_new_with_mnemonic (_("Previous user"));
|
||||
gtk_widget_show (menu_previous_user);
|
||||
@@ -565,9 +565,9 @@ create_main_window (void)
|
||||
GDK_F8, 0,
|
||||
GTK_ACCEL_VISIBLE);
|
||||
|
||||
image221 = gtk_image_new_from_stock ("gtk-go-back", GTK_ICON_SIZE_MENU);
|
||||
gtk_widget_show (image221);
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_previous_user), image221);
|
||||
image226 = gtk_image_new_from_stock ("gtk-go-back", GTK_ICON_SIZE_MENU);
|
||||
gtk_widget_show (image226);
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_previous_user), image226);
|
||||
|
||||
menu_manage_users = gtk_image_menu_item_new_with_mnemonic (_("Manage users"));
|
||||
gtk_widget_show (menu_manage_users);
|
||||
@@ -576,9 +576,9 @@ create_main_window (void)
|
||||
GDK_F12, 0,
|
||||
GTK_ACCEL_VISIBLE);
|
||||
|
||||
image222 = gtk_image_new_from_stock ("gtk-justify-fill", GTK_ICON_SIZE_MENU);
|
||||
gtk_widget_show (image222);
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_manage_users), image222);
|
||||
image227 = gtk_image_new_from_stock ("gtk-justify-fill", GTK_ICON_SIZE_MENU);
|
||||
gtk_widget_show (image227);
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_manage_users), image227);
|
||||
|
||||
menu_finances_stadium = gtk_menu_item_new_with_mnemonic (_("FinStad"));
|
||||
gtk_widget_show (menu_finances_stadium);
|
||||
@@ -587,13 +587,12 @@ create_main_window (void)
|
||||
menu_finances_stadium_menu = gtk_menu_new ();
|
||||
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_finances_stadium), menu_finances_stadium_menu);
|
||||
|
||||
menu_increase_capacity = gtk_menu_item_new_with_mnemonic (_("Increase capacity"));
|
||||
gtk_widget_show (menu_increase_capacity);
|
||||
gtk_container_add (GTK_CONTAINER (menu_finances_stadium_menu), menu_increase_capacity);
|
||||
|
||||
menu_increase_safety = gtk_menu_item_new_with_mnemonic (_("Increase safety"));
|
||||
gtk_widget_show (menu_increase_safety);
|
||||
gtk_container_add (GTK_CONTAINER (menu_finances_stadium_menu), menu_increase_safety);
|
||||
menu_show_finances = gtk_menu_item_new_with_mnemonic (_("Show finances"));
|
||||
gtk_widget_show (menu_show_finances);
|
||||
gtk_container_add (GTK_CONTAINER (menu_finances_stadium_menu), menu_show_finances);
|
||||
gtk_widget_add_accelerator (menu_show_finances, "activate", accel_group,
|
||||
GDK_f, 0,
|
||||
GTK_ACCEL_VISIBLE);
|
||||
|
||||
menu_get_loan = gtk_menu_item_new_with_mnemonic (_("Get loan"));
|
||||
gtk_widget_show (menu_get_loan);
|
||||
@@ -603,6 +602,13 @@ create_main_window (void)
|
||||
gtk_widget_show (menu_pay_loan);
|
||||
gtk_container_add (GTK_CONTAINER (menu_finances_stadium_menu), menu_pay_loan);
|
||||
|
||||
menu_show_stadium = gtk_menu_item_new_with_mnemonic (_("Show stadium"));
|
||||
gtk_widget_show (menu_show_stadium);
|
||||
gtk_container_add (GTK_CONTAINER (menu_finances_stadium_menu), menu_show_stadium);
|
||||
gtk_widget_add_accelerator (menu_show_stadium, "activate", accel_group,
|
||||
GDK_f, GDK_CONTROL_MASK,
|
||||
GTK_ACCEL_VISIBLE);
|
||||
|
||||
menu_help = gtk_menu_item_new_with_mnemonic (_("_Help"));
|
||||
gtk_widget_show (menu_help);
|
||||
gtk_container_add (GTK_CONTAINER (menubar1), menu_help);
|
||||
@@ -1157,11 +1163,8 @@ create_main_window (void)
|
||||
g_signal_connect ((gpointer) menu_finances_stadium, "activate",
|
||||
G_CALLBACK (on_menu_finances_stadium_activate),
|
||||
NULL);
|
||||
g_signal_connect ((gpointer) menu_increase_capacity, "activate",
|
||||
G_CALLBACK (on_menu_increase_capacity_activate),
|
||||
NULL);
|
||||
g_signal_connect ((gpointer) menu_increase_safety, "activate",
|
||||
G_CALLBACK (on_menu_increase_safety_activate),
|
||||
g_signal_connect ((gpointer) menu_show_finances, "activate",
|
||||
G_CALLBACK (on_menu_show_finances_activate),
|
||||
NULL);
|
||||
g_signal_connect ((gpointer) menu_get_loan, "activate",
|
||||
G_CALLBACK (on_menu_get_loan_activate),
|
||||
@@ -1169,6 +1172,9 @@ create_main_window (void)
|
||||
g_signal_connect ((gpointer) menu_pay_loan, "activate",
|
||||
G_CALLBACK (on_menu_pay_loan_activate),
|
||||
NULL);
|
||||
g_signal_connect ((gpointer) menu_show_stadium, "activate",
|
||||
G_CALLBACK (on_menu_show_stadium_activate),
|
||||
NULL);
|
||||
g_signal_connect ((gpointer) menu_about, "activate",
|
||||
G_CALLBACK (on_menu_about_activate),
|
||||
NULL);
|
||||
@@ -1243,15 +1249,15 @@ create_main_window (void)
|
||||
GLADE_HOOKUP_OBJECT (main_window, trennlinie1, "trennlinie1");
|
||||
GLADE_HOOKUP_OBJECT (main_window, separatormenuitem1, "separatormenuitem1");
|
||||
GLADE_HOOKUP_OBJECT (main_window, start_editor, "start_editor");
|
||||
GLADE_HOOKUP_OBJECT (main_window, image217, "image217");
|
||||
GLADE_HOOKUP_OBJECT (main_window, image222, "image222");
|
||||
GLADE_HOOKUP_OBJECT (main_window, start_update, "start_update");
|
||||
GLADE_HOOKUP_OBJECT (main_window, image218, "image218");
|
||||
GLADE_HOOKUP_OBJECT (main_window, image223, "image223");
|
||||
GLADE_HOOKUP_OBJECT (main_window, trennlinie2, "trennlinie2");
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_quit, "menu_quit");
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_options, "menu_options");
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_options_menu, "menu_options_menu");
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_preferences, "menu_preferences");
|
||||
GLADE_HOOKUP_OBJECT (main_window, image219, "image219");
|
||||
GLADE_HOOKUP_OBJECT (main_window, image224, "image224");
|
||||
GLADE_HOOKUP_OBJECT (main_window, trennlinie7, "trennlinie7");
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_notify, "menu_notify");
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_job_offers, "menu_job_offers");
|
||||
@@ -1306,17 +1312,17 @@ create_main_window (void)
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_user_show_last_stats, "menu_user_show_last_stats");
|
||||
GLADE_HOOKUP_OBJECT (main_window, trennlinie9, "trennlinie9");
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_next_user, "menu_next_user");
|
||||
GLADE_HOOKUP_OBJECT (main_window, image220, "image220");
|
||||
GLADE_HOOKUP_OBJECT (main_window, image225, "image225");
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_previous_user, "menu_previous_user");
|
||||
GLADE_HOOKUP_OBJECT (main_window, image221, "image221");
|
||||
GLADE_HOOKUP_OBJECT (main_window, image226, "image226");
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_manage_users, "menu_manage_users");
|
||||
GLADE_HOOKUP_OBJECT (main_window, image222, "image222");
|
||||
GLADE_HOOKUP_OBJECT (main_window, image227, "image227");
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_finances_stadium, "menu_finances_stadium");
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_finances_stadium_menu, "menu_finances_stadium_menu");
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_increase_capacity, "menu_increase_capacity");
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_increase_safety, "menu_increase_safety");
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_show_finances, "menu_show_finances");
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_get_loan, "menu_get_loan");
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_pay_loan, "menu_pay_loan");
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_show_stadium, "menu_show_stadium");
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_help, "menu_help");
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_help_menu, "menu_help_menu");
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_about, "menu_about");
|
||||
|
18
src/league.c
18
src/league.c
@@ -259,3 +259,21 @@ league_get_index(gint clid)
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/** Return the average stadium capacity of cpu teams
|
||||
in the specified league or cup. */
|
||||
gint
|
||||
league_cup_average_capacity(gint clid)
|
||||
{
|
||||
gint i;
|
||||
gfloat sum = 0;
|
||||
const GArray *teams = (clid < ID_CUP_START) ?
|
||||
league_from_clid(clid)->teams :
|
||||
cup_from_clid(clid)->teams;
|
||||
|
||||
for(i=0;i<teams->len;i++)
|
||||
if(team_is_user(&g_array_index(teams, Team, i)) == -1)
|
||||
sum += g_array_index(teams, Team, i).stadium.capacity;
|
||||
|
||||
return sum / (gfloat)teams->len;
|
||||
}
|
||||
|
@@ -37,4 +37,7 @@ league_cup_get_previous_fixture(gint clid, gint week_number, gint week_round_num
|
||||
gint
|
||||
league_get_index(gint clid);
|
||||
|
||||
gint
|
||||
league_cup_average_capacity(gint clid);
|
||||
|
||||
#endif
|
||||
|
@@ -112,7 +112,7 @@ live_game_fill_new_unit(LiveGameUnit *new)
|
||||
LiveGameUnit *old = &last_unit;
|
||||
gfloat rndom = math_rnd(0, 1);
|
||||
gfloat stadium_event =
|
||||
1 - powf((gfloat)tm0->stadium.safety / 100,
|
||||
1 - powf((gfloat)tm0->stadium.safety,
|
||||
const_float("float_live_game_stadium_event_exponent"));
|
||||
gfloat possession_change, scoring_chance = 0,
|
||||
injury_event_prob, foul_event_prob;
|
||||
@@ -126,10 +126,10 @@ live_game_fill_new_unit(LiveGameUnit *new)
|
||||
|
||||
injury_event_prob = const_float("float_live_game_injury") *
|
||||
(1 + (const_float("float_player_boost_injury_effect") *
|
||||
(tm[0]->boost != 0 || tm[1]->boost != 0)));
|
||||
(tm0->boost != 0 || tm1->boost != 0)));
|
||||
|
||||
foul_event_prob = const_float("float_live_game_foul") *
|
||||
(1 + (tm[0]->boost + tm[1]->boost) * const_float("float_team_boost_foul_factor"));
|
||||
(1 + (tm0->boost + tm1->boost) * const_float("float_team_boost_foul_factor"));
|
||||
|
||||
new->possession = old->possession;
|
||||
|
||||
@@ -430,19 +430,32 @@ live_game_event_injury(gint team, gint player, gboolean create_new)
|
||||
void
|
||||
live_game_event_stadium(void)
|
||||
{
|
||||
gint i;
|
||||
gfloat rndom = math_rnd(0, 1);
|
||||
gfloat probs[3] =
|
||||
{const_float("float_live_game_stadium_event_breakdown"),
|
||||
const_float("float_live_game_stadium_event_riots"),
|
||||
const_float("float_live_game_stadium_event_fire")};
|
||||
|
||||
for(i=1;i<3;i++)
|
||||
probs[i] += probs[i - 1];
|
||||
|
||||
if(opt_int("int_opt_debug"))
|
||||
printf("live_game_event_stadium\n");
|
||||
if(rndom < const_float("float_live_game_stadium_event_fire"))
|
||||
last_unit.event.type = LIVE_GAME_EVENT_STADIUM_FIRE;
|
||||
else if(rndom < const_float("float_live_game_stadium_event_riots"))
|
||||
last_unit.event.type = LIVE_GAME_EVENT_STADIUM_RIOTS;
|
||||
else if(rndom < const_float("float_live_game_stadium_event_breakdown"))
|
||||
if(rndom <= probs[0])
|
||||
last_unit.event.type = LIVE_GAME_EVENT_STADIUM_BREAKDOWN;
|
||||
else if(rndom <= probs[1])
|
||||
last_unit.event.type = LIVE_GAME_EVENT_STADIUM_RIOTS;
|
||||
else if(rndom <= probs[2])
|
||||
last_unit.event.type = LIVE_GAME_EVENT_STADIUM_FIRE;
|
||||
|
||||
live_game_finish_unit();
|
||||
|
||||
if(team_is_user(tm0) != -1)
|
||||
game_stadium_event(&tm0->stadium, last_unit.event.type);
|
||||
|
||||
match->stadium_event = TRUE;
|
||||
|
||||
live_game_event_general(TRUE);
|
||||
}
|
||||
|
||||
@@ -1473,7 +1486,7 @@ live_game_injury_get_player(void)
|
||||
for(i=1;i<11;i++)
|
||||
{
|
||||
fitness_factor = (player_of(tm[j], i)->fitness < 0.025) ?
|
||||
40 : 1 / ((gfloat)player_of(tm[j], i)->fitness / 10000);
|
||||
40 : 1 / ((gfloat)player_of(tm[j], i)->fitness);
|
||||
probs[i + j * 11] = probs[i + j * 11 - 1] + (1 - goalie_factor) * fitness_factor *
|
||||
(player_of(tm[j], i)->cskill != 0) * (1 + tm[j]->boost * boost_factor);
|
||||
}
|
||||
@@ -1484,7 +1497,7 @@ live_game_injury_get_player(void)
|
||||
if(rndom < probs[0])
|
||||
{
|
||||
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] =
|
||||
player_of(tm[0], 0)->id;
|
||||
player_of(tm0, 0)->id;
|
||||
last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM] = 0;
|
||||
}
|
||||
else
|
||||
|
@@ -39,8 +39,8 @@ enum LiveGameEventType
|
||||
LIVE_GAME_EVENT_PENALTIES,
|
||||
LIVE_GAME_EVENT_STADIUM,
|
||||
LIVE_GAME_EVENT_STADIUM_BREAKDOWN,
|
||||
LIVE_GAME_EVENT_STADIUM_FIRE,
|
||||
LIVE_GAME_EVENT_STADIUM_RIOTS,
|
||||
LIVE_GAME_EVENT_STADIUM_FIRE,
|
||||
LIVE_GAME_EVENT_SUBSTITUTION,
|
||||
LIVE_GAME_EVENT_STRUCTURE_CHANGE,
|
||||
LIVE_GAME_EVENT_STYLE_CHANGE_ALL_OUT_DEFEND,
|
||||
|
@@ -4,6 +4,7 @@
|
||||
#include "free.h"
|
||||
#include "game_gui.h"
|
||||
#include "live_game.h"
|
||||
#include "main.h"
|
||||
#include "misc_callback_func.h"
|
||||
#include "misc_callbacks.h"
|
||||
#include "option.h"
|
||||
@@ -39,8 +40,7 @@ void
|
||||
on_team_selection_cancel_clicked (GtkButton *button,
|
||||
gpointer user_data)
|
||||
{
|
||||
free_memory();
|
||||
gtk_main_quit();
|
||||
main_exit_program(EXIT_OK, NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -50,8 +50,7 @@ on_team_selection_tv_row_activated (GtkTreeView *treeview,
|
||||
GtkTreeViewColumn *column,
|
||||
gpointer user_data)
|
||||
{
|
||||
if(GTK_WIDGET_IS_SENSITIVE(lookup_widget(window.startup, "team_selection_ok")))
|
||||
misc_callback_start_game();
|
||||
on_button_add_player_clicked(NULL, NULL);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -1,6 +1,8 @@
|
||||
#include "cup.h"
|
||||
#include "file.h"
|
||||
#include "finance.h"
|
||||
#include "fixture.h"
|
||||
#include "game_gui.h"
|
||||
#include "gui.h"
|
||||
#include "league.h"
|
||||
#include "live_game.h"
|
||||
@@ -32,7 +34,9 @@ WeekFunc start_week_round_funcs[] =
|
||||
|
||||
/** Array of functions called when a week
|
||||
is started. */
|
||||
WeekFunc start_week_funcs[] = {start_week_update_user_teams, NULL};
|
||||
WeekFunc start_week_funcs[] =
|
||||
{start_week_update_users, start_week_update_user_teams,
|
||||
start_week_update_user_finances, NULL};
|
||||
|
||||
WeekFunc end_week_funcs[] = {NULL};
|
||||
|
||||
@@ -246,8 +250,11 @@ start_week_round(void)
|
||||
start_func++;
|
||||
}
|
||||
|
||||
/* if(!user_games_this_week_round()) */
|
||||
/* end_week_round(); */
|
||||
if(!user_games_this_week_round())
|
||||
end_week_round();
|
||||
|
||||
current_user = 0;
|
||||
game_gui_show_main();
|
||||
}
|
||||
|
||||
/** Start a new week. */
|
||||
@@ -285,3 +292,29 @@ start_week_round_update_user_teams(void)
|
||||
for(i=0;i<users->len;i++)
|
||||
team_update_user_team_week_roundly(usr(i).tm);
|
||||
}
|
||||
|
||||
/** Deduce wages etc. */
|
||||
void
|
||||
start_week_update_user_finances(void)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for(i=0;i<users->len;i++)
|
||||
finance_update_user_weekly(&usr(i));
|
||||
}
|
||||
|
||||
/** Some general user update. */
|
||||
void
|
||||
start_week_update_users(void)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for(i=0;i<users->len;i++)
|
||||
{
|
||||
if(usr(i).scout >= 100)
|
||||
usr(i).scout = math_get_place(usr(i).scout, 2);
|
||||
|
||||
if(usr(i).physio >= 100)
|
||||
usr(i).physio = math_get_place(usr(i).physio, 2);
|
||||
}
|
||||
}
|
||||
|
@@ -42,4 +42,10 @@ start_week_update_user_teams(void);
|
||||
void
|
||||
start_week_round_update_user_teams(void);
|
||||
|
||||
void
|
||||
start_week_update_user_finances(void);
|
||||
|
||||
void
|
||||
start_week_update_users(void);
|
||||
|
||||
#endif
|
||||
|
148
src/treeview.c
148
src/treeview.c
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "cup.h"
|
||||
#include "file.h"
|
||||
#include "finance.h"
|
||||
#include "fixture.h"
|
||||
#include "free.h"
|
||||
#include "gui.h"
|
||||
@@ -870,6 +871,11 @@ treeview_create_game_stats(LiveGame *live_game)
|
||||
}
|
||||
}
|
||||
|
||||
misc_print_grouped_int(live_game->fix->attendance, buf[0], FALSE);
|
||||
sprintf(buf[1], "Attendance\n%s", buf[0]);
|
||||
gtk_list_store_append(liststore, &iter);
|
||||
gtk_list_store_set(liststore, &iter, 0, buf[1], 1, "", 2, "", -1);
|
||||
|
||||
gtk_list_store_append(liststore, &iter);
|
||||
gtk_list_store_set(liststore, &iter, 0, "", 1, "", 2, "", -1);
|
||||
|
||||
@@ -969,7 +975,7 @@ treeview_create_fixtures_header(const Fixture *fix, GtkListStore *liststore)
|
||||
const_str("string_treeview_fixture_header_bg"),
|
||||
const_str("string_treeview_fixture_header_fg"),
|
||||
name, round_name);
|
||||
sprintf(buf2, _("<span background='%s' foreground='%s'>%s</span>"),
|
||||
sprintf(buf2, "<span background='%s' foreground='%s'>%s</span>",
|
||||
const_str("string_treeview_fixture_header_bg"),
|
||||
const_str("string_treeview_fixture_header_fg"), buf3);
|
||||
|
||||
@@ -1383,3 +1389,143 @@ treeview_show_table(GtkTreeView *treeview, gint clid)
|
||||
gtk_tree_view_set_model(treeview, model);
|
||||
g_object_unref(model);
|
||||
}
|
||||
|
||||
GtkTreeModel*
|
||||
treeview_create_finances(const User* user)
|
||||
{
|
||||
gint i, balance = 0;
|
||||
gchar buf[SMALL], buf2[SMALL], buf3[SMALL];
|
||||
gint *in = user->money_in[0],
|
||||
*out = user->money_out[0];
|
||||
gchar *in_titles[MON_IN_TRANSFERS] =
|
||||
{_("Prize money"),
|
||||
_("Ticket income")};
|
||||
gchar *out_titles[MON_OUT_TRANSFERS] =
|
||||
{_("Wages"),
|
||||
_("Physio"),
|
||||
_("Scout"),
|
||||
_("Journey costs"),
|
||||
_("Stadium improvements"),
|
||||
_("Stadium bills")};
|
||||
GtkTreeIter iter;
|
||||
GtkListStore *liststore =
|
||||
gtk_list_store_new(3,
|
||||
G_TYPE_STRING,
|
||||
G_TYPE_STRING,
|
||||
G_TYPE_STRING);
|
||||
|
||||
gtk_list_store_append(liststore, &iter);
|
||||
gtk_list_store_set(liststore, &iter, 0, _("Last week's finances"), 1, "", 2, "", -1);
|
||||
|
||||
for(i=0;i<MON_IN_TRANSFERS;i++)
|
||||
if(in[i] != 0)
|
||||
{
|
||||
misc_print_grouped_int(in[i], buf, FALSE);
|
||||
gtk_list_store_append(liststore, &iter);
|
||||
gtk_list_store_set(liststore, &iter, 0, in_titles[i], 1, buf, 2, "", -1);
|
||||
balance += in[i];
|
||||
}
|
||||
|
||||
if(in[MON_IN_TRANSFERS] != 0 || out[MON_OUT_TRANSFERS] != 0)
|
||||
{
|
||||
misc_print_grouped_int(in[MON_IN_TRANSFERS], buf, FALSE);
|
||||
misc_print_grouped_int(out[MON_IN_TRANSFERS], buf3, FALSE);
|
||||
sprintf(buf2, "<span foreground='%s'>%s</span>",
|
||||
const_str("string_treeview_finances_expenses_fg"), buf3);
|
||||
gtk_list_store_append(liststore, &iter);
|
||||
gtk_list_store_set(liststore, &iter, 0, _("Transfers"), 1, buf, 2, buf2, -1);
|
||||
balance += (in[MON_IN_TRANSFERS] + out[MON_OUT_TRANSFERS]);
|
||||
}
|
||||
|
||||
for(i=0;i<MON_OUT_TRANSFERS;i++)
|
||||
if(out[i] != 0)
|
||||
{
|
||||
misc_print_grouped_int(out[i], buf3, FALSE);
|
||||
sprintf(buf, "<span foreground='%s'>%s</span>",
|
||||
const_str("string_treeview_finances_expenses_fg"), buf3);
|
||||
gtk_list_store_append(liststore, &iter);
|
||||
gtk_list_store_set(liststore, &iter, 0, out_titles[i], 1, "", 2, buf, -1);
|
||||
balance += out[i];
|
||||
}
|
||||
|
||||
misc_print_grouped_int(balance, buf, FALSE);
|
||||
gtk_list_store_append(liststore, &iter);
|
||||
gtk_list_store_set(liststore, &iter, 0, _("Balance"), 1, "", 2, "", -1);
|
||||
if(balance >= 0)
|
||||
strcpy(buf2, buf);
|
||||
else
|
||||
sprintf(buf2, "<span foreground='%s'>%s</span>",
|
||||
const_str("string_treeview_finances_expenses_fg"), buf);
|
||||
gtk_list_store_set(liststore, &iter, 1 + (balance < 0), buf2, -1);
|
||||
|
||||
gtk_list_store_append(liststore, &iter);
|
||||
gtk_list_store_set(liststore, &iter, 0, "", 1, "", 2, "", -1);
|
||||
|
||||
misc_print_grouped_int(user->money, buf, FALSE);
|
||||
gtk_list_store_append(liststore, &iter);
|
||||
if(user->money >= 0)
|
||||
strcpy(buf2, buf);
|
||||
else
|
||||
sprintf(buf2, "<span foreground='%s'>%s</span>",
|
||||
const_str("string_treeview_finances_expenses_fg"), buf);
|
||||
gtk_list_store_set(liststore, &iter, 0, _("Money"), 1, buf2, 2, "", -1);
|
||||
|
||||
misc_print_grouped_int(finance_team_drawing_credit_loan(user->tm, FALSE), buf, FALSE);
|
||||
gtk_list_store_append(liststore, &iter);
|
||||
gtk_list_store_set(liststore, &iter, 0, _("Drawing credit"), 1, buf, 2, "", -1);
|
||||
|
||||
if(user->debt != 0)
|
||||
{
|
||||
misc_print_grouped_int(user->debt, buf, FALSE);
|
||||
sprintf(buf2, "<span foreground='%s'>%s</span>",
|
||||
const_str("string_treeview_finances_expenses_fg"), buf);
|
||||
gtk_list_store_append(liststore, &iter);
|
||||
gtk_list_store_set(liststore, &iter, 0, _("Debt"), 1, "", 2, buf2, -1);
|
||||
}
|
||||
|
||||
return GTK_TREE_MODEL(liststore);
|
||||
}
|
||||
|
||||
void
|
||||
treeview_set_up_finances(GtkTreeView *treeview)
|
||||
{
|
||||
gint i;
|
||||
GtkTreeViewColumn *col;
|
||||
GtkCellRenderer *renderer;
|
||||
gchar *titles[3] =
|
||||
{"",
|
||||
_("Income"),
|
||||
_("Expenses")};
|
||||
|
||||
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(treeview),
|
||||
GTK_SELECTION_NONE);
|
||||
|
||||
for(i=0;i<3;i++)
|
||||
{
|
||||
col = gtk_tree_view_column_new();
|
||||
gtk_tree_view_column_set_title(col, titles[i]);
|
||||
gtk_tree_view_append_column(treeview, col);
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
gtk_tree_view_column_pack_start(col, renderer, FALSE);
|
||||
gtk_tree_view_column_add_attribute(col, renderer,
|
||||
"markup", i);
|
||||
|
||||
if(i == 0)
|
||||
g_object_set(renderer, "xalign", 1.0, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/** Show the finance overview of the user. */
|
||||
void
|
||||
treeview_show_finances(GtkTreeView *treeview, const User* user)
|
||||
{
|
||||
GtkTreeModel *model = NULL;
|
||||
|
||||
treeview_clear(treeview);
|
||||
gtk_tree_view_set_headers_visible(treeview, TRUE);
|
||||
|
||||
treeview_set_up_finances(treeview);
|
||||
model = treeview_create_finances(user);
|
||||
gtk_tree_view_set_model(treeview, model);
|
||||
g_object_unref(model);
|
||||
}
|
||||
|
@@ -128,4 +128,13 @@ void
|
||||
treeview_get_table_element_colours(const Table *table, gint idx, gchar *colour_fg,
|
||||
gchar *colour_bg, gboolean user);
|
||||
|
||||
void
|
||||
treeview_show_finances(GtkTreeView *treeview, const User* user);
|
||||
|
||||
void
|
||||
treeview_set_up_finances(GtkTreeView *treeview);
|
||||
|
||||
GtkTreeModel*
|
||||
treeview_create_finances(const User* user);
|
||||
|
||||
#endif
|
||||
|
13
src/user.c
13
src/user.c
@@ -90,10 +90,13 @@ user_set_up_finances(User *user)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for(i=0; i<FIN_END;i++)
|
||||
user->finances[i] = 0;
|
||||
for(i=0; i<MON_OUT_END;i++)
|
||||
user->money_out[0][i] = user->money_out[1][i] = 0;
|
||||
for(i=0; i<MON_IN_END;i++)
|
||||
user->money_in[0][i] = user->money_in[1][i] = 0;
|
||||
|
||||
user->finances[FIN_MONEY] =
|
||||
user->debt = 0;
|
||||
user->money =
|
||||
math_round_integer(user->tm->stadium.capacity *
|
||||
math_rndi(const_int("int_initial_money_lower"),
|
||||
const_int("int_initial_money_upper")), 2);
|
||||
@@ -146,8 +149,8 @@ user_games_in_week_round(gint week_number, gint week_round_number)
|
||||
for(i=0;i<cps->len;i++)
|
||||
for(j=0;j<cp(i).fixtures->len;j++)
|
||||
if(fixture_user_team_involved(&g_array_index(cp(i).fixtures, Fixture, j)) != -1 &&
|
||||
g_array_index(lig(i).fixtures, Fixture, j).week_number == week_number &&
|
||||
g_array_index(lig(i).fixtures, Fixture, j).week_round_number == week_round_number)
|
||||
g_array_index(cp(i).fixtures, Fixture, j).week_number == week_number &&
|
||||
g_array_index(cp(i).fixtures, Fixture, j).week_round_number == week_round_number)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@@ -6,6 +6,28 @@
|
||||
#include "team_struct.h"
|
||||
#include "live_game_struct.h"
|
||||
|
||||
/** Indices for the money_in array. */
|
||||
enum MonIn
|
||||
{
|
||||
MON_IN_PRIZE = 0,
|
||||
MON_IN_TICKET,
|
||||
MON_IN_TRANSFERS,
|
||||
MON_IN_END
|
||||
};
|
||||
|
||||
/** Indices for the money_out array. */
|
||||
enum MonOut
|
||||
{
|
||||
MON_OUT_WAGE = 0,
|
||||
MON_OUT_PHYSIO,
|
||||
MON_OUT_SCOUT,
|
||||
MON_OUT_JOURNEY,
|
||||
MON_OUT_STADIUM_IMPROVEMENT,
|
||||
MON_OUT_STADIUM_BILLS,
|
||||
MON_OUT_TRANSFERS,
|
||||
MON_OUT_END
|
||||
};
|
||||
|
||||
/** A structure representing a human player. */
|
||||
typedef struct
|
||||
{
|
||||
@@ -15,8 +37,11 @@ typedef struct
|
||||
Team *tm;
|
||||
/** User options. */
|
||||
GArray *options;
|
||||
/** The user's finances. @see #FinanceValue */
|
||||
gint finances[FIN_END];
|
||||
/** The user's money, debt, income and expenses.
|
||||
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];
|
||||
/** The attributes shown in the player lists.
|
||||
@see #PlayerListAttribute
|
||||
@see #PlayerListAttributeValue */
|
||||
|
@@ -54,8 +54,56 @@ float_team_stadium_safety_upper 10000
|
||||
# generation
|
||||
int_team_stadium_ticket_price 30
|
||||
|
||||
# factor for stadium size
|
||||
float_team_stadium_size_wage_factor 24000
|
||||
# factor for stadium size; this determines the income
|
||||
# of the user teams
|
||||
float_team_stadium_size_wage_factor 25000
|
||||
|
||||
# stadium safety deterioration values (per game)
|
||||
float_game_stadium_safety_deterioration_lower 20
|
||||
float_game_stadium_safety_deterioration_upper 50
|
||||
|
||||
# journey cost factor for national and international games
|
||||
float_game_finance_journey_factor_national 3000
|
||||
float_game_finance_journey_factor_international 6000
|
||||
|
||||
# how many spectators in a perfectly safe stadium
|
||||
float_game_stadium_attendance_percentage_lower 7000
|
||||
float_game_stadium_attendance_percentage_upper 11000
|
||||
|
||||
# percentage increasing factor in cup games
|
||||
float_game_stadium_attendance_cup_national_factor 11500
|
||||
float_game_stadium_attendance_cup_international_factor 12500
|
||||
|
||||
# how many rounds before the final there's full house
|
||||
int_game_stadium_attendance_cup_rounds_full_house 3
|
||||
|
||||
# below which rank (in pct. of the number of teams in the league)
|
||||
# there are more spectators
|
||||
float_game_stadium_attendance_rank_percentage 2500
|
||||
|
||||
# factor for an opponent with high rank
|
||||
float_game_stadium_attendance_rank_factor 11000
|
||||
|
||||
# exponent of the stadium safety (the bigger the greater
|
||||
# the influence of the safety on the percentage)
|
||||
float_game_stadium_attendance_safety_exponent 5000
|
||||
|
||||
# how many spectators there can be at most compared to
|
||||
# the average stadium size in the league
|
||||
float_game_stadium_attendance_average_exceed_factor 20000
|
||||
|
||||
# reduce (in percentage) of capacity for different
|
||||
# stadium events
|
||||
float_game_stadium_safety_reduce_breakdown_lower 300
|
||||
float_game_stadium_safety_reduce_breakdown_upper 600
|
||||
float_game_stadium_safety_reduce_riots_lower 500
|
||||
float_game_stadium_safety_reduce_riots_upper 1000
|
||||
float_game_stadium_safety_reduce_fire_lower 1000
|
||||
float_game_stadium_safety_reduce_fire_upper 1500
|
||||
|
||||
# factor we multiply the safety reduction with to obtain the
|
||||
# capacity reduction; the bigger the higher the reduction
|
||||
float_game_stadium_capacity_reduce_factor 15000
|
||||
|
||||
# lsu addition for injured players who are older
|
||||
# than their peak age
|
||||
@@ -108,6 +156,31 @@ float_player_max_skill 990000
|
||||
int_initial_money_lower 80
|
||||
int_initial_money_upper 110
|
||||
|
||||
# wage factors for scout and physio
|
||||
# four apiece because of the different qualities
|
||||
float_finance_scout_factor1 20000
|
||||
float_finance_scout_factor2 15000
|
||||
float_finance_scout_factor3 10000
|
||||
float_finance_scout_factor4 5000
|
||||
|
||||
float_finance_physio_factor1 6000
|
||||
float_finance_physio_factor2 5000
|
||||
float_finance_physio_factor3 4000
|
||||
float_finance_physio_factor4 3000
|
||||
|
||||
# interest rate
|
||||
float_finance_interest 200
|
||||
|
||||
# weight of player values (compared to stadium capacity)
|
||||
# for drawing credit and loan; between 0 and 10000
|
||||
float_finance_credit_player_value_weight 1000
|
||||
|
||||
# influence of the stadium safety on the value of the stadium
|
||||
float_finance_credit_stadium_safety_exponent 2500
|
||||
|
||||
# scaling factors for the drawing credit and loan
|
||||
float_finance_credit_factor_drawing 2000
|
||||
float_finance_credit_factor_loan 8000
|
||||
|
||||
# live game scale configuration
|
||||
float_game_gui_live_game_scale_attack 3000
|
||||
@@ -215,15 +288,20 @@ float_live_game_possession_after_post 3000
|
||||
float_live_game_general_event_second_player 5000
|
||||
|
||||
# constants for stadium events.
|
||||
float_live_game_stadium_event_exponent 500
|
||||
float_live_game_stadium_event_fire 2000
|
||||
float_live_game_stadium_event_riots 5000
|
||||
float_live_game_stadium_event_breakdown 10000
|
||||
# influence of the stadium safety on the stadium
|
||||
# event probability
|
||||
float_live_game_stadium_event_exponent 150
|
||||
|
||||
# probabilities of different events; should add
|
||||
# up to 10000
|
||||
float_live_game_stadium_event_breakdown 6000
|
||||
float_live_game_stadium_event_riots 3000
|
||||
float_live_game_stadium_event_fire 1000
|
||||
|
||||
# foul probabilities.
|
||||
float_live_game_foul 1100
|
||||
float_live_game_foul_red_injury 500
|
||||
float_live_game_foul_red 800
|
||||
float_live_game_foul_red_injury 400
|
||||
float_live_game_foul_red 600
|
||||
float_live_game_foul_yellow 2300
|
||||
|
||||
# ban duration probabilities
|
||||
@@ -239,9 +317,9 @@ float_live_game_ban_5 200
|
||||
float_live_game_foul_by_possession 2000
|
||||
|
||||
# injury probabilities.
|
||||
float_live_game_injury 170
|
||||
float_live_game_injury 140
|
||||
float_live_game_injury_goalie_factor 2000
|
||||
float_live_game_injury_is_temp 7000
|
||||
float_live_game_injury_is_temp 7500
|
||||
|
||||
# probabilities for different injuries
|
||||
# these should add up to 1000
|
||||
@@ -559,3 +637,6 @@ string_treeview_table_promotion lightblue
|
||||
string_treeview_table_relegation lightgreen
|
||||
string_treeview_table_promgames khaki
|
||||
string_treeview_table_best_advance khaki
|
||||
|
||||
# colour for expenses in the finances
|
||||
string_treeview_finances_expenses_fg red
|
||||
|
Reference in New Issue
Block a user