diff --git a/src/components/OXTable.vue b/src/components/OXTable.vue index 194fd1d01d4dbf90e5bb2545f1b2a7958d843ff5..e2ec8ca9f478faa9ea206092c033c3a823cdc36d 100644 --- a/src/components/OXTable.vue +++ b/src/components/OXTable.vue @@ -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: {