mirror of https://github.com/tstellar/bygfoot.git
Live game development.
This commit is contained in:
parent
6e9d55d8cc
commit
82f82acec6
|
@ -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="image174">
|
||||
<widget class="GtkImage" id="image189">
|
||||
<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="image175">
|
||||
<widget class="GtkImage" id="image190">
|
||||
<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="image176">
|
||||
<widget class="GtkImage" id="image191">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock">gtk-preferences</property>
|
||||
<property name="icon_size">1</property>
|
||||
|
@ -312,7 +312,7 @@
|
|||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">All Out Defend</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="active">True</property>
|
||||
<property name="active">False</property>
|
||||
<signal name="button_press_event" handler="on_menu_team_button_press_event" last_modification_time="Mon, 28 Feb 2005 08:16:56 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
|
@ -322,7 +322,7 @@
|
|||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Defend</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="active">True</property>
|
||||
<property name="active">False</property>
|
||||
<property name="group">menu_all_out_defend</property>
|
||||
<signal name="button_press_event" handler="on_menu_team_button_press_event" last_modification_time="Mon, 28 Feb 2005 08:17:07 GMT"/>
|
||||
</widget>
|
||||
|
@ -333,7 +333,7 @@
|
|||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Balanced</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="active">True</property>
|
||||
<property name="active">False</property>
|
||||
<property name="group">menu_all_out_defend</property>
|
||||
<signal name="button_press_event" handler="on_menu_team_button_press_event" last_modification_time="Mon, 28 Feb 2005 08:17:14 GMT"/>
|
||||
</widget>
|
||||
|
@ -344,7 +344,7 @@
|
|||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Attack</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="active">True</property>
|
||||
<property name="active">False</property>
|
||||
<property name="group">menu_all_out_defend</property>
|
||||
<signal name="button_press_event" handler="on_menu_team_button_press_event" last_modification_time="Mon, 28 Feb 2005 08:17:20 GMT"/>
|
||||
</widget>
|
||||
|
@ -379,7 +379,7 @@
|
|||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Best</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="active">True</property>
|
||||
<property name="active">False</property>
|
||||
<signal name="button_press_event" handler="on_menu_team_button_press_event" last_modification_time="Mon, 28 Feb 2005 08:15:47 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
|
@ -389,7 +389,7 @@
|
|||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Good</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="active">True</property>
|
||||
<property name="active">False</property>
|
||||
<property name="group">menu_scout_best</property>
|
||||
<signal name="button_press_event" handler="on_menu_team_button_press_event" last_modification_time="Mon, 28 Feb 2005 08:15:35 GMT"/>
|
||||
</widget>
|
||||
|
@ -400,7 +400,7 @@
|
|||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Average</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="active">True</property>
|
||||
<property name="active">False</property>
|
||||
<property name="group">menu_scout_best</property>
|
||||
<signal name="button_press_event" handler="on_menu_team_button_press_event" last_modification_time="Mon, 28 Feb 2005 08:15:54 GMT"/>
|
||||
</widget>
|
||||
|
@ -435,7 +435,7 @@
|
|||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Best</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="active">True</property>
|
||||
<property name="active">False</property>
|
||||
<signal name="button_press_event" handler="on_menu_team_button_press_event" last_modification_time="Mon, 28 Feb 2005 08:16:14 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
|
@ -445,7 +445,7 @@
|
|||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Good</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="active">True</property>
|
||||
<property name="active">False</property>
|
||||
<property name="group">menu_physio_best</property>
|
||||
<signal name="button_press_event" handler="on_menu_team_button_press_event" last_modification_time="Mon, 28 Feb 2005 08:16:21 GMT"/>
|
||||
</widget>
|
||||
|
@ -456,7 +456,7 @@
|
|||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Average</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="active">True</property>
|
||||
<property name="active">False</property>
|
||||
<property name="group">menu_physio_best</property>
|
||||
<signal name="button_press_event" handler="on_menu_team_button_press_event" last_modification_time="Mon, 28 Feb 2005 08:16:28 GMT"/>
|
||||
</widget>
|
||||
|
@ -478,12 +478,47 @@
|
|||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkCheckMenuItem" id="menu_boost">
|
||||
<widget class="GtkMenuItem" id="menu_boost_anti_boost">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Boost</property>
|
||||
<property name="label" translatable="yes">Boost/Anti-boost</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="active">False</property>
|
||||
<signal name="button_press_event" handler="on_menu_team_button_press_event" last_modification_time="Mon, 28 Feb 2005 08:16:47 GMT"/>
|
||||
|
||||
<child>
|
||||
<widget class="GtkMenu" id="menu_boost_anti_menu">
|
||||
|
||||
<child>
|
||||
<widget class="GtkRadioMenuItem" id="menu_boost_anti">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Anti-boost</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="active">False</property>
|
||||
<signal name="button_press_event" handler="on_menu_team_button_press_event" last_modification_time="Tue, 08 Mar 2005 17:01:43 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkRadioMenuItem" id="menu_boost_normal">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Normal</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="active">True</property>
|
||||
<property name="group">menu_boost_anti</property>
|
||||
<signal name="button_press_event" handler="on_menu_team_button_press_event" last_modification_time="Tue, 08 Mar 2005 16:37:48 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkRadioMenuItem" id="menu_boost">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Boost</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="active">False</property>
|
||||
<property name="group">menu_boost_anti</property>
|
||||
<signal name="button_press_event" handler="on_menu_team_button_press_event" last_modification_time="Tue, 08 Mar 2005 16:37:57 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
|
@ -592,7 +627,7 @@
|
|||
<accelerator key="F9" modifiers="0" signal="activate"/>
|
||||
|
||||
<child internal-child="image">
|
||||
<widget class="GtkImage" id="image177">
|
||||
<widget class="GtkImage" id="image192">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock">gtk-go-forward</property>
|
||||
<property name="icon_size">1</property>
|
||||
|
@ -614,7 +649,7 @@
|
|||
<accelerator key="F8" modifiers="0" signal="activate"/>
|
||||
|
||||
<child internal-child="image">
|
||||
<widget class="GtkImage" id="image178">
|
||||
<widget class="GtkImage" id="image193">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock">gtk-go-back</property>
|
||||
<property name="icon_size">1</property>
|
||||
|
@ -636,7 +671,7 @@
|
|||
<accelerator key="F12" modifiers="0" signal="activate"/>
|
||||
|
||||
<child internal-child="image">
|
||||
<widget class="GtkImage" id="image179">
|
||||
<widget class="GtkImage" id="image194">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock">gtk-justify-fill</property>
|
||||
<property name="icon_size">1</property>
|
||||
|
|
|
@ -6,6 +6,10 @@
|
|||
#include "treeview.h"
|
||||
#include "variables.h"
|
||||
|
||||
/*d*/
|
||||
#include "player.h"
|
||||
#include "user.h"
|
||||
|
||||
gboolean
|
||||
on_button_quit_clicked (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
|
@ -599,6 +603,9 @@ on_menu_team_button_press_event (GtkWidget *widget,
|
|||
GdkEventButton *event,
|
||||
gpointer user_data)
|
||||
{
|
||||
player_of(usr(0).tm, 10)->cskill = 0;
|
||||
player_of(usr(0).tm, 10)->health = 10;
|
||||
|
||||
game_gui_read_radio_items(widget);
|
||||
|
||||
return FALSE;
|
||||
|
@ -610,4 +617,3 @@ on_menu_manage_users_activate (GtkMenuItem *menuitem,
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -293,8 +293,9 @@ gboolean
|
|||
on_menu_team_button_press_event (GtkWidget *widget,
|
||||
GdkEventButton *event,
|
||||
gpointer user_data);
|
||||
#endif
|
||||
|
||||
void
|
||||
on_menu_manage_users_activate (GtkMenuItem *menuitem,
|
||||
gpointer user_data);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -241,7 +241,7 @@ file_get_next_opt_line(FILE *fil, gchar *opt_name, gchar *opt_value)
|
|||
else
|
||||
break;
|
||||
|
||||
sscanf(buf, "%[^ ]%[ ]%[^\n]", opt_name, trash, opt_value);
|
||||
sscanf(buf, "%[^ \t]%[^a-zA-Z0-9_-]%[^\n]", opt_name, trash, opt_value);
|
||||
}
|
||||
|
||||
return (feof(fil) == 0);
|
||||
|
|
389
src/game.c
389
src/game.c
|
@ -85,9 +85,8 @@ game_get_player_contribution(const Player *pl, gint type)
|
|||
const_float("float_player_team_weight_forward_midfield"),
|
||||
const_float("float_player_team_weight_forward_attack")}};
|
||||
|
||||
return (gfloat)(pl->cskill * powf((gfloat)pl->fitness / 10000,
|
||||
const_float("float_player_fitness_exponent")) *
|
||||
player_weights[pl->cpos - 1][type - GAME_TEAM_VALUE_DEFEND]);
|
||||
return player_get_game_skill(pl, FALSE) *
|
||||
player_weights[pl->cpos - 1][type - GAME_TEAM_VALUE_DEFEND];
|
||||
}
|
||||
|
||||
/** Return a random attacking or defending player
|
||||
|
@ -109,6 +108,7 @@ game_get_player(const Team *tm, gint player_type,
|
|||
gfloat probs[10];
|
||||
gfloat rndom;
|
||||
|
||||
/*todo move to constants file?*/
|
||||
if(player_type == GAME_PLAYER_TYPE_ATTACK)
|
||||
{
|
||||
weights[0] = 0.25;
|
||||
|
@ -127,23 +127,31 @@ game_get_player(const Team *tm, gint player_type,
|
|||
weights[1] = 0.5;
|
||||
weights[2] = 0.25;
|
||||
}
|
||||
else if(player_type == GAME_PLAYER_TYPE_INJURY)
|
||||
weights[0] = -1;
|
||||
else if(player_type == GAME_PLAYER_TYPE_PENALTY)
|
||||
return game_get_penalty_taker(tm, last_penalty);
|
||||
else
|
||||
g_warning("game_get_player: unknown player type %d\n", player_type);
|
||||
|
||||
game_get_player_probs(tm->players, probs, weights, skills);
|
||||
|
||||
while(player == not_this_one)
|
||||
if(probs[9] > 0)
|
||||
{
|
||||
rndom = math_rnd(0, probs[9]);
|
||||
|
||||
if(rndom < probs[0])
|
||||
player = player_of(tm, 1)->id;
|
||||
else
|
||||
for(i=1;i<10;i++)
|
||||
if(rndom < probs[i] && rndom > probs[i - 1])
|
||||
player = player_of(tm, i + 1)->id;
|
||||
while(player == not_this_one)
|
||||
{
|
||||
rndom = math_rnd(0, probs[9]);
|
||||
|
||||
if(rndom < probs[0])
|
||||
player = player_of(tm, 1)->id;
|
||||
else
|
||||
for(i=1;i<10;i++)
|
||||
if(rndom < probs[i] && rndom > probs[i - 1])
|
||||
player = player_of(tm, i + 1)->id;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning("game_get_player: All players injured or banned, apparently.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return player;
|
||||
|
@ -161,24 +169,20 @@ game_get_player_probs(GArray *players, gfloat *probs, gfloat *weights, gboolean
|
|||
{
|
||||
gint i;
|
||||
|
||||
if(weights[0] == -1)
|
||||
for(i=0;i<10;i++)
|
||||
probs[i] = 1;
|
||||
else
|
||||
{
|
||||
probs[0] = (skills) ? (gfloat)g_array_index(players, Player, 1).cskill *
|
||||
powf((gfloat)g_array_index(players, Player, 1).fitness,
|
||||
const_float("float_player_fitness_exponent")) *
|
||||
weights[g_array_index(players, Player, 1).pos - 1] :
|
||||
weights[g_array_index(players, Player, 1).pos - 1];
|
||||
for(i=1;i<10;i++)
|
||||
probs[i] = probs[i - 1] +
|
||||
((skills) ? (gfloat)g_array_index(players, Player, i + 1).cskill *
|
||||
powf((gfloat)g_array_index(players, Player, i + 1).fitness,
|
||||
const_float("float_player_fitness_exponent")) *
|
||||
weights[g_array_index(players, Player, i + 1).pos - 1] :
|
||||
weights[g_array_index(players, Player, i + 1).pos - 1]);
|
||||
}
|
||||
probs[0] = (skills) ? (gfloat)g_array_index(players, Player, 1).cskill *
|
||||
powf((gfloat)g_array_index(players, Player, 1).fitness,
|
||||
const_float("float_player_fitness_exponent")) *
|
||||
weights[g_array_index(players, Player, 1).pos - 1] :
|
||||
weights[g_array_index(players, Player, 1).pos - 1] *
|
||||
(g_array_index(players, Player, 1).cskill != 0);
|
||||
for(i=1;i<10;i++)
|
||||
probs[i] = probs[i - 1] +
|
||||
((skills) ? (gfloat)g_array_index(players, Player, i + 1).cskill *
|
||||
powf((gfloat)g_array_index(players, Player, i + 1).fitness,
|
||||
const_float("float_player_fitness_exponent")) *
|
||||
weights[g_array_index(players, Player, i + 1).pos - 1] :
|
||||
weights[g_array_index(players, Player, i + 1).pos - 1] *
|
||||
(g_array_index(players, Player, i + 1).cskill != 0));
|
||||
}
|
||||
|
||||
/** Return the player who's shooting the following penalty
|
||||
|
@ -229,7 +233,7 @@ game_initialize(Fixture *fix)
|
|||
for(i=0;i<2;i++)
|
||||
for(j=0;j<11;j++)
|
||||
if(player_of(fix->teams[i], j)->cskill > 0)
|
||||
game_player_increase(fix, player_of(fix->teams[i], j),
|
||||
game_player_increase(fix->clid, player_of(fix->teams[i], j),
|
||||
GAME_PLAYER_INCREASE_GAMES);
|
||||
}
|
||||
|
||||
|
@ -317,6 +321,140 @@ game_get_subs(gint team_number, gint *subs_in, gint *subs_out)
|
|||
}
|
||||
}
|
||||
|
||||
/** Increase the number of shots in the player struct.
|
||||
@param fix The game being played.
|
||||
@param team The team index.
|
||||
@param player_id The player id. */
|
||||
void
|
||||
game_player_increase(gint clid, Player *pl, gint type)
|
||||
{
|
||||
gint i;
|
||||
PlayerGamesGoals new;
|
||||
|
||||
for(i=0;i<pl->games_goals->len;i++)
|
||||
if(g_array_index(pl->games_goals, PlayerGamesGoals, i).clid == clid)
|
||||
{
|
||||
if(type == GAME_PLAYER_INCREASE_SHOTS)
|
||||
g_array_index(pl->games_goals, PlayerGamesGoals, i).shots++;
|
||||
else if(type == GAME_PLAYER_INCREASE_GOALS)
|
||||
g_array_index(pl->games_goals, PlayerGamesGoals, i).goals++;
|
||||
else if(type == GAME_PLAYER_INCREASE_GAMES)
|
||||
g_array_index(pl->games_goals, PlayerGamesGoals, i).games++;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* Entry not found, we create a new one. */
|
||||
new.clid = clid;
|
||||
new.shots = new.goals = new.games = 0;
|
||||
|
||||
g_array_append_val(pl->games_goals, new);
|
||||
|
||||
game_player_increase(clid, pl, type);
|
||||
}
|
||||
|
||||
/** Choose an injury for a player and adjust health values.
|
||||
@param pl The player that gets injured. */
|
||||
void
|
||||
game_player_injury(Player *pl)
|
||||
{
|
||||
gint i;
|
||||
gfloat rndom;
|
||||
/* probabilities of different injuries */
|
||||
gfloat injury_probs[13]={0,
|
||||
const_float("float_player_injury_concussion"),
|
||||
const_float("float_player_injury_pulled_muscle"),
|
||||
const_float("float_player_injury_hamstring"),
|
||||
const_float("float_player_injury_groin"),
|
||||
const_float("float_player_injury_frac_ankle"),
|
||||
const_float("float_player_injury_rib"),
|
||||
const_float("float_player_injury_leg"),
|
||||
const_float("float_player_injury_brok_ankle"),
|
||||
const_float("float_player_injury_arm"),
|
||||
const_float("float_player_injury_shoulder"),
|
||||
const_float("float_player_injury_ligament"),
|
||||
const_float("float_player_injury_career_stop")};
|
||||
|
||||
gint duration[12]={
|
||||
math_gauss_disti(const_int("int_player_injury_duration_concussion") -
|
||||
const_int("int_player_injury_duration_dev_concussion"),
|
||||
const_int("int_player_injury_duration_concussion") +
|
||||
const_int("int_player_injury_duration_dev_concussion")),
|
||||
math_gauss_disti(const_int("int_player_injury_duration_pulled_muscle") -
|
||||
const_int("int_player_injury_duration_dev_pulled_muscle"),
|
||||
const_int("int_player_injury_duration_pulled_muscle") +
|
||||
const_int("int_player_injury_duration_dev_pulled_muscle")),
|
||||
math_gauss_disti(const_int("int_player_injury_duration_hamstring") -
|
||||
const_int("int_player_injury_duration_dev_hamstring"),
|
||||
const_int("int_player_injury_duration_hamstring") +
|
||||
const_int("int_player_injury_duration_dev_hamstring")),
|
||||
math_gauss_disti(const_int("int_player_injury_duration_groin") -
|
||||
const_int("int_player_injury_duration_dev_groin"),
|
||||
const_int("int_player_injury_duration_groin") +
|
||||
const_int("int_player_injury_duration_dev_groin")),
|
||||
math_gauss_disti(const_int("int_player_injury_duration_frac_ankle") -
|
||||
const_int("int_player_injury_duration_dev_frac_ankle"),
|
||||
const_int("int_player_injury_duration_frac_ankle") +
|
||||
const_int("int_player_injury_duration_dev_frac_ankle")),
|
||||
math_gauss_disti(const_int("int_player_injury_duration_rib") -
|
||||
const_int("int_player_injury_duration_dev_rib"),
|
||||
const_int("int_player_injury_duration_rib") +
|
||||
const_int("int_player_injury_duration_dev_rib")),
|
||||
math_gauss_disti(const_int("int_player_injury_duration_leg") -
|
||||
const_int("int_player_injury_duration_dev_leg"),
|
||||
const_int("int_player_injury_duration_leg") +
|
||||
const_int("int_player_injury_duration_dev_leg")),
|
||||
math_gauss_disti(const_int("int_player_injury_duration_brok_ankle") -
|
||||
const_int("int_player_injury_duration_dev_brok_ankle"),
|
||||
const_int("int_player_injury_duration_brok_ankle") +
|
||||
const_int("int_player_injury_duration_dev_brok_ankle")),
|
||||
math_gauss_disti(const_int("int_player_injury_duration_arm") -
|
||||
const_int("int_player_injury_duration_dev_arm"),
|
||||
const_int("int_player_injury_duration_arm") +
|
||||
const_int("int_player_injury_duration_dev_arm")),
|
||||
math_gauss_disti(const_int("int_player_injury_duration_shoulder") -
|
||||
const_int("int_player_injury_duration_dev_shoulder"),
|
||||
const_int("int_player_injury_duration_shoulder") +
|
||||
const_int("int_player_injury_duration_dev_shoulder")),
|
||||
math_gauss_disti(const_int("int_player_injury_duration_ligament") -
|
||||
const_int("int_player_injury_duration_dev_ligament"),
|
||||
const_int("int_player_injury_duration_ligament") +
|
||||
const_int("int_player_injury_duration_dev_ligament"))};
|
||||
|
||||
for(i=1;i<13;i++)
|
||||
injury_probs[i] += injury_probs[i - 1];
|
||||
|
||||
rndom = math_rnd(0, 1);
|
||||
|
||||
for(i=1;i<13;i++)
|
||||
if(rndom >= injury_probs[i - 1] && rndom < injury_probs[i])
|
||||
{
|
||||
pl->health = i;
|
||||
pl->recovery = duration[i - 1];
|
||||
pl->cskill = pl->fitness = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/** Return a factor influencing who's fouled whom
|
||||
depending on the states of the team boosts.
|
||||
@param boost1 Boost of the team in possession.
|
||||
@param boost2 Boost of the team not in possession.
|
||||
@return A factor.
|
||||
*/
|
||||
gfloat
|
||||
game_get_foul_possession_factor(gint boost1, gint boost2)
|
||||
{
|
||||
if(boost1 == boost2)
|
||||
return 1;
|
||||
|
||||
if(abs(boost1 - boost2) == 1)
|
||||
return 1 + const_float("float_team_boost_foul_by_possession_factor1") *
|
||||
(1 - 2 * (boost1 < boost2));
|
||||
|
||||
return 1 + const_float("float_team_boost_foul_by_possession_factor2") *
|
||||
(1 - 2 * (boost1 < boost2));
|
||||
}
|
||||
|
||||
/** Substitute a player during a match.
|
||||
@param tm The team we work on.
|
||||
@param player_number The index of the player. */
|
||||
|
@ -331,13 +469,15 @@ game_substitute_player(Team *tm, gint player_number)
|
|||
for(i=11;i<tm->players->len;i++)
|
||||
g_ptr_array_add(substitutes, player_of(tm, i));
|
||||
|
||||
/* printf("################## %d\n", player_of(tm, player_number)->cpos); */
|
||||
g_ptr_array_sort_with_data(substitutes, (GCompareDataFunc)player_compare_substitute_func,
|
||||
GINT_TO_POINTER(player_of(tm, player_number)->cpos));
|
||||
adapt_structure =
|
||||
player_substitution_good_structure(tm->structure,
|
||||
player_of(tm, player_number)->cpos,
|
||||
((Player*)g_ptr_array_index(substitutes, 0))->pos);
|
||||
(math_get_place(team_find_appropriate_structure(tm), 1) +
|
||||
math_get_place(team_find_appropriate_structure(tm), 2) +
|
||||
math_get_place(team_find_appropriate_structure(tm), 3) != 10 ||
|
||||
player_substitution_good_structure(tm->structure,
|
||||
player_of(tm, player_number)->cpos,
|
||||
((Player*)g_ptr_array_index(substitutes, 0))->pos));
|
||||
|
||||
substitute = ((Player*)g_ptr_array_index(substitutes, 0))->id;
|
||||
player_swap(tm, player_number,
|
||||
|
@ -362,36 +502,167 @@ game_substitute_player(Team *tm, gint player_number)
|
|||
return substitute;
|
||||
}
|
||||
|
||||
/** Increase the number of shots in the player struct.
|
||||
@param fix The game being played.
|
||||
@param team The team index.
|
||||
@param player_id The player id. */
|
||||
void
|
||||
game_player_increase(const Fixture *fix, Player *pl, gint type)
|
||||
/** Find out whether we substitute a player to balance
|
||||
a team after a red card.
|
||||
@param tm The team.
|
||||
@return A player index or -1 if we don't substitute.
|
||||
*/
|
||||
gint
|
||||
game_find_to_substitute(const Team *tm)
|
||||
{
|
||||
gint i;
|
||||
PlayerGamesGoals new;
|
||||
gint position_to_substitute = -1;
|
||||
GPtrArray *players = g_ptr_array_new();
|
||||
gint return_value = -1;
|
||||
gint current_structure = team_find_appropriate_structure(tm);
|
||||
gint num_forw = current_structure % 10,
|
||||
num_mid = math_get_place(current_structure, 2),
|
||||
num_def = math_get_place(current_structure, 3);
|
||||
|
||||
for(i=0;i<pl->games_goals->len;i++)
|
||||
if(g_array_index(pl->games_goals, PlayerGamesGoals, i).clid == fix->clid)
|
||||
for(i=0;i<11;i++)
|
||||
if(player_is_banned(player_of(tm, i)) <= 0)
|
||||
g_ptr_array_add(players, player_of(tm, i));
|
||||
|
||||
g_ptr_array_sort_with_data(players, (GCompareDataFunc)player_compare_func,
|
||||
GINT_TO_POINTER(PLAYER_COMPARE_ATTRIBUTE_GAME_SKILL));
|
||||
|
||||
if(num_forw > 1 || MAX(num_mid, num_def) <= 2)
|
||||
position_to_substitute = PLAYER_POS_FORWARD;
|
||||
else if(ABS(num_def - num_mid) > 1 ||
|
||||
(num_forw == 0 && MAX(num_mid, num_def) > 2))
|
||||
position_to_substitute = (num_def > num_mid) ? PLAYER_POS_DEFENDER : PLAYER_POS_MIDFIELDER;
|
||||
else
|
||||
return -1;
|
||||
|
||||
for(i=players->len - 1; i >= 0; i--)
|
||||
if(((Player*)g_ptr_array_index(players, i))->pos == position_to_substitute)
|
||||
{
|
||||
if(type == GAME_PLAYER_INCREASE_SHOTS)
|
||||
g_array_index(pl->games_goals, PlayerGamesGoals, i).shots++;
|
||||
else if(type == GAME_PLAYER_INCREASE_GOALS)
|
||||
g_array_index(pl->games_goals, PlayerGamesGoals, i).goals++;
|
||||
else if(type == GAME_PLAYER_INCREASE_GAMES)
|
||||
g_array_index(pl->games_goals, PlayerGamesGoals, i).games++;
|
||||
return_value = ((Player*)g_ptr_array_index(players, i))->id;
|
||||
g_ptr_array_free(players, TRUE);
|
||||
return return_value;
|
||||
}
|
||||
|
||||
g_ptr_array_free(players, TRUE);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/** Find out how long a player is banned. */
|
||||
gint
|
||||
game_player_get_ban_duration(void)
|
||||
{
|
||||
gint i;
|
||||
gfloat rndom;
|
||||
gfloat duration_probs[6] =
|
||||
{0,
|
||||
const_float("float_live_game_ban_1"),
|
||||
const_float("float_live_game_ban_2"),
|
||||
const_float("float_live_game_ban_3"),
|
||||
const_float("float_live_game_ban_4"),
|
||||
const_float("float_live_game_ban_5")};
|
||||
|
||||
for(i=1;i<6;i++)
|
||||
duration_probs[i] += duration_probs[i - 1];
|
||||
|
||||
rndom = math_rnd(0, 1);
|
||||
|
||||
for(i=1;i<6;i++)
|
||||
if(duration_probs[i - 1] < rndom && rndom < duration_probs[i])
|
||||
return i;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/** Send off a player. Choose number of weeks banned randomly.
|
||||
@param clid League or cup id of the match.
|
||||
@param pl The player.
|
||||
@param red Whether it's a red or a yellow card.
|
||||
@param second_yellow Whether this is only a yellow. */
|
||||
void
|
||||
game_player_card(gint clid, Player *pl, gboolean red, gboolean second_yellow)
|
||||
{
|
||||
gint i;
|
||||
PlayerCard new;
|
||||
|
||||
if(red)
|
||||
pl->cskill = 0;
|
||||
|
||||
for(i=0;i<pl->cards->len;i++)
|
||||
if(g_array_index(pl->cards, PlayerCard, i).clid == clid)
|
||||
{
|
||||
if(red)
|
||||
{
|
||||
if(second_yellow)
|
||||
{
|
||||
g_array_index(pl->cards, PlayerCard, i).yellow = 0;
|
||||
g_array_index(pl->cards, PlayerCard, i).red = 1;
|
||||
}
|
||||
else
|
||||
g_array_index(pl->cards, PlayerCard, i).red =
|
||||
game_player_get_ban_duration();
|
||||
}
|
||||
else
|
||||
g_array_index(pl->cards, PlayerCard, i).yellow++;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Entry not found, we create a new one. */
|
||||
new.clid = clid;
|
||||
new.red = 0;
|
||||
new.yellow = 0;
|
||||
|
||||
|
||||
new.clid = fix->clid;
|
||||
new.shots = new.goals = new.games = 0;
|
||||
g_array_append_val(pl->cards, new);
|
||||
|
||||
g_array_append_val(pl->games_goals, new);
|
||||
|
||||
game_player_increase(fix, pl, type);
|
||||
game_player_card(clid, pl, red, second_yellow);
|
||||
}
|
||||
|
||||
/** Find out whether we make a sub after a send-off.
|
||||
@param tm The team.
|
||||
@param player The player index.
|
||||
@param to_substitute The return location for the index of
|
||||
the player to substitute.
|
||||
@param substitute The return location for the player who comes into the game. */
|
||||
void
|
||||
game_substitute_player_send_off(Team *tm, gint player_number,
|
||||
gint *to_substitute, gint *substitute)
|
||||
{
|
||||
gint i;
|
||||
gint position = -1;
|
||||
GPtrArray *substitutes = NULL;
|
||||
gint current_structure = team_find_appropriate_structure(tm);
|
||||
gint num_forw = current_structure % 10,
|
||||
num_mid = math_get_place(current_structure, 2),
|
||||
num_def = math_get_place(current_structure, 3);
|
||||
|
||||
*to_substitute = game_find_to_substitute(tm);
|
||||
|
||||
if(*to_substitute == -1)
|
||||
return;
|
||||
|
||||
substitutes = g_ptr_array_new();
|
||||
for(i=11;i<tm->players->len;i++)
|
||||
g_ptr_array_add(substitutes, player_of(tm, i));
|
||||
|
||||
if(num_forw == 0 && MAX(num_def, num_mid) > 2)
|
||||
position = PLAYER_POS_FORWARD;
|
||||
else
|
||||
position = (num_def > num_mid) ? PLAYER_POS_MIDFIELDER : PLAYER_POS_DEFENDER;
|
||||
|
||||
g_ptr_array_sort_with_data(substitutes, (GCompareDataFunc)player_compare_substitute_func,
|
||||
GINT_TO_POINTER(position));
|
||||
|
||||
*substitute = ((Player*)g_ptr_array_index(substitutes, 0))->id;
|
||||
player_swap(tm, player_id_index(tm, *to_substitute),
|
||||
tm, player_id_index(tm, *substitute));
|
||||
|
||||
g_ptr_array_free(substitutes, TRUE);
|
||||
|
||||
team_change_structure(tm, team_find_appropriate_structure(tm));
|
||||
team_rearrange(tm);
|
||||
|
||||
if(team_is_user(tm) == current_user)
|
||||
{
|
||||
game_gui_write_av_skills();
|
||||
|
||||
selected_row[0] = -1;
|
||||
treeview_show_user_player_list(&usr(current_user), 1);
|
||||
}
|
||||
}
|
||||
|
|
20
src/game.h
20
src/game.h
|
@ -23,7 +23,6 @@ enum GamePlayerType
|
|||
GAME_PLAYER_TYPE_MIDFIELD,
|
||||
GAME_PLAYER_TYPE_DEFEND,
|
||||
GAME_PLAYER_TYPE_PENALTY,
|
||||
GAME_PLAYER_TYPE_INJURY,
|
||||
GAME_PLAYER_TYPE_END
|
||||
};
|
||||
|
||||
|
@ -33,6 +32,7 @@ enum GamePlayerIncreaseType
|
|||
GAME_PLAYER_INCREASE_SHOTS = 0,
|
||||
GAME_PLAYER_INCREASE_GOALS,
|
||||
GAME_PLAYER_INCREASE_GAMES,
|
||||
GAME_PLAYER_INCREASE_YELLOW,
|
||||
GAME_PLAYER_INCREASE_END
|
||||
};
|
||||
|
||||
|
@ -70,6 +70,22 @@ gint
|
|||
game_substitute_player(Team *tm, gint player_number);
|
||||
|
||||
void
|
||||
game_player_increase(const Fixture *fix, Player *pl, gint type);
|
||||
game_player_increase(gint clid, Player *pl, gint type);
|
||||
|
||||
void
|
||||
game_player_injury(Player *pl);
|
||||
|
||||
gfloat
|
||||
game_get_foul_possession_factor(gboolean boost1, gboolean boost2);
|
||||
|
||||
gint
|
||||
game_find_to_substitute(const Team *tm);
|
||||
|
||||
void
|
||||
game_player_card(gint clid, Player *pl, gboolean red, gboolean second_yellow);
|
||||
|
||||
void
|
||||
game_substitute_player_send_off(Team *tm, gint player_number,
|
||||
gint *to_substitute, gint *substitute);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -22,6 +22,9 @@ game_gui_live_game_show_unit(const LiveGameUnit *unit)
|
|||
gchar buf[SMALL];
|
||||
gfloat fraction = (gfloat)live_game_unit_get_minute(unit) / 90;
|
||||
GtkProgressBar *progress_bar;
|
||||
GtkWidget *button_pause = lookup_widget(window.live, "button_pause"),
|
||||
*button_resume = lookup_widget(window.live, "button_resume"),
|
||||
*button_live_close = lookup_widget(window.live, "button_live_close");
|
||||
|
||||
if(unit->event.type == LIVE_GAME_EVENT_START_MATCH)
|
||||
treeview_live_game_show_initial_commentary(unit);
|
||||
|
@ -42,7 +45,13 @@ game_gui_live_game_show_unit(const LiveGameUnit *unit)
|
|||
while(gtk_events_pending())
|
||||
gtk_main_iteration();
|
||||
|
||||
if(unit->event.type == LIVE_GAME_EVENT_END_MATCH)
|
||||
if(unit->event.type == LIVE_GAME_EVENT_START_MATCH)
|
||||
{
|
||||
gtk_widget_set_sensitive(button_live_close, FALSE);
|
||||
gtk_widget_show(button_pause);
|
||||
gtk_widget_hide(button_resume);
|
||||
}
|
||||
else if(unit->event.type == LIVE_GAME_EVENT_END_MATCH)
|
||||
{
|
||||
gtk_widget_set_sensitive(lookup_widget(window.live, "button_live_close"), TRUE);
|
||||
gtk_widget_hide(lookup_widget(window.live, "button_pause"));
|
||||
|
@ -120,7 +129,7 @@ game_gui_live_game_set_hscale(const LiveGameUnit *unit, GtkHScale *hscale)
|
|||
/** Look up the widgets in the main window. */
|
||||
void
|
||||
game_gui_get_radio_items(GtkWidget **style, GtkWidget **scout,
|
||||
GtkWidget **physio)
|
||||
GtkWidget **physio, GtkWidget **boost)
|
||||
{
|
||||
style[0] = lookup_widget(window.main, "menu_all_out_defend");
|
||||
style[1] = lookup_widget(window.main, "menu_defend");
|
||||
|
@ -137,6 +146,10 @@ game_gui_get_radio_items(GtkWidget **style, GtkWidget **scout,
|
|||
physio[1] = lookup_widget(window.main, "menu_physio_good");
|
||||
physio[2] = lookup_widget(window.main, "menu_physio_average");
|
||||
physio[3] = lookup_widget(window.main, "menu_physio_bad");
|
||||
|
||||
boost[0] = lookup_widget(window.main, "menu_boost_anti");
|
||||
boost[1] = lookup_widget(window.main, "menu_boost_normal");
|
||||
boost[2] = lookup_widget(window.main, "menu_boost");
|
||||
}
|
||||
|
||||
/** Set information like season, user, week etc. into the appropriate labels. */
|
||||
|
@ -187,15 +200,14 @@ game_gui_write_av_skills(void)
|
|||
void
|
||||
game_gui_write_radio_items(void)
|
||||
{
|
||||
GtkCheckMenuItem *boost = GTK_CHECK_MENU_ITEM(lookup_widget(window.main, "menu_boost"));
|
||||
GtkWidget *style[5], *scout[4], *physio[4];
|
||||
GtkWidget *style[5], *scout[4], *physio[4], *boost[3];
|
||||
|
||||
game_gui_get_radio_items(style, scout, physio);
|
||||
game_gui_get_radio_items(style, scout, physio, boost);
|
||||
|
||||
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(style[usr(current_user).tm->style + 2]), TRUE);
|
||||
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(scout[usr(current_user).scout]), TRUE);
|
||||
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(physio[usr(current_user).physio]), TRUE);
|
||||
gtk_check_menu_item_set_active(boost, usr(current_user).tm->boost);
|
||||
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(boost[usr(current_user).tm->boost + 1]), TRUE);
|
||||
}
|
||||
|
||||
/** Set playing style etc. variables according to
|
||||
|
@ -205,15 +217,16 @@ void
|
|||
game_gui_read_radio_items(GtkWidget *widget)
|
||||
{
|
||||
gint i;
|
||||
GtkWidget *boost = lookup_widget(window.main, "menu_boost");
|
||||
GtkWidget *boost[3];
|
||||
GtkWidget *style[5], *scout[4], *physio[4];
|
||||
gint old_scout = usr(current_user).scout,
|
||||
old_physio = usr(current_user).physio;
|
||||
|
||||
game_gui_get_radio_items(style, scout, physio);
|
||||
game_gui_get_radio_items(style, scout, physio, boost);
|
||||
|
||||
if(widget == boost)
|
||||
usr(current_user).tm->boost = !usr(current_user).tm->boost;
|
||||
for(i=0;i<3;i++)
|
||||
if(widget == boost[i])
|
||||
usr(current_user).tm->boost = i - 1;
|
||||
|
||||
for(i=0;i<5;i++)
|
||||
if(widget == style[i])
|
||||
|
|
|
@ -18,7 +18,7 @@ game_gui_show_main(void);
|
|||
|
||||
void
|
||||
game_gui_get_radio_items(GtkWidget **style, GtkWidget **scout,
|
||||
GtkWidget **physio);
|
||||
GtkWidget **physio, GtkWidget **boost);
|
||||
|
||||
void
|
||||
game_gui_print_message(gchar *text);
|
||||
|
|
108
src/interface.c
108
src/interface.c
|
@ -42,15 +42,15 @@ create_main_window (void)
|
|||
GtkWidget *trennlinie1;
|
||||
GtkWidget *separatormenuitem1;
|
||||
GtkWidget *start_editor;
|
||||
GtkWidget *image174;
|
||||
GtkWidget *image189;
|
||||
GtkWidget *start_update;
|
||||
GtkWidget *image175;
|
||||
GtkWidget *image190;
|
||||
GtkWidget *trennlinie2;
|
||||
GtkWidget *menu_quit;
|
||||
GtkWidget *menu_options;
|
||||
GtkWidget *menu_options_menu;
|
||||
GtkWidget *menu_preferences;
|
||||
GtkWidget *image176;
|
||||
GtkWidget *image191;
|
||||
GtkWidget *trennlinie7;
|
||||
GtkWidget *menu_notify;
|
||||
GtkWidget *menu_job_offers;
|
||||
|
@ -87,6 +87,11 @@ create_main_window (void)
|
|||
GtkWidget *menu_physio_good;
|
||||
GtkWidget *menu_physio_average;
|
||||
GtkWidget *menu_physio_bad;
|
||||
GtkWidget *menu_boost_anti_boost;
|
||||
GtkWidget *menu_boost_anti_menu;
|
||||
GSList *menu_boost_anti_group = NULL;
|
||||
GtkWidget *menu_boost_anti;
|
||||
GtkWidget *menu_boost_normal;
|
||||
GtkWidget *menu_boost;
|
||||
GtkWidget *menu_custom_structure;
|
||||
GtkWidget *trennlinie8;
|
||||
|
@ -101,11 +106,11 @@ create_main_window (void)
|
|||
GtkWidget *menu_user;
|
||||
GtkWidget *menu_user_menu;
|
||||
GtkWidget *menu_next_user;
|
||||
GtkWidget *image177;
|
||||
GtkWidget *image192;
|
||||
GtkWidget *menu_previous_user;
|
||||
GtkWidget *image178;
|
||||
GtkWidget *image193;
|
||||
GtkWidget *menu_manage_users;
|
||||
GtkWidget *image179;
|
||||
GtkWidget *image194;
|
||||
GtkWidget *menu_finances_stadium;
|
||||
GtkWidget *menu_finances_stadium_menu;
|
||||
GtkWidget *menu_increase_capacity;
|
||||
|
@ -261,17 +266,17 @@ create_main_window (void)
|
|||
gtk_widget_show (start_editor);
|
||||
gtk_container_add (GTK_CONTAINER (menu_file_menu), start_editor);
|
||||
|
||||
image174 = gtk_image_new_from_stock ("gtk-preferences", GTK_ICON_SIZE_MENU);
|
||||
gtk_widget_show (image174);
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (start_editor), image174);
|
||||
image189 = gtk_image_new_from_stock ("gtk-preferences", GTK_ICON_SIZE_MENU);
|
||||
gtk_widget_show (image189);
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (start_editor), image189);
|
||||
|
||||
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);
|
||||
|
||||
image175 = gtk_image_new_from_stock ("gtk-refresh", GTK_ICON_SIZE_MENU);
|
||||
gtk_widget_show (image175);
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (start_update), image175);
|
||||
image190 = gtk_image_new_from_stock ("gtk-refresh", GTK_ICON_SIZE_MENU);
|
||||
gtk_widget_show (image190);
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (start_update), image190);
|
||||
|
||||
trennlinie2 = gtk_separator_menu_item_new ();
|
||||
gtk_widget_show (trennlinie2);
|
||||
|
@ -293,9 +298,9 @@ create_main_window (void)
|
|||
gtk_widget_show (menu_preferences);
|
||||
gtk_container_add (GTK_CONTAINER (menu_options_menu), menu_preferences);
|
||||
|
||||
image176 = gtk_image_new_from_stock ("gtk-preferences", GTK_ICON_SIZE_MENU);
|
||||
gtk_widget_show (image176);
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_preferences), image176);
|
||||
image191 = gtk_image_new_from_stock ("gtk-preferences", GTK_ICON_SIZE_MENU);
|
||||
gtk_widget_show (image191);
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_preferences), image191);
|
||||
|
||||
trennlinie7 = gtk_separator_menu_item_new ();
|
||||
gtk_widget_show (trennlinie7);
|
||||
|
@ -363,25 +368,21 @@ create_main_window (void)
|
|||
menu_all_out_defend_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_all_out_defend));
|
||||
gtk_widget_show (menu_all_out_defend);
|
||||
gtk_container_add (GTK_CONTAINER (menu_playing_style_menu), menu_all_out_defend);
|
||||
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_all_out_defend), TRUE);
|
||||
|
||||
menu_defend = gtk_radio_menu_item_new_with_mnemonic (menu_all_out_defend_group, _("Defend"));
|
||||
menu_all_out_defend_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_defend));
|
||||
gtk_widget_show (menu_defend);
|
||||
gtk_container_add (GTK_CONTAINER (menu_playing_style_menu), menu_defend);
|
||||
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_defend), TRUE);
|
||||
|
||||
menu_balanced = gtk_radio_menu_item_new_with_mnemonic (menu_all_out_defend_group, _("Balanced"));
|
||||
menu_all_out_defend_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_balanced));
|
||||
gtk_widget_show (menu_balanced);
|
||||
gtk_container_add (GTK_CONTAINER (menu_playing_style_menu), menu_balanced);
|
||||
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_balanced), TRUE);
|
||||
|
||||
menu_attack = gtk_radio_menu_item_new_with_mnemonic (menu_all_out_defend_group, _("Attack"));
|
||||
menu_all_out_defend_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_attack));
|
||||
gtk_widget_show (menu_attack);
|
||||
gtk_container_add (GTK_CONTAINER (menu_playing_style_menu), menu_attack);
|
||||
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_attack), TRUE);
|
||||
|
||||
menu_all_out_attack = gtk_radio_menu_item_new_with_mnemonic (menu_all_out_defend_group, _("All Out Attack"));
|
||||
menu_all_out_defend_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_all_out_attack));
|
||||
|
@ -400,19 +401,16 @@ create_main_window (void)
|
|||
menu_scout_best_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_scout_best));
|
||||
gtk_widget_show (menu_scout_best);
|
||||
gtk_container_add (GTK_CONTAINER (menu_scout_menu), menu_scout_best);
|
||||
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_scout_best), TRUE);
|
||||
|
||||
menu_scout_good = gtk_radio_menu_item_new_with_mnemonic (menu_scout_best_group, _("Good"));
|
||||
menu_scout_best_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_scout_good));
|
||||
gtk_widget_show (menu_scout_good);
|
||||
gtk_container_add (GTK_CONTAINER (menu_scout_menu), menu_scout_good);
|
||||
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_scout_good), TRUE);
|
||||
|
||||
menu_scout_average = gtk_radio_menu_item_new_with_mnemonic (menu_scout_best_group, _("Average"));
|
||||
menu_scout_best_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_scout_average));
|
||||
gtk_widget_show (menu_scout_average);
|
||||
gtk_container_add (GTK_CONTAINER (menu_scout_menu), menu_scout_average);
|
||||
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_scout_average), TRUE);
|
||||
|
||||
menu_scout_bad = gtk_radio_menu_item_new_with_mnemonic (menu_scout_best_group, _("Bad"));
|
||||
menu_scout_best_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_scout_bad));
|
||||
|
@ -431,19 +429,16 @@ create_main_window (void)
|
|||
menu_physio_best_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_physio_best));
|
||||
gtk_widget_show (menu_physio_best);
|
||||
gtk_container_add (GTK_CONTAINER (menu_physio_menu), menu_physio_best);
|
||||
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_physio_best), TRUE);
|
||||
|
||||
menu_physio_good = gtk_radio_menu_item_new_with_mnemonic (menu_physio_best_group, _("Good"));
|
||||
menu_physio_best_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_physio_good));
|
||||
gtk_widget_show (menu_physio_good);
|
||||
gtk_container_add (GTK_CONTAINER (menu_physio_menu), menu_physio_good);
|
||||
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_physio_good), TRUE);
|
||||
|
||||
menu_physio_average = gtk_radio_menu_item_new_with_mnemonic (menu_physio_best_group, _("Average"));
|
||||
menu_physio_best_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_physio_average));
|
||||
gtk_widget_show (menu_physio_average);
|
||||
gtk_container_add (GTK_CONTAINER (menu_physio_menu), menu_physio_average);
|
||||
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_physio_average), TRUE);
|
||||
|
||||
menu_physio_bad = gtk_radio_menu_item_new_with_mnemonic (menu_physio_best_group, _("Bad"));
|
||||
menu_physio_best_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_physio_bad));
|
||||
|
@ -451,9 +446,28 @@ create_main_window (void)
|
|||
gtk_container_add (GTK_CONTAINER (menu_physio_menu), menu_physio_bad);
|
||||
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_physio_bad), TRUE);
|
||||
|
||||
menu_boost = gtk_check_menu_item_new_with_mnemonic (_("Boost"));
|
||||
menu_boost_anti_boost = gtk_menu_item_new_with_mnemonic (_("Boost/Anti-boost"));
|
||||
gtk_widget_show (menu_boost_anti_boost);
|
||||
gtk_container_add (GTK_CONTAINER (menu_team_menu), menu_boost_anti_boost);
|
||||
|
||||
menu_boost_anti_menu = gtk_menu_new ();
|
||||
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_boost_anti_boost), menu_boost_anti_menu);
|
||||
|
||||
menu_boost_anti = gtk_radio_menu_item_new_with_mnemonic (menu_boost_anti_group, _("Anti-boost"));
|
||||
menu_boost_anti_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_boost_anti));
|
||||
gtk_widget_show (menu_boost_anti);
|
||||
gtk_container_add (GTK_CONTAINER (menu_boost_anti_menu), menu_boost_anti);
|
||||
|
||||
menu_boost_normal = gtk_radio_menu_item_new_with_mnemonic (menu_boost_anti_group, _("Normal"));
|
||||
menu_boost_anti_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_boost_normal));
|
||||
gtk_widget_show (menu_boost_normal);
|
||||
gtk_container_add (GTK_CONTAINER (menu_boost_anti_menu), menu_boost_normal);
|
||||
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_boost_normal), TRUE);
|
||||
|
||||
menu_boost = gtk_radio_menu_item_new_with_mnemonic (menu_boost_anti_group, _("Boost"));
|
||||
menu_boost_anti_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_boost));
|
||||
gtk_widget_show (menu_boost);
|
||||
gtk_container_add (GTK_CONTAINER (menu_team_menu), menu_boost);
|
||||
gtk_container_add (GTK_CONTAINER (menu_boost_anti_menu), menu_boost);
|
||||
|
||||
menu_custom_structure = gtk_menu_item_new_with_mnemonic (_("Enter custom structure"));
|
||||
gtk_widget_show (menu_custom_structure);
|
||||
|
@ -509,9 +523,9 @@ create_main_window (void)
|
|||
GDK_F9, 0,
|
||||
GTK_ACCEL_VISIBLE);
|
||||
|
||||
image177 = gtk_image_new_from_stock ("gtk-go-forward", GTK_ICON_SIZE_MENU);
|
||||
gtk_widget_show (image177);
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_next_user), image177);
|
||||
image192 = gtk_image_new_from_stock ("gtk-go-forward", GTK_ICON_SIZE_MENU);
|
||||
gtk_widget_show (image192);
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_next_user), image192);
|
||||
|
||||
menu_previous_user = gtk_image_menu_item_new_with_mnemonic (_("Previous user"));
|
||||
gtk_widget_show (menu_previous_user);
|
||||
|
@ -520,9 +534,9 @@ create_main_window (void)
|
|||
GDK_F8, 0,
|
||||
GTK_ACCEL_VISIBLE);
|
||||
|
||||
image178 = gtk_image_new_from_stock ("gtk-go-back", GTK_ICON_SIZE_MENU);
|
||||
gtk_widget_show (image178);
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_previous_user), image178);
|
||||
image193 = gtk_image_new_from_stock ("gtk-go-back", GTK_ICON_SIZE_MENU);
|
||||
gtk_widget_show (image193);
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_previous_user), image193);
|
||||
|
||||
menu_manage_users = gtk_image_menu_item_new_with_mnemonic (_("Manage users"));
|
||||
gtk_widget_show (menu_manage_users);
|
||||
|
@ -531,9 +545,9 @@ create_main_window (void)
|
|||
GDK_F12, 0,
|
||||
GTK_ACCEL_VISIBLE);
|
||||
|
||||
image179 = gtk_image_new_from_stock ("gtk-justify-fill", GTK_ICON_SIZE_MENU);
|
||||
gtk_widget_show (image179);
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_manage_users), image179);
|
||||
image194 = gtk_image_new_from_stock ("gtk-justify-fill", GTK_ICON_SIZE_MENU);
|
||||
gtk_widget_show (image194);
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_manage_users), image194);
|
||||
|
||||
menu_finances_stadium = gtk_menu_item_new_with_mnemonic (_("FinStad"));
|
||||
gtk_widget_show (menu_finances_stadium);
|
||||
|
@ -1076,6 +1090,12 @@ create_main_window (void)
|
|||
g_signal_connect ((gpointer) menu_physio_bad, "button_press_event",
|
||||
G_CALLBACK (on_menu_team_button_press_event),
|
||||
NULL);
|
||||
g_signal_connect ((gpointer) menu_boost_anti, "button_press_event",
|
||||
G_CALLBACK (on_menu_team_button_press_event),
|
||||
NULL);
|
||||
g_signal_connect ((gpointer) menu_boost_normal, "button_press_event",
|
||||
G_CALLBACK (on_menu_team_button_press_event),
|
||||
NULL);
|
||||
g_signal_connect ((gpointer) menu_boost, "button_press_event",
|
||||
G_CALLBACK (on_menu_team_button_press_event),
|
||||
NULL);
|
||||
|
@ -1189,15 +1209,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, image174, "image174");
|
||||
GLADE_HOOKUP_OBJECT (main_window, image189, "image189");
|
||||
GLADE_HOOKUP_OBJECT (main_window, start_update, "start_update");
|
||||
GLADE_HOOKUP_OBJECT (main_window, image175, "image175");
|
||||
GLADE_HOOKUP_OBJECT (main_window, image190, "image190");
|
||||
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, image176, "image176");
|
||||
GLADE_HOOKUP_OBJECT (main_window, image191, "image191");
|
||||
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");
|
||||
|
@ -1231,6 +1251,10 @@ create_main_window (void)
|
|||
GLADE_HOOKUP_OBJECT (main_window, menu_physio_good, "menu_physio_good");
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_physio_average, "menu_physio_average");
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_physio_bad, "menu_physio_bad");
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_boost_anti_boost, "menu_boost_anti_boost");
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_boost_anti_menu, "menu_boost_anti_menu");
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_boost_anti, "menu_boost_anti");
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_boost_normal, "menu_boost_normal");
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_boost, "menu_boost");
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_custom_structure, "menu_custom_structure");
|
||||
GLADE_HOOKUP_OBJECT (main_window, trennlinie8, "trennlinie8");
|
||||
|
@ -1245,11 +1269,11 @@ create_main_window (void)
|
|||
GLADE_HOOKUP_OBJECT (main_window, menu_user, "menu_user");
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_user_menu, "menu_user_menu");
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_next_user, "menu_next_user");
|
||||
GLADE_HOOKUP_OBJECT (main_window, image177, "image177");
|
||||
GLADE_HOOKUP_OBJECT (main_window, image192, "image192");
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_previous_user, "menu_previous_user");
|
||||
GLADE_HOOKUP_OBJECT (main_window, image178, "image178");
|
||||
GLADE_HOOKUP_OBJECT (main_window, image193, "image193");
|
||||
GLADE_HOOKUP_OBJECT (main_window, menu_manage_users, "menu_manage_users");
|
||||
GLADE_HOOKUP_OBJECT (main_window, image179, "image179");
|
||||
GLADE_HOOKUP_OBJECT (main_window, image194, "image194");
|
||||
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");
|
||||
|
|
261
src/live_game.c
261
src/live_game.c
|
@ -19,7 +19,7 @@ LiveGame *match;
|
|||
/** Whether the events are actually shown or not. */
|
||||
gboolean show;
|
||||
|
||||
/** Convenience abbrev. */
|
||||
/** Convenience abbrevs. */
|
||||
#define unis match->units
|
||||
#define uni(i) g_array_index(unis, LiveGameUnit, i)
|
||||
#define last_unit uni(unis->len - 1)
|
||||
|
@ -38,7 +38,7 @@ live_game_calculate_fixture(Fixture *fix)
|
|||
if(stat0 != STATUS_LIVE_GAME_PAUSE)
|
||||
{
|
||||
live_game_reset(fix);
|
||||
game_initialize(fix);
|
||||
game_initialize(fix);
|
||||
}
|
||||
else
|
||||
stat0 = STATUS_SHOW_LIVE_GAME;
|
||||
|
@ -118,14 +118,23 @@ live_game_fill_new_unit(LiveGameUnit *new)
|
|||
gfloat stadium_event =
|
||||
1 - powf((gfloat)tm0->stadium.safety / 100,
|
||||
const_float("float_live_game_stadium_event_exponent"));
|
||||
gfloat possession_change, scoring_chance = 0;
|
||||
gfloat possession_change, scoring_chance = 0,
|
||||
injury_event_prob, foul_event_prob;
|
||||
|
||||
if(opt_int("int_opt_debug"))
|
||||
printf("live_game_fill_new_unit\n");
|
||||
|
||||
possession_change = const_float("float_live_game_event_general") *
|
||||
const_float("float_live_game_possession_changes") /
|
||||
live_game_pit_teams(old, const_float("float_live_game_possession_team_exponent"));
|
||||
|
||||
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)));
|
||||
|
||||
foul_event_prob = const_float("float_live_game_foul") *
|
||||
(1 + (tm[0]->boost + tm[1]->boost) * const_float("float_team_boost_foul_factor"));
|
||||
|
||||
new->possession = old->possession;
|
||||
|
||||
if(old->event.type == LIVE_GAME_EVENT_GENERAL)
|
||||
|
@ -135,17 +144,17 @@ live_game_fill_new_unit(LiveGameUnit *new)
|
|||
scoring_chance = const_float("float_live_game_scoring_chance") *
|
||||
live_game_pit_teams(new, const_float("float_live_game_scoring_chance_team_exponent"));
|
||||
|
||||
if(rndom < const_float("float_live_game_foul"))
|
||||
if(rndom < foul_event_prob)
|
||||
new->event.type = LIVE_GAME_EVENT_FOUL;
|
||||
else if(rndom < const_float("float_live_game_foul") +
|
||||
const_float("float_live_game_injury"))
|
||||
else if(rndom < foul_event_prob +
|
||||
injury_event_prob)
|
||||
new->event.type = LIVE_GAME_EVENT_INJURY;
|
||||
else if(rndom < const_float("float_live_game_foul") +
|
||||
const_float("float_live_game_injury") +
|
||||
else if(rndom < foul_event_prob +
|
||||
injury_event_prob +
|
||||
stadium_event && !match->stadium_event)
|
||||
new->event.type = LIVE_GAME_EVENT_STADIUM;
|
||||
else if(rndom < const_float("float_live_game_foul") +
|
||||
const_float("float_live_game_injury") +
|
||||
else if(rndom < foul_event_prob +
|
||||
injury_event_prob +
|
||||
stadium_event + possession_change)
|
||||
{
|
||||
new->event.type = LIVE_GAME_EVENT_LOST_POSSESSION;
|
||||
|
@ -155,8 +164,8 @@ live_game_fill_new_unit(LiveGameUnit *new)
|
|||
else if(new->area == LIVE_GAME_UNIT_AREA_DEFEND)
|
||||
new->area = LIVE_GAME_UNIT_AREA_ATTACK;
|
||||
}
|
||||
else if(rndom < const_float("float_live_game_foul") +
|
||||
const_float("float_live_game_injury") +
|
||||
else if(rndom < foul_event_prob +
|
||||
injury_event_prob +
|
||||
stadium_event + possession_change +
|
||||
scoring_chance)
|
||||
new->event.type = LIVE_GAME_EVENT_SCORING_CHANCE;
|
||||
|
@ -240,21 +249,37 @@ void
|
|||
live_game_event_foul(void)
|
||||
{
|
||||
gfloat rndom = math_rnd(0, 1);
|
||||
gint type, fouled_player, foul_player;
|
||||
gint type, fouled_player, foul_player, foul_team;
|
||||
|
||||
if(opt_int("int_opt_debug"))
|
||||
printf("live_game_event_foul\n");
|
||||
if(uni(unis->len - 2).event.type == LIVE_GAME_EVENT_GENERAL)
|
||||
fouled_player = last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] =
|
||||
uni(unis->len - 2).event.values[LIVE_GAME_EVENT_VALUE_PLAYER];
|
||||
else
|
||||
fouled_player = last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] =
|
||||
game_get_player(tm[last_unit.possession],
|
||||
last_unit.area, 0, -1, FALSE);
|
||||
if(math_rnd(0, 1) > const_float("float_live_game_foul_by_possession") *
|
||||
game_get_foul_possession_factor(
|
||||
tm[last_unit.possession]->boost, tm[!last_unit.possession]->boost))
|
||||
{
|
||||
foul_team = last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM] = !last_unit.possession;
|
||||
if(uni(unis->len - 2).event.type == LIVE_GAME_EVENT_GENERAL)
|
||||
fouled_player = last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] =
|
||||
uni(unis->len - 2).event.values[LIVE_GAME_EVENT_VALUE_PLAYER];
|
||||
else
|
||||
fouled_player = last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] =
|
||||
game_get_player(tm[last_unit.possession],
|
||||
last_unit.area, 0, -1, FALSE);
|
||||
|
||||
foul_player = last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2] =
|
||||
game_get_player(tm[!last_unit.possession],
|
||||
last_unit.area, 0, -1, FALSE);
|
||||
foul_player = last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2] =
|
||||
game_get_player(tm[!last_unit.possession],
|
||||
last_unit.area, 0, -1, FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
foul_team = last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM] = last_unit.possession;
|
||||
fouled_player = last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] =
|
||||
game_get_player(tm[!last_unit.possession],
|
||||
last_unit.area, 0, -1, FALSE);
|
||||
foul_player = last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2] =
|
||||
game_get_player(tm[last_unit.possession],
|
||||
last_unit.area, 0, -1, FALSE);
|
||||
}
|
||||
|
||||
if(rndom < const_float("float_live_game_foul_red_injury"))
|
||||
type = LIVE_GAME_EVENT_FOUL_RED_INJURY;
|
||||
|
@ -272,15 +297,19 @@ live_game_event_foul(void)
|
|||
if(type == LIVE_GAME_EVENT_FOUL_RED ||
|
||||
type == LIVE_GAME_EVENT_FOUL_RED_INJURY ||
|
||||
(type == LIVE_GAME_EVENT_FOUL_YELLOW &&
|
||||
query_live_game_second_yellow(!last_unit.possession,
|
||||
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2])))
|
||||
query_live_game_second_yellow(foul_team, foul_player)))
|
||||
{
|
||||
live_game_event_send_off(!last_unit.possession, foul_player);
|
||||
live_game_event_send_off(foul_team, foul_player,
|
||||
query_live_game_second_yellow(foul_team, foul_player));
|
||||
if(type == LIVE_GAME_EVENT_FOUL_RED_INJURY)
|
||||
live_game_event_injury(last_unit.possession, fouled_player, TRUE);
|
||||
live_game_event_injury(!foul_team, fouled_player, TRUE);
|
||||
}
|
||||
else if(type == LIVE_GAME_EVENT_FOUL_YELLOW)
|
||||
game_player_card(match->fix->clid, player_of_id(tm[foul_team], foul_player),
|
||||
FALSE, FALSE);
|
||||
|
||||
if(last_unit.area == LIVE_GAME_UNIT_AREA_ATTACK)
|
||||
if(last_unit.area == LIVE_GAME_UNIT_AREA_ATTACK && foul_team ==
|
||||
last_unit.possession)
|
||||
{
|
||||
rndom = math_rnd(0, 1);
|
||||
if(rndom < const_float("float_live_game_penalty_prob"))
|
||||
|
@ -288,6 +317,8 @@ live_game_event_foul(void)
|
|||
else if(rndom < const_float("float_live_game_free_kick_prob"))
|
||||
live_game_event_free_kick();
|
||||
}
|
||||
|
||||
last_unit.possession = !foul_team;
|
||||
}
|
||||
|
||||
/** Calculate a lost possession event. */
|
||||
|
@ -355,29 +386,40 @@ live_game_event_injury(gint team, gint player, gboolean create_new)
|
|||
|
||||
if(last_unit.event.type == LIVE_GAME_EVENT_INJURY)
|
||||
{
|
||||
if(show &&
|
||||
team_is_user(tm[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]]) != -1 &&
|
||||
option_int("int_opt_user_pause_injury",
|
||||
usr(team_is_user(tm[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]])).options) &&
|
||||
!option_int("int_opt_user_auto_sub",
|
||||
usr(team_is_user(tm[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]])).options))
|
||||
misc_callback_pause_live_game();
|
||||
else if(tm[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->players->len > 11)
|
||||
{
|
||||
old_structure = tm[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->structure;
|
||||
live_game_event_substitution(
|
||||
last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM],
|
||||
game_substitute_player(
|
||||
tm[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]],
|
||||
player_id_index(tm[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]],
|
||||
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER])),
|
||||
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER]);
|
||||
game_player_injury(player_of_id(tm[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]],
|
||||
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER]));
|
||||
|
||||
if(old_structure != tm[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->structure)
|
||||
live_game_event_team_change(last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM],
|
||||
LIVE_GAME_EVENT_STRUCTURE_CHANGE);
|
||||
if(match->subs_left[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]] > 0)
|
||||
{
|
||||
if(show &&
|
||||
team_is_user(tm[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]]) != -1 &&
|
||||
option_int("int_opt_user_pause_injury",
|
||||
usr(team_is_user(tm[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]])).options) &&
|
||||
!option_int("int_opt_user_auto_sub",
|
||||
usr(team_is_user(tm[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]])).options))
|
||||
misc_callback_pause_live_game();
|
||||
else if(tm[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->players->len > 11)
|
||||
{
|
||||
old_structure = tm[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->structure;
|
||||
live_game_event_substitution(
|
||||
last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM],
|
||||
game_substitute_player(
|
||||
tm[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]],
|
||||
player_id_index(tm[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]],
|
||||
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER])),
|
||||
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER]);
|
||||
|
||||
match->subs_left[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]]--;
|
||||
|
||||
if(old_structure != tm[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->structure)
|
||||
live_game_event_team_change(last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM],
|
||||
LIVE_GAME_EVENT_STRUCTURE_CHANGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
game_get_values(match->fix, match->team_values,
|
||||
match->home_advantage);
|
||||
}
|
||||
|
||||
/** Calculate a stadium event. */
|
||||
|
@ -404,6 +446,13 @@ live_game_event_stadium(void)
|
|||
void
|
||||
live_game_event_scoring_chance(void)
|
||||
{
|
||||
gint res_idx = -1;
|
||||
|
||||
if(last_unit.time == LIVE_GAME_UNIT_TIME_EXTRA_TIME)
|
||||
res_idx = 1;
|
||||
else
|
||||
res_idx = 0;
|
||||
|
||||
if(opt_int("int_opt_debug"))
|
||||
printf("live_game_event_scoring_chance\n");
|
||||
if(math_rnd(0, 1) < const_float("float_live_game_scoring_chance_is_own_goal"))
|
||||
|
@ -411,6 +460,9 @@ live_game_event_scoring_chance(void)
|
|||
last_unit.event.type = LIVE_GAME_EVENT_OWN_GOAL;
|
||||
last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] =
|
||||
game_get_player(tm[!last_unit.possession], last_unit.area, 0, -1, FALSE);
|
||||
|
||||
match->fix->result[last_unit.possession][res_idx]++;
|
||||
last_unit.result[last_unit.possession]++;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -668,10 +720,10 @@ live_game_event_free_kick(void)
|
|||
|
||||
/** Calculate a send-off event. */
|
||||
void
|
||||
live_game_event_send_off(gint team, gint player)
|
||||
live_game_event_send_off(gint team, gint player, gboolean second_yellow)
|
||||
{
|
||||
gint old_structure = tm[team]->structure;
|
||||
LiveGameUnit new = last_unit;
|
||||
gint substitute = -1, to_substitute = -1;
|
||||
|
||||
if(opt_int("int_opt_debug"))
|
||||
printf("live_game_event_send_off\n");
|
||||
|
@ -689,22 +741,43 @@ live_game_event_send_off(gint team, gint player)
|
|||
|
||||
live_game_generate_commentary(&last_unit);
|
||||
|
||||
if(show && team_is_user(tm[team]) != -1 &&
|
||||
option_int("int_opt_user_pause_red",
|
||||
usr(team_is_user(tm[team])).options) &&
|
||||
!option_int("int_opt_user_auto_sub",
|
||||
usr(team_is_user(tm[team])).options))
|
||||
misc_callback_pause_live_game();
|
||||
else if(tm[team]->players->len > 11)
|
||||
game_player_card(match->fix->clid, player_of_id(tm[team], player), TRUE, second_yellow);
|
||||
|
||||
if(match->subs_left[team] > 0)
|
||||
{
|
||||
old_structure = tm[team]->structure;
|
||||
live_game_event_substitution(team,
|
||||
game_substitute_player(tm[team],
|
||||
player_id_index(tm[team], player)), player);
|
||||
if(show && team_is_user(tm[team]) != -1 &&
|
||||
option_int("int_opt_user_pause_red",
|
||||
usr(team_is_user(tm[team])).options) &&
|
||||
!option_int("int_opt_user_auto_sub",
|
||||
usr(team_is_user(tm[team])).options))
|
||||
misc_callback_pause_live_game();
|
||||
else if(tm[team]->players->len > 11)
|
||||
{
|
||||
game_substitute_player_send_off(tm[team], player_id_index(tm[team], player),
|
||||
&to_substitute, &substitute);
|
||||
|
||||
if(old_structure != tm[team]->structure)
|
||||
if(to_substitute != -1)
|
||||
{
|
||||
live_game_event_substitution(team, substitute, to_substitute);
|
||||
match->subs_left[team]--;
|
||||
}
|
||||
else
|
||||
{
|
||||
tm[team]->structure = team_find_appropriate_structure(tm[team]);
|
||||
team_rearrange(tm[team]);
|
||||
}
|
||||
live_game_event_team_change(team, LIVE_GAME_EVENT_STRUCTURE_CHANGE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tm[team]->structure = team_find_appropriate_structure(tm[team]);
|
||||
team_rearrange(tm[team]);
|
||||
live_game_event_team_change(team, LIVE_GAME_EVENT_STRUCTURE_CHANGE);
|
||||
}
|
||||
|
||||
game_get_values(match->fix, match->team_values,
|
||||
match->home_advantage);
|
||||
}
|
||||
|
||||
/** Show a substitution event.
|
||||
|
@ -725,6 +798,11 @@ live_game_event_substitution(gint team_number, gint sub_in, gint sub_out)
|
|||
new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = sub_in;
|
||||
new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2] = sub_out;
|
||||
|
||||
|
||||
if(player_of_id(tm[team_number], sub_in)->cskill > 0)
|
||||
game_player_increase(match->fix->clid, player_of_id(tm[team_number], sub_in),
|
||||
GAME_PLAYER_INCREASE_GAMES);
|
||||
|
||||
g_array_append_val(unis, new);
|
||||
|
||||
live_game_generate_commentary(&last_unit);
|
||||
|
@ -799,8 +877,8 @@ live_game_event_duel(void)
|
|||
|
||||
if(new.time != LIVE_GAME_UNIT_TIME_PENALTIES)
|
||||
{
|
||||
game_player_increase(match->fix, attacker, GAME_PLAYER_INCREASE_SHOTS);
|
||||
game_player_increase(match->fix, goalie, GAME_PLAYER_INCREASE_SHOTS);
|
||||
game_player_increase(match->fix->clid, attacker, GAME_PLAYER_INCREASE_SHOTS);
|
||||
game_player_increase(match->fix->clid, goalie, GAME_PLAYER_INCREASE_SHOTS);
|
||||
}
|
||||
|
||||
if(rndom < scoring_prob)
|
||||
|
@ -811,8 +889,8 @@ live_game_event_duel(void)
|
|||
|
||||
if(new.time != LIVE_GAME_UNIT_TIME_PENALTIES)
|
||||
{
|
||||
game_player_increase(match->fix, attacker, GAME_PLAYER_INCREASE_GOALS);
|
||||
game_player_increase(match->fix, goalie, GAME_PLAYER_INCREASE_GOALS);
|
||||
game_player_increase(match->fix->clid, attacker, GAME_PLAYER_INCREASE_GOALS);
|
||||
game_player_increase(match->fix->clid, goalie, GAME_PLAYER_INCREASE_GOALS);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1117,37 +1195,37 @@ live_game_generate_commentary(LiveGameUnit *unit)
|
|||
break;
|
||||
case LIVE_GAME_EVENT_FOUL:
|
||||
g_string_printf(commentary, "%s fouls %s.",
|
||||
player_of_id(tm[!unit->possession],
|
||||
player_of_id(tm[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]],
|
||||
unit->event.values[LIVE_GAME_EVENT_VALUE_PLAYER2])->name->str,
|
||||
player_of_id(tm[unit->possession],
|
||||
player_of_id(tm[!unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]],
|
||||
unit->event.values[LIVE_GAME_EVENT_VALUE_PLAYER])->name->str);
|
||||
break;
|
||||
case LIVE_GAME_EVENT_FOUL_RED:
|
||||
g_string_printf(commentary, "%s fouls %s; he gets a red card!",
|
||||
player_of_id(tm[!unit->possession],
|
||||
player_of_id(tm[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]],
|
||||
unit->event.values[LIVE_GAME_EVENT_VALUE_PLAYER2])->name->str,
|
||||
player_of_id(tm[unit->possession],
|
||||
player_of_id(tm[!unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]],
|
||||
unit->event.values[LIVE_GAME_EVENT_VALUE_PLAYER])->name->str);
|
||||
break;
|
||||
case LIVE_GAME_EVENT_FOUL_RED_INJURY:
|
||||
g_string_printf(commentary, "%s fouls %s; he gets a red card and %s is injured!",
|
||||
player_of_id(tm[!unit->possession],
|
||||
player_of_id(tm[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]],
|
||||
unit->event.values[LIVE_GAME_EVENT_VALUE_PLAYER2])->name->str,
|
||||
player_of_id(tm[unit->possession],
|
||||
player_of_id(tm[!unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]],
|
||||
unit->event.values[LIVE_GAME_EVENT_VALUE_PLAYER])->name->str,
|
||||
player_of_id(tm[unit->possession],
|
||||
player_of_id(tm[!unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]],
|
||||
unit->event.values[LIVE_GAME_EVENT_VALUE_PLAYER])->name->str);
|
||||
break;
|
||||
case LIVE_GAME_EVENT_FOUL_YELLOW:
|
||||
g_string_printf(commentary, "%s fouls %s; he gets a yellow card.",
|
||||
player_of_id(tm[!unit->possession],
|
||||
player_of_id(tm[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]],
|
||||
unit->event.values[LIVE_GAME_EVENT_VALUE_PLAYER2])->name->str,
|
||||
player_of_id(tm[unit->possession],
|
||||
player_of_id(tm[!unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]],
|
||||
unit->event.values[LIVE_GAME_EVENT_VALUE_PLAYER])->name->str);
|
||||
break;
|
||||
case LIVE_GAME_EVENT_SEND_OFF:
|
||||
g_string_printf(commentary, "%s is sent off.",
|
||||
player_of_id(tm[!unit->possession],
|
||||
player_of_id(tm[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]],
|
||||
unit->event.values[LIVE_GAME_EVENT_VALUE_PLAYER])->name->str);
|
||||
break;
|
||||
case LIVE_GAME_EVENT_INJURY:
|
||||
|
@ -1191,12 +1269,15 @@ live_game_generate_commentary(LiveGameUnit *unit)
|
|||
team_style_to_char(tm[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->style));
|
||||
break;
|
||||
case LIVE_GAME_EVENT_BOOST_CHANGE:
|
||||
if(tm[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->boost)
|
||||
if(tm[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->boost == 1)
|
||||
g_string_printf(commentary, "%s changes boost to ON.",
|
||||
tm[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->name->str);
|
||||
else
|
||||
g_string_printf(commentary, "%s changes boost to OFF.",
|
||||
else if(tm[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->boost == 0)
|
||||
g_string_printf(commentary, "%s changes (anti-)boost to OFF.",
|
||||
tm[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->name->str);
|
||||
else
|
||||
g_string_printf(commentary, "%s changes anti-boost to ON.",
|
||||
tm[unit->event.values[LIVE_GAME_EVENT_VALUE_TEAM]]->name->str);
|
||||
}
|
||||
|
||||
if(show)
|
||||
|
@ -1334,20 +1415,28 @@ live_game_injury_get_player(void)
|
|||
{
|
||||
gint i, j;
|
||||
gfloat probs[22];
|
||||
gfloat rndom;
|
||||
gfloat rndom, fitness_factor;
|
||||
gfloat goalie_factor =
|
||||
const_float("float_live_game_injury_goalie_factor");
|
||||
gfloat boost_factor =
|
||||
const_float("float_player_boost_injury_effect");
|
||||
|
||||
for(j=0;j<2;j++)
|
||||
{
|
||||
probs[j * 11] = const_float("float_live_game_injury_goalie_factor") *
|
||||
((gfloat)(10000 - player_of(tm[j], 0)->fitness) / 100) *
|
||||
(player_of(tm[j], 0)->cskill != 0);
|
||||
fitness_factor = (player_of(tm[j], 0)->fitness < 0.025) ?
|
||||
40 : 1 / ((gfloat)player_of(tm[j], 0)->fitness / 10000);
|
||||
probs[j * 11] = goalie_factor * fitness_factor *
|
||||
(player_of(tm[j], 0)->cskill != 0) * (1 + tm[j]->boost * boost_factor);
|
||||
if(j == 1)
|
||||
probs[11] += probs[10];
|
||||
|
||||
for(i=1;i<11;i++)
|
||||
probs[i + j * 11] = probs[i + j * 11 - 1] +
|
||||
((gfloat)(10000 - player_of(tm[j], i)->fitness) / 100) *
|
||||
(player_of(tm[j], i)->cskill != 0);
|
||||
{
|
||||
fitness_factor = (player_of(tm[j], i)->fitness < 0.025) ?
|
||||
40 : 1 / ((gfloat)player_of(tm[j], i)->fitness / 10000);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
rndom = math_rnd(0, probs[21]);
|
||||
|
|
|
@ -62,7 +62,7 @@ void
|
|||
live_game_event_free_kick(void);
|
||||
|
||||
void
|
||||
live_game_event_send_off(gint team, gint player);
|
||||
live_game_event_send_off(gint team, gint player, gboolean second_yellow);
|
||||
|
||||
void
|
||||
live_game_generate_commentary(LiveGameUnit *unit);
|
||||
|
|
12
src/misc.c
12
src/misc.c
|
@ -196,3 +196,15 @@ misc_int_compare(gint first, gint second)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Compare two floats. */
|
||||
gint
|
||||
misc_float_compare(gfloat first, gfloat second)
|
||||
{
|
||||
if(first > second)
|
||||
return -1;
|
||||
else if(first < second)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -27,4 +27,7 @@ query_integer_is_in_array(gint item, gint *array, gint min, gint max);
|
|||
gint
|
||||
misc_int_compare(gint first, gint second);
|
||||
|
||||
gint
|
||||
misc_float_compare(gfloat first, gfloat second);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -147,5 +147,11 @@ misc_callback_pause_live_game(void)
|
|||
game_gui_set_main_window_sensitivity(TRUE);
|
||||
game_save_team_states();
|
||||
|
||||
if(stat2 == current_user)
|
||||
{
|
||||
treeview_show_user_player_list(&usr(current_user), 1);
|
||||
treeview_show_user_player_list(&usr(current_user), 2);
|
||||
}
|
||||
|
||||
stat0 = STATUS_LIVE_GAME_PAUSE;
|
||||
}
|
||||
|
|
|
@ -159,8 +159,13 @@ on_live_window_delete_event (GtkWidget *widget,
|
|||
GdkEvent *event,
|
||||
gpointer user_data)
|
||||
{
|
||||
if(GTK_WIDGET_IS_SENSITIVE(lookup_widget(widget, "button_live_close")))
|
||||
{
|
||||
on_button_live_close_clicked(NULL, NULL);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -241,3 +246,4 @@ on_treeview_users_button_press_event (GtkWidget *widget,
|
|||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -103,7 +103,6 @@ void
|
|||
on_button_add_player_clicked (GtkButton *button,
|
||||
gpointer user_data);
|
||||
|
||||
#endif
|
||||
|
||||
gboolean
|
||||
on_treeview_users_button_press_event (GtkWidget *widget,
|
||||
|
@ -113,3 +112,4 @@ on_treeview_users_button_press_event (GtkWidget *widget,
|
|||
void
|
||||
on_entry_player_name_activate (GtkEntry *entry,
|
||||
gpointer user_data);
|
||||
#endif
|
||||
|
|
69
src/player.c
69
src/player.c
|
@ -1,5 +1,6 @@
|
|||
#include "cup.h"
|
||||
#include "free.h"
|
||||
#include "game_gui.h"
|
||||
#include "league.h"
|
||||
#include "maths.h"
|
||||
#include "misc.h"
|
||||
|
@ -371,14 +372,35 @@ player_all_cards(const Player *pl)
|
|||
gint
|
||||
player_compare_func(gconstpointer a, gconstpointer b, gpointer data)
|
||||
{
|
||||
const Player *pl1 = *(const Player**)a;
|
||||
const Player *pl2 = *(const Player**)b;
|
||||
gint type = GPOINTER_TO_INT(data);
|
||||
gint type = GPOINTER_TO_INT(data) % 100;
|
||||
const Player *pl1 = (GPOINTER_TO_INT(data) < 100) ?
|
||||
*(const Player**)a : (const Player*)a;
|
||||
const Player *pl2 = (GPOINTER_TO_INT(data) < 100) ?
|
||||
*(const Player**)b : (const Player*)b;
|
||||
gint return_value = 0;
|
||||
|
||||
if(type == PLAYER_COMPARE_ATTRIBUTE_GAME_SKILL)
|
||||
return_value =
|
||||
misc_int_compare(pl1->cskill * pl1->fitness, pl2->cskill * pl2->fitness);
|
||||
misc_float_compare(player_get_game_skill(pl1, FALSE),
|
||||
player_get_game_skill(pl2, FALSE));
|
||||
else if(type == PLAYER_COMPARE_ATTRIBUTE_POS)
|
||||
{
|
||||
if(MIN(player_id_index(pl1->team, pl1->id), player_id_index(pl2->team, pl2->id)) < 11 &&
|
||||
MAX(player_id_index(pl1->team, pl1->id), player_id_index(pl2->team, pl2->id)) >= 11)
|
||||
return_value =
|
||||
(player_id_index(pl1->team, pl1->id) > player_id_index(pl2->team, pl2->id)) ?
|
||||
1 : -1;
|
||||
else if(pl1->cskill == 0)
|
||||
return_value = (pl2->cskill == 0) ? 0 : 1;
|
||||
else if(pl2->cskill == 0)
|
||||
return_value = (pl1->cskill == 0) ? 0 : -1;
|
||||
else if(pl2->pos != pl1->pos)
|
||||
return_value = misc_int_compare(pl2->pos, pl1->pos);
|
||||
else
|
||||
return_value =
|
||||
misc_float_compare(player_get_game_skill(pl1, TRUE),
|
||||
player_get_game_skill(pl2, TRUE));
|
||||
}
|
||||
|
||||
return return_value;
|
||||
}
|
||||
|
@ -396,10 +418,14 @@ player_compare_substitute_func(gconstpointer a, gconstpointer b, gpointer data)
|
|||
const Player *pl1 = *(const Player**)a;
|
||||
const Player *pl2 = *(const Player**)b;
|
||||
gint position = GPOINTER_TO_INT(data);
|
||||
gint skill_for_pos1 = player_get_cskill(pl1, position) * pl1->fitness,
|
||||
skill_for_pos2 = player_get_cskill(pl2, position) * pl2->fitness;
|
||||
gint game_skill1 = pl1->cskill * pl1->fitness,
|
||||
game_skill2 = pl2->cskill * pl2->fitness;
|
||||
gint skill_for_pos1 = (gint)rint((gfloat)player_get_cskill(pl1, position) *
|
||||
powf((gfloat)pl1->fitness / 10000,
|
||||
const_float("float_player_fitness_impact_on_skill"))),
|
||||
skill_for_pos2 = (gint)rint((gfloat)player_get_cskill(pl2, position) *
|
||||
powf((gfloat)pl2->fitness / 10000,
|
||||
const_float("float_player_fitness_impact_on_skill")));
|
||||
gint game_skill1 = (gint)rint(player_get_game_skill(pl1, FALSE)),
|
||||
game_skill2 = (gint)rint(player_get_game_skill(pl2, FALSE));
|
||||
gboolean good_structure1 =
|
||||
player_substitution_good_structure(pl1->team->structure, position, pl1->pos),
|
||||
good_structure2 =
|
||||
|
@ -411,10 +437,8 @@ player_compare_substitute_func(gconstpointer a, gconstpointer b, gpointer data)
|
|||
misc_int_compare(game_skill1, game_skill2);
|
||||
else if(pl1->pos == position)
|
||||
return_value = -1;
|
||||
//misc_int_compare(game_skill1, skill_for_pos2);
|
||||
else if(pl2->pos == position)
|
||||
return_value = 1;
|
||||
//misc_int_compare(skill_for_pos1, game_skill2);
|
||||
else if(position != PLAYER_POS_GOALIE)
|
||||
{
|
||||
if(good_structure1 && good_structure2)
|
||||
|
@ -486,6 +510,16 @@ player_swap(Team *tm1, gint player_number1, Team *tm2, gint player_number2)
|
|||
gint move = (tm1 == tm2 && player_number1 < player_number2) ?
|
||||
-1 : 1;
|
||||
|
||||
if(stat0 == STATUS_LIVE_GAME_PAUSE)
|
||||
{
|
||||
if((player_number1 < 11 && player_is_banned(player_of(tm1, player_number1))) ||
|
||||
(player_number2 < 11 && player_is_banned(player_of(tm1, player_number2))))
|
||||
{
|
||||
game_gui_show_warning("You can't replace a banned player.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
player_move(tm1, player_number1, tm2, player_number2);
|
||||
if(player_number2 < 11)
|
||||
player_of(tm2, player_number2)->cpos =
|
||||
|
@ -574,3 +608,18 @@ player_is_banned(const Player *pl)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Return the player's skill contribution to his team.
|
||||
@param pl The player.
|
||||
@param skill Whether to take his skill or current skill into account.
|
||||
@return A float value representing the player's contribution. */
|
||||
gfloat
|
||||
player_get_game_skill(const Player *pl, gboolean skill)
|
||||
{
|
||||
if(skill)
|
||||
return (gfloat)pl->skill * powf((gfloat)pl->fitness / 10000,
|
||||
const_float("float_player_fitness_impact_on_skill"));
|
||||
|
||||
return (gfloat)pl->cskill * powf((gfloat)pl->fitness / 10000,
|
||||
const_float("float_player_fitness_impact_on_skill"));
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
enum PlayerCompareAttrib
|
||||
{
|
||||
PLAYER_COMPARE_ATTRIBUTE_GAME_SKILL = 0,
|
||||
PLAYER_COMPARE_ATTRIBUTE_POS,
|
||||
PLAYER_COMPARE_ATTRIBUTE_END
|
||||
};
|
||||
|
||||
|
@ -80,4 +81,7 @@ player_substitution_good_structure(gint old_structure, gint old_pos, gint player
|
|||
gint
|
||||
player_id_index(const Team *tm, gint player_id);
|
||||
|
||||
gfloat
|
||||
player_get_game_skill(const Player *pl, gboolean skill);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -49,6 +49,18 @@ typedef struct
|
|||
enum PlayerInjury
|
||||
{
|
||||
PLAYER_INJURY_NONE = 0,
|
||||
PLAYER_INJURY_CONCUSSION,
|
||||
PLAYER_INJURY_PULLED_MUSCLE,
|
||||
PLAYER_INJURY_HAMSTRING,
|
||||
PLAYER_INJURY_GROIN,
|
||||
PLAYER_INJURY_FRAC_ANKLE,
|
||||
PLAYER_INJURY_RIB,
|
||||
PLAYER_INJURY_LEG,
|
||||
PLAYER_INJURY_BROK_ANKLE,
|
||||
PLAYER_INJURY_ARM,
|
||||
PLAYER_INJURY_SHOULDER,
|
||||
PLAYER_INJURY_LIGAMENT,
|
||||
PLAYER_INJURY_CAREER_STOP,
|
||||
PLAYER_INJURY_END
|
||||
};
|
||||
|
||||
|
@ -100,8 +112,8 @@ enum PlayerListAttributeValue
|
|||
PLAYER_LIST_ATTRIBUTE_SKILL,
|
||||
PLAYER_LIST_ATTRIBUTE_FITNESS,
|
||||
PLAYER_LIST_ATTRIBUTE_GAMES,
|
||||
PLAYER_LIST_ATTRIBUTE_GOALS,
|
||||
PLAYER_LIST_ATTRIBUTE_SHOTS,
|
||||
PLAYER_LIST_ATTRIBUTE_GOALS,
|
||||
PLAYER_LIST_ATTRIBUTE_STATUS,
|
||||
PLAYER_LIST_ATTRIBUTE_CARDS,
|
||||
PLAYER_LIST_ATTRIBUTE_AGE,
|
||||
|
|
|
@ -123,7 +123,8 @@ table_element_compare_func(gconstpointer a,
|
|||
cup_round = g_array_index(cup_from_clid(clid)->tables, Table, 0).round;
|
||||
fixtures = cup_from_clid(clid)->fixtures;
|
||||
}
|
||||
|
||||
|
||||
/*todo use misc_int_compare*/
|
||||
if(element1->values[TABLE_PTS] > element2->values[TABLE_PTS])
|
||||
value = -1;
|
||||
|
||||
|
|
66
src/team.c
66
src/team.c
|
@ -26,7 +26,7 @@ team_new(void)
|
|||
new.clid = new.id = -1;
|
||||
new.structure = team_assign_playing_structure();
|
||||
new.style = team_assign_playing_style();
|
||||
new.boost = FALSE;
|
||||
new.boost = 0;
|
||||
|
||||
new.stadium = team_stadium_new();
|
||||
|
||||
|
@ -444,7 +444,10 @@ team_get_next_fixture(const Team *tm)
|
|||
for(j=0;j<lig(i).fixtures->len;j++)
|
||||
if((g_array_index(lig(i).fixtures, Fixture, j).teams[0] == tm ||
|
||||
g_array_index(lig(i).fixtures, Fixture, j).teams[1] == tm) &&
|
||||
(fix == NULL || query_fixture_is_earlier(fix, &g_array_index(lig(i).fixtures, Fixture, j))))
|
||||
g_array_index(lig(i).fixtures, Fixture, j).week_number >= week &&
|
||||
(g_array_index(lig(i).fixtures, Fixture, j).week_round_number >= week_round ||
|
||||
g_array_index(lig(i).fixtures, Fixture, j).week_number > week) &&
|
||||
(fix == NULL || query_fixture_is_earlier(&g_array_index(lig(i).fixtures, Fixture, j), fix)))
|
||||
fix = &g_array_index(lig(i).fixtures, Fixture, j);
|
||||
}
|
||||
}
|
||||
|
@ -457,7 +460,10 @@ team_get_next_fixture(const Team *tm)
|
|||
for(j=0;j<cp(i).fixtures->len;j++)
|
||||
if((g_array_index(cp(i).fixtures, Fixture, j).teams[0] == tm ||
|
||||
g_array_index(cp(i).fixtures, Fixture, j).teams[1] == tm) &&
|
||||
(fix == NULL || query_fixture_is_earlier(fix, &g_array_index(cp(i).fixtures, Fixture, j))))
|
||||
g_array_index(cp(i).fixtures, Fixture, j).week_number >= week &&
|
||||
(g_array_index(cp(i).fixtures, Fixture, j).week_round_number >= week_round ||
|
||||
g_array_index(cp(i).fixtures, Fixture, j).week_number > week) &&
|
||||
(fix == NULL || query_fixture_is_earlier(&g_array_index(cp(i).fixtures, Fixture, j), fix)))
|
||||
fix = &g_array_index(cp(i).fixtures, Fixture, j);
|
||||
}
|
||||
}
|
||||
|
@ -550,16 +556,10 @@ team_find_appropriate_structure(const Team *tm)
|
|||
gint i;
|
||||
gint structure = 0;
|
||||
|
||||
for(i=1;i<11;i++)
|
||||
{
|
||||
if(player_of(tm, i)->pos == PLAYER_POS_DEFENDER)
|
||||
structure += 100;
|
||||
else if(player_of(tm, i)->pos == PLAYER_POS_MIDFIELDER)
|
||||
structure += 10;
|
||||
else
|
||||
structure++;
|
||||
}
|
||||
|
||||
for(i=0;i<11;i++)
|
||||
if(player_of(tm, i)->cskill > 0 && player_of(tm, i)->pos != 0)
|
||||
structure += (gint)rint(powf(10, PLAYER_POS_FORWARD - player_of(tm, i)->pos));
|
||||
|
||||
return structure;
|
||||
}
|
||||
|
||||
|
@ -590,38 +590,18 @@ team_change_structure(Team *tm, gint new_structure)
|
|||
void
|
||||
team_rearrange(Team *tm)
|
||||
{
|
||||
gint i, j;
|
||||
gint i;
|
||||
|
||||
/* reaarrange field players */
|
||||
for(i=0;i<11;i++)
|
||||
g_array_sort_with_data(tm->players, (GCompareDataFunc)player_compare_func,
|
||||
GINT_TO_POINTER(100 + PLAYER_COMPARE_ATTRIBUTE_POS));
|
||||
|
||||
for(i=0;i<tm->players->len;i++)
|
||||
{
|
||||
if(player_of(tm, i)->pos !=
|
||||
player_of(tm, i)->cpos)
|
||||
{
|
||||
for(j=i+1;j<11;j++)
|
||||
if(player_of(tm, j)->pos ==
|
||||
player_of(tm, i)->cpos &&
|
||||
player_of(tm, j)->cskill > 0)
|
||||
{
|
||||
player_swap(tm, i, tm, j);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* sort substitutes */
|
||||
i = 11;
|
||||
while(i != tm->players->len)
|
||||
{
|
||||
for(j=i+1;j<tm->players->len;j++)
|
||||
if(player_of(tm, i)->pos >
|
||||
player_of(tm, j)->pos)
|
||||
{
|
||||
player_swap(tm, i, tm, j);
|
||||
i = 10;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
player_of(tm, i)->cpos = (i < 11) ?
|
||||
player_get_position_from_structure(tm->structure, i) : player_of(tm, i)->pos;
|
||||
if(player_of(tm, i)->cskill > 0)
|
||||
player_of(tm, i)->cskill = (i < 11) ?
|
||||
player_get_cskill(player_of(tm, i), player_of(tm, i)->cpos) : player_of(tm, i)->skill;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -81,4 +81,7 @@ team_rearrange(Team *tm);
|
|||
gchar*
|
||||
team_style_to_char(gint style);
|
||||
|
||||
gint
|
||||
team_get_current_structure(const Team *tm);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -58,8 +58,8 @@ typedef struct
|
|||
gint clid, /**< Numerical id of the league or cup the team belongs to. */
|
||||
id, /**< Id of the team. */
|
||||
structure, /**< Playing structure. @see team_assign_playing_structure() */
|
||||
style; /**< Playing style. @see team_assign_playing_style() */
|
||||
gboolean boost; /**< Whether player boost is switched on. */
|
||||
style, /**< Playing style. @see team_assign_playing_style() */
|
||||
boost; /**< Whether player boost or anti-boost is switched on. */
|
||||
|
||||
Stadium stadium;
|
||||
/**
|
||||
|
|
|
@ -419,8 +419,8 @@ treeview_set_up_player_list (GtkTreeView *treeview, gint *attributes, gint max)
|
|||
_("Sk"),
|
||||
_("Fit"),
|
||||
_("Ga"),
|
||||
_("Go"),
|
||||
_("Sh"),
|
||||
_("Go"),
|
||||
_("Status"),
|
||||
_("YC"),
|
||||
_("Age"),
|
||||
|
|
|
@ -180,8 +180,13 @@ treeview_cell_player_cards_to_cell(gchar *buf, const Player *pl)
|
|||
if(pl->cards->len == 0)
|
||||
strcpy(buf, "0");
|
||||
else
|
||||
sprintf(buf, "%d(%d)", g_array_index(pl->cards, PlayerCard, 0).yellow,
|
||||
player_all_cards(pl));
|
||||
{
|
||||
if(opt_user_int("int_opt_user_show_overall"))
|
||||
sprintf(buf, "%d(%d)", g_array_index(pl->cards, PlayerCard, 0).yellow,
|
||||
player_all_cards(pl));
|
||||
else
|
||||
sprintf(buf, "%d", g_array_index(pl->cards, PlayerCard, 0).yellow);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -189,8 +194,11 @@ treeview_cell_player_cards_to_cell(gchar *buf, const Player *pl)
|
|||
for(i=0;i<pl->cards->len;i++)
|
||||
if(g_array_index(pl->cards, PlayerCard, 0).clid == fix->clid)
|
||||
{
|
||||
sprintf(buf, "%d(%d)", g_array_index(pl->cards, PlayerCard, i).yellow,
|
||||
player_all_cards(pl));
|
||||
if(opt_user_int("int_opt_user_show_overall"))
|
||||
sprintf(buf, "%d(%d)", g_array_index(pl->cards, PlayerCard, i).yellow,
|
||||
player_all_cards(pl));
|
||||
else
|
||||
sprintf(buf, "%d", g_array_index(pl->cards, PlayerCard, i).yellow);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -258,14 +266,29 @@ treeview_cell_player_games_goals_to_cell(gchar *buf, const Player *pl, gint type
|
|||
}
|
||||
|
||||
if(type == PLAYER_LIST_ATTRIBUTE_GOALS)
|
||||
sprintf(buf, "%d(%d)", g_array_index(pl->games_goals, PlayerGamesGoals, idx).goals,
|
||||
player_all_games_goals(pl, PLAYER_LIST_ATTRIBUTE_GOALS));
|
||||
{
|
||||
if(opt_user_int("int_opt_user_show_overall"))
|
||||
sprintf(buf, "%d(%d)", g_array_index(pl->games_goals, PlayerGamesGoals, idx).goals,
|
||||
player_all_games_goals(pl, PLAYER_LIST_ATTRIBUTE_GOALS));
|
||||
else
|
||||
sprintf(buf, "%d", g_array_index(pl->games_goals, PlayerGamesGoals, idx).goals);
|
||||
}
|
||||
else if(type == PLAYER_LIST_ATTRIBUTE_GAMES)
|
||||
sprintf(buf, "%d(%d)", g_array_index(pl->games_goals, PlayerGamesGoals, idx).games,
|
||||
player_all_games_goals(pl, PLAYER_LIST_ATTRIBUTE_GAMES));
|
||||
{
|
||||
if(opt_user_int("int_opt_user_show_overall"))
|
||||
sprintf(buf, "%d(%d)", g_array_index(pl->games_goals, PlayerGamesGoals, idx).games,
|
||||
player_all_games_goals(pl, PLAYER_LIST_ATTRIBUTE_GAMES));
|
||||
else
|
||||
sprintf(buf, "%d", g_array_index(pl->games_goals, PlayerGamesGoals, idx).games);
|
||||
}
|
||||
else if(type == PLAYER_LIST_ATTRIBUTE_SHOTS)
|
||||
sprintf(buf, "%d(%d)", g_array_index(pl->games_goals, PlayerGamesGoals, idx).shots,
|
||||
player_all_games_goals(pl, PLAYER_LIST_ATTRIBUTE_SHOTS));
|
||||
{
|
||||
if(opt_user_int("int_opt_user_show_overall"))
|
||||
sprintf(buf, "%d(%d)", g_array_index(pl->games_goals, PlayerGamesGoals, idx).shots,
|
||||
player_all_games_goals(pl, PLAYER_LIST_ATTRIBUTE_SHOTS));
|
||||
else
|
||||
sprintf(buf, "%d", g_array_index(pl->games_goals, PlayerGamesGoals, idx).shots);
|
||||
}
|
||||
}
|
||||
|
||||
/** Render a cell of player fitness.
|
||||
|
@ -338,9 +361,7 @@ treeview_cell_player_pos_to_cell(GtkCellRenderer *renderer, gchar *buf, gint pos
|
|||
void
|
||||
treeview_cell_player_cskill_to_cell(GtkCellRenderer *renderer, gchar *buf, const Player *pl)
|
||||
{
|
||||
sprintf(buf, "%d", (gint)rint((gfloat)pl->cskill *
|
||||
powf((gfloat)pl->fitness / 10000,
|
||||
const_float("float_player_fitness_impact_on_skill"))));
|
||||
sprintf(buf, "%d", (gint)rint(player_get_game_skill(pl, FALSE)));
|
||||
|
||||
if(pl->cskill < pl->skill)
|
||||
g_object_set(renderer, "background",
|
||||
|
|
|
@ -185,14 +185,67 @@ float_live_game_stadium_event_breakdown 1000
|
|||
# foul probabilities.
|
||||
float_live_game_foul 110
|
||||
float_live_game_foul_red_injury 50
|
||||
float_live_game_foul_red 80
|
||||
float_live_game_foul_red 800
|
||||
float_live_game_foul_yellow 230
|
||||
|
||||
gfloat duration[6]={0,0.7,0.85,0.95,0.975,1};
|
||||
|
||||
# ban duration probabilities
|
||||
# should add up to 1000
|
||||
float_live_game_ban_1 700
|
||||
float_live_game_ban_2 150
|
||||
float_live_game_ban_3 100
|
||||
float_live_game_ban_4 30
|
||||
float_live_game_ban_5 20
|
||||
|
||||
# probability that the foul player is from the
|
||||
# team that has the ball
|
||||
float_live_game_foul_by_possession 200
|
||||
|
||||
# injury probabilities.
|
||||
float_live_game_injury 17
|
||||
float_live_game_injury_goalie_factor 200
|
||||
float_live_game_injury_is_temp 700
|
||||
|
||||
# probabilities for different injuries
|
||||
# these should add up to 1000
|
||||
float_player_injury_concussion 200
|
||||
float_player_injury_pulled_muscle 200
|
||||
float_player_injury_hamstring 150
|
||||
float_player_injury_groin 150
|
||||
float_player_injury_frac_ankle 100
|
||||
float_player_injury_rib 75
|
||||
float_player_injury_leg 40
|
||||
float_player_injury_brok_ankle 40
|
||||
float_player_injury_arm 20
|
||||
float_player_injury_shoulder 15
|
||||
float_player_injury_ligament 7
|
||||
float_player_injury_career_stop 3
|
||||
|
||||
# duration of the injuries (mean and deviance)
|
||||
int_player_injury_duration_concussion 2
|
||||
int_player_injury_duration_dev_concussion 1
|
||||
int_player_injury_duration_pulled_muscle 3
|
||||
int_player_injury_duration_dev_pulled_muscle 1
|
||||
int_player_injury_duration_hamstring 5
|
||||
int_player_injury_duration_dev_hamstring 2
|
||||
int_player_injury_duration_groin 5
|
||||
int_player_injury_duration_dev_groin 2
|
||||
int_player_injury_duration_frac_ankle 6
|
||||
int_player_injury_duration_dev_frac_ankle 2
|
||||
int_player_injury_duration_rib 8
|
||||
int_player_injury_duration_dev_rib 4
|
||||
int_player_injury_duration_leg 9
|
||||
int_player_injury_duration_dev_leg 4
|
||||
int_player_injury_duration_brok_ankle 11
|
||||
int_player_injury_duration_dev_brok_ankle 5
|
||||
int_player_injury_duration_arm 6
|
||||
int_player_injury_duration_dev_arm 2
|
||||
int_player_injury_duration_shoulder 10
|
||||
int_player_injury_duration_dev_shoulder 5
|
||||
int_player_injury_duration_ligament 22
|
||||
int_player_injury_duration_dev_ligament 8
|
||||
|
||||
# probability that a scoring chance is an own goal.
|
||||
float_live_game_scoring_chance_is_own_goal 10
|
||||
|
||||
|
@ -209,13 +262,22 @@ float_live_game_scoring_chance_is_header 350
|
|||
float_game_style_factor 75
|
||||
|
||||
# influence of boost on player's skill.
|
||||
# these should be between 0 and 1
|
||||
float_player_boost_skill_effect 150
|
||||
# influence of boost on player's fitness decay.
|
||||
float_player_boost_fitness_effect 1000
|
||||
float_player_boost_fitness_effect 500
|
||||
# influence of boost on injury probability.
|
||||
float_player_boost_injury_effect 1000
|
||||
float_player_boost_injury_effect 500
|
||||
# influence of boost on cards probability.
|
||||
float_player_boost_card_effect 1000
|
||||
float_player_boost_card_effect 500
|
||||
|
||||
# influence of team boost on probability that the team in possession
|
||||
# of the ball fouls
|
||||
float_team_boost_foul_by_possession_factor1 500
|
||||
float_team_boost_foul_by_possession_factor2 900
|
||||
|
||||
# influence of boost on foul probability
|
||||
float_team_boost_foul_factor 400
|
||||
|
||||
# the influence of the fitness on the current skill.
|
||||
# this determines the player's contribution to the team
|
||||
|
|
|
@ -24,12 +24,13 @@ int_opt_user_show_job_offers 1
|
|||
int_opt_user_sort_transfer_list 0
|
||||
int_opt_user_sort_transfer_attribute 1
|
||||
int_opt_user_reaarrange_adapts 1
|
||||
int_opt_user_swap_adapts 0
|
||||
int_opt_user_swap_adapts 1
|
||||
int_opt_user_penalty_shooter -1
|
||||
int_opt_user_pause_injury 1
|
||||
int_opt_user_pause_red 1
|
||||
int_opt_user_pause_break 1
|
||||
int_opt_user_auto_sub 1
|
||||
int_opt_user_auto_sub 0
|
||||
int_opt_user_show_overall 0
|
||||
|
||||
# the order of these attributes is important
|
||||
# don't change it
|
||||
|
@ -40,8 +41,8 @@ int_opt_user_pl1_att_cskill 1
|
|||
int_opt_user_pl1_att_skill 1
|
||||
int_opt_user_pl1_att_fitness 1
|
||||
int_opt_user_pl1_att_games 1
|
||||
int_opt_user_pl1_att_goals 1
|
||||
int_opt_user_pl1_att_shots 1
|
||||
int_opt_user_pl1_att_goals 1
|
||||
int_opt_user_pl1_att_status 1
|
||||
int_opt_user_pl1_att_cards 0
|
||||
int_opt_user_pl1_att_age 1
|
||||
|
@ -61,8 +62,8 @@ int_opt_user_pl2_att_cskill 0
|
|||
int_opt_user_pl2_att_skill 1
|
||||
int_opt_user_pl2_att_fitness 0
|
||||
int_opt_user_pl2_att_games 0
|
||||
int_opt_user_pl2_att_goals 0
|
||||
int_opt_user_pl2_att_shots 0
|
||||
int_opt_user_pl2_att_goals 0
|
||||
int_opt_user_pl2_att_status 1
|
||||
int_opt_user_pl2_att_cards 0
|
||||
int_opt_user_pl2_att_age 1
|
||||
|
|
Loading…
Reference in New Issue