Advertisement
Guest User

benji

a guest
Jun 17th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.92 KB | None | 0 0
  1. static void couleurCasePion(Case c){
  2.         int cx = c.getAbscisse();
  3.         int cy = c.getOrdonnee();
  4.     // Test PION BLANC
  5.  
  6.         if(c.getPiece().getCouleur() == CouleurPiece.blanc && cx != 7){
  7.  
  8.         // Test MANGER POUR LES BLANCS
  9.             if(cy!=7){
  10.                 if(monEchiquier[cx+1][cy+1].getPiece().getCouleur() != c.getPiece().getCouleur() && monEchiquier[cx+1][cy+1].getPiece().getCouleur() != CouleurPiece.vide){
  11.                     monEchiquier[cx+1][cy+1].setBorder(Echec1.greenline);
  12.                     monEchiquier[cx+1][cy+1].setEnabled(true);
  13.                 }
  14.             }
  15.             if (cy != 0){
  16.                 if(monEchiquier[cx + 1][cy - 1].getPiece().getCouleur() != c.getPiece().getCouleur() && monEchiquier[cx + 1][cy - 1].getPiece().getCouleur() != CouleurPiece.vide){
  17.                     monEchiquier[cx + 1][cy - 1].setBorder(Echec1.greenline);
  18.                     monEchiquier[cx + 1][cy - 1].setEnabled(true);
  19.                 }
  20.             }
  21.  
  22.         // Test AVANCER POUR LES BLANCS QUAND CASE DE DEPART    
  23.                 if(cx == 1){
  24.                     if(monEchiquier[cx +1][cy].getPiece().getType() == TypePiece.vide){
  25.                         monEchiquier[cx + 1][cy].setBorder(Echec1.greenline);
  26.                         monEchiquier[cx + 1][cy].setEnabled(true);
  27.                     }
  28.                     else{
  29.                         monEchiquier[cx + 1][cy].setBorder(Echec1.magentaline);        
  30.                     }
  31.                     if(monEchiquier[cx + 2][cy].getPiece().getType() == TypePiece.vide){
  32.                         monEchiquier[cx + 2][cy].setBorder(Echec1.greenline);
  33.                         monEchiquier[cx + 2][cy].setEnabled(true);
  34.                     }
  35.                     else{
  36.                         monEchiquier[cx + 2][cy].setBorder(Echec1.magentaline);            
  37.                     }
  38.                 }
  39.         //  Test AVANCER POUR LES BLANCS QUAND PAS CASE DE DEPART
  40.                 else{
  41.                     if(monEchiquier[cx + 1][cy].getPiece().getType() == TypePiece.vide){
  42.                         monEchiquier[cx + 1][cy].setBorder(Echec1.greenline);
  43.                         monEchiquier[cx + 1][cy].setEnabled(true);
  44.                     }
  45.                     else{
  46.                         monEchiquier[cx + 1][cy].setBorder(Echec1.magentaline);            
  47.                     }
  48.                 }  
  49.             }
  50.  
  51.             // TEST PION NOIR
  52.  
  53.             else{
  54.                 if(c.getPiece().getCouleur() == CouleurPiece.noir && cx != 0){
  55.                     // Test MANGER POUR LES BLANCS
  56.                 if(cy!=7){
  57.                     if(monEchiquier[cx-1][cy+1].getPiece().getCouleur() != c.getPiece().getCouleur() && monEchiquier[cx-1][cy+1].getPiece().getCouleur() != CouleurPiece.vide){
  58.                         monEchiquier[cx-1][cy+1].setBorder(Echec1.greenline);
  59.                         monEchiquier[cx - 1][cy + 1].setEnabled(true);
  60.                     }
  61.                 }
  62.                 if (cy != 0){
  63.                     if(monEchiquier[cx - 1][cy - 1].getPiece().getCouleur() != c.getPiece().getCouleur() && monEchiquier[cx - 1][cy - 1].getPiece().getCouleur() != CouleurPiece.vide){
  64.                         monEchiquier[cx - 1][cy - 1].setBorder(Echec1.greenline);
  65.                         monEchiquier[cx - 1][cy - 1].setEnabled(true);
  66.                     }
  67.                 }
  68.  
  69.             // Test AVANCER POUR LES BLANCS QUAND CASE DE DEPART    
  70.                     if(cx == 6){
  71.                         if(monEchiquier[cx - 1][cy].getPiece().getType() == TypePiece.vide){
  72.                             monEchiquier[cx - 1 ][cy].setBorder(Echec1.greenline);
  73.                             monEchiquier[cx - 1][cy].setEnabled(true);
  74.                         }
  75.                         else{
  76.                             monEchiquier[cx - 1][cy].setBorder(Echec1.magentaline);      
  77.                         }
  78.                         if(monEchiquier[cx - 2][cy].getPiece().getType() == TypePiece.vide){
  79.                             monEchiquier[cx - 2][cy].setBorder(Echec1.greenline);
  80.                             monEchiquier[cx - 2][cy].setEnabled(true);
  81.                         }
  82.                         else{
  83.                             monEchiquier[cx - 2][cy].setBorder(Echec1.magentaline);          
  84.                         }
  85.                     }
  86.             //  Test AVANCER POUR LES BLANCS QUAND PAS CASE DE DEPART
  87.                     else{
  88.                         if(monEchiquier[cx - 1][cy].getPiece().getType() == TypePiece.vide ){
  89.                             monEchiquier[cx - 1][cy].setBorder(Echec1.greenline);
  90.                             monEchiquier[cx - 1][cy].setEnabled(true);
  91.                         }
  92.                         else{
  93.                             monEchiquier[cx - 1][cy].setBorder(Echec1.magentaline);            
  94.                         }
  95.                     }
  96.                 }  
  97.             }
  98.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement