mirror of
https://github.com/tstellar/bygfoot.git
synced 2025-02-03 01:07:51 +01:00
Added new struct style and cup struct.
This commit is contained in:
parent
d2e3997553
commit
ba51e1a908
@ -35,12 +35,10 @@ enum ExitCodes
|
||||
EXIT_END
|
||||
};
|
||||
|
||||
typedef struct _Country Country;
|
||||
|
||||
/**
|
||||
* A struct representing a country.
|
||||
*/
|
||||
struct _Country
|
||||
typedef struct
|
||||
{
|
||||
GString *name, /**< Name of the country. */
|
||||
*symbol, /**< Symbol of the country, e.g. a flag pixmap. */
|
||||
@ -50,7 +48,7 @@ struct _Country
|
||||
GArray *leagues,
|
||||
*cups,
|
||||
*supercups;
|
||||
};
|
||||
} Country;
|
||||
|
||||
/** Convenience abbreviation. */
|
||||
#define ligs country.leagues
|
||||
|
101
src/cup.h
Normal file
101
src/cup.h
Normal file
@ -0,0 +1,101 @@
|
||||
#ifndef CUP_H
|
||||
#define CUP_H
|
||||
|
||||
#include "bygfoot.h"
|
||||
|
||||
/**
|
||||
There are only two cup types currently,
|
||||
national and international cups.
|
||||
*/
|
||||
enum CupType
|
||||
{
|
||||
CUP_TYPE_NATIONAL = 0,
|
||||
CUP_TYPE_INTERNATIONAL,
|
||||
CUP_TYPE_END
|
||||
};
|
||||
|
||||
/** Rules for a round of a cup.
|
||||
Cups consist of rounds, e.g. the final counts as
|
||||
a round or the round robin games. */
|
||||
typedef struct
|
||||
{
|
||||
/** Whether there are home and away games or only one leg.
|
||||
Default: TRUE. */
|
||||
gboolean home_away;
|
||||
/** How many times a match gets repeated if there's a draw.
|
||||
Default: 0. */
|
||||
gint replay;
|
||||
/** Whether the matches are on neutral ground.
|
||||
Default: FALSE. */
|
||||
gboolean neutral;
|
||||
/** How many round robin groups there are.
|
||||
Default: 0 (ie. no round robin). */
|
||||
gint round_robin_number_of_groups;
|
||||
/** How many teams advance from each group.
|
||||
Default: -1. */
|
||||
gint round_robin_number_of_advance;
|
||||
/** How many teams advance apart from those that
|
||||
are specified already (e.g. the first two advance
|
||||
and additionally the best 3 from all the groups.
|
||||
Default: -1. */
|
||||
gint round_robin_number_of_best_advance;
|
||||
|
||||
} CupRound;
|
||||
|
||||
/**
|
||||
Rules for choosing teams from the league files.
|
||||
This could tell us to select the first three teams
|
||||
from the league 'Italy 1' to participate in the cup.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
/** The string id of the league we choose from.
|
||||
Default: "". */
|
||||
GString *id;
|
||||
/** The number of teams chosen.
|
||||
Default: -1 (ie. all teams are chosen). */
|
||||
gint number_of_teams;
|
||||
/** The range from which the teams are chosen,
|
||||
e.g. 2 and 5 means the teams from 2 to 5 are chosen
|
||||
(given that 'number_of_teams' is 4).
|
||||
Defaults: -1. */
|
||||
gint start_idx, end_idx;
|
||||
/** Whether the teams are chosen randomly,
|
||||
ie. 3 random teams from the range 1-20.
|
||||
Default: FALSE. */
|
||||
gboolean randomly;
|
||||
} CupChooseTeam;
|
||||
|
||||
/**
|
||||
Structure representing a cup.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
/** Name and short name of the cup, a pixmap path,
|
||||
and the string id (e.g. england_fa or so). */
|
||||
GString *name, *short_name, *symbol, *id;
|
||||
/** Numerical id.*/
|
||||
gint nid;
|
||||
/** The cup type. @see #CupType*/
|
||||
gint cup_type;
|
||||
/** Last week (typically the week the final
|
||||
takes place) and weeks between matchdays. */
|
||||
gint last_week, week_gap;
|
||||
/** Number of yellow cards that lead to a missed match. */
|
||||
gint yellow_red;
|
||||
/** These are only read if it's an international cup. */
|
||||
gint average_skill, average_talent;
|
||||
/** Array with rules how teams are chosen.
|
||||
@see #CupChooseTeam */
|
||||
GArray *choose_teams;
|
||||
/** The ChooseTeam rule according to which
|
||||
the participant from the user's league is chosen.
|
||||
This is irrelevant for national cups.
|
||||
@see #CupChooseTeam */
|
||||
CupChooseTeam user;
|
||||
/** The rounds of the cup.
|
||||
@see #CupRound*/
|
||||
GArray *rounds;
|
||||
} Cup;
|
||||
|
||||
#endif
|
54
src/league.h
54
src/league.h
@ -4,16 +4,10 @@
|
||||
#include "bygfoot.h"
|
||||
#include "team.h"
|
||||
|
||||
typedef struct _League League;
|
||||
typedef struct _Table Table;
|
||||
typedef struct _TableElement TableElement;
|
||||
typedef struct _PromRel PromRel;
|
||||
typedef struct _PromRelElement PromRelElement;
|
||||
|
||||
/**
|
||||
Table element values.
|
||||
@see _TableElement
|
||||
@see _Table
|
||||
@see TableElement
|
||||
@see Table
|
||||
*/
|
||||
enum TableElementValues
|
||||
{
|
||||
@ -29,70 +23,70 @@ enum TableElementValues
|
||||
|
||||
/**
|
||||
An element representing a team in the tables.
|
||||
@see _Table
|
||||
@see Table
|
||||
@see #TableElementValues
|
||||
*/
|
||||
struct _TableElement
|
||||
typedef struct
|
||||
{
|
||||
gint team_id;
|
||||
gint values[TABLE_END];
|
||||
};
|
||||
} TableElement;
|
||||
|
||||
/**
|
||||
A table belonging to a league or a cup with round robin.
|
||||
@see _TableElement
|
||||
@see TableElement
|
||||
*/
|
||||
struct _Table
|
||||
typedef struct
|
||||
{
|
||||
GString *name;
|
||||
GString *league_id;
|
||||
GArray *elements;
|
||||
};
|
||||
} Table;
|
||||
|
||||
/**
|
||||
An element representing a promotion or relegation rule.
|
||||
This means, a PromRelElement specifies a range of teams
|
||||
that get promoted or relegated to a given league.
|
||||
@see _PromRel
|
||||
@see PromRel
|
||||
*/
|
||||
struct _PromRelElement
|
||||
typedef struct
|
||||
{
|
||||
gint ranks[2]; /**< The range of teams; default 0 and 0 */
|
||||
GString *dest_id; /**< The id of the destination league. Default "" */
|
||||
};
|
||||
} PromRelElement;
|
||||
|
||||
/**
|
||||
This structure specifies how promotion and relegation is handled in a league.
|
||||
It contains promotion and relegation rules in an array and possibly also
|
||||
a rule about promotion games to be played.
|
||||
@see _PromRelElement
|
||||
@see PromRelElement
|
||||
*/
|
||||
struct _PromRel
|
||||
typedef struct
|
||||
{
|
||||
/** The id of the league the promotion games winner gets promoted to. Default "" */
|
||||
GString *prom_games_dest_id;
|
||||
/** The id of the cup that specifies the promotion games format.
|
||||
We regard the promotion games as a national cup like any other cup.
|
||||
@see _Cup
|
||||
@see Cup
|
||||
*/
|
||||
GString *prom_games_cup_id; /* "" */
|
||||
|
||||
/** Array with promotion/relegation rules.
|
||||
@see _PromRelElement
|
||||
@see PromRelElement
|
||||
*/
|
||||
GArray *elements;
|
||||
};
|
||||
} PromRel;
|
||||
|
||||
/**
|
||||
Representation of a league.
|
||||
@see _PromRel
|
||||
@see _Table
|
||||
@see PromRel
|
||||
@see Table
|
||||
*/
|
||||
struct _League
|
||||
typedef struct
|
||||
{
|
||||
/** Default value "" */
|
||||
GString *name, *short_name, *id, *symbol;
|
||||
/** @see _PromRel */
|
||||
/** @see PromRel */
|
||||
PromRel prom_rel;
|
||||
/** Numerical id, as opposed to the string id. */
|
||||
gint nid;
|
||||
@ -103,13 +97,15 @@ struct _League
|
||||
/** Number of yellow cards until a player gets banned.
|
||||
Default 1000 (which means 'off', basically). */
|
||||
gint yellow_red;
|
||||
/** Average skill and talent values for the first season. */
|
||||
gint average_skill, average_talent;
|
||||
/** Array of teams in the league.
|
||||
@see _Team */
|
||||
@see Team */
|
||||
GArray *teams;
|
||||
/** League table.
|
||||
@see _Table */
|
||||
@see Table */
|
||||
Table table;
|
||||
};
|
||||
} League;
|
||||
|
||||
|
||||
League
|
||||
|
11
src/player.h
11
src/player.h
@ -4,9 +4,6 @@
|
||||
#include "variables.h"
|
||||
#include "bygfoot.h"
|
||||
|
||||
typedef struct _Player Player;
|
||||
typedef struct _PlayerCard PlayerCard;
|
||||
|
||||
/**
|
||||
Player attribute indices.
|
||||
*/
|
||||
@ -36,7 +33,7 @@ enum PlayerAttributes
|
||||
Representation of a player.
|
||||
@see #PlayerAttributes
|
||||
*/
|
||||
struct _Player
|
||||
typedef struct
|
||||
{
|
||||
GString *name;
|
||||
gint values[PLAYER_END];
|
||||
@ -45,13 +42,13 @@ struct _Player
|
||||
GArray *cards;
|
||||
/** Player history. To be specified. */
|
||||
GArray *history;
|
||||
};
|
||||
} Player;
|
||||
|
||||
/**
|
||||
Cards in different cups are counted separately for players;
|
||||
for each league or cup the cards are stored in such a struct.
|
||||
*/
|
||||
struct _PlayerCard
|
||||
typedef struct
|
||||
{
|
||||
/** Numerical id of the league or cup. */
|
||||
gint league_cup_id;
|
||||
@ -59,6 +56,6 @@ struct _PlayerCard
|
||||
gint yellow;
|
||||
/** Number of weeks the player is banned. */
|
||||
gint red;
|
||||
};
|
||||
} PlayerCard;
|
||||
|
||||
#endif
|
||||
|
@ -5,13 +5,11 @@
|
||||
#include "maths.h"
|
||||
#include "player.h"
|
||||
|
||||
typedef struct _Team Team;
|
||||
|
||||
/**
|
||||
Structure representing a team.
|
||||
@see _Player
|
||||
@see Player
|
||||
*/
|
||||
struct _Team
|
||||
typedef struct
|
||||
{
|
||||
GString *name;
|
||||
/**
|
||||
@ -32,7 +30,7 @@ struct _Team
|
||||
Array of players.
|
||||
*/
|
||||
GArray *players;
|
||||
};
|
||||
} Team;
|
||||
|
||||
Team
|
||||
team_new(void);
|
||||
|
Loading…
x
Reference in New Issue
Block a user