diff --git a/src/fixture.c b/src/fixture.c index 966a3ae6..918d6e29 100644 --- a/src/fixture.c +++ b/src/fixture.c @@ -1203,7 +1203,7 @@ fixture_compare_func(gconstpointer a, gconstpointer b, gpointer data) /** Return an array with the last fixtures of the team. */ GPtrArray* -fixture_get_latest(const Team *tm) +fixture_get_latest(const Team *tm, gboolean with_cups) { #ifdef DEBUG printf("fixture_get_latest\n"); @@ -1222,15 +1222,18 @@ fixture_get_latest(const Team *tm) g_array_index(lig(i).fixtures, Fixture, j).teams[1] == tm) g_ptr_array_add(latest, &g_array_index(lig(i).fixtures, Fixture, j)); } - - for(i=0;ilen;i++) + + if(with_cups) { - for(j=0;jfixtures->len;j++) - if(g_array_index(acp(i)->fixtures, Fixture, j).attendance == -1) - break; - else if(g_array_index(acp(i)->fixtures, Fixture, j).teams[0] == tm || - g_array_index(acp(i)->fixtures, Fixture, j).teams[1] == tm) - g_ptr_array_add(latest, &g_array_index(acp(i)->fixtures, Fixture, j)); + for(i=0;ilen;i++) + { + for(j=0;jfixtures->len;j++) + if(g_array_index(acp(i)->fixtures, Fixture, j).attendance == -1) + break; + else if(g_array_index(acp(i)->fixtures, Fixture, j).teams[0] == tm || + g_array_index(acp(i)->fixtures, Fixture, j).teams[1] == tm) + g_ptr_array_add(latest, &g_array_index(acp(i)->fixtures, Fixture, j)); + } } g_ptr_array_sort_with_data(latest, fixture_compare_func, diff --git a/src/fixture.h b/src/fixture.h index 04c37d65..e3723774 100644 --- a/src/fixture.h +++ b/src/fixture.h @@ -124,7 +124,7 @@ Fixture* fixture_get_previous(gint clid, gint week_number, gint week_round_number); GPtrArray* -fixture_get_latest(const Team *tm); +fixture_get_latest(const Team *tm, gboolean with_cups); gint fixture_compare_func(gconstpointer a, gconstpointer b, gpointer data); diff --git a/src/news.c b/src/news.c index 78b7ac3d..69a64a9a 100644 --- a/src/news.c +++ b/src/news.c @@ -294,12 +294,78 @@ news_set_match_tokens(const LiveGame *live_game) lg_commentary_set_stats_tokens(&live_game->stats, token_rep_news); news_set_fixture_tokens(live_game->fix); news_set_league_cup_tokens(live_game->fix); + news_set_streak_tokens(live_game->fix); news_set_scorer_tokens(&live_game->stats); if(live_game->fix->clid < ID_CUP_START) news_set_rank_tokens(live_game->fix); } +/** Set overall and league streak tokens for the two teams. */ +void +news_set_streak_tokens(const Fixture *fix) +{ +#ifdef DEBUG + printf("news_set_streak_tokens\n"); +#endif + + gint i, j, k, + streak_won, streak_lost; + gint res[2]; + gchar buf[SMALL], buf2[SMALL]; + GPtrArray *latest_fixtures; + + for(i = 0; i < 2; i++) + { + for(k = 0; k < 2; k++) + { + latest_fixtures = fixture_get_latest(fix->teams[0], (k == 0)); + streak_won = streak_lost = 0; + + for(j=latest_fixtures->len - 1;j>=0;j--) + { + res[0] = math_sum_int_array(((Fixture*)g_ptr_array_index(latest_fixtures, j))->result[0], 3); + res[1] = math_sum_int_array(((Fixture*)g_ptr_array_index(latest_fixtures, j))->result[1], 3); + + if(res[0] == res[1]) + break; + else if(res[(((Fixture*)g_ptr_array_index(latest_fixtures, j))->teams[0] == fix->teams[i])] > + res[(((Fixture*)g_ptr_array_index(latest_fixtures, j))->teams[0] != fix->teams[i])]) + { + if(streak_won == 0) + streak_lost++; + else + break; + } + else + { + if(streak_lost == 0) + streak_won++; + else + break; + } + } + + if(k == 0) + strcpy(buf2, ""); + else + strcpy(buf2, "league_"); + + sprintf(buf, "string_token_streak_%swon%d", buf2, i); + misc_token_add(token_rep_news, + option_int(buf, &tokens), + misc_int_to_char(streak_won)); + sprintf(buf, "string_token_streak_%slost%d", buf2, i); + misc_token_add(token_rep_news, + option_int(buf, &tokens), + misc_int_to_char(streak_lost)); + + + g_ptr_array_free(latest_fixtures, TRUE); + } + } +} + void news_set_scorer_tokens(const LiveGameStats *stats) { @@ -369,9 +435,9 @@ news_set_scorer_tokens(const LiveGameStats *stats) else if(j == scorers[i]->len - 1 && j != 0) { if(scorer_goals > 1) - sprintf(scorer_str, "%s and %s (%d)", buf, scorer, scorer_goals); + sprintf(scorer_str, _("%s and %s (%d)"), buf, scorer, scorer_goals); else - sprintf(scorer_str, "%s and %s", buf, scorer); + sprintf(scorer_str, _("%s and %s"), buf, scorer); } else { @@ -564,6 +630,7 @@ news_free_tokens(void) gint i; +/* printf("\n\n---------------------------------\n"); */ for(i=token_rep_news[0]->len - 1;i >= 0; i--) { /* printf("%s/%s\n", (gchar*)g_ptr_array_index(token_rep_news[0], i), */ diff --git a/src/news.h b/src/news.h index 3de666b0..1dd9c5e1 100644 --- a/src/news.h +++ b/src/news.h @@ -76,4 +76,7 @@ news_set_rank_tokens(const Fixture *fix); void news_articles_get_order(const GArray *articles, gint *order); +void +news_set_streak_tokens(const Fixture *fix); + #endif diff --git a/src/team.c b/src/team.c index 05c5bef1..19b05c76 100644 --- a/src/team.c +++ b/src/team.c @@ -1121,7 +1121,7 @@ team_write_results(const Team *tm, gchar *result_buf, gchar *goals_buf) #endif gint i; - GPtrArray *latest_fixtures = fixture_get_latest(tm); + GPtrArray *latest_fixtures = fixture_get_latest(tm, TRUE); gint res[2], goals[2] = {0, 0}; gint end_idx = latest_fixtures->len - const_int("int_treeview_latest_results"); diff --git a/support_files/bygfoot_tokens b/support_files/bygfoot_tokens index 7649363a..45525e04 100644 --- a/support_files/bygfoot_tokens +++ b/support_files/bygfoot_tokens @@ -99,3 +99,11 @@ string_token_rank0 _RANK0_ string_token_oldrank0 _OLDRANK0_ string_token_rank1 _RANK1_ string_token_oldrank1 _OLDRANK1_ +string_token_streak_won0 _WON0_ +string_token_streak_lost0 _LOST0_ +string_token_streak_won1 _WON1_ +string_token_streak_lost1 _LOST1_ +string_token_streak_league_won0 _LEAGUEWON0_ +string_token_streak_league_lost0 _LEAGUELOST0_ +string_token_streak_league_won1 _LEAGUEWON1_ +string_token_streak_league_lost1 _LEAGUELOST1_ diff --git a/support_files/news/news_de.xml b/support_files/news/news_de.xml index a4daf714..484b1f5c 100644 --- a/support_files/news/news_de.xml +++ b/support_files/news/news_de.xml @@ -7,23 +7,27 @@ News Of The Sports World match - _CUP_ = 0 _GD_ G 1 + _CUP_ = 0 and _GD_ G 1 _TW_ [beats|crushes|kills] _TL_! - Result: _RE_ _TL_ loses to _TW_! - _TL_ doesn't stand a chance against a _GOALS_TWN__ goal barrage. _TW_ wipes out _TL_! - _RE_ is flattering for _TL_. _TL_ loses again! - _TW_ just too strong. _TL_ in a world of misery! - _TW_: _RE_ against _TL_. _LEAGUECUPNAME_: _TL_ loses to _TW_! + Result: _RE_ + _TL_ doesn't stand a chance against a _GOALS_TWN__ goal barrage. + _RE_ is flattering for _TL_. + _TW_ just too strong. + _TW_: _RE_ against _TL_. _TL_ overwhelmed by _SHOTS_TWN__ shots. _SCORERS_TWN__ ensure victory for _TW_. - _TW_ moves to rank _RANK_TWN__ in _LEAGUECUPNAME_. + _TW_ moves to rank _RANK_TWN__ in _LEAGUECUPNAME_. _TW_ moves to rank _RANK_TWN__ in _LEAGUECUPNAME_. _TW_ on top after defeating _TL_ _RE_. + _TW_'s streak now at _WON_TWN__ wins. + _TL_'s losing streak now at _LOST_TLN__! + _TW_ wins _WON_TWN__th in a row in _LEAGUECUPNAME_. + _TL_ loses _LOST_TLN__th in a row in _LEAGUECUPNAME_. diff --git a/support_files/news/news_en.xml b/support_files/news/news_en.xml index a4daf714..484b1f5c 100644 --- a/support_files/news/news_en.xml +++ b/support_files/news/news_en.xml @@ -7,23 +7,27 @@ News Of The Sports World match - _CUP_ = 0 _GD_ G 1 + _CUP_ = 0 and _GD_ G 1 _TW_ [beats|crushes|kills] _TL_! - Result: _RE_ _TL_ loses to _TW_! - _TL_ doesn't stand a chance against a _GOALS_TWN__ goal barrage. _TW_ wipes out _TL_! - _RE_ is flattering for _TL_. _TL_ loses again! - _TW_ just too strong. _TL_ in a world of misery! - _TW_: _RE_ against _TL_. _LEAGUECUPNAME_: _TL_ loses to _TW_! + Result: _RE_ + _TL_ doesn't stand a chance against a _GOALS_TWN__ goal barrage. + _RE_ is flattering for _TL_. + _TW_ just too strong. + _TW_: _RE_ against _TL_. _TL_ overwhelmed by _SHOTS_TWN__ shots. _SCORERS_TWN__ ensure victory for _TW_. - _TW_ moves to rank _RANK_TWN__ in _LEAGUECUPNAME_. + _TW_ moves to rank _RANK_TWN__ in _LEAGUECUPNAME_. _TW_ moves to rank _RANK_TWN__ in _LEAGUECUPNAME_. _TW_ on top after defeating _TL_ _RE_. + _TW_'s streak now at _WON_TWN__ wins. + _TL_'s losing streak now at _LOST_TLN__! + _TW_ wins _WON_TWN__th in a row in _LEAGUECUPNAME_. + _TL_ loses _LOST_TLN__th in a row in _LEAGUECUPNAME_.