Bug couleur

This commit is contained in:
Justine Yannis 2022-11-17 09:24:06 +01:00
parent ff568ee6f5
commit d97c0b9e2d

View File

@ -28,6 +28,7 @@ public class ColorChooserDialog extends JDialog{
private JTextField field1;
private JTextField field2;
private JTextField field3;
private int playerNumber;
private boolean confirm = false;
/**
@ -39,6 +40,7 @@ public class ColorChooserDialog extends JDialog{
*/
public ColorChooserDialog(Frame owner, boolean modal, int playerNumber) {
super(owner, "Choisissez vos noms et couleurs",modal);
this.playerNumber = playerNumber;
this.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
@ -208,11 +210,11 @@ public class ColorChooserDialog extends JDialog{
JOptionPane.showMessageDialog(this,"Les deux couleurs sont trop proches (1,2)","Erreur ", JOptionPane.ERROR_MESSAGE);
return false;
}
if(distanceBetweenP1AndP3 < 150f) {
if(playerNumber == 3 && distanceBetweenP1AndP3 < 150f) {
JOptionPane.showMessageDialog(this,"Les deux couleurs sont trop proches (1,3)","Erreur ", JOptionPane.ERROR_MESSAGE);
return false;
}
if(distanceBetweenP2AndP3 < 150f) {
if(playerNumber == 3 && distanceBetweenP2AndP3 < 150f) {
JOptionPane.showMessageDialog(this,"Les deux couleurs sont trop proches (2,3)","Erreur ", JOptionPane.ERROR_MESSAGE);
return false;
}
@ -224,7 +226,7 @@ public class ColorChooserDialog extends JDialog{
JOptionPane.showMessageDialog(this,"La couleur du joueur 2 est trop sombre","Erreur ", JOptionPane.ERROR_MESSAGE);
return false;
}
else if(distanceBetweenP3AndEmpty < 150f) {
else if(playerNumber == 3 && distanceBetweenP3AndEmpty < 150f) {
JOptionPane.showMessageDialog(this,"La couleur du joueur 3 est trop sombre","Erreur ", JOptionPane.ERROR_MESSAGE);
return false;
}