Skip to content
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

Merged
merged 13 commits into from
Mar 20, 2017
Merged

Conversation

david540
Copy link
Contributor

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

Copy link
Owner

@matthieu637 matthieu637 left a 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()&&current.testUniciteDeLaConnexion(client)==false)
Copy link
Owner

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;
Copy link
Owner

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(){
Copy link
Owner

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)
Copy link
Owner

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());
Copy link
Owner

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){
Copy link
Owner

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"

@david540
Copy link
Contributor Author

Je crois avoir fait les modifications.
J'ai mis 0 ou 1 pour modeExam pour refléter un boolean et 1, 2 ou 3 pour refléter un choix mais bon je ne sais pas si c'est plus clair pour l'utilisation côté client ou pas.

Copy link
Owner

@matthieu637 matthieu637 left a 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;
Copy link
Owner

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;

@david540
Copy link
Contributor Author

Voilà je crois que c'est bon

@matthieu637
Copy link
Owner

Oui merci.

@matthieu637 matthieu637 merged commit 4c0fe11 into matthieu637:master Mar 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants