-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ajout modes banques et mode examen #23
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super merci. Il y a quelques modifs à revoir.
D'ailleurs, penses à mettre à jour libererPartie dans Client (en retirant l'identifiant dans ta listeHostAdress). Au cas où quelqu'un rejoint, bug et voudrait rejoindre à nouveau avant le top.
@@ -190,9 +197,15 @@ public void run() { | |||
envoyer(out, "-3"); | |||
continue; | |||
} | |||
|
|||
current = serveur.getListepartie(numero_partie); | |||
if (current.isModeExamen()&¤t.testUniciteDeLaConnexion(client)==false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"== false", est équivalent à "!"
public Partie() { | ||
marche = new Marche(); | ||
private final List<String> liste_HostAdress; | ||
private final int modeExam; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changer le modeExam par un booléen serait plus lisible
return marche.creer_joueur(nom, nom_complet+":"+s.getInetAddress().getHostAddress()); | ||
} | ||
|
||
public Boolean isModeExamen(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A moins d'avoir besoin d'un objet (avec son pointeur associé), le type boolean (vs objet Boolean) suffit en général.
return marche.creer_joueur(nom, nom_complet+":"+s.getInetAddress().getHostAddress()); | ||
} | ||
|
||
public Boolean isModeExamen(){ | ||
if(modeExam==1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Si modeExam est un booléen, il suffit de le retourner. On gagne ainsi une comparaison.
@@ -22,8 +27,26 @@ public Partie() { | |||
|
|||
public Joueur ajouter_client(Socket s, String nom, String nom_complet){ | |||
liste_client.add(s); | |||
if(modeExam==1) | |||
liste_HostAdress.add(s.getInetAddress().getHostAddress()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Faire une restriction sur les IP publiques est trop strict. Plusieurs VMs peuvent avoir la même IP publique, pareil au niveau de l'université.
En théorie, il faudrait identifier les étudiants par des clés uniques connues d'eux seuls. (cf todo list)
Pour le moment, je te propose d'utiliser
nom_complet+":"+s.getInetAddress().getHostAddress()
pour la clé, même si ça n'est pas vraiment idéal.
return true; | ||
return false; | ||
} | ||
public Boolean testUniciteDeLaConnexion(Socket s){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Il faudra ajouter "nom_complet"
Je crois avoir fait les modifications. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Il manque encore les opérations de suppression dans la liste liste_HostAdress.
Cf mon commentaire précédent :
"D'ailleurs, penses à mettre à jour network.Client::libererPartie dans network.Client (en retirant l'identifiant dans ta listeHostAdress). Au cas où quelqu'un rejoint, bug et voudrait rejoindre à nouveau avant le top."
if(modeExamen==1) | ||
isModeExam=true; | ||
else | ||
isModeExam=false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ces 4 lignes peuvent être réduite en 1 seule :
modeExamen = isModeExam == 1;
Voilà je crois que c'est bon |
Oui merci. |
Dans client.py: si le parametre modeBanque vaut 1 : presence ou non de banque, 2: presence de banque, 3: pas de banque
modeExamen: 1 si une seule connexion par utilisateur est accepté(mode Examen)
0 sinon