2005-10-20 15:45:00 +00:00
|
|
|
/*
|
2005-11-26 16:52:51 +00:00
|
|
|
league.h
|
|
|
|
|
2005-10-20 15:45:00 +00:00
|
|
|
Bygfoot Football Manager -- a small and simple GTK2-based
|
|
|
|
football management game.
|
|
|
|
|
|
|
|
http://bygfoot.sourceforge.net
|
|
|
|
|
|
|
|
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
2004-12-30 16:48:19 +00:00
|
|
|
#ifndef LEAGUE_H
|
|
|
|
#define LEAGUE_H
|
2004-12-23 12:58:39 +00:00
|
|
|
|
|
|
|
#include "bygfoot.h"
|
2005-06-05 10:39:29 +00:00
|
|
|
#include "cup.h"
|
2004-12-30 16:48:19 +00:00
|
|
|
#include "league_struct.h"
|
2005-03-19 20:04:08 +00:00
|
|
|
#include "fixture_struct.h"
|
2004-12-23 12:58:39 +00:00
|
|
|
|
2005-04-16 07:46:04 +00:00
|
|
|
#define league_cup_get_fixtures(clid) (clid < ID_CUP_START) ? (league_from_clid(clid)->fixtures) : (cup_from_clid(clid)->fixtures)
|
2005-10-09 09:35:44 +00:00
|
|
|
#define league_cup_get_name_string(clid) (clid < ID_CUP_START) ? league_from_clid(clid)->name : cup_from_clid(clid)->name
|
2005-04-16 07:46:04 +00:00
|
|
|
#define league_cup_get_yellow_red(clid) (clid < ID_CUP_START) ? (league_from_clid(clid)->yellow_red) : (cup_from_clid(clid)->yellow_red)
|
2008-11-24 11:16:36 +00:00
|
|
|
|
|
|
|
#define league_table_cumul(league) (&g_array_index((league)->tables, Table, 0))
|
|
|
|
#define league_table(league) (&g_array_index((league)->tables, Table, league->tables->len - 1))
|
2005-03-27 17:59:57 +00:00
|
|
|
|
2008-12-23 10:33:55 +00:00
|
|
|
#define query_league_has_prom_games(league) (league->prom_rel.prom_games->len > 0)
|
2008-11-24 11:16:36 +00:00
|
|
|
#define query_league_active(league) (!query_league_cup_has_property((league)->id, "inactive"))
|
2005-04-14 19:07:25 +00:00
|
|
|
|
2005-08-15 13:18:28 +00:00
|
|
|
/** A struct needed when managing promotions
|
|
|
|
and relegations. */
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
Team tm; /**< The team we move. */
|
|
|
|
GArray *dest_idcs; /**< Array of possible destination indices. */
|
|
|
|
gint prom_rel_type; /**< Promotion or relegation */
|
|
|
|
gboolean dest_assigned; /**< Whether a destination league for the team
|
|
|
|
is already assigned. */
|
|
|
|
} TeamMove;
|
|
|
|
|
|
|
|
|
2020-10-02 07:41:58 -07:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
gint num_promotions_from;
|
|
|
|
gint num_promotions_to;
|
|
|
|
gint num_relegations_from;
|
|
|
|
gint max_promotions;
|
|
|
|
} MoveSummary;
|
|
|
|
|
2004-12-23 12:58:39 +00:00
|
|
|
League
|
2005-04-14 19:07:25 +00:00
|
|
|
league_new(gboolean new_id);
|
2004-12-23 12:58:39 +00:00
|
|
|
|
|
|
|
PromRelElement
|
|
|
|
prom_rel_element_new(void);
|
|
|
|
|
2008-12-23 10:33:55 +00:00
|
|
|
PromGames
|
|
|
|
prom_games_new(void);
|
|
|
|
|
2005-01-09 20:21:22 +00:00
|
|
|
gint
|
|
|
|
league_cup_get_index_from_clid(gint clid);
|
|
|
|
|
2005-03-03 12:46:48 +00:00
|
|
|
League*
|
|
|
|
league_from_clid(gint clid);
|
|
|
|
|
2005-03-14 17:47:27 +00:00
|
|
|
gint
|
2005-10-01 08:12:06 +00:00
|
|
|
league_cup_get_next_clid(gint clid, gboolean count_inactive);
|
2005-03-14 17:47:27 +00:00
|
|
|
|
|
|
|
gint
|
2005-10-01 08:12:06 +00:00
|
|
|
league_cup_get_previous_clid(gint clid, gboolean count_inactive);
|
2005-03-14 17:47:27 +00:00
|
|
|
|
|
|
|
Fixture*
|
|
|
|
league_cup_get_next_fixture(gint clid, gint week_number, gint week_round_number);
|
|
|
|
|
|
|
|
Fixture*
|
|
|
|
league_cup_get_previous_fixture(gint clid, gint week_number, gint week_round_number);
|
|
|
|
|
2005-03-16 20:48:25 +00:00
|
|
|
gint
|
|
|
|
league_cup_average_capacity(gint clid);
|
|
|
|
|
2005-04-13 13:01:59 +00:00
|
|
|
void
|
|
|
|
league_get_team_movements(League *league, GArray *team_movements);
|
|
|
|
|
|
|
|
gint
|
|
|
|
league_index_from_sid(const gchar *sid);
|
|
|
|
|
|
|
|
void
|
|
|
|
league_remove_team_with_id(League *league, gint id);
|
|
|
|
|
|
|
|
void
|
|
|
|
league_season_start(League *league);
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
query_league_rank_in_prom_games(const League *league, gint rank);
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
query_league_prom_games_begin(const League *league);
|
|
|
|
|
2005-04-24 14:19:57 +00:00
|
|
|
gboolean
|
|
|
|
query_league_matches_in_week(const League *league, gint week_number);
|
|
|
|
|
2020-10-02 07:41:58 -07:00
|
|
|
void
|
|
|
|
country_apply_reserve_prom_rules(const Country *country, GArray *team_movements);
|
|
|
|
|
2005-06-25 14:09:37 +00:00
|
|
|
void
|
|
|
|
league_get_team_movements_prom_rel(const League *league, GArray *team_movements);
|
|
|
|
|
|
|
|
void
|
2008-12-23 10:33:55 +00:00
|
|
|
league_get_team_movements_prom_games(const League *league, const PromGames *prom_games,
|
|
|
|
GArray *team_movements,
|
2005-06-25 14:09:37 +00:00
|
|
|
const GPtrArray *prom_games_teams, gboolean up);
|
|
|
|
|
2005-08-14 19:03:11 +00:00
|
|
|
void
|
|
|
|
league_team_movements_destinations(GArray *team_movements, const gint *league_size);
|
|
|
|
|
|
|
|
void
|
|
|
|
league_team_movements_prune(GArray *team_movements, const gint *league_size,
|
|
|
|
gint *league_cur_size);
|
|
|
|
|
|
|
|
void
|
|
|
|
league_team_movements_assign_dest(GArray *team_movements, gint idx,
|
|
|
|
const gint *league_size, gint *league_cur_size);
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
query_league_team_movements_unassigned_single(const GArray *team_movements);
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
query_league_team_movements_unassigned(const GArray *team_movements);
|
|
|
|
|
|
|
|
void
|
|
|
|
league_team_movements_print(const GArray *team_movements,
|
|
|
|
const gint *league_size, const gint *league_cur_size);
|
|
|
|
|
|
|
|
gint
|
|
|
|
league_team_movements_compare_dest_idcs(gconstpointer a, gconstpointer b,
|
|
|
|
gpointer data);
|
|
|
|
|
2005-09-28 10:21:43 +00:00
|
|
|
gboolean
|
|
|
|
query_leagues_active_in_country(void);
|
|
|
|
|
2007-02-17 12:06:30 +00:00
|
|
|
gboolean
|
2007-02-18 13:04:19 +00:00
|
|
|
query_league_cup_matchday_in_two_match_week(GArray **two_match_weeks, gint matchday);
|
2007-02-17 12:06:30 +00:00
|
|
|
|
2008-11-22 16:51:31 +00:00
|
|
|
void
|
|
|
|
league_check_new_tables(League *league);
|
|
|
|
|
|
|
|
void
|
|
|
|
league_add_table(League *league);
|
|
|
|
|
2008-12-07 11:28:18 +00:00
|
|
|
gboolean
|
|
|
|
query_league_cup_has_property(gint clid, const gchar *property);
|
|
|
|
|
|
|
|
GPtrArray*
|
|
|
|
league_cup_get_teams(gint clid);
|
|
|
|
|
|
|
|
GPtrArray*
|
|
|
|
league_cup_get_properties(gint clid);
|
|
|
|
|
2008-12-14 10:37:10 +00:00
|
|
|
void
|
|
|
|
league_cup_adjust_rr_breaks(GArray *rr_breaks, gint round_robins, gint week_gap);
|
|
|
|
|
|
|
|
void
|
|
|
|
league_cup_fill_rr_breaks(GArray *rr_breaks, const gchar *breaks);
|
|
|
|
|
2008-12-26 15:59:46 +00:00
|
|
|
void
|
|
|
|
league_cup_adjust_week_breaks(GArray *week_breaks, gint week_gap);
|
|
|
|
|
|
|
|
gint
|
|
|
|
league_cup_get_week_with_break(gint clid, gint week_number);
|
|
|
|
|
2020-10-02 07:23:25 -07:00
|
|
|
void
|
|
|
|
country_lookup_first_team_ids(const Country *country);
|
|
|
|
|
2020-10-02 07:41:58 -07:00
|
|
|
gboolean
|
|
|
|
league_can_accept_promoted_team(const League *league, const Team *tm,
|
|
|
|
const GArray *team_movements);
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
league_allows_reserve_teams(const League *league);
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
league_allows_multiple_reserve_teams(const League *league);
|
|
|
|
|
2004-12-23 12:58:39 +00:00
|
|
|
#endif
|