Gitlab@Informatics

Skip to content
Snippets Groups Projects
Commit bc9e7c14 authored by 62160286's avatar 62160286
Browse files

Add method checkWin

parent 73faec71
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,8 @@ import OXCell from './OXCell.vue'
export default {
data () {
return {
finish: false,
winner: '-',
turn: 'O',
table: [
['-', '-', '-'],
......@@ -34,6 +36,12 @@ export default {
cellClick (row, col) {
console.log('Cell click ' + row + ' ' + col)
this.table[row][col] = this.turn
if (this.checkwin(row, col)) {
console.log('Win')
this.finish = true
this.winner = this.turn
return
}
this.switchTurn()
},
switchTurn () {
......@@ -49,6 +57,28 @@ export default {
} else {
this.turn = 'X'
}
},
checkwin (row, col) {
if (
this.checkRow(row) ||
this.checkCol(col) ||
this.checkX1() ||
this.checkX2()
) {
return this.turn
}
},
checkRow (row) {
return false
},
checkCol (col) {
return false
},
checkX1 () {
return false
},
checkX2 () {
return false
}
},
components: {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment