Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created August 5, 2020 18:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/8125eacb537b60c49bc5e1238240fb3d to your computer and use it in GitHub Desktop.
Save parzibyte/8125eacb537b60c49bc5e1238240fb3d to your computer and use it in GitHub Desktop.
async makeMove(columnNumber) {
const columnIndex = columnNumber - 1;
const firstEmptyRow = this.getFirstEmptyRow(columnIndex, this.board);
if (firstEmptyRow === -1) {
Swal.fire('Cannot put here, it is full');
return;
}
Vue.set(this.board[firstEmptyRow], columnIndex, this.currentPlayer);
const status = await this.checkGameStatus();
if (!status) {
this.togglePlayer();
this.makeCpuMove();
} else {
this.askUserForAnotherMatch();
}
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment