From 927c5d89cca9a56a528f9a8256dc19d4e4074f74 Mon Sep 17 00:00:00 2001 From: gyboth Date: Sat, 6 Dec 2008 08:01:43 +0000 Subject: [PATCH] Newspaper progressing. --- src/news.c | 53 +++++++++++++++++++++++++++++---- src/news.h | 3 ++ support_files/bygfoot_tokens | 28 +++++++++-------- support_files/bygfoot_user.conf | 6 ++-- support_files/news/news_de.xml | 11 ++++++- 5 files changed, 79 insertions(+), 22 deletions(-) diff --git a/src/news.c b/src/news.c index 8d1a2a0f..ebf4ac13 100644 --- a/src/news.c +++ b/src/news.c @@ -74,7 +74,7 @@ news_generate_match(const LiveGame *live_game) new_article.subtitle = g_strdup(subtitle); new_article.title_id = title_id; new_article.subtitle_id = subtitle_id; -// printf("%s / %s -- %d %d\n", title, subtitle, title_id, subtitle_id); +/* printf("%s / %s -- %d %d\n", title, subtitle, title_id, subtitle_id); */ g_array_append_val(newspaper.articles, new_article); /* gint i; */ @@ -98,17 +98,24 @@ news_select(const GArray *news_array, gchar *title, gchar *subtitle, gint i; const NewsArticle *article; + gint order_articles[news_array->len]; + + math_generate_permutation(order_articles, 0, news_array->len - 1); *title_id = *subtitle_id = -1; for(i=0;ilen;i++) - if(misc_parse_condition(g_array_index(news_array, NewsArticle, i).condition, token_rep_news)) + { +/* printf("cond %s res %d\n", g_array_index(news_array, NewsArticle, order_articles[i]).condition, */ +/* misc_parse_condition(g_array_index(news_array, NewsArticle, order_articles[i]).condition, token_rep_news)); */ + if(misc_parse_condition(g_array_index(news_array, NewsArticle, order_articles[i]).condition, token_rep_news)) break; + } if(i == news_array->len) return; - article = &g_array_index(news_array, NewsArticle, i); + article = &g_array_index(news_array, NewsArticle, order_articles[i]); gint order_titles[article->titles->len], order_subtitles[article->subtitles->len]; @@ -140,6 +147,8 @@ news_get_title(const GArray *titles, gchar *title, gint *order, for(i = 0; i < titles->len; i++) { + gboolean res = misc_string_replace_all_tokens(token_rep_news, g_array_index(titles, NewsText, order[i]).text, title); +/* printf("title: %s %d\n", title, res); */ if(misc_parse_condition(g_array_index(titles, NewsText, order[i]).condition, token_rep_news) && misc_string_replace_all_tokens(token_rep_news, g_array_index(titles, NewsText, order[i]).text, title)) { @@ -235,6 +244,9 @@ news_set_match_tokens(const LiveGame *live_game) news_set_fixture_tokens(live_game->fix); news_set_league_cup_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); } void @@ -325,7 +337,7 @@ news_set_scorer_tokens(const LiveGameStats *stats) if(strcmp(scorer_str, "") != 0) { - sprintf(buf, "string_token_multiple_scorers%d", i); + sprintf(buf, "string_token_bool_multiple_scorers%d", i); misc_token_add_bool(token_rep_news, option_int(buf, &tokens), (scorers[i]->len > 1)); @@ -381,7 +393,7 @@ news_set_league_cup_tokens(const Fixture *fix) g_strdup(league_cup_get_name_string(fix->clid))); misc_token_add_bool(token_rep_news, - option_int("string_token_cup", &tokens), + option_int("string_token_bool_cup", &tokens), (fix->clid >= ID_CUP_START)); if(fix->clid >= ID_CUP_START) @@ -395,7 +407,7 @@ news_set_league_cup_tokens(const Fixture *fix) g_strdup(buf)); misc_token_add_bool(token_rep_news, - option_int("string_token_cup_knockout", &tokens), + option_int("string_token_bool_cup_knockout", &tokens), (cupround->tables->len == 0)); if(fix->decisive) @@ -405,6 +417,7 @@ news_set_league_cup_tokens(const Fixture *fix) } } +/** Set the news tokens related to the fixture. */ void news_set_fixture_tokens(const Fixture *fix) { @@ -462,6 +475,34 @@ news_set_fixture_tokens(const Fixture *fix) } } +/** Set the rank tokens of the involved teams. */ +void +news_set_rank_tokens(const Fixture *fix) +{ +#ifdef DEBUG + printf("news_set_rank_tokens\n"); +#endif + + gint i, j; + gchar buf[SMALL]; + const Table *table; + + for(i = 0; i < 2; i++) + { + table = league_table(league_from_clid(fix->teams[i]->clid)); + for(j = 0; j < table->elements->len; j++) + if(g_array_index(table->elements, TableElement, j).team == fix->teams[i]) + { + sprintf(buf, "string_token_rank%d", i); + misc_token_add(token_rep_news, option_int(buf, &tokens), misc_int_to_char(j + 1)); + sprintf(buf, "string_token_oldrank%d", i); + misc_token_add(token_rep_news, option_int(buf, &tokens), + misc_int_to_char(g_array_index(table->elements, TableElement, j).old_rank)); + break; + } + } +} + /** Free the memory occupied by the tokens array and the permanent tokens. */ void news_free_tokens(void) diff --git a/src/news.h b/src/news.h index 3d2f6ec7..7b632161 100644 --- a/src/news.h +++ b/src/news.h @@ -70,4 +70,7 @@ news_set_league_cup_tokens(const Fixture *fix); void news_set_fixture_tokens(const Fixture *fix); +void +news_set_rank_tokens(const Fixture *fix); + #endif diff --git a/support_files/bygfoot_tokens b/support_files/bygfoot_tokens index d2f5849a..7649363a 100644 --- a/support_files/bygfoot_tokens +++ b/support_files/bygfoot_tokens @@ -83,15 +83,19 @@ string_token_form _FORMATION_ # tokens for news articles #------------------------------------ -string_token_cup _CUP_ -string_token_cup_knockout _CUPKO_ -string_token_cup_stage _CUPSTAGE_ -string_token_cup_match_winner _CUPMATCHWINNER_ -string_token_multiple_scorers0 _MULTIPLESCORERS_ -string_token_multiple_scorers1 _MULTIPLESCORERS_ -string_token_scorers0 _SCORERS0_ -string_token_highscorer0 _HIGHSCORER0_ -string_token_highscorer_goals0 _HIGHGOALS0_ -string_token_scorers1 _SCORERS1_ -string_token_highscorer1 _HIGHSCORER1_ -string_token_highscorer_goals1 _HIGHGOALS1_ +string_token_bool_cup _CUP_ +string_token_bool_cup_knockout _CUPKO_ +string_token_cup_stage _CUPSTAGE_ +string_token_cup_match_winner _CUPMATCHWINNER_ +string_token_bool_multiple_scorers0 _MULTIPLESCORERS_ +string_token_bool_multiple_scorers1 _MULTIPLESCORERS_ +string_token_scorers0 _SCORERS0_ +string_token_highscorer0 _HIGHSCORER0_ +string_token_highscorer_goals0 _HIGHGOALS0_ +string_token_scorers1 _SCORERS1_ +string_token_highscorer1 _HIGHSCORER1_ +string_token_highscorer_goals1 _HIGHGOALS1_ +string_token_rank0 _RANK0_ +string_token_oldrank0 _OLDRANK0_ +string_token_rank1 _RANK1_ +string_token_oldrank1 _OLDRANK1_ diff --git a/support_files/bygfoot_user.conf b/support_files/bygfoot_user.conf index 4ec03d8a..e85d6b31 100644 --- a/support_files/bygfoot_user.conf +++ b/support_files/bygfoot_user.conf @@ -1,7 +1,7 @@ -int_opt_user_confirm_youth 1 +int_opt_user_confirm_youth 0 int_opt_user_show_live_game 0 int_opt_user_live_game_speed 40 -int_opt_user_live_game_verbosity 5 +int_opt_user_live_game_verbosity 7 int_opt_user_show_tendency_bar 1 int_opt_user_pause_injury 1 int_opt_user_pause_red 1 @@ -10,7 +10,7 @@ int_opt_user_auto_sub 0 int_opt_user_show_job_offers 1 int_opt_user_swap_adapts 1 int_opt_user_show_overall 0 -int_opt_user_show_all_leagues 0 +int_opt_user_show_all_leagues 1 int_opt_user_contract_limit 12 int_opt_user_penalty_shooter -1 int_opt_user_bet_show_all_leagues 0 diff --git a/support_files/news/news_de.xml b/support_files/news/news_de.xml index f91e4903..b04120ac 100644 --- a/support_files/news/news_de.xml +++ b/support_files/news/news_de.xml @@ -7,7 +7,7 @@ News Of The Sports World match - _GD_ > 1 + _GD_ G 1 _TW_ [beats|crushes|kills] _TL_! Result: _RE_ _TL_ loses to _TW_! @@ -23,4 +23,13 @@ _SCORERS_TWN__ ensure victory for _TW_. + + match + _CUP_ = 0 + _TW_ victorious! + _TW_ moves to rank _RANK_TWN__ in _LEAGUECUPNAME_. + _TW_ moves to rank _RANK_TWN__ in _LEAGUECUPNAME_. + _TW_ on top after defeating _TL_ _RE_. + +