From ac5c469494478bf3774d412581e342d9fa97ec16 Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Thu, 8 Jan 2015 17:37:13 +0100 Subject: initialize the items (aka objects) of the teams Signed-off-by: Olivier Gayot --- menuchoixpersos.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'menuchoixpersos.c') diff --git a/menuchoixpersos.c b/menuchoixpersos.c index e2d5cfc..0ce0360 100644 --- a/menuchoixpersos.c +++ b/menuchoixpersos.c @@ -72,6 +72,17 @@ static void init_team_players(struct team_t *team, bool left, } } +static void init_team(struct team_t *team, int chr_cnt) +{ + team->objects.potions = 10; + team->objects.ethers = 10; + team->objects.potionsplus = 5; + team->objects.ethersplus = 5; + + team->chr_cnt = chr_cnt; + team->chr_cur = rand() % team->chr_cnt; + team->chrs = malloc(sizeof(struct character_t) * team->chr_cnt); +} static struct team_t *new_ally_team(SURFACES *surfaces, @@ -81,9 +92,8 @@ struct team_t *new_ally_team(SURFACES *surfaces, team->name = "Team Player"; team->cpu = false; - team->chr_cnt = cnt; - team->chr_cur = rand() % team->chr_cnt; - team->chrs = malloc(sizeof(struct character_t) * team->chr_cnt); + + init_team(team, cnt); init_team_players(team, true, classes, surfaces); @@ -126,9 +136,8 @@ struct team_t *new_enemy_team(SURFACES *surfaces, const struct team_t *ally_team team->name = "Team CPU"; team->cpu = true; - team->chr_cnt = rand() % 5 + 1; - team->chr_cur = rand() % team->chr_cnt; - team->chrs = malloc(sizeof(struct character_t) * team->chr_cnt); + + init_team(team, rand() % 5 + 1); classes = malloc(sizeof(enum character_class_t) * team->chr_cnt); -- cgit v1.2.3