Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- verif_stack_diaf_rtol(move){
- let x = this.move.get_abs();
- let y = this.move.get_ord();
- let i,j =0;
- let nb_top_right = 0, nb_bottom_left = 0;
- for (i = x - 1, j = y + 1; i >= 0, j < 7; i--, j++) {
- if (this._board[x][y] !== this._board[i][j]) break;
- nb_top_right++;
- }
- for (i = x + 1, j = y - 1; i < 7, j >= 0; i++, j--) {
- if (this._board[x][y] !== this._board[i][j]) break;
- nb_bottom_left++;
- }
- if(this._board[x][y] === Color.BLACK && nb_top_right + nb_bottom_left >= 2 ) {
- for (i = x - nb_top_right, j = y - nb_top_right; i < x + nb_bottom_left, j < y + nb_bottom_left; i++, j++)
- this._board[i][j] = Color.BLACK_TEMP;
- } else if(this._board[x][y] === Color.WHITE && nb_top_right + nb_bottom_left >= 2 ) {
- for (i = x - nb_top_right, j = y - nb_top_right; i < x + nb_bottom_left, j < y + nb_bottom_left; i++, j++)
- this._board[i][j] = Color.WHITE_TEMP;
- }
- return Color.NONE;
- }
- verif_stack_diag_ltor(move) {
- let x = this.move.get_abs();
- let y = this.move.get_ord();
- let i,j =0;
- let nb_top_left = 0, nb_bottom_right = 0;
- for (i = x - 1, j = y - 1 ; i >= 0, j >= 0; i--, j--) {
- if (this._board[x][y] !== this._board[i][j]) break;
- nb_top_left++;
- }
- for (i = x + 1, j = y + 1; i < 7, j<7; i++, j++) {
- if (this._board[x][y] !== this._board[i][j]) break;
- nb_bottom_right++;
- }
- if(this._board[x][y] === Color.BLACK && nb_top_left + nb_bottom_right >= 2) {
- for (i = x - nb_top_left, j = y - nb_top_left; i < x + nb_bottom_right, j < y + nb_bottom_right; i++, j++)
- this._board[i][j] = Color.BLACK_TEMP;
- } else if(this._board[x][y] === Color.WHITE && nb_top_left + nb_bottom_right >= 2) {
- for (i = x - nb_top_left, j = y - nb_top_left; i < x + nb_bottom_right, j < y + nb_bottom_right; i++, j++)
- this._board[i][j] = Color.WHITE_TEMP;
- }
- return Color.NONE;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement