Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Partita start(Partita ng){
- /**Questa funzione si occupa di estrarre il giocatore iniziale casualmente, evitando che sia maggiore di 4 o minore di 0.
- Con un do while viene assicurato il fatto che il turno venga eseguito almeno una volta, fino a che i giocatori vivi non siano uguali a 1 **/
- int index;
- int i;
- printf("\nSta per iniziare la partita\n");
- if(ng.caricamento == 0){ ///il file non è stato caricato, viene iniziata una partita come di norma
- printf("\nEstrazione giocatore iniziale");
- ng.informazioni.turnoG = rand()%NUM_G; ///viene entratto un numero random, rispettando il numero dei giocatori
- index = ng.informazioni.turnoG;
- }
- else ///se è stato caricato il file
- {
- index = ng.informazioni.turnoG;
- printf("\n Variabile informazioni %d \n variabile turnogiocatore %d", ng.informazioni.turnoG, index);
- ng.giocatoriVivi = 0;
- for(i = 0; i < NUM_G; i++){ ///viene controllato quanti giocatori siano vivi
- printf("\n %d", ng.players[i].status);
- if(ng.players[i].status == true){
- ng.giocatoriVivi++;
- }
- }
- printf("\n Giocatore a cui spetta il turno: %s", ng.players[ng.informazioni.turnoG].nome);
- if(ng.informazioni.savedAfterAttack == true){
- ng.attack = 1;
- }else ng.attack = 0;
- }
- printf("\nInizia %s!", ng.players[index].nome); ///crusha qui, perchè il numero salvato è un numero random troppo alto
- do{
- ng.turno = 0; ///indica il turno a cui sono arrivati i giocatori (contatore)
- printf("\n Turno %d", ng.turno);
- if(ng.players[index].status == true){
- if(ng.attack == 1) ///viene implementata la carta attack, tramite un while che costringe il giocatore successivo a fare due turni
- {
- ng.informazioni.savedAfterAttack = true;
- i = 0;
- while(i != 2){
- printf("\nSei sotto Attack!");
- ng = turn (ng); ///entra nella funzione turno
- i++;
- }
- ng.informazioni.savedAfterAttack = false;
- index++;
- ng.informazioni.turnoG = index;
- ng.attack = 0;
- }else
- {
- ng = turn (ng); ///entra nella funzione turno
- index++;
- ng.informazioni.turnoG = index;
- }
- }else
- {
- index++;
- ng.informazioni.turnoG = index;
- ng.turno++;
- }
- if(index == NUM_G) index = 0; ///così dall'ultimo giocatore tornerà al primo
- }while(ng.giocatoriVivi != 1);
- return ng;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement