1
1
mirror of https://github.com/tstellar/bygfoot.git synced 2025-03-10 07:40:11 +01:00

"Betting bugfix."

This commit is contained in:
gyboth 2005-10-31 16:19:14 +00:00
parent b1c539abe0
commit 54132543c4
45 changed files with 9961 additions and 8546 deletions

View File

@ -3,6 +3,8 @@
- added strategies for CPU teams - added strategies for CPU teams
- added option to randomise teams in cups in the startup window - added option to randomise teams in cups in the startup window
(relevant for the World Cup definition, mainly) (relevant for the World Cup definition, mainly)
- added betting
- minor bugfixes
10/16/2005: v1.9.2 10/16/2005: v1.9.2

File diff suppressed because one or more lines are too long

View File

@ -151,14 +151,25 @@
</child> </child>
<child> <child>
<widget class="GtkTreeView" id="treeview_bets"> <widget class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="headers_visible">True</property> <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="rules_hint">False</property> <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="reorderable">False</property> <property name="shadow_type">GTK_SHADOW_IN</property>
<property name="enable_search">True</property> <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<signal name="button_press_event" handler="on_treeview_bets_button_press_event" last_modification_time="Thu, 27 Oct 2005 19:43:51 GMT"/>
<child>
<widget class="GtkTreeView" id="treeview_bets">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="headers_visible">True</property>
<property name="rules_hint">False</property>
<property name="reorderable">False</property>
<property name="enable_search">True</property>
<signal name="button_press_event" handler="on_treeview_bets_button_press_event" last_modification_time="Thu, 27 Oct 2005 19:43:51 GMT"/>
</widget>
</child>
</widget> </widget>
<packing> <packing>
<property name="padding">0</property> <property name="padding">0</property>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

1460
po/bg.po

File diff suppressed because it is too large Load Diff

5588
po/da.po

File diff suppressed because it is too large Load Diff

1454
po/de.po

File diff suppressed because it is too large Load Diff

2013
po/es.po

File diff suppressed because it is too large Load Diff

1454
po/fr.po

File diff suppressed because it is too large Load Diff

1460
po/nl.po

File diff suppressed because it is too large Load Diff

1485
po/pl.po

File diff suppressed because it is too large Load Diff

1454
po/ro.po

File diff suppressed because it is too large Load Diff

1454
po/zh.po

File diff suppressed because it is too large Load Diff

View File

