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/>.
24 enum position
{ Goalie
, Defender
, Midfielder
, Attacker
};
25 const char *position_name
[4] = { "Goalie", "Defender", "Midfielder", "Attacker" };
39 static struct player
*pvec
;
41 int player_init(int elements
)
44 pvec
= calloc(elements
, sizeof(*pvec
));
56 int player_generate(int country
, int player_index
, int division_order_number
)
61 p
->name
= country_random_player_name(country
);
62 p
->number
= player_index
+2;
63 p
->age
= 17 + (rand() % 17);
64 p
->skill
= (rand() % 25) - (division_order_number
) + 60 - (rand() % (34 - p
->age
));
65 p
->wage
= (p
->skill
*1200)-(rand()%1500);
66 if(player_index
< 2+rand()%2)
70 else if(player_index
< 9+rand()%2)
74 else if(player_index
>= 9 && player_index
<15+rand()%2)
78 else if(player_index
>= 15)
86 void player_print(int player
)
90 printf("%3d. %-15s \t Skill: %-3d \t Age: %-3d \t Wage: %-9d \t Position: %-10s\n",
96 position_name
[p
->pos
]);
107 int main(int argc
, char *argv
[])
112 italy
= country_read(DATADIR
"italy.txt");
113 assert(player_init(2) == 0);
114 p
= player_generate(italy
, 0, 0);
116 p
= player_generate(italy
, 1, 0);
118 assert(pvec
[p
].number
== 3);