Skip to content
This repository has been archived by the owner on Feb 1, 2018. It is now read-only.

Commit

Permalink
Modified ritirata() as decided in #12
Browse files Browse the repository at this point in the history
  • Loading branch information
alegotta committed Jan 24, 2018
1 parent e6f8d93 commit 5b6ff37
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/characters/Personaggio.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,19 @@ public Personaggio(int puntiVitaTotali, int attacco, int difesa, int velocita, i
}

/**
* Fa scappare un personaggio dal terreno di gioco<br>
* Fa scappare un personaggio dal terreno di gioco:<br>
* - Calcola la probabilità di riuscire a scappare (50 + (VEL personaggio che si vuole ritirare - VEL nemico))
* - Genera un numero casuale tra 1 e 100
* Se il numero generato è minore della probabilità, il personaggio riesce a scappare, altrimenti no
* NB (TODO): Bisognerà prevedere una funzione nella classe di gestione per finire il duello (caso 1) o proseguirlo (caso 0)
* @param avv Personaggio avversario da cui si sta cercando di scappare
* @return 1 se il personaggio riesce a scappare; 0 altrimenti
*/
public int ritirata(Personaggio avv) {
if (velocita > avv.getVelocita()) {
if (50 + (50 - avv.getVelocita()) < ThreadLocalRandom.current().nextInt(1, 101))
return 1;
} else {
else
return 0;
}
}

/**
Expand Down

2 comments on commit 5b6ff37

@Fs00
Copy link
Owner

@Fs00 Fs00 commented on 5b6ff37 Jan 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forse sarebbe meglio tornare un booleano invece di 0 o 1? @alegotta

@Fs00
Copy link
Owner

@Fs00 Fs00 commented on 5b6ff37 Jan 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alegotta ho rivisto il metodo nel commit 34b9276.

Please sign in to comment.