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