diff options
Diffstat (limited to 'menuchoixpersos.c')
-rw-r--r-- | menuchoixpersos.c | 88 |
1 files changed, 62 insertions, 26 deletions
diff --git a/menuchoixpersos.c b/menuchoixpersos.c index 7790255..05e1a0a 100644 --- a/menuchoixpersos.c +++ b/menuchoixpersos.c @@ -6,6 +6,63 @@ #include "prototypes.h" #include <SDL/SDL_image.h> #include <SDL/SDL_ttf.h> +#include "players.h" + +static +struct team_t *new_ally_team(SURFACES *surfaces, + const enum character_class_t *classes, int cnt) +{ + struct team_t *team = malloc(sizeof(struct team_t)); + + team->name = "Team Player"; + team->cpu = false; + team->chr_cnt = cnt; + team->chrs = malloc(sizeof(struct character_t) * team->chr_cnt); + + for (int i = 0; i < team->chr_cnt; i++) { + struct character_t *chr = &team->chrs[i]; + + chr->name = "Player"; + chr->cpu = false; + chr->team = team; + chr->class_ = classes[i]; + chr->alive = true; + + switch (chr->class_) { + case CLASS_PALADIN: + chr->def_surf = surfaces->Ppaladin; + chr->red_surf = surfaces->red_paladin; + break; + case CLASS_PRIEST: + chr->def_surf = surfaces->Ppretre; + chr->red_surf = surfaces->red_priest; + break; + case CLASS_THIEF: + chr->def_surf = surfaces->Pvoleur; + chr->red_surf = surfaces->red_thief; + break; + default: + abort(); + } + + chr->surf = chr->def_surf; + + chr->hp = base_stats_g[chr->class_].hp; + chr->max_hp = base_stats_g[chr->class_].hp; + chr->mp = base_stats_g[chr->class_].mp; + chr->max_mp = base_stats_g[chr->class_].mp; + chr->magic = base_stats_g[chr->class_].magic; + chr->strength = base_stats_g[chr->class_].strength; + chr->defense = base_stats_g[chr->class_].defense; + chr->spirit = base_stats_g[chr->class_].spirit; + + /* set its position */ + chr->pos.x = 20; + chr->pos.y = (YWIN / (cnt + 1)) * (i + 1) - chr->def_surf->h / 2; + } + + return team; +} void Fmenuchoixpersos (SURFACES *surfaces, POSITIONS *positions) { @@ -13,7 +70,8 @@ void Fmenuchoixpersos (SURFACES *surfaces, POSITIONS *positions) int Vchoix = PALADIN; SDL_Color vert; bool continuer = true; - PERSONNAGES persos[3]; + struct team_t *ally_team; + enum character_class_t chr_classes[3]; ENNEMIS ennemis[5]; SDL_Event event; int Vnbperso = 0; @@ -84,7 +142,7 @@ void Fmenuchoixpersos (SURFACES *surfaces, POSITIONS *positions) break; case SDLK_RETURN: case SDLK_f: - persos[Vnbperso++].classe = Vchoix; + chr_classes[Vnbperso++] = Vchoix; continuer = false; break; default: @@ -96,8 +154,8 @@ void Fmenuchoixpersos (SURFACES *surfaces, POSITIONS *positions) } TTF_CloseFont (police); SDL_Flip(surfaces->Pecran); - Fremplirpersos2 (surfaces,persos); - Fmap(surfaces,positions,persos,ennemis); + ally_team = new_ally_team(surfaces, chr_classes, 3); + Fmap(surfaces,positions, ally_team,ennemis); } void Fchangersurlignage2 (int Vchoix, SURFACES *surfaces, POSITIONS *positions) @@ -115,28 +173,6 @@ void Fchangersurlignage2 (int Vchoix, SURFACES *surfaces, POSITIONS *positions) SDL_Flip (surfaces->Pecran); } -void Fremplirpersos2 (SURFACES *surfaces, PERSONNAGES persos[]) -{ - - int i; - - for (i = 0; i < 3; i++) { - switch (persos[i].classe) { - case PALADIN: - surfaces->Tperso[i] = surfaces->Ppaladin; - break; - case PRETRE: - surfaces->Tperso[i] = surfaces->Ppretre; - break; - case VOLEUR: - surfaces->Tperso[i] = surfaces->Pvoleur; - break; - default: - abort(); - } - } -} - void Fremplirennemis (SURFACES *surfaces,int Vnbennemis,ENNEMIS ennemis[]) { |