Advertisement
Guest User

FRANCOIS TROP BEAU

a guest
Jun 20th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. verif_stack_diaf_rtol(move){
  2.  
  3. let x = this.move.get_abs();
  4. let y = this.move.get_ord();
  5. let i,j =0;
  6. let nb_top_right = 0, nb_bottom_left = 0;
  7.  
  8. for (i = x - 1, j = y + 1; i >= 0, j < 7; i--, j++) {
  9. if (this._board[x][y] !== this._board[i][j]) break;
  10. nb_top_right++;
  11. }
  12. for (i = x + 1, j = y - 1; i < 7, j >= 0; i++, j--) {
  13. if (this._board[x][y] !== this._board[i][j]) break;
  14. nb_bottom_left++;
  15. }
  16. if(this._board[x][y] === Color.BLACK && nb_top_right + nb_bottom_left >= 2 ) {
  17. for (i = x - nb_top_right, j = y - nb_top_right; i < x + nb_bottom_left, j < y + nb_bottom_left; i++, j++)
  18. this._board[i][j] = Color.BLACK_TEMP;
  19. } else if(this._board[x][y] === Color.WHITE && nb_top_right + nb_bottom_left >= 2 ) {
  20. for (i = x - nb_top_right, j = y - nb_top_right; i < x + nb_bottom_left, j < y + nb_bottom_left; i++, j++)
  21. this._board[i][j] = Color.WHITE_TEMP;
  22. }
  23. return Color.NONE;
  24.  
  25. }
  26. verif_stack_diag_ltor(move) {
  27.  
  28. let x = this.move.get_abs();
  29. let y = this.move.get_ord();
  30. let i,j =0;
  31. let nb_top_left = 0, nb_bottom_right = 0;
  32.  
  33. for (i = x - 1, j = y - 1 ; i >= 0, j >= 0; i--, j--) {
  34. if (this._board[x][y] !== this._board[i][j]) break;
  35. nb_top_left++;
  36. }
  37. for (i = x + 1, j = y + 1; i < 7, j<7; i++, j++) {
  38. if (this._board[x][y] !== this._board[i][j]) break;
  39. nb_bottom_right++;
  40. }
  41. if(this._board[x][y] === Color.BLACK && nb_top_left + nb_bottom_right >= 2) {
  42. for (i = x - nb_top_left, j = y - nb_top_left; i < x + nb_bottom_right, j < y + nb_bottom_right; i++, j++)
  43. this._board[i][j] = Color.BLACK_TEMP;
  44. } else if(this._board[x][y] === Color.WHITE && nb_top_left + nb_bottom_right >= 2) {
  45. for (i = x - nb_top_left, j = y - nb_top_left; i < x + nb_bottom_right, j < y + nb_bottom_right; i++, j++)
  46. this._board[i][j] = Color.WHITE_TEMP;
  47. }
  48. return Color.NONE;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement