Commit f8df818f authored by L.Perine's avatar L.Perine
Browse files
parents 5b930c99 d4fca4ae
......@@ -81,8 +81,7 @@ public class HostControleur implements ActionListener {
panelPrincipal.add(id);
panelPrincipal.setPreferredSize(new Dimension(200,50));
attente.setContentPane(panelPrincipal);
attente.setModal(true);
attente.setModalityType(JDialog.ModalityType.APPLICATION_MODAL);
attente.setModal(false);
attente.setLocation((screenWidth-200)/2, (screenHeight-50)/2);
attente.pack();
attente.setResizable(false);
......@@ -91,12 +90,13 @@ public class HostControleur implements ActionListener {
try {
while(Network.getInfo(appli.getServerUrl(),appli.getGame(), appli.getPlayer())!=10){
try { attente.wait(1); } catch (InterruptedException e1) {System.out.println("haha");}
System.out.println(Network.getInfo(appli.getServerUrl(),appli.getGame(), appli.getPlayer()));
}
attente.dispose();
appli.afficherPageJeu();
} catch(IllegalMonitorStateException e2){
JOptionPane.showMessageDialog(appli.getFenetre(), "La partie à été annulée");
return;
} catch (UnirestException e1) {
JOptionPane.showMessageDialog(appli.getFenetre(), "Erreur Serveur.");
e1.printStackTrace();
......
......@@ -39,7 +39,6 @@ public class Shoot implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
pageJeu.gagne(true);//TODO à supprimer
JDialog attente = new JDialog(appli.getFenetre(),"Attente");
JPanel panelPrincipal = new JPanel();
JLabel label = new JLabel("En attente du tir Adverse");
......@@ -52,8 +51,7 @@ public class Shoot implements ActionListener {
panelPrincipal.add(label);
panelPrincipal.setPreferredSize(new Dimension(200,50));
attente.setContentPane(panelPrincipal);
attente.setModal(true);
attente.setModalityType(JDialog.ModalityType.APPLICATION_MODAL);
attente.setModal(false);
attente.setLocation((screenWidth-200)/2, (screenHeight-50)/2);
attente.pack();
attente.setResizable(false);
......@@ -65,16 +63,21 @@ public class Shoot implements ActionListener {
throw new BadCoordException();
}
int response = -10;
int info = 0;
while (response == -10 && info != 100) {
attente.wait(1);
response = Network.playOneTurn(appli.getServerUrl(), appli.getGame(), appli.getPlayer(), cell);
int info = Network.getInfo(appli.getServerUrl(), appli.getGame(), appli.getPlayer());
while (true) {
if (info == 10){
attente.dispose();
response = Network.playOneTurn(appli.getServerUrl(), appli.getGame(), appli.getPlayer(), cell);
break;
}else if (info == 100) {
pageJeu.gagne(true);
return;
}else if (info == -100) {
pageJeu.gagne(false);
return;
}
info = Network.getInfo(appli.getServerUrl(), appli.getGame(), appli.getPlayer());
}
if (info == 100) {
pageJeu.gagne(false);
return;
}
switch (response) {
case 0:
pageJeu.manque();
......@@ -99,7 +102,6 @@ public class Shoot implements ActionListener {
} catch (BadCoordException e1) {
JOptionPane.showMessageDialog(appli.getFenetre(), "Erreur : Veuillez selectionner une nouvelle cellulle.",
"Le tir n'a pas été effectué.", JOptionPane.OK_OPTION);
} catch (InterruptedException | IllegalMonitorStateException e1) {
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment