diff --git a/doc/~$uveau_Versionnage_EII.docx b/doc/~$uveau_Versionnage_EII.docx new file mode 100644 index 0000000000000000000000000000000000000000..387e934fd2728b119bbbf5aeff6c45854e9ba282 Binary files /dev/null and b/doc/~$uveau_Versionnage_EII.docx differ diff --git a/resources/Maps.xml b/resources/Maps.xml index f31ce2f226eed8cb494adb77940616a4686dc458..d0d290c13a63e37ca117a1e48d080fdd9682810e 100644 --- a/resources/Maps.xml +++ b/resources/Maps.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <Maps> -<Map id="MAP_1" name="Comté de la sieste" desc="Cette map est so-mmeil" taille_lignes="10"> +<Map id="MAP_1" name="Comte de la sieste" desc="Cette map est so-mmeil" taille_lignes="10"> <Line>MFPPRRPPFM</Line> <Line>MFPPRRPPFM</Line> <Line>MFPPRRPPFM</Line> @@ -20,7 +20,7 @@ <Line>MFPPPPPPFM</Line> </Map> -<Map id="MAP_2" name="Chasse au trésor" desc="Une map pour 2 joueurs qui rend fou !! " taille_lignes="10"> +<Map id="MAP_2" name="Les forets de l'oubli" desc="Une map avec des forets " taille_lignes="10"> <Line>MFPPRRPFFF</Line> <Line>MFPPRRFFFF</Line> <Line>MFPPRRPFFF</Line> @@ -28,18 +28,18 @@ <Line>MFPPRRPPFF</Line> <Line>MFPPRRPPFM</Line> <Line>MFPPPPPPFM</Line> - <Line>MFPPPPPPFM</Line> - <Line>MFPPRRPPFM</Line> - <Line>MFPPRRPPFM</Line> - <Line>MFPPRRPPFM</Line> - <Line>MFPPRRPPFM</Line> - <Line>MFPPRRPPFM</Line> - <Line>MFPPRRPPFM</Line> + <Line>FFFFPPPPFM</Line> + <Line>FFFFRRPPFM</Line> + <Line>FFFFRRPPFM</Line> <Line>MFPPRRPPFM</Line> <Line>MFPPRRPPFM</Line> + <Line>MFPPRRPFFF</Line> + <Line>MFPPRRFFFF</Line> + <Line>MFPPRRPFFF</Line> + <Line>MFPPRRPFFF</Line> </Map> -<Map id="MAP_3" name="Chasse au trésor" desc="Une map pour 2 joueurs qui rend fou !! " taille_lignes="10"> +<Map id="MAP_3" name="Chasse au tresor" desc="Une map pour 2 joueurs qui rend fou !! " taille_lignes="10"> <Line>MFPPRRPPFM</Line> <Line>MFPPRRPPFM</Line> <Line>MFPPRRPPFM</Line> @@ -58,4 +58,61 @@ <Line>MFPPRRPPFM</Line> </Map> +<Map id="MAP_4" name="Le lac mysterieux" desc="que d'eau!" taille_lignes="10"> + <Line>MFPPPPPPFM</Line> + <Line>MFPPPPPPFM</Line> + <Line>MFPPPPPPFM</Line> + <Line>MFPPPRPPFM</Line> + <Line>MFPPRRPPFM</Line> + <Line>MFPRRRRPFM</Line> + <Line>MFPRRRRRFM</Line> + <Line>MFPRRRRRFM</Line> + <Line>MFPRRRRPFM</Line> + <Line>MFPPRRRPFM</Line> + <Line>MFPPRRRPFM</Line> + <Line>MFPPPRRPFM</Line> + <Line>MFPPPRRPFM</Line> + <Line>MFPPPPRRFM</Line> + <Line>MFPPPPRRFM</Line> + <Line>MFPPPPPRRF</Line> +</Map> + +<Map id="MAP_5" name="Carte basique" desc="Le mec qui l'a creee ne s'est pas foule... " taille_lignes="10"> + <Line>PPPPPPPPPP</Line> + <Line>PPPPPPPPPP</Line> + <Line>PPPPPPPPPP</Line> + <Line>PPPPPPPPPP</Line> + <Line>PPPPPPPPPP</Line> + <Line>PPPPPPPPPP</Line> + <Line>PPPPPPPPPP</Line> + <Line>PPPPPPPPPP</Line> + <Line>PPPPPPPPPP</Line> + <Line>PPPPPPPPPP</Line> + <Line>PPPPPPPPPP</Line> + <Line>PPPPPPPPPP</Line> + <Line>PPPPPPPPPP</Line> + <Line>PPPPPPPPPP</Line> + <Line>PPPPPPPPPP</Line> + <Line>PPPPPPPPPP</Line> +</Map> + +<Map id="MAP_6" name="Carte 6" desc="inserez ici une description" taille_lignes="10"> + <Line>FFFFFFFFFF</Line> + <Line>FFFFFFFFFF</Line> + <Line>FFFFFFFFFF</Line> + <Line>PPPFFFFPPP</Line> + <Line>PPPPPFPPPP</Line> + <Line>PPPPRRPPPP</Line> + <Line>PPPRRRRPPP</Line> + <Line>PPPRRRRPPP</Line> + <Line>PPPRRRRPPP</Line> + <Line>PPPRRRRPPP</Line> + <Line>PPPRRRRPPP</Line> + <Line>PPPPRRPPPP</Line> + <Line>PPPPPFPPPP</Line> + <Line>PPPFFFFPPP/Line> + <Line>FFFFFFFFFF</Line> + <Line>FFFFFFFFFF</Line> +</Map> + </Maps> diff --git a/src/affichage.c b/src/affichage.c index b00d3079afbb2318ce6952f928772b461b632a71..e5891a85e038f252ca2388d72da0a64405ff0116 100644 --- a/src/affichage.c +++ b/src/affichage.c @@ -15,7 +15,6 @@ EtatsJeu etat; char* nom_1; char* nom_2; -int num_carte_selectionnee; /*! @@ -67,6 +66,78 @@ int main_affichage() } +/*! + * \fn int afficher_cartes_personnalisees() + * \brief Fonction permettant le choix d'une carte personnalisee (càd qui n'est pas l'une des 4 previsualisees) par le joueur + * elle affiche leur nom, et leur description + * + * \return le numero de la carte choisie (ou -2 si l'utilisateur ferme la fenetre) + */ +int afficher_cartes_personnalisees() +{ + int i; + int c=-1; + int nbChoix=nbCartes()-4; + SDL_Surface* fenetre=NULL; + SDL_Surface* textes[nbChoix]; + SDL_Surface* desc[nbChoix]; + SDL_Rect positionsTextes[nbChoix]; + SDL_Rect positionsDesc[nbChoix]; + SDL_Event event; + SDL_Color couleurNoire = {0, 0, 0}; + SDL_Color couleurBlanche = {255, 255, 255}; + TTF_Font* police=TTF_OpenFont("../resources/fonts/arial.ttf",40); + TTF_Font* petite_police=TTF_OpenFont("../resources/fonts/arial.ttf",22); + + for(i=0; i<nbChoix; i++) + { + textes[i]=TTF_RenderText_Shaded(police, obtenirNomsCartes()[i+4], couleurBlanche,couleurNoire); + desc[i]=TTF_RenderText_Shaded(petite_police, obtenirDescriptionCarte()[i+4], couleurBlanche,couleurNoire); + positionsTextes[i].x=0; + positionsDesc[i].x=0; + positionsTextes[i].y=i*(textes[0]->h+desc[0]->h+5); + positionsDesc[i].y=positionsTextes[i].y+textes[i]->h; + } + fenetre = SDL_SetVideoMode(400, nbChoix*(textes[0]->h+desc[0]->h), 32, SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_RESIZABLE); + while(c==-1) + { + SDL_WaitEvent(&event); + switch(event.type) + { + case SDL_QUIT: + c=-2; + break; + case SDL_MOUSEBUTTONDOWN: + for(i=0; i<nbChoix; i++) + { + if(event.button.y/(textes[0]->h+desc[0]->h)==i) + { + c=4+i; + } + } + break; + default: + break; + } + for(i=0; i<nbChoix; i++) + { + SDL_BlitSurface(textes[i],NULL,fenetre,&positionsTextes[i]); + SDL_BlitSurface(desc[i],NULL,fenetre,&positionsDesc[i]); + } + SDL_Flip(fenetre); + } + SDL_FreeSurface(fenetre); + for(i=0; i<nbChoix; i++) + { + SDL_FreeSurface(textes[i]); + SDL_FreeSurface(desc[i]); + } + TTF_CloseFont(police); + TTF_CloseFont(petite_police); + return c; +} + + /*! * \fn char* afficherListeClasses(char** nomsClasses, char** skinsClasses, int nbChoix, TTF_Font* police,SDL_Color couleurTexte) * \brief Fonction permettant le choix de la classe d'un personnage par le joueur @@ -109,7 +180,6 @@ char* afficherListeClasses(char** nomsClasses, char** skinsClasses, int nbChoix, case SDL_QUIT: SDL_FreeSurface(fenetre); return "fermer"; - break; case SDL_MOUSEBUTTONDOWN: for(i=0; i<nbChoix; i++) { @@ -360,8 +430,7 @@ int affichage_menu_configuration() police=TTF_OpenFont("../resources/fonts/arial.ttf",26); - char src[50], dest[50]; - char buffer[2]; + char src[2], dest[20]; for(i=0; i<NB_PERSO; i++) { strcpy(dest, "personnage "); @@ -466,9 +535,21 @@ int affichage_menu_configuration() { if(event.button.x>position_carte[i].x&&event.button.x<position_carte[i].x+previsualisation[0]->w&&event.button.y>position_carte[i].y&&event.button.y<position_carte[i].y+previsualisation[0]->h) { - c=i; - selectionnerCarte(obtenirNomsCartes()[c]); - num_carte_selectionnee=c+1; + if(i!=4) + { + c=i; + selectionnerCarte(obtenirNomsCartes()[c]); + } + else + { + c=afficher_cartes_personnalisees(); + if(c==-2){ + c=-1; + }else{ + selectionnerCarte(obtenirNomsCartes()[c]); + } + ecran = SDL_SetVideoMode(LARGEUR_CARTE*(LARGEUR_CASE+1), HAUTEUR_CARTE*(HAUTEUR_CASE+2), 32, SDL_HWSURFACE|SDL_DOUBLEBUF); + } } } if(event.button.x>posTextes[0].x&&event.button.x<posTextes[0].x+textes[0]->w) @@ -519,7 +600,8 @@ int affichage_menu_configuration() { SDL_BlitSurface(previsualisation[i],NULL,ecran,&position_carte[i]); } - if(c!=-1) SDL_BlitSurface(map_choisie,NULL,ecran,&position_carte[c]); + if(c>-1&&c<4) SDL_BlitSurface(map_choisie,NULL,ecran,&position_carte[c]); + if(c>3) SDL_BlitSurface(map_choisie,NULL,ecran,&position_carte[4]); SDL_Flip(ecran); p=0; j=0; @@ -596,6 +678,16 @@ int affichage_carte() SDL_SetColorKey(classes[i], SDL_SRCCOLORKEY, SDL_MapRGB(classes[i]->format, 0, 0, 255)); } + /* for(i=0; i<NB_JOUEURS*NB_PERSO; i++) + { + persos[i]=SDL_LoadBMP(obtenirSkinPerso(i+1)); + if (!persos[i]) + { + printf("Unable to load bitmap: %s\n", SDL_GetError()); + return 1; + } + }*/ + Guerrier_select = SDL_LoadBMP("../resources/Skins/guerrier_select.bmp"); if (!Guerrier_select) { @@ -624,7 +716,8 @@ int affichage_carte() Position_Case[j][i].y=j*HAUTEUR_CASE+(HAUTEUR_CASE/2); } } - while(etat!=FERMER&&etat!=VICTOIRE) + Position_Case_brillante=Position_Case[0][0]; + while(etat!=FERMER) { SDL_WaitEvent(&event); switch(event.type) /* Test du type d'événement */ @@ -655,9 +748,9 @@ int affichage_carte() } break; } - /*for(i=0;i<NB_PERSO;i++){ - Position_Perso[i].x=get_position_perso_x(i); - Position_Perso[i].y=get_position_perso_y(i); + /*for(i=0;i<NB_PERSO*NB_JOUEURS;i++){ + Position_Perso[i].x=get_position_perso_x(i+1); + Position_Perso[i].y=get_position_perso_y(i+1); } Position_Guerrier_select.x = get_position_case_x(&Position_Perso[persoactuel()]); Position_Guerrier_select.y = get_position_case_y(&Position_Perso[persoactuel()]); @@ -672,7 +765,7 @@ int affichage_carte() } for(i=0; i<NB_PERSO*NB_JOUEURS; i++) { - //TODO + //SDL_BlitSurface(persos[i],NULL,ecran,&Position_Perso[i]); } /*SDL_BlitSurface(Guerrier_select,NULL,ecran,&Position_Guerrier_select);*/ SDL_BlitSurface(Case_brillante,NULL,ecran,&Position_Case_brillante); @@ -692,7 +785,7 @@ int affichage_carte() int afficher_menu() { SDL_Event event; - SDL_Surface* ecran = SDL_SetVideoMode(LARGEUR_CARTE*(LARGEUR_CASE+1), HAUTEUR_CARTE*(HAUTEUR_CASE+2), 32, SDL_HWSURFACE|SDL_DOUBLEBUF); + SDL_Surface* fenetre = SDL_SetVideoMode(LARGEUR_CARTE*(LARGEUR_CASE+1), HAUTEUR_CARTE*(HAUTEUR_CASE+2), 32, SDL_HWSURFACE|SDL_DOUBLEBUF); SDL_Surface* bouton_continuer=NULL; SDL_Surface* bouton_quitter=NULL; SDL_Rect pos_bouton_continuer; @@ -715,21 +808,23 @@ int afficher_menu() printf("Unable to load bitmap: %s\n", SDL_GetError()); return 1; } + while(etat!=FERMER) { + SDL_WaitEvent(&event); switch(event.type) /* Test du type d'événement */ { case SDL_QUIT: /* Si c'est un événement de type "Quitter" */ - etat=FERMER; + return 0; break; case SDL_MOUSEBUTTONDOWN: if(pos_bouton_continuer.x<event.button.x&&event.button.x<pos_bouton_continuer.x+LARGEUR_BOUTON) { - if(pos_bouton_continuer.y<event.button.y&&event.button.y<pos_bouton_continuer.x+HAUTEUR_BOUTON) + if(pos_bouton_continuer.y<event.button.y&&event.button.y<pos_bouton_continuer.y+HAUTEUR_BOUTON) { return 0; } - if(pos_bouton_quitter.y<event.button.y&&event.button.y<pos_bouton_quitter.x+HAUTEUR_BOUTON) + if(pos_bouton_quitter.y<event.button.y&&event.button.y<pos_bouton_quitter.y+HAUTEUR_BOUTON) { etat=FERMER; } @@ -746,7 +841,12 @@ int afficher_menu() } break; } + SDL_BlitSurface(bouton_continuer,NULL,fenetre,&pos_bouton_continuer); + SDL_BlitSurface(bouton_quitter,NULL,fenetre,&pos_bouton_quitter); + SDL_Flip(fenetre); } - //free les surfaces + SDL_FreeSurface(fenetre); + SDL_FreeSurface(bouton_continuer); + SDL_FreeSurface(bouton_quitter); return 0; } diff --git a/src/affichage.h b/src/affichage.h index 20a99ce132564a0cf7b60747113ad459b9efe16d..42f3add2c4f4c97efe1f540cd2224fb699a93095 100644 --- a/src/affichage.h +++ b/src/affichage.h @@ -28,5 +28,6 @@ int affichage_carte(); int afficher_menu(); +int afficher_cartes_personnalisees(); #endif diff --git a/src/controleur.c b/src/controleur.c index a8ca3e96ebd83ee0e583eeaadf52b141e261807e..b91424e48f10e7d461ac8d5af52bed342910d3b4 100644 --- a/src/controleur.c +++ b/src/controleur.c @@ -191,7 +191,7 @@ char ** obtenirLignesCarte(int numCarte){ */ char ** obtenirDescriptionCarte(){ int i; - //Allocation du tableau contenant les chaines de charactères + //Allocation du tableau contenant les chaines de caractères char ** tabDescCartes = malloc((getNbCartes(packGlobal))*sizeof(char *)); for(i=0;i<getNbCartes(packGlobal);i++){ tabDescCartes[i]= malloc(100*sizeof(char)); @@ -469,13 +469,148 @@ char * obtenirNomClassePersonnage(int numero){ } } -int obtenirPVPersonnage(int numero); -int obtenirPVMaxPersonnage(int numero); -int obtenirManaPersonnage(int numero); -int obtenirManaMaxPersonnage(int numero); -int obtenirPDPersonnage(int numero); -int obtenirPDMaxPersonnage(int numero); -char ** obtenirNomsAttaquesPersonnage(int numero); +int obtenirPVPersonnage(int numero){ + Joueur * actuel = NULL; + actuel = getCurrentJoueur(getListJoueur(partieGlobale)); + int PVPersonnage = -1; + + if((numero>0)&&(numero<=3)){ + setOnFirstJoueur(getListJoueur(partieGlobale)); + PVPersonnage = get_PV(getPersonnage(getCurrentJoueur(getListJoueur(partieGlobale)),numero-1)); + setOnJoueur(getListJoueur(partieGlobale),actuel); + return PVPersonnage; + } + + else if ((numero>3)&&(numero<=6)){ + setOnFirstJoueur(getListJoueur(partieGlobale)); + nextJoueur(getListJoueur(partieGlobale)); + PVPersonnage = get_PV(getPersonnage(getCurrentJoueur(getListJoueur(partieGlobale)),numero-4)); + setOnJoueur(getListJoueur(partieGlobale),actuel); + return PVPersonnage; + } + setOnJoueur(getListJoueur(partieGlobale),actuel); + return PVPersonnage; +} + + +int obtenirPVMaxPersonnage(int numero){ + Joueur * actuel = NULL; + actuel = getCurrentJoueur(getListJoueur(partieGlobale)); + int PVMaxPersonnage = -1; + + if((numero>0)&&(numero<=3)){ + setOnFirstJoueur(getListJoueur(partieGlobale)); + PVMaxPersonnage = getPVMax(getClasse(getPersonnage(getCurrentJoueur(getListJoueur(partieGlobale)),numero-1))); + setOnJoueur(getListJoueur(partieGlobale),actuel); + return PVMaxPersonnage; + } + + else if ((numero>3)&&(numero<=6)){ + setOnFirstJoueur(getListJoueur(partieGlobale)); + nextJoueur(getListJoueur(partieGlobale)); + PVMaxPersonnage = getPVMax(getClasse(getPersonnage(getCurrentJoueur(getListJoueur(partieGlobale)),numero-4))); + setOnJoueur(getListJoueur(partieGlobale),actuel); + return PVMaxPersonnage; + } + setOnJoueur(getListJoueur(partieGlobale), actuel); + return PVMaxPersonnage; +} + +int obtenirManaPersonnage(int numero){ + Joueur * actuel = NULL; + actuel = getCurrentJoueur(getListJoueur(partieGlobale)); + int ManaPersonnage = -1; + + if((numero>0)&&(numero<=3)){ + setOnFirstJoueur(getListJoueur(partieGlobale)); + ManaPersonnage = get_mana(getPersonnage(getCurrentJoueur(getListJoueur(partieGlobale)),numero-1)); + setOnJoueur(getListJoueur(partieGlobale),actuel); + return ManaPersonnage; + } + + else if ((numero>3)&&(numero<=6)){ + setOnFirstJoueur(getListJoueur(partieGlobale)); + nextJoueur(getListJoueur(partieGlobale)); + ManaPersonnage = get_mana(getPersonnage(getCurrentJoueur(getListJoueur(partieGlobale)),numero-4)); + setOnJoueur(getListJoueur(partieGlobale),actuel); + return ManaPersonnage; + } + setOnJoueur(getListJoueur(partieGlobale), actuel); + return ManaPersonnage; +} + +int obtenirManaMaxPersonnage(int numero){ + Joueur * actuel = NULL; + actuel = getCurrentJoueur(getListJoueur(partieGlobale)); + int ManaMaxPersonnage = -1; + + if((numero>0)&&(numero<=3)){ + setOnFirstJoueur(getListJoueur(partieGlobale)); + ManaMaxPersonnage = getManaMax(getClasse(getPersonnage(getCurrentJoueur(getListJoueur(partieGlobale)), numero-1))); + setOnJoueur(getListJoueur(partieGlobale),actuel); + return ManaMaxPersonnage; + } + + else if ((numero>3)&&(numero<=6)){ + setOnFirstJoueur(getListJoueur(partieGlobale)); + nextJoueur(getListJoueur(partieGlobale)); + ManaMaxPersonnage = getManaMax(getClasse(getPersonnage(getCurrentJoueur(getListJoueur(partieGlobale)), numero-4))); + setOnJoueur(getListJoueur(partieGlobale),actuel); + return ManaMaxPersonnage; + } + setOnJoueur(getListJoueur(partieGlobale), actuel); + return ManaMaxPersonnage; +} + +int obtenirPDPersonnage(int numero){ + Joueur * actuel = NULL; + actuel = getCurrentJoueur(getListJoueur(partieGlobale)); + int PDPersonnage = -1; + + if((numero>0)&&(numero<=3)){ + setOnFirstJoueur(getListJoueur(partieGlobale)); + PDPersonnage = get_PD(getPersonnage(getCurrentJoueur(getListJoueur(partieGlobale)),numero-1)); + setOnJoueur(getListJoueur(partieGlobale),actuel); + return PDPersonnage; + } + + else if ((numero>3)&&(numero<=6)){ + setOnFirstJoueur(getListJoueur(partieGlobale)); + nextJoueur(getListJoueur(partieGlobale)); + PDPersonnage = get_PD(getPersonnage(getCurrentJoueur(getListJoueur(partieGlobale)),numero-4)); + setOnJoueur(getListJoueur(partieGlobale),actuel); + return PDPersonnage; + } + setOnJoueur(getListJoueur(partieGlobale), actuel); + return PDPersonnage; +} + +int obtenirPDMaxPersonnage(int numero){ + Joueur * actuel = NULL; + actuel = getCurrentJoueur(getListJoueur(partieGlobale)); + int PDMaxPersonnage = -1; + + if((numero>0)&&(numero<=3)){ + setOnFirstJoueur(getListJoueur(partieGlobale)); + PDMaxPersonnage = getPDMax(getClasse(getPersonnage(getCurrentJoueur(getListJoueur(partieGlobale)),numero-1))); + setOnJoueur(getListJoueur(partieGlobale),actuel); + return PDMaxPersonnage; + } + + else if ((numero>3)&&(numero<=6)){ + setOnFirstJoueur(getListJoueur(partieGlobale)); + nextJoueur(getListJoueur(partieGlobale)); + PDMaxPersonnage = getPDMax(getClasse(getPersonnage(getCurrentJoueur(getListJoueur(partieGlobale)),numero-4))); + setOnJoueur(getListJoueur(partieGlobale),actuel); + return PDMaxPersonnage; + } + setOnJoueur(getListJoueur(partieGlobale), actuel); + return PDMaxPersonnage; +} + +char ** obtenirNomsAttaquesPersonnage(int numero){ + +} // Je met ici mes tests réalisés dans le main pour éviter de les réécrire si jamais il y a un problème. // Si vous voulez tester aussi, à recopier dans le main avant l'appel à initJeu(). @@ -527,6 +662,13 @@ void testControlleurConsole(){ n=4+getIndicePersonnage((getListJoueur(partieGlobale)->lastNodeJoueur->j),trouverPersonnage(getCase(getCarte(partieGlobale),i,j))); } printf("%s\n", obtenirNomClassePersonnage(n)); + printf("%s\n", obtenirPVPersonnage(n)); + printf("%s\n", obtenirPVMaxPersonnage(n)); + printf("%s\n", obtenirManaPersonnage(n)); + printf("%s\n", obtenirManaMaxPersonnage(n)); + printf("%s\n", obtenirPDPersonnage(n)); + printf("%s\n", obtenirPDMaxPersonnage(n)); + } } }