@ -51,19 +51,18 @@ bet_round_odd(gfloat odd)
/** Find the bet containing the fixture. */ /** Find the bet containing the fixture. */
BetMatch* BetMatch*
bet_from_fixture(const Fixture *fix) bet_from_fixture(gint fix_id)
{ {
gint i, j; gint i, j;
for(i=1;i>=0;i--) for(i=1;i>=0;i--)
for(j=0;j<bets[i]->len;j++) for(j=0;j<bets[i]->len;j++)
if(g_array_index(bets[i], BetMatch, j).fix == fix) if(g_array_index(bets[i], BetMatch, j).fix_id == fix_id)
return &g_array_index(bets[i], BetMatch, j); return &g_array_index(bets[i], BetMatch, j);
main_exit_program(EXIT_BET_ERROR, main_exit_program(EXIT_BET_ERROR,
"bet_from_fixture: bet going with fixture %s %s - %s not found", "bet_from_fixture: bet going with fixture %d not found",
league_cup_get_name_string(fix->clid), fix_id);
fix->teams[0]->name, fix->teams[0]->name);
return NULL; return NULL;
} }
@ -73,7 +72,8 @@ void
bet_update_user_bets(void) bet_update_user_bets(void)
{ {
gint i, j, outcome; gint i, j, outcome;
const BetMatch *bet; const BetMatch *bet = NULL;
const Fixture *fix = NULL;
for(i=0;i<users->len;i++) for(i=0;i<users->len;i++)
{ {
@ -82,12 +82,13 @@ bet_update_user_bets(void)
for(j=0;j<usr(i).bets[1]->len;j++) for(j=0;j<usr(i).bets[1]->len;j++)
{ {
bet = bet_from_fixture(g_array_index(usr(i).bets[1], BetUser, j).fix); bet = bet_from_fixture(g_array_index(usr(i).bets[1], BetUser, j).fix_id);
fix = fixture_from_id(g_array_index(usr(i).bets[1], BetUser, j).fix_id);
if(bet->fix->result[0][0] < bet->fix->result[1][0]) if(fix->result[0][0] < fix->result[1][0])
outcome = 2; outcome = 2;
else else
outcome = (bet->fix->result[0][0] == bet->fix->result[1][0]); outcome = (fix->result[0][0] == fix->result[1][0]);
if(outcome == g_array_index(usr(i).bets[1], BetUser, j).outcome) if(outcome == g_array_index(usr(i).bets[1], BetUser, j).outcome)
{ {
@ -123,7 +124,8 @@ bet_update_user_bets(void)
void void
bet_get_odds(BetMatch *bet) bet_get_odds(BetMatch *bet)
{ {
gfloat home_advantage = (bet->fix->home_advantage) ? const Fixture *fix = fixture_from_id(bet->fix_id);
gfloat home_advantage = (fix->home_advantage) ?
(const_float("float_game_home_advantage_lower") + (const_float("float_game_home_advantage_lower") +
const_float("float_game_home_advantage_upper")) / 2 : 0; const_float("float_game_home_advantage_upper")) / 2 : 0;
gfloat av_skill[2] = {0, 0}, skilldiff; gfloat av_skill[2] = {0, 0}, skilldiff;
@ -133,7 +135,7 @@ bet_get_odds(BetMatch *bet)
{ {
for(j=0;j<11;j++) for(j=0;j<11;j++)
av_skill[i] += av_skill[i] +=
player_get_game_skill(player_of_idx_team(bet->fix->teams[i], j), player_get_game_skill(player_of_idx_team(fix->teams[i], j),
FALSE, TRUE); FALSE, TRUE);
av_skill[i] /= 11; av_skill[i] /= 11;
@ -189,7 +191,7 @@ bet_update(void)
for(i=0;i<fixtures->len;i++) for(i=0;i<fixtures->len;i++)
if(fixture_user_team_involved((Fixture*)g_ptr_array_index(fixtures, i)) == -1) if(fixture_user_team_involved((Fixture*)g_ptr_array_index(fixtures, i)) == -1)
{ {
new_bet.fix = (Fixture*)g_ptr_array_index(fixtures, i); new_bet.fix_id = ((Fixture*)g_ptr_array_index(fixtures, i))->id;
bet_get_odds(&new_bet); bet_get_odds(&new_bet);
g_array_append_val(bets[1], new_bet); g_array_append_val(bets[1], new_bet);
} }
@ -205,7 +207,7 @@ bet_is_user(const BetMatch *bet)
for(i=1;i>=0;i--) for(i=1;i>=0;i--)
for(j=0;j<current_user.bets[i]->len;j++) for(j=0;j<current_user.bets[i]->len;j++)
if(bet->fix == g_array_index(current_user.bets[i], BetUser, j).fix) if(bet->fix_id == g_array_index(current_user.bets[i], BetUser, j).fix_id)
return &g_array_index(current_user.bets[i], BetUser, j); return &g_array_index(current_user.bets[i], BetUser, j);
return NULL; return NULL;
@ -213,7 +215,7 @@ bet_is_user(const BetMatch *bet)
/** Place a new bet. */ /** Place a new bet. */
void void
bet_place(const Fixture *fix, gint outcome, gint wager) bet_place(gint fix_id, gint outcome, gint wager)
{ {
gfloat max_wager = finance_wage_unit(current_user.tm) * gfloat max_wager = finance_wage_unit(current_user.tm) *
const_float("float_bet_wager_limit_factor"); const_float("float_bet_wager_limit_factor");
@ -236,7 +238,7 @@ bet_place(const Fixture *fix, gint outcome, gint wager)
return; return;
} }
new_bet.fix = fix; new_bet.fix_id = fix_id;
new_bet.outcome = outcome; new_bet.outcome = outcome;
new_bet.wager = wager; new_bet.wager = wager;
@ -248,12 +250,12 @@ bet_place(const Fixture *fix, gint outcome, gint wager)
/** Remove the bet on the given fixture. */ /** Remove the bet on the given fixture. */
void void
bet_remove(const Fixture *fix) bet_remove(gint fix_id)
{ {
gint i; gint i;
for(i=0;i<current_user.bets[1]->len;i++) for(i=0;i<current_user.bets[1]->len;i++)
if(g_array_index(current_user.bets[1], BetUser, i).fix == fix) if(g_array_index(current_user.bets[1], BetUser, i).fix_id == fix_id)
{ {
g_array_remove_index(current_user.bets[1], i); g_array_remove_index(current_user.bets[1], i);
return; return;

View File

@ -29,7 +29,7 @@
#include "fixture_struct.h" #include "fixture_struct.h"
BetMatch* BetMatch*
bet_from_fixture(const Fixture *fix); bet_from_fixture(gint fix_id);
void void
bet_update_user_bets(void); bet_update_user_bets(void);
@ -47,9 +47,9 @@ BetUser*
bet_is_user(const BetMatch *bet); bet_is_user(const BetMatch *bet);
void void
bet_place(const Fixture *fix, gint outcome, gint wager); bet_place(gint fix_id, gint outcome, gint wager);
void void
bet_remove(const Fixture *fix); bet_remove(gint fix_id);
#endif #endif

View File

@ -31,7 +31,7 @@
typedef struct typedef struct
{ {
/** The match the bet is about. */ /** The match the bet is about. */
const Fixture *fix; gint fix_id;
/** The odds for a win, draw or loss of the first team. */ /** The odds for a win, draw or loss of the first team. */
gfloat odds[3]; gfloat odds[3];
@ -41,7 +41,7 @@ typedef struct
typedef struct typedef struct
{ {
/** Match the user betted on. */ /** Match the user betted on. */
const Fixture *fix; gint fix_id;
/** Which outcome he picked. */ /** Which outcome he picked. */
gint outcome; gint outcome;
/** How much he wagered. */ /** How much he wagered. */

View File

@ -42,6 +42,8 @@
#include "user.h" #include "user.h"
#include "window.h" #include "window.h"
#include "bet.h"
/** Show the users' live games. */ /** Show the users' live games. */
void void
callback_show_next_live_game(void) callback_show_next_live_game(void)

View File

@ -166,7 +166,8 @@ query_cup_choose_team_is_league(const gchar *sid)
return FALSE; return FALSE;
} }
/** Write the cup or league of the chooseteam into the appropriate pointer. */ /** Write the cup or league of the chooseteam into the appropriate pointer
and return TRUE; return FALSE if no cup/league is found. */
void void
cup_get_choose_team_league_cup(const CupChooseTeam *ct, cup_get_choose_team_league_cup(const CupChooseTeam *ct,
const League **league, const Cup **cup) const League **league, const Cup **cup)
@ -179,12 +180,12 @@ cup_get_choose_team_league_cup(const CupChooseTeam *ct,
sscanf(ct->sid, "%[^0-9]%d", trash, &idx); sscanf(ct->sid, "%[^0-9]%d", trash, &idx);
if(g_str_has_prefix(ct->sid, "LEAGUE")) if(g_str_has_prefix(ct->sid, "LEAGUE") && idx >=0 && idx <= ligs->len)
{ {
*league = &lig(idx - 1); *league = &lig(idx - 1);
*cup = NULL; *cup = NULL;
} }
else if(g_str_has_prefix(ct->sid, "CUP")) else if(g_str_has_prefix(ct->sid, "CUP") && idx >=0 && idx <= cps->len)
{ {
*cup = &cp(idx - 1); *cup = &cp(idx - 1);
*league = NULL; *league = NULL;

View File

@ -1335,3 +1335,9 @@ fixture_get_goals_to_win(const Fixture *fix, const Team *tm)
return return_value; return return_value;
} }
gint
fixture_get_goals_to_draw(const Fixture *fix, const Team *tm)
{
}

View File

@ -399,9 +399,6 @@ league_season_start(League *league)
player_season_start( player_season_start(
&g_array_index(g_array_index(league->teams, Team, i).players, Player, j), team_change_factor); &g_array_index(g_array_index(league->teams, Team, i).players, Player, j), team_change_factor);
if(team_is_user(&g_array_index(league->teams, Team, i)) == -1)
team_update_cpu_structure(&g_array_index(league->teams, Team, i));
g_array_index(league->teams, Team, i).stadium.average_attendance = g_array_index(league->teams, Team, i).stadium.average_attendance =
g_array_index(league->teams, Team, i).stadium.games = g_array_index(league->teams, Team, i).stadium.games =
g_array_index(league->teams, Team, i).stadium.possible_attendance = 0; g_array_index(league->teams, Team, i).stadium.possible_attendance = 0;

View File

@ -74,7 +74,7 @@ live_game_calculate_fixture(Fixture *fix)
game_get_values(match->fix, match->team_values, game_get_values(match->fix, match->team_values,
match->home_advantage); match->home_advantage);
if((debug > 80 && fixture_user_team_involved(match->fix) != -1) || if((debug > 80 && stat2 != -1) ||
debug > 130) debug > 130)
printf("\n\nlive_game_calculate_fixture\n%04d %s %s %04d\n\n", printf("\n\nlive_game_calculate_fixture\n%04d %s %s %04d\n\n",
tm0->id, tm0->name, tm1->name, tm1->id); tm0->id, tm0->name, tm1->name, tm1->id);
@ -90,7 +90,7 @@ live_game_calculate_fixture(Fixture *fix)
if(last_unit.event.type == LIVE_GAME_EVENT_END_MATCH) if(last_unit.event.type == LIVE_GAME_EVENT_END_MATCH)
{ {
if(fixture_user_team_involved(match->fix) != -1 || stat5 < -1000) if(stat2 != -1 || stat5 < -1000)
lg_commentary_free_tokens(); lg_commentary_free_tokens();
game_post_match(fix); game_post_match(fix);
} }
@ -102,14 +102,14 @@ live_game_calculate_fixture(Fixture *fix)
void void
live_game_initialize(Fixture *fix) live_game_initialize(Fixture *fix)
{ {
statp= (fixture_user_team_involved(fix) != -1) ?
&usr(fixture_user_team_involved(fix)).live_game : &live_game_temp;
show = (fixture_user_team_involved(fix) != -1 &&
option_int("int_opt_user_show_live_game",
&usr(fixture_user_team_involved(fix)).options));
stat2 = fixture_user_team_involved(fix); stat2 = fixture_user_team_involved(fix);
statp= (stat2 != -1) ?
&usr(stat2).live_game : &live_game_temp;
show = (stat2 != -1 &&
option_int("int_opt_user_show_live_game",
&usr(stat2).options));
live_game_reset(match, fix, TRUE); live_game_reset(match, fix, TRUE);
if(show) if(show)
@ -128,7 +128,7 @@ live_game_initialize(Fixture *fix)
game_initialize(fix); game_initialize(fix);
if(fixture_user_team_involved(fix) != -1 || stat5 < -1000) if(stat2 != -1 || stat5 < -1000)
lg_commentary_initialize(fix); lg_commentary_initialize(fix);
} }
@ -139,7 +139,7 @@ live_game_create_unit(void)
{ {
LiveGameUnit new; LiveGameUnit new;
if((debug > 100 && fixture_user_team_involved(match->fix) != -1) || if((debug > 100 && stat2 != -1) ||
debug > 130) debug > 130)
printf("\t\tlive_game_create_unit\n"); printf("\t\tlive_game_create_unit\n");
@ -199,7 +199,7 @@ live_game_fill_new_unit(LiveGameUnit *new)
gfloat possession_change, scoring_chance = 0, gfloat possession_change, scoring_chance = 0,
injury_event_prob, foul_event_prob; injury_event_prob, foul_event_prob;
if((debug > 100 && fixture_user_team_involved(match->fix) != -1) || if((debug > 100 && stat2 != -1) ||
debug > 130) debug > 130)
printf("\t\tlive_game_fill_new_unit\n"); printf("\t\tlive_game_fill_new_unit\n");
@ -259,7 +259,7 @@ live_game_create_start_unit(void)
{ {
LiveGameUnit new; LiveGameUnit new;
if((debug > 100 && fixture_user_team_involved(match->fix) != -1) || if((debug > 100 && stat2 != -1) ||
debug > 130) debug > 130)
printf("\t\tlive_game_create_start_unit\n"); printf("\t\tlive_game_create_start_unit\n");
new.event.player = new.event.player =
@ -288,7 +288,7 @@ live_game_evaluate_unit(LiveGameUnit *unit)
{ {
gint type = unit->event.type; gint type = unit->event.type;
if((debug > 100 && fixture_user_team_involved(match->fix) != -1) || if((debug > 100 && stat2 != -1) ||
debug > 130) debug > 130)
printf("\t\tlive_game_evaluate_unit\n"); printf("\t\tlive_game_evaluate_unit\n");
if(type == LIVE_GAME_EVENT_FOUL) if(type == LIVE_GAME_EVENT_FOUL)
@ -314,7 +314,7 @@ live_game_evaluate_unit(LiveGameUnit *unit)
{ {
live_game_finish_unit(); live_game_finish_unit();
if(type != LIVE_GAME_EVENT_END_MATCH && show && if(type != LIVE_GAME_EVENT_END_MATCH && show &&
option_int("int_opt_user_pause_break", &usr(fixture_user_team_involved(match->fix)).options)) option_int("int_opt_user_pause_break", &usr(stat2).options))
misc_callback_pause_live_game(); misc_callback_pause_live_game();
} }
else if(type != LIVE_GAME_EVENT_END_MATCH) else if(type != LIVE_GAME_EVENT_END_MATCH)
@ -329,7 +329,7 @@ live_game_event_foul(void)
gfloat rndom = math_rnd(0, 1); gfloat rndom = math_rnd(0, 1);
gint type, fouled_player, foul_player, foul_team; gint type, fouled_player, foul_player, foul_team;
if((debug > 100 && fixture_user_team_involved(match->fix) != -1) || if((debug > 100 && stat2 != -1) ||
debug > 130) debug > 130)
printf("\t\tlive_game_event_foul\n"); printf("\t\tlive_game_event_foul\n");
if(math_rnd(0, 1) > const_float("float_live_game_foul_by_possession") * if(math_rnd(0, 1) > const_float("float_live_game_foul_by_possession") *
@ -408,7 +408,7 @@ live_game_event_foul(void)
void void
live_game_event_lost_possession(void) live_game_event_lost_possession(void)
{ {
if((debug > 100 && fixture_user_team_involved(match->fix) != -1) || if((debug > 100 && stat2 != -1) ||
debug > 130) debug > 130)
printf("\t\tlive_game_event_lost_possession\n"); printf("\t\tlive_game_event_lost_possession\n");
last_unit.event.player = last_unit.event.player =
@ -439,8 +439,9 @@ live_game_event_injury(gint team, gint player, gboolean create_new)
{ {
LiveGameUnit new; LiveGameUnit new;
gint old_structure = -1, sub_in = -1; gint old_structure = -1, sub_in = -1;
gint usr_idx = -1;
if((debug > 100 && fixture_user_team_involved(match->fix) != -1) || if((debug > 100 && stat2 != -1) ||
debug > 130) debug > 130)
printf("\t\tlive_game_event_injury\n"); printf("\t\tlive_game_event_injury\n");
if(create_new) if(create_new)
@ -456,6 +457,8 @@ live_game_event_injury(gint team, gint player, gboolean create_new)
else else
live_game_injury_get_player(); live_game_injury_get_player();
usr_idx = team_is_user(tm[last_unit.event.team]);
last_unit.minute = -1; last_unit.minute = -1;
last_unit.event.type = LIVE_GAME_EVENT_INJURY; last_unit.event.type = LIVE_GAME_EVENT_INJURY;
@ -464,7 +467,7 @@ live_game_event_injury(gint team, gint player, gboolean create_new)
last_unit.event.type = LIVE_GAME_EVENT_TEMP_INJURY; last_unit.event.type = LIVE_GAME_EVENT_TEMP_INJURY;
if(debug < 50 || if(debug < 50 ||
team_is_user(tm[last_unit.event.team]) == -1) usr_idx == -1)
player_of_id_team(tm[last_unit.event.team], player_of_id_team(tm[last_unit.event.team],
last_unit.event.player)->fitness = last_unit.event.player)->fitness =
MAX(0, player_of_id_team(tm[last_unit.event.team], MAX(0, player_of_id_team(tm[last_unit.event.team],
@ -476,7 +479,7 @@ live_game_event_injury(gint team, gint player, gboolean create_new)
live_game_finish_unit(); live_game_finish_unit();
if(debug >= 50 && if(debug >= 50 &&
team_is_user(tm[last_unit.event.team]) != -1) usr_idx != -1)
return; return;
if(last_unit.event.type == LIVE_GAME_EVENT_INJURY) if(last_unit.event.type == LIVE_GAME_EVENT_INJURY)
@ -487,11 +490,11 @@ live_game_event_injury(gint team, gint player, gboolean create_new)
if(match->subs_left[last_unit.event.team] > 0) if(match->subs_left[last_unit.event.team] > 0)
{ {
if(show && if(show &&
team_is_user(tm[last_unit.event.team]) != -1 && usr_idx != -1 &&
((option_int("int_opt_user_pause_injury", ((option_int("int_opt_user_pause_injury",
&usr(team_is_user(tm[last_unit.event.team])).options) && &usr(usr_idx).options) &&
!option_int("int_opt_user_auto_sub", !option_int("int_opt_user_auto_sub",
&usr(team_is_user(tm[last_unit.event.team])).options)) || &usr(usr_idx).options)) ||
tm[last_unit.event.team]->players->len == 11)) tm[last_unit.event.team]->players->len == 11))
misc_callback_pause_live_game(); misc_callback_pause_live_game();
else if(tm[last_unit.event.team]->players->len > 11) else if(tm[last_unit.event.team]->players->len > 11)
@ -532,7 +535,7 @@ live_game_event_stadium(void)
for(i=1;i<3;i++) for(i=1;i<3;i++)
probs[i] += probs[i - 1]; probs[i] += probs[i - 1];
if((debug > 100 && fixture_user_team_involved(match->fix) != -1) || if((debug > 100 && stat2 != -1) ||
debug > 130) debug > 130)
printf("\t\tlive_game_event_stadium\n"); printf("\t\tlive_game_event_stadium\n");
if(rndom <= probs[0]) if(rndom <= probs[0])
@ -563,7 +566,7 @@ live_game_event_scoring_chance(void)
else else
res_idx = 0; res_idx = 0;
if((debug > 100 && fixture_user_team_involved(match->fix) != -1) || if((debug > 100 && stat2 != -1) ||
debug > 130) debug > 130)
printf("\t\tlive_game_event_scoring_chance\n"); printf("\t\tlive_game_event_scoring_chance\n");
@ -633,7 +636,7 @@ live_game_event_penalty(void)
{ {
LiveGameUnit new; LiveGameUnit new;
if((debug > 100 && fixture_user_team_involved(match->fix) != -1) || if((debug > 100 && stat2 != -1) ||
debug > 130) debug > 130)
printf("\t\tlive_game_event_penalty\n"); printf("\t\tlive_game_event_penalty\n");
@ -699,7 +702,7 @@ live_game_event_general(gboolean create_new)
{ {
LiveGameUnit new; LiveGameUnit new;
if((debug > 100 && fixture_user_team_involved(match->fix) != -1) || if((debug > 100 && stat2 != -1) ||
debug > 130) debug > 130)
printf("\t\tlive_game_event_general\n"); printf("\t\tlive_game_event_general\n");
@ -789,7 +792,7 @@ live_game_event_general_get_players(void)
uni(unis->len - 2).event.player; uni(unis->len - 2).event.player;
gint type = uni(unis->len - 2).event.type; gint type = uni(unis->len - 2).event.type;
if((debug > 100 && fixture_user_team_involved(match->fix) != -1) || if((debug > 100 && stat2 != -1) ||
debug > 130) debug > 130)
printf("\t\tlive_game_event_general_get_players\n"); printf("\t\tlive_game_event_general_get_players\n");
*pl1 = *pl2 = -1; *pl1 = *pl2 = -1;
@ -823,7 +826,7 @@ live_game_event_free_kick(void)
{ {
LiveGameUnit new = last_unit; LiveGameUnit new = last_unit;
if((debug > 100 && fixture_user_team_involved(match->fix) != -1) || if((debug > 100 && stat2 != -1) ||
debug > 130) debug > 130)
printf("\t\tlive_game_event_free_kick\n"); printf("\t\tlive_game_event_free_kick\n");
new.event.player = new.event.player =
@ -856,8 +859,9 @@ live_game_event_send_off(gint team, gint player, gboolean second_yellow)
{ {
LiveGameUnit new = last_unit; LiveGameUnit new = last_unit;
gint substitute = -1, to_substitute = -1; gint substitute = -1, to_substitute = -1;
gint usr_idx = team_is_user(tm[team]);
if((debug > 100 && fixture_user_team_involved(match->fix) != -1) || if((debug > 100 && stat2 != -1) ||
debug > 130) debug > 130)
printf("\t\tlive_game_event_send_off\n"); printf("\t\tlive_game_event_send_off\n");
new.event.player = new.event.player =
@ -874,7 +878,7 @@ live_game_event_send_off(gint team, gint player, gboolean second_yellow)
live_game_finish_unit(); live_game_finish_unit();
if(debug >= 50 && team_is_user(tm[team]) != -1) if(debug >= 50 && usr_idx != -1)
return; return;
player_streak_add_to_prob( player_streak_add_to_prob(
@ -895,7 +899,7 @@ live_game_event_send_off(gint team, gint player, gboolean second_yellow)
player_of_id_team(tm[team], player)->career[PLAYER_VALUE_CARD_RED]++; player_of_id_team(tm[team], player)->career[PLAYER_VALUE_CARD_RED]++;
if(team_is_user(tm[team]) != -1) if(usr_idx != -1)
{ {
tm[team]->structure = team_find_appropriate_structure(tm[team]); tm[team]->structure = team_find_appropriate_structure(tm[team]);
team_rearrange(tm[team]); team_rearrange(tm[team]);
@ -904,11 +908,11 @@ live_game_event_send_off(gint team, gint player, gboolean second_yellow)
if(match->subs_left[team] > 0) if(match->subs_left[team] > 0)
{ {
if(show && team_is_user(tm[team]) != -1 && if(show && usr_idx != -1 &&
((option_int("int_opt_user_pause_red", ((option_int("int_opt_user_pause_red",
&usr(team_is_user(tm[team])).options) && &usr(usr_idx).options) &&
!option_int("int_opt_user_auto_sub", !option_int("int_opt_user_auto_sub",
&usr(team_is_user(tm[team])).options)) || &usr(usr_idx).options)) ||
tm[team]->players->len == 1)) tm[team]->players->len == 1))
misc_callback_pause_live_game(); misc_callback_pause_live_game();
else if(tm[team]->players->len > 11) else if(tm[team]->players->len > 11)
@ -927,7 +931,7 @@ live_game_event_send_off(gint team, gint player, gboolean second_yellow)
live_game_event_team_change(team, LIVE_GAME_EVENT_STRUCTURE_CHANGE); live_game_event_team_change(team, LIVE_GAME_EVENT_STRUCTURE_CHANGE);
} }
} }
else if(team_is_user(tm[team]) == -1) else if(usr_idx == -1)
{ {
tm[team]->structure = team_find_appropriate_structure(tm[team]); tm[team]->structure = team_find_appropriate_structure(tm[team]);
team_rearrange(tm[team]); team_rearrange(tm[team]);
@ -1018,7 +1022,7 @@ live_game_event_duel(void)
Player *attacker, *goalie, *assistant; Player *attacker, *goalie, *assistant;
gint res_idx1, res_idx2; gint res_idx1, res_idx2;
if((debug > 100 && fixture_user_team_involved(match->fix) != -1) || if((debug > 100 && stat2 != -1) ||
debug > 130) debug > 130)
printf("\t\tlive_game_event_duel\n"); printf("\t\tlive_game_event_duel\n");
@ -1399,11 +1403,11 @@ live_game_finish_unit(void)
{ {
LiveGameUnit *unit = &last_unit; LiveGameUnit *unit = &last_unit;
if((debug > 100 && fixture_user_team_involved(match->fix) != -1) || if((debug > 100 && stat2 != -1) ||
debug > 130) debug > 130)
printf("\t\tlive_game_finish_unit\n"); printf("\t\tlive_game_finish_unit\n");
if((debug > 100 && fixture_user_team_involved(match->fix) != -1) || if((debug > 100 && stat2 != -1) ||
debug > 130) debug > 130)
printf("OOOO1 idx %d min %d type %d poss %d team %d pl %d %d\n", unis->len - 1, printf("OOOO1 idx %d min %d type %d poss %d team %d pl %d %d\n", unis->len - 1,
unit->minute, unit->minute,
@ -1416,13 +1420,13 @@ live_game_finish_unit(void)
game_decrease_fitness(match->fix); game_decrease_fitness(match->fix);
game_get_values(match->fix, match->team_values, game_get_values(match->fix, match->team_values,
match->home_advantage); match->home_advantage);
if(fixture_user_team_involved(match->fix) != -1 && if(stat2 != -1 &&
stat2 == cur_user && show && stat2 == cur_user && show &&
unit->minute % opt_int("int_opt_live_game_player_list_refresh") == 0) unit->minute % opt_int("int_opt_live_game_player_list_refresh") == 0)
treeview_show_user_player_list(); treeview_show_user_player_list();
} }
if(fixture_user_team_involved(match->fix) != -1 || stat5 < -1000) if(stat2 != -1 || stat5 < -1000)
{ {
if(unit->time != LIVE_GAME_UNIT_TIME_PENALTIES) if(unit->time != LIVE_GAME_UNIT_TIME_PENALTIES)
{ {
@ -1457,7 +1461,7 @@ live_game_finish_unit(void)
if(show) if(show)
game_gui_live_game_show_unit(unit); game_gui_live_game_show_unit(unit);
if((debug > 100 && fixture_user_team_involved(match->fix) != -1) || if((debug > 100 && stat2 != -1) ||
debug > 130) debug > 130)
printf("OOOO idx %d type %d poss %d team %d pl %d %d\n", unis->len - 1, printf("OOOO idx %d type %d poss %d team %d pl %d %d\n", unis->len - 1,
unit->event.type, unit->possession, unit->event.team, unit->event.type, unit->possession, unit->event.team,

View File

@ -118,8 +118,6 @@ main_parse_cl_arguments(gint *argc, gchar ***argv)
option_add(&options, "int_opt_calodds_skilldiffmax", skilldiffmax, NULL); option_add(&options, "int_opt_calodds_skilldiffmax", skilldiffmax, NULL);
option_add(&options, "int_opt_calodds_matches", num_matches, NULL); option_add(&options, "int_opt_calodds_matches", num_matches, NULL);
} }
else
option_add(&options, "int_opt_calodds", 0, NULL);
if(testcom) if(testcom)
{ {
@ -203,6 +201,8 @@ main_init_variables(void)
language_set(language_get_code_index(opt_str("string_opt_language_code")) + 1); language_set(language_get_code_index(opt_str("string_opt_language_code")) + 1);
option_add(&options, "int_opt_calodds", 0, NULL);
/** Some of these (or all) are disabled (set to 1) in supernational /** Some of these (or all) are disabled (set to 1) in supernational
country defs. */ country defs. */
option_add(&settings, "int_opt_disable_finances", 0, NULL); option_add(&settings, "int_opt_disable_finances", 0, NULL);

View File

@ -29,7 +29,7 @@
#include "bygfoot.h" #include "bygfoot.h"
/** /**
Macros for random number generation (#rnd for float, #rndi and #gauss_disti for integer). Macros for random number generation.
*/ */
#define math_rnd(lower,upper) g_rand_double_range(rand_generator, lower, upper) #define math_rnd(lower,upper) g_rand_double_range(rand_generator, lower, upper)
#define math_rndi(lower,upper) g_rand_int_range(rand_generator, lower, upper + 1) #define math_rndi(lower,upper) g_rand_int_range(rand_generator, lower, upper + 1)

View File

@ -135,6 +135,24 @@ misc_randomise_g_pointer_array(GPtrArray *array)
return new; return new;
} }
/** Return a freshly allocated copy of the array. */
GPtrArray*
misc_copy_ptr_array(const GPtrArray *array)
{
gint i;
GPtrArray *copy = NULL;
if(array != NULL)
copy = g_ptr_array_new();
else
return NULL;
for(i=0;i<array->len;i++)
g_ptr_array_add(copy, g_ptr_array_index(array, i));
return copy;
}
/** Print a thousands-grouped output of 'number' into 'buf', /** Print a thousands-grouped output of 'number' into 'buf',
like 2 234 345 instead of 2234345. like 2 234 345 instead of 2234345.
@param number The number to print. @param number The number to print.
@ -248,30 +266,6 @@ query_misc_string_in_array(const gchar *string, GPtrArray *array)
return FALSE; return FALSE;
} }
/** Replace a token in a string by another string.
The replacement should NOT CONTAIN THE TOKEN otherwise
we end up in an infinite loop. */
void
misc_string_replace_token(gchar *string, const gchar *token, const gchar *replacement)
{
gchar buf[SMALL], buf2[SMALL];
gchar *occurrence = NULL;
if(strlen(string) < strlen(token))
return;
occurrence = g_strrstr(string, token);
if(occurrence != NULL)
{
strncpy(buf, string, strlen(string) - strlen(occurrence));
buf[strlen(string) - strlen(occurrence)] = '\0';
strcpy(buf2, occurrence + strlen(token));
sprintf(string, "%s%s%s", buf, replacement, buf2);
misc_string_replace_token(string, token, replacement);
}
}
/** Replace sums of the form [1 + 2 - 3] in the string. */ /** Replace sums of the form [1 + 2 - 3] in the string. */
void void
misc_replace_sums(gchar *string) misc_replace_sums(gchar *string)
@ -280,21 +274,21 @@ misc_replace_sums(gchar *string)
gchar buf[SMALL], buf2[SMALL]; gchar buf[SMALL], buf2[SMALL];
const gchar *buf_return = NULL; const gchar *buf_return = NULL;
strcpy(buf, string); while(g_strrstr(string, "["))
{
strcpy(buf, string);
for(i=0;i<strlen(buf);i++) for(i=0;i<strlen(buf);i++)
if(buf[i] == '[') if(buf[i] == '[')
{ {
strncpy(buf2, buf, i); strncpy(buf2, buf, i);
buf2[i] = '\0'; buf2[i] = '\0';
buf_return = misc_parse_expression(buf + i + 1, &result); buf_return = misc_parse_expression(buf + i + 1, &result);
sprintf(string, "%s%d%s", buf2, result, buf_return + 1); sprintf(string, "%s%d%s", buf2, result, buf_return + 1);
}
misc_replace_sums(string); }
}
} }
/** Get a float representation of someone's age /** Get a float representation of someone's age
based on his birth year and month. */ based on his birth year and month. */
gfloat gfloat
@ -458,24 +452,6 @@ misc_parse(const gchar *s, gint *result)
return s; return s;
} }
/** Return a freshly allocated copy of the array. */
GPtrArray*
misc_copy_ptr_array(const GPtrArray *array)
{
gint i;
GPtrArray *copy = NULL;
if(array != NULL)
copy = g_ptr_array_new();
else
return NULL;
for(i=0;i<array->len;i++)
g_ptr_array_add(copy, g_ptr_array_index(array, i));
return copy;
}
/** Free the string if it's non-NULL and assign the contents to it. */ /** Free the string if it's non-NULL and assign the contents to it. */
void void
misc_string_assign(gchar **string, const gchar *contents) misc_string_assign(gchar **string, const gchar *contents)
@ -519,6 +495,30 @@ misc_string_choose_random(gchar *string)
strcpy(string, start); strcpy(string, start);
} }
/** Replace a token in a string by another string.
The replacement should NOT CONTAIN THE TOKEN otherwise
we end up in an infinite loop. */
void
misc_string_replace_token(gchar *string, const gchar *token, const gchar *replacement)
{
gchar buf[SMALL], buf2[SMALL];
gchar *occurrence = NULL;
occurrence = g_strrstr(string, token);
if(occurrence == NULL || strlen(string) < strlen(token))
return;
while(occurrence != NULL)
{
strncpy(buf, string, strlen(string) - strlen(occurrence));
buf[strlen(string) - strlen(occurrence)] = '\0';
strcpy(buf2, occurrence + strlen(token));
sprintf(string, "%s%s%s", buf, replacement, buf2);
occurrence = g_strrstr(string, token);
}
}
/** Replace simple arithmetic expressions like "1 + 2" /** Replace simple arithmetic expressions like "1 + 2"
and comparisons like "3 < 4" with the appropriate result. */ and comparisons like "3 < 4" with the appropriate result. */
void void
@ -527,63 +527,64 @@ misc_string_replace_expressions(gchar *string)
gint i, j, last_idx = 0; gint i, j, last_idx = 0;
gint value = -1; gint value = -1;
gchar buf[SMALL], buf2[SMALL]; gchar buf[SMALL], buf2[SMALL];
gchar *occurrence = NULL,
*occurrence2 = NULL;
if(debug > 100) if(debug > 100)
printf("misc_string_replace_expressions: #%s#\n", printf("misc_string_replace_expressions: #%s#\n",
string); string);
if(g_strrstr(string, "[") == NULL) while(g_strrstr(string, "[") != NULL)
return; {
strcpy(buf, string);
strcpy(string, "");
strcpy(buf, string); occurrence = g_strrstr(buf, "[");
strcpy(string, ""); i = strlen(buf) - strlen(occurrence);
for(i=strlen(buf) - 1; i>=0; i--) strncpy(buf2, buf, i);
if(buf[i] == '[') buf2[i] = '\0';
strcat(string, buf2);
occurrence2 = g_strstr_len(occurrence, strlen(occurrence), "]");
if(occurrence2 == NULL)
{ {
strncpy(buf2, buf, i); g_warning("misc_string_replace_expressions: no matching ] found.");
buf2[i] = '\0'; return;
strcat(string, buf2);
for(j=i + 1;j<strlen(buf);j++)
{
if(buf[j] == ']')
{
strncpy(buf2, buf + i + 1, j - i - 1);
buf2[j - i - 1] = '\0';
if (g_strrstr(buf2, "|"))
misc_string_choose_random(buf2);
else
{
if(g_strrstr(buf2, "<") ||
g_strrstr(buf2, ">") ||
g_strrstr(buf2, "=") ||
g_strrstr(buf2, " G ") ||
g_strrstr(buf2, " L ") ||
g_strrstr(buf2, " GE ") ||
g_strrstr(buf2, " LE "))
misc_parse(buf2, &value);
else
misc_parse_expression(buf2, &value);
sprintf(buf2, "%d", value);
}
strcat(string, buf2);
value = -1;
last_idx = j + 1;
break;
}
}
break;
} }
if(last_idx < strlen(buf)) j = strlen(buf) - strlen(occurrence2);
{
strncpy(buf2, buf + last_idx, strlen(buf) - last_idx); strncpy(buf2, buf + i + 1, j - i - 1);
buf2[strlen(buf) - last_idx] = '\0'; buf2[j - i - 1] = '\0';
if (g_strrstr(buf2, "|"))
misc_string_choose_random(buf2);
else
{
if(g_strrstr(buf2, "<") ||
g_strrstr(buf2, ">") ||
g_strrstr(buf2, "=") ||
g_strrstr(buf2, " G ") ||
g_strrstr(buf2, " L ") ||
g_strrstr(buf2, " GE ") ||
g_strrstr(buf2, " LE "))
misc_parse(buf2, &value);
else
misc_parse_expression(buf2, &value);
sprintf(buf2, "%d", value);
}
strcat(string, buf2); strcat(string, buf2);
value = -1;
last_idx = j + 1;
if(last_idx < strlen(buf))
{
strncpy(buf2, buf + last_idx, strlen(buf) - last_idx);
buf2[strlen(buf) - last_idx] = '\0';
strcat(string, buf2);
}
} }
} }
@ -628,8 +629,6 @@ misc_string_get_parenthesised(const gchar *string, gchar *dest)
strncpy(dest, openpar + 1, len); strncpy(dest, openpar + 1, len);
dest[len] = '\0'; dest[len] = '\0';
printf("getpar %s\n", dest);
} }
/** Find out whether the conditions in the string are fulfilled. */ /** Find out whether the conditions in the string are fulfilled. */
@ -639,9 +638,6 @@ misc_parse_condition(const gchar *condition, GPtrArray **token_rep)
gboolean return_value = FALSE; gboolean return_value = FALSE;
gchar buf[SMALL], buf2[SMALL]; gchar buf[SMALL], buf2[SMALL];
if(condition == NULL)
return TRUE;
strcpy(buf, condition); strcpy(buf, condition);
while(g_strrstr(buf, "(")) while(g_strrstr(buf, "("))

View File

@ -57,6 +57,11 @@ misc2_callback_transfer_user_player(void)
user_from_team(new_team)->money -= transoff(stat2, 0).fee; user_from_team(new_team)->money -= transoff(stat2, 0).fee;
user_from_team(new_team)->money_out[1][MON_OUT_TRANSFERS] -= user_from_team(new_team)->money_out[1][MON_OUT_TRANSFERS] -=
transoff(stat2, 0).fee; transoff(stat2, 0).fee;
if(player_of_id_team(trans(stat2).tm, trans(stat2).id)->id ==
opt_user_int("int_opt_user_penalty_shooter"))
opt_user_set_int("int_opt_user_penalty_shooter", -1);
player_copy(player_of_id_team(trans(stat2).tm, trans(stat2).id), player_copy(player_of_id_team(trans(stat2).tm, trans(stat2).id),
new_team, new_team->players->len); new_team, new_team->players->len);
player_of_idx_team(new_team, new_team->players->len - 1)->contract = player_of_idx_team(new_team, new_team->players->len - 1)->contract =

View File

@ -148,7 +148,7 @@ on_button_digits_ok_clicked (GtkButton *button,
current_user.youth_academy.percentage = values[1]; current_user.youth_academy.percentage = values[1];
break; break;
case STATUS_PLACE_BET: case STATUS_PLACE_BET:
bet_place((Fixture*)statp, stat2, values[0]); bet_place(stat2, stat3, values[0]);
break; break;
} }

View File

@ -22,6 +22,7 @@
*/ */
#include "bet.h" #include "bet.h"
#include "fixture.h"
#include "misc3_callbacks.h" #include "misc3_callbacks.h"
#include "misc3_interface.h" #include "misc3_interface.h"
#include "option.h" #include "option.h"
@ -112,12 +113,12 @@ on_treeview_bets_button_press_event (GtkWidget *widget,
gtk_tree_model_get(model, &iter, col_num, &bet, -1); gtk_tree_model_get(model, &iter, col_num, &bet, -1);
if(bet == NULL || bet->fix->attendance != -1) if(bet == NULL || fixture_from_id(bet->fix_id)->attendance != -1)
return TRUE; return TRUE;
if(bet_is_user(bet)) if(bet_is_user(bet))
{ {
bet_remove(bet->fix); bet_remove(bet->fix_id);
treeview2_show_bets(); treeview2_show_bets();
return FALSE; return FALSE;
} }
@ -125,9 +126,9 @@ on_treeview_bets_button_press_event (GtkWidget *widget,
sprintf(buf, _("You bet on outcome %d with an odd of %.2f. How much do you wager?"), sprintf(buf, _("You bet on outcome %d with an odd of %.2f. How much do you wager?"),
col_num - 1, bet->odds[col_num - 1]); col_num - 1, bet->odds[col_num - 1]);
statp = (gpointer)bet->fix;
stat1 = STATUS_PLACE_BET; stat1 = STATUS_PLACE_BET;
stat2 = col_num - 1; stat2 = bet->fix_id;
stat3 = col_num - 1;
window_show_digits(buf, _("Wager"), 0, NULL, -1); window_show_digits(buf, _("Wager"), 0, NULL, -1);
spin_wager = GTK_SPIN_BUTTON(lookup_widget(window.digits, "spinbutton1")); spin_wager = GTK_SPIN_BUTTON(lookup_widget(window.digits, "spinbutton1"));
@ -153,4 +154,3 @@ on_checkbutton_bet_user_recent_button_press_event
return FALSE; return FALSE;
} }

View File

@ -38,6 +38,7 @@ create_window_bets (void)
GtkWidget *checkbutton_bet_cups; GtkWidget *checkbutton_bet_cups;
GtkWidget *checkbutton_bet_user_recent; GtkWidget *checkbutton_bet_user_recent;
GtkWidget *hseparator2; GtkWidget *hseparator2;
GtkWidget *scrolledwindow1;
GtkWidget *treeview_bets; GtkWidget *treeview_bets;
GtkWidget *button_bet_close; GtkWidget *button_bet_close;
GtkAccelGroup *accel_group; GtkAccelGroup *accel_group;
@ -90,9 +91,15 @@ create_window_bets (void)
gtk_box_pack_start (GTK_BOX (vbox1), hseparator2, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox1), hseparator2, FALSE, FALSE, 0);
gtk_widget_set_size_request (hseparator2, 1, 10); gtk_widget_set_size_request (hseparator2, 1, 10);
scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_show (scrolledwindow1);
gtk_box_pack_start (GTK_BOX (vbox1), scrolledwindow1, TRUE, TRUE, 0);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_SHADOW_IN);
treeview_bets = gtk_tree_view_new (); treeview_bets = gtk_tree_view_new ();
gtk_widget_show (treeview_bets); gtk_widget_show (treeview_bets);
gtk_box_pack_start (GTK_BOX (vbox1), treeview_bets, TRUE, TRUE, 0); gtk_container_add (GTK_CONTAINER (scrolledwindow1), treeview_bets);
button_bet_close = gtk_button_new_from_stock ("gtk-close"); button_bet_close = gtk_button_new_from_stock ("gtk-close");
gtk_widget_show (button_bet_close); gtk_widget_show (button_bet_close);
@ -131,6 +138,7 @@ create_window_bets (void)
GLADE_HOOKUP_OBJECT (window_bets, checkbutton_bet_cups, "checkbutton_bet_cups"); GLADE_HOOKUP_OBJECT (window_bets, checkbutton_bet_cups, "checkbutton_bet_cups");
GLADE_HOOKUP_OBJECT (window_bets, checkbutton_bet_user_recent, "checkbutton_bet_user_recent"); GLADE_HOOKUP_OBJECT (window_bets, checkbutton_bet_user_recent, "checkbutton_bet_user_recent");
GLADE_HOOKUP_OBJECT (window_bets, hseparator2, "hseparator2"); GLADE_HOOKUP_OBJECT (window_bets, hseparator2, "hseparator2");
GLADE_HOOKUP_OBJECT (window_bets, scrolledwindow1, "scrolledwindow1");
GLADE_HOOKUP_OBJECT (window_bets, treeview_bets, "treeview_bets"); GLADE_HOOKUP_OBJECT (window_bets, treeview_bets, "treeview_bets");
GLADE_HOOKUP_OBJECT (window_bets, button_bet_close, "button_bet_close"); GLADE_HOOKUP_OBJECT (window_bets, button_bet_close, "button_bet_close");
GLADE_HOOKUP_OBJECT_NO_REF (window_bets, tooltips, "tooltips"); GLADE_HOOKUP_OBJECT_NO_REF (window_bets, tooltips, "tooltips");

View File

@ -65,12 +65,13 @@ player_new(Team *tm, gfloat average_talent, gboolean new_id)
(new.pos == PLAYER_POS_GOALIE) * (new.pos == PLAYER_POS_GOALIE) *
const_float("float_player_peak_age_goalie_addition"));//30; const_float("float_player_peak_age_goalie_addition"));//30;
new.peak_region = new.peak_region =
math_gauss_dist(const_float("float_player_peak_region_lower"), math_gauss_dist(const_float("float_player_peak_region_lower"),
const_float("float_player_peak_region_upper"));//2; const_float("float_player_peak_region_upper"));//2;
new.talent = CLAMP(average_talent * skill_factor, 0, new.talent =
const_float("float_player_max_skill"));//85; CLAMP(average_talent * skill_factor, 0,
const_float("float_player_max_skill"));//85;
new.skill = player_skill_from_talent(&new); new.skill = player_skill_from_talent(&new);
new.cskill = new.skill; new.cskill = new.skill;
@ -1131,6 +1132,13 @@ player_remove_contract(Player *pl)
void void
player_remove_from_team(Team *tm, gint idx) player_remove_from_team(Team *tm, gint idx)
{ {
gint usr_idx = team_is_user(tm);
if(usr_idx != -1 &&
player_of_idx_team(tm, idx)->id ==
option_int("int_opt_user_penalty_shooter", &usr(usr_idx).options))
option_set_int("int_opt_user_penalty_shooter", &usr(usr_idx).options, -1);
transfer_remove_player_ptr(player_of_idx_team(tm, idx)); transfer_remove_player_ptr(player_of_idx_team(tm, idx));
free_player(player_of_idx_team(tm, idx)); free_player(player_of_idx_team(tm, idx));
g_array_remove_index(tm->players, idx); g_array_remove_index(tm->players, idx);

View File

@ -273,7 +273,8 @@ strategy_update_team_pre_match(Team *tm)
strategy_set_tokens(tm, NULL); strategy_set_tokens(tm, NULL);
for(i=prematches->len - 1; i >= 0; i--) for(i=prematches->len - 1; i >= 0; i--)
if(misc_parse_condition(g_array_index(prematches, StrategyPrematch, i).condition, if(g_array_index(prematches, StrategyPrematch, i).condition == NULL ||
misc_parse_condition(g_array_index(prematches, StrategyPrematch, i).condition,
token_strat)) token_strat))
{ {
strategy_apply_prematch(tm, &g_array_index(prematches, StrategyPrematch, i)); strategy_apply_prematch(tm, &g_array_index(prematches, StrategyPrematch, i));
@ -565,7 +566,8 @@ strategy_live_game_apply_action(LiveGame *match, gint team_idx,
} }
if(action->sub_in_pos != -1 && match->subs_left[team_idx] > 0 && if(action->sub_in_pos != -1 && match->subs_left[team_idx] > 0 &&
misc_parse_condition(action->sub_condition, token_strat)) (action->sub_condition == NULL ||
misc_parse_condition(action->sub_condition, token_strat)))
{ {
sub_in_id = strategy_get_sub(tm, action->sub_in_pos, sub_in_id = strategy_get_sub(tm, action->sub_in_pos,
action->sub_in_prop, TRUE); action->sub_in_prop, TRUE);
@ -608,9 +610,10 @@ strategy_live_game_check(LiveGame *match, gint team_idx)
!query_misc_integer_is_in_g_array( !query_misc_integer_is_in_g_array(
g_array_index(strat->match_action, StrategyMatchAction, i).id, g_array_index(strat->match_action, StrategyMatchAction, i).id,
match->action_ids[team_idx]) && match->action_ids[team_idx]) &&
misc_parse_condition( (g_array_index(strat->match_action, StrategyMatchAction, i).condition == NULL ||
g_array_index(strat->match_action, StrategyMatchAction, i).condition, misc_parse_condition(
token_strat)) g_array_index(strat->match_action, StrategyMatchAction, i).condition,
token_strat)))
{ {
strategy_live_game_apply_action( strategy_live_game_apply_action(
match, team_idx, match, team_idx,

View File

@ -55,8 +55,8 @@ team_new(gboolean new_id)
new.clid = -1; new.clid = -1;
new.id = (new_id) ? team_id_new : -1; new.id = (new_id) ? team_id_new : -1;
new.structure = 442; ///*dteam_assign_playing_structure(); new.structure = 442;
new.style = 0; ///*dteam_assign_playing_style(); new.style = 0;
new.boost = 0; new.boost = 0;
new.average_talent = 0; new.average_talent = 0;
@ -65,54 +65,6 @@ team_new(gboolean new_id)
return new; return new;
} }
/**
Return a random playing style.
@see The #TeamPlayingStyle enumeration.
*/
gint
team_assign_playing_style(void)
{
gfloat rndom;
rndom = math_rnd(0,1);
/* all out defend */
if(rndom < const_float("float_team_playing_style_prob1"))
return -2;
/* defend */
else if(rndom < const_float("float_team_playing_style_prob2"))
return -1;
/* balanced */
else if(rndom < const_float("float_team_playing_style_prob3"))
return 0;
/* attack */
else if(rndom < const_float("float_team_playing_style_prob4"))
return 1;
/* all out attack */
return 2;
}
/**
Return a random playing structure.
*/
gint
team_assign_playing_structure(void)
{
gfloat rndom = math_rnd(0,1);
if(rndom < const_float("float_team_playing_structure_prob1"))
return 532;
else if(rndom < const_float("float_team_playing_structure_prob2"))
return 442;
else if(rndom < const_float("float_team_playing_structure_prob3"))
return 352;
else if(rndom < const_float("float_team_playing_structure_prob4"))
return 433;
return 343;
}
/* Fill the players array of the team and the stadium. /* Fill the players array of the team and the stadium.
@param tm The team that gets filled. */ @param tm The team that gets filled. */
void void
@ -600,96 +552,6 @@ team_change_attribute_with_message(Team *tm, gint attribute, gint new_value)
} }
} }
/*d remove*/
/** Make cpu players healthy etc.
@param tm The cpu team.
@param reset_fitness Whether to reset the fitness values of playes. */
void
team_update_cpu_corrections(Team *tm, gboolean reset_fitness)
{
gint i, j;
Player *pl;
for(i=0;i<tm->players->len;i++)
{
pl = player_of_idx_team(tm, i);
for(j=0;j<pl->cards->len;j++)
g_array_index(pl->cards, PlayerCard, j).red = 0;
if(pl->cskill == 0)
{
pl->health = pl->recovery = 0;
pl->cskill = player_get_cskill(pl, pl->cpos, FALSE);
pl->fitness = math_rnd(const_float("float_player_fitness_lower"),
const_float("float_player_fitness_upper"));
}
if(pl->pos != pl->cpos)
{
pl->pos = pl->cpos;
pl->cskill = player_get_cskill(pl, pl->cpos, FALSE);
}
if(reset_fitness)
pl->fitness = math_rnd(const_float("float_player_fitness_lower"),
const_float("float_player_fitness_upper"));
}
team_rearrange(tm);
tm->structure = team_find_appropriate_structure(tm);
if(!player_substitution_good_structure(tm->structure, PLAYER_POS_DEFENDER, PLAYER_POS_DEFENDER))
{
tm->structure = team_assign_playing_structure();
for(i=0;i<tm->players->len;i++)
{
pl = player_of_idx_team(tm, i);
pl->pos = pl->cpos = player_get_position_from_structure(tm->structure, i);
}
}
}
/*d remove*/
/** Make some random substitutions in the cpu team. */
void
team_update_cpu_subs(Team *tm)
{
gint i;
gint number_of_subs = math_rndi(const_int("int_team_subs_lower"),
const_int("int_team_subs_upper"));
gint player_numbers[11];
math_generate_permutation(player_numbers, 0, 10);
for(i=0;i<number_of_subs;i++)
game_substitute_player(tm, player_numbers[i]);
if(player_get_game_skill(player_of_idx_team(tm, 0), FALSE, TRUE) <
player_get_game_skill(player_of_idx_team(tm, 10), FALSE, TRUE) &&
math_rnd(0, 1) < const_float("float_team_replace_worse_goalie"))
game_substitute_player(tm, 0);
}
/*d remove*/
/** Change a cpu team's structure. */
void
team_update_cpu_structure(Team *tm)
{
gint i;
Player *pl = NULL;
tm->structure = team_assign_playing_structure();
for(i=0;i<tm->players->len;i++)
{
pl = &g_array_index(tm->players, Player, i);
pl->pos = pl->cpos = player_get_position_from_structure(tm->structure, i);
}
}
/** Replace some players by new ones in a team. */ /** Replace some players by new ones in a team. */
void void
team_update_cpu_new_players(Team *tm) team_update_cpu_new_players(Team *tm)
@ -708,27 +570,6 @@ team_update_cpu_new_players(Team *tm)
} }
} }
/*d remove*/
/** Heal players, re-set fitnesses, make some random subs
and replace some players with new ones.
@param tm The team we examine.
@param reset_fitness Whether to reset the fitness values of players. */
void
team_update_cpu_team(Team *tm, gboolean reset_fitness)
{
team_update_cpu_corrections(tm, reset_fitness);
team_update_cpu_subs(tm);
if(math_rnd(0, 1) < const_float("float_team_new_player_probability"))
team_update_cpu_new_players(tm);
if(math_rnd(0, 1) < const_float("float_team_new_style"))
tm->style = team_assign_playing_style();
if(math_rnd(0, 1) < const_float("float_team_new_structure"))
team_update_cpu_structure(tm);
}
/** Increase player ages etc. /** Increase player ages etc.
@param tm The user team we examine. */ @param tm The user team we examine. */
void void

View File

@ -44,12 +44,6 @@ enum TeamCompare
Team Team
team_new(gboolean new_id); team_new(gboolean new_id);
gint
team_assign_playing_structure(void);
gint
team_assign_playing_style(void);
gboolean gboolean
query_is_my_team(const Team *tm); query_is_my_team(const Team *tm);
@ -104,21 +98,9 @@ team_change_attribute_with_message(Team * tm, gint attribute, gint new_value);
void void
team_update_team_weekly(Team *tm); team_update_team_weekly(Team *tm);
void
team_update_cpu_team(Team *tm, gboolean reset_fitness);
void void
team_update_post_match(Team *tm, const Fixture *fix); team_update_post_match(Team *tm, const Fixture *fix);
void
team_update_cpu_corrections(Team *tm, gboolean reset_fitness);
void
team_update_cpu_subs(Team *tm);
void
team_update_cpu_structure(Team *tm);
void void
team_update_cpu_new_players(Team *tm); team_update_cpu_new_players(Team *tm);

View File

@ -256,6 +256,7 @@ treeview2_create_bets(GtkListStore *ls)
team_names[2][SMALL]; team_names[2][SMALL];
const BetMatch *bet = NULL; const BetMatch *bet = NULL;
const BetUser *bet_user = NULL; const BetUser *bet_user = NULL;
const Fixture *fix = NULL;
for(k=1;k>=0;k--) for(k=1;k>=0;k--)
{ {
@ -271,11 +272,11 @@ treeview2_create_bets(GtkListStore *ls)
for(i=0;i<bets[k]->len;i++) for(i=0;i<bets[k]->len;i++)
{ {
if(g_array_index(bets[k], BetMatch, i).fix->clid == fix = fixture_from_id(g_array_index(bets[k], BetMatch, i).fix_id);
current_user.tm->clid || if(fix->clid == current_user.tm->clid ||
(g_array_index(bets[k], BetMatch, i).fix->clid >= ID_CUP_START && (fix->clid >= ID_CUP_START &&
opt_user_int("int_opt_user_bet_show_cups")) || opt_user_int("int_opt_user_bet_show_cups")) ||
(g_array_index(bets[k], BetMatch, i).fix->clid < ID_CUP_START && (fix->clid < ID_CUP_START &&
opt_user_int("int_opt_user_bet_show_all_leagues"))) opt_user_int("int_opt_user_bet_show_all_leagues")))
{ {
bet = &g_array_index(bets[k], BetMatch, i); bet = &g_array_index(bets[k], BetMatch, i);
@ -286,8 +287,8 @@ treeview2_create_bets(GtkListStore *ls)
(bet_user != NULL || (bet_user != NULL ||
!opt_user_int("int_opt_user_bet_show_my_recent")))) !opt_user_int("int_opt_user_bet_show_my_recent"))))
{ {
if(i == 0 || bet->fix->clid != if(i == 0 || fix->clid !=
g_array_index(bets[k], BetMatch, i - 1).fix->clid) fixture_from_id(g_array_index(bets[k], BetMatch, i - 1).fix_id)->clid)
{ {
if(i > 0) if(i > 0)
{ {
@ -298,7 +299,7 @@ treeview2_create_bets(GtkListStore *ls)
gtk_list_store_append(ls, &iter); gtk_list_store_append(ls, &iter);
gtk_list_store_set(ls, &iter, gtk_list_store_set(ls, &iter,
0, league_cup_get_name_string(bet->fix->clid), 0, league_cup_get_name_string(fix->clid),
1, NULL, 2, NULL, 3, NULL, 4, "", 5, "", -1); 1, NULL, 2, NULL, 3, NULL, 4, "", 5, "", -1);
} }
@ -314,24 +315,24 @@ treeview2_create_bets(GtkListStore *ls)
} }
for(j=0;j<2;j++) for(j=0;j<2;j++)
if(query_fixture_has_tables(bet->fix)) if(query_fixture_has_tables(fix))
{ {
if(bet->fix->clid < ID_CUP_START) if(fix->clid < ID_CUP_START)
rank = team_get_league_rank(bet->fix->teams[j]); rank = team_get_league_rank(fix->teams[j]);
else else
rank = team_get_cup_rank(bet->fix->teams[j], rank = team_get_cup_rank(fix->teams[j],
cup_get_last_tables_round(bet->fix->clid), TRUE); cup_get_last_tables_round(fix->clid), TRUE);
sprintf(team_names[j], "%s [%d]", sprintf(team_names[j], "%s [%d]",
bet->fix->teams[j]->name, rank); fix->teams[j]->name, rank);
} }
else if(bet->fix->clid >= ID_CUP_START && else if(fix->clid >= ID_CUP_START &&
query_cup_is_national(bet->fix->clid)) query_cup_is_national(fix->clid))
sprintf(team_names[j], "%s (%d)", sprintf(team_names[j], "%s (%d)",
bet->fix->teams[j]->name, fix->teams[j]->name,
league_from_clid(bet->fix->teams[j]->clid)->layer); league_from_clid(fix->teams[j]->clid)->layer);
else else
strcpy(team_names[j], bet->fix->teams[j]->name); strcpy(team_names[j], fix->teams[j]->name);
gtk_list_store_append(ls, &iter); gtk_list_store_append(ls, &iter);
gtk_list_store_set(ls, &iter, 0, team_names[0], gtk_list_store_set(ls, &iter, 0, team_names[0],

View File

@ -1603,6 +1603,7 @@ treeview_helper_bet_odds(GtkTreeViewColumn *col,
{ {
gint column = treeview_helper_get_col_number_column(col); gint column = treeview_helper_get_col_number_column(col);
gchar buf[SMALL]; gchar buf[SMALL];
const Fixture *fix = NULL;
const BetMatch *bet = NULL; const BetMatch *bet = NULL;
const BetUser *bet_user = NULL; const BetUser *bet_user = NULL;
@ -1619,14 +1620,15 @@ treeview_helper_bet_odds(GtkTreeViewColumn *col,
strcpy(buf, ""); strcpy(buf, "");
bet_user = bet_is_user(bet); bet_user = bet_is_user(bet);
fix = fixture_from_id(bet->fix_id);
if(bet->fix->attendance == -1) if(fix->attendance == -1)
sprintf(buf, "%.2f", bet->odds[column - 1]); sprintf(buf, "%.2f", bet->odds[column - 1]);
else if(column == 2) else if(column == 2)
sprintf(buf, "%d - %d", bet->fix->result[0][0], sprintf(buf, "%d - %d", fix->result[0][0],
bet->fix->result[1][0]); fix->result[1][0]);
if(bet->fix->attendance == -1 && if(fix->attendance == -1 &&
bet_user != NULL && bet_user != NULL &&
bet_user->outcome == column - 1) bet_user->outcome == column - 1)
g_object_set(renderer, "background", g_object_set(renderer, "background",

View File

@ -166,7 +166,7 @@ xml_loadsave_misc_text (GMarkupParseContext *context,
else if(state == TAG_MISC_BET_ODD) else if(state == TAG_MISC_BET_ODD)
new_bet.odds[oddidx] = float_value; new_bet.odds[oddidx] = float_value;
else if(state == TAG_MISC_BET_FIX_ID) else if(state == TAG_MISC_BET_FIX_ID)
new_bet.fix = fixture_from_id(int_value); new_bet.fix_id = int_value;
} }
@ -255,7 +255,7 @@ xml_loadsave_misc_write_bets(FILE *fil)
for(j=0;j<bets[i]->len;j++) for(j=0;j<bets[i]->len;j++)
{ {
fprintf(fil, "%s<_%d>\n", I0, (i == 0) ? TAG_MISC_BET0 : TAG_MISC_BET1); fprintf(fil, "%s<_%d>\n", I0, (i == 0) ? TAG_MISC_BET0 : TAG_MISC_BET1);
xml_write_int(fil, g_array_index(bets[i], BetMatch, j).fix->id, xml_write_int(fil, g_array_index(bets[i], BetMatch, j).fix_id,
TAG_MISC_BET_FIX_ID, I1); TAG_MISC_BET_FIX_ID, I1);
for(k=0;k<3;k++) for(k=0;k<3;k++)
xml_write_float(fil, g_array_index(bets[i], BetMatch, j).odds[k], xml_write_float(fil, g_array_index(bets[i], BetMatch, j).odds[k],

View File

@ -315,7 +315,7 @@ xml_loadsave_users_text (GMarkupParseContext *context,
else if(state == TAG_USER_BET_OUTCOME) else if(state == TAG_USER_BET_OUTCOME)
new_bet.outcome = int_value; new_bet.outcome = int_value;
else if(state == TAG_USER_BET_FIX_ID) else if(state == TAG_USER_BET_FIX_ID)
new_bet.fix = fixture_from_id(int_value); new_bet.fix_id = int_value;
else if(state >= TAG_START_PLAYERS && state <= TAG_END_PLAYERS) else if(state >= TAG_START_PLAYERS && state <= TAG_END_PLAYERS)
xml_loadsave_players_text(buf); xml_loadsave_players_text(buf);
} }
@ -500,7 +500,7 @@ xml_user_write_bets(FILE *fil, GArray **bets)
TAG_USER_BET_WAGER, I2); TAG_USER_BET_WAGER, I2);
xml_write_int(fil, g_array_index(bets[i], BetUser, j).outcome, xml_write_int(fil, g_array_index(bets[i], BetUser, j).outcome,
TAG_USER_BET_OUTCOME, I2); TAG_USER_BET_OUTCOME, I2);
xml_write_int(fil, g_array_index(bets[i], BetUser, j).fix->id, xml_write_int(fil, g_array_index(bets[i], BetUser, j).fix_id,
TAG_USER_BET_FIX_ID, I2); TAG_USER_BET_FIX_ID, I2);
fprintf(fil, "%s</_%d>\n", I1, fprintf(fil, "%s</_%d>\n", I1,
(i == 0) ? TAG_USER_BET0 : TAG_USER_BET1); (i == 0) ? TAG_USER_BET0 : TAG_USER_BET1);