2 dribble - a football manager game
3 Copyright (C) 2008 Jonas Sandberg
5 This file is part of dribble.
7 dribble is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
12 dribble is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with dribble. If not, see <http://www.gnu.org/licenses/>.
32 static struct league
*lvec
;
34 int league_init(int elements
)
36 lvec
= calloc(elements
, sizeof(*lvec
));
48 int league_generate(int country
, const char *name
)
52 lvec
[lnum
].ndivs
= country_num_divisions(country
);
53 lvec
[lnum
].divisions
= calloc(lvec
[lnum
].ndivs
, sizeof(*lvec
[lnum
].divisions
));
55 for(i
=0 ; i
<lvec
[lnum
].ndivs
; i
++)
58 rank
= country_division_rank(country
, i
);
59 lvec
[lnum
].divisions
[i
] = division_generate(country
, rank
);
62 lvec
[lnum
].name
= name
;
67 int league_num_divs(int league
)
69 return lvec
[league
].ndivs
;
75 for(i
=0 ; i
<lnum
; i
++)
77 free(lvec
[i
].divisions
);
87 int main(int argc
, char *argv
[])
96 italy
= country_read(DATADIR
"italy.txt");
97 nteams
= country_num_teams_total(italy
);
98 ndivs
= country_num_divisions(italy
);
100 assert(player_init((division_rand_players_base()+division_rand_players_top())*nteams
) == 0);
101 assert(team_init(nteams
) == 0);
102 assert(division_init(ndivs
) == 0);
103 assert(league_init(1) == 0);
105 liga
= league_generate(italy
, "Italian league");
106 assert(league_num_divs(liga
) == 2);
107 assert(strcmp(lvec
[0].name
, "Italian league") == 0);