diff options
author | Olivier Gayot <duskcoder@gmail.com> | 2015-01-08 17:37:13 +0100 |
---|---|---|
committer | Olivier Gayot <duskcoder@gmail.com> | 2015-01-08 17:42:25 +0100 |
commit | ac5c469494478bf3774d412581e342d9fa97ec16 (patch) | |
tree | 745ba0638ecafd7335f715d52f1090be9e9b8a3e | |
parent | c416b1a5520ac5cfad0311d650a76b416c889e50 (diff) |
initialize the items (aka objects) of the teams
Signed-off-by: Olivier Gayot <duskcoder@gmail.com>
-rw-r--r-- | jouer.c | 9 | ||||
-rw-r--r-- | menuchoixpersos.c | 21 | ||||
-rw-r--r-- | prototypes.h | 1 |
3 files changed, 15 insertions, 16 deletions
@@ -237,7 +237,6 @@ int Fjouer (SURFACES *surfaces, POSITIONS *positions, struct team_t *ally, struc surfaces->Pfondjeu=NULL; } Fblitterfond(surfaces); // on blit le fond du jeu - Fremplirobjets(&ally->objects); // on monte les variables potions ether, etc /* compute whether the allies or the enemies should begin */ Vtour = rand() % 2; @@ -332,11 +331,3 @@ int Fjouer (SURFACES *surfaces, POSITIONS *positions, struct team_t *ally, struc } return 0; } - -void Fremplirobjets(OBJET *objets) -{ - objets->potions=10; - objets->ethers=10; - objets->potionsplus=5; - objets->ethersplus=5; -} 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); diff --git a/prototypes.h b/prototypes.h index ffa1c94..582bfee 100644 --- a/prototypes.h +++ b/prototypes.h @@ -37,7 +37,6 @@ void blit_character_affinities(SURFACES *, POSITIONS *, const struct character_t void update_list_entries(SURFACES *surfaces, POSITIONS *positions, const struct entry_t *entries, int cnt, int selected); void Fblitterpvcible (SURFACES *surfaces,POSITIONS *positions, const struct character_t *); void Fblitterpmcible (SURFACES *surfaces,POSITIONS *positions, const struct character_t *); -void Fremplirobjets(OBJET *objets); void Fblitterfond(SURFACES* surfaces); Uint32 obtenirPixel(SDL_Surface *surface, int x, int y); |