From fdae0a741133c80d7b3f509c9b9e61085867e673 Mon Sep 17 00:00:00 2001 From: Hector Alfaro Date: Tue, 24 Sep 2019 05:56:02 -0400 Subject: [PATCH 1/7] Add tests --- __test__/game.test.js | 97 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 __test__/game.test.js diff --git a/__test__/game.test.js b/__test__/game.test.js new file mode 100644 index 0000000..acf7552 --- /dev/null +++ b/__test__/game.test.js @@ -0,0 +1,97 @@ +const Game = require('../src/game').default + +describe('Game', () => { + let game, p1, p2 + beforeEach(() => { + p1 = 'Salem' + p2 = 'Nate' + game = new Game(p1, p2) + }) + + describe('Game', () => { + it('Initializes with two players', async () => { + expect(game.p1).toBe('Salem') + expect(game.p2).toBe('Nate') + }) + + it('Initializes with an empty board', async () => { + for (let r = 0; r < game.board.length; r++) { + for (let c = 0; c < game.board[r].lenght; c++) { + expect(game.board[r][c]).toBeUndefined() + } + } + }) + + it('Starts the game with a random player', async () => { + Math.random = () => 0.4 + expect(new Game(p1, p2).player).toBe('Salem') + + Math.random = () => 0.6 + expect(new Game(p1, p2).player).toBe('Nate') + }) + }) + + describe('turn', () => { + it("Inserts an 'X' into the top center", async () => { + game.turn(0, 1) + expect(game.board[0][1]).toBe('X') + }) + + it("Inserts an 'X' into the top left", async () => { + game.turn(0) + expect(game.board[0][0]).toBe('X') + }) + }) + + describe('nextPlayer', () => { + it('Sets the current player to be whoever it is not', async () => { + Math.random = () => 0.4 + const game = new Game(p1, p2) + expect(game.player).toBe('Salem') + game.nextPlayer() + expect(game.player).toBe('Nate') + }) + }) + + describe('hasWinner', () => { + it('Wins if any row is filled', async () => { + for (let r = 0; r < game.board.length; r++) { + for (let c = 0; c < game.board[r].length; c++) { + game.board[r][c] = 'X' + } + expect(game.hasWinner()).toBe(true) + + for (let c = 0; c < game.board[r].length; c++) { + game.board[r][c] = null + } + } + }) + + it('Wins if any column is filled', async () => { + for (let r = 0; r < game.board.length; r++) { + for (let c = 0; c < game.board[r].length; c++) { + game.board[c][r] = 'X' + } + expect(game.hasWinner()).toBe(true) + + for (let c = 0; c < game.board[r].length; c++) { + game.board[c][r] = null + } + } + }) + + it('Wins if down-left diagonal is filled', async () => { + for (let r = 0; r < game.board.length; r++) { + game.board[r][r] = 'X' + } + expect(game.hasWinner()).toBe(true) + }) + + it('Wins if up-right diagonal is filled', async () => { + for (let r = 0; r < game.board.length; r++) { + game.board[2 - r][r] = 'X' + } + expect(game.hasWinner()).toBe(true) + }) + }) +}) From ab19c6fd71bfbfc9320fe43adbcd2bc75eb32db5 Mon Sep 17 00:00:00 2001 From: Hector Alfaro Date: Tue, 24 Sep 2019 05:59:57 -0400 Subject: [PATCH 2/7] add a Bananas name --- src/game.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game.js b/src/game.js index a30a0fa..ef4df8b 100644 --- a/src/game.js +++ b/src/game.js @@ -1,7 +1,7 @@ export default class Game { constructor (p1, p2) { this.p1 = p1 - this.p2 = p2 + this.p2 = 'Bananas' this.board = [[null, null, null], [null, null, null], [null, null, null]] this.player = Math.random() < 0.5 ? this.p1 : this.p2 this.sym = 'X' From 4d6e5f12584b7746fb5d41640b201a000fe78144 Mon Sep 17 00:00:00 2001 From: Hector Alfaro Date: Wed, 16 Oct 2019 13:48:24 -0400 Subject: [PATCH 3/7] add snapshots to tests --- __test__/__snapshots__/game.test.js.snap | 3 +++ __test__/game.test.js | 11 +++++++++++ 2 files changed, 14 insertions(+) create mode 100644 __test__/__snapshots__/game.test.js.snap diff --git a/__test__/__snapshots__/game.test.js.snap b/__test__/__snapshots__/game.test.js.snap new file mode 100644 index 0000000..228f65e --- /dev/null +++ b/__test__/__snapshots__/game.test.js.snap @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`App Contains the compiled JavaScript 1`] = `"!function(t){var e={};function n(r){if(e[r])return e[r].exports;var l=e[r]={i:r,l:!1,exports:{}};return t[r].call(l.exports,l,l.exports,n),l.l=!0,l.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){\\"undefined\\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:\\"Module\\"}),Object.defineProperty(t,\\"__esModule\\",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&\\"object\\"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,\\"default\\",{enumerable:!0,value:t}),2&e&&\\"string\\"!=typeof t)for(var l in t)n.d(r,l,function(e){return t[e]}.bind(null,l));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,\\"a\\",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p=\\"\\",n(n.s=1)}([function(t,e,n){\\"use strict\\";n.r(e),n.d(e,\\"default\\",(function(){return r}));class r{constructor(t,e){this.p1=t,this.p2=e,this.board=[[null,null,null],[null,null,null],[null,null,null]],this.player=Math.random()<.5?this.p1:this.p2,this.sym=\\"X\\"}turn(t,e){e=e||t,this.board[t][e]=this.sym}nextPlayer(){this.player=this.player===this.p1?this.p2:this.p1,this.sym=\\"X\\"===this.sym?\\"O\\":\\"X\\"}hasWinner(){return this.rowWin()||this.colWin()||this.diagWin()}rowWin(){let t=!1;for(let e=0;e<3;e++){const n=this.board[e];null!==n[0]&&(t=t||n[0]===n[1]&&n[0]===n[2])}return t}colWin(){let t=!1;for(let e=0;e<3;e++){const n=this.board;null!==n[0][e]&&(t=t||n[0][e]===n[1][e]&&n[0][e]===n[2][e])}return t}diagWin(){const t=this.board;return null!==t[0][0]&&t[0][0]===t[1][1]&&t[0][0]===t[2][2]||null!==t[0][2]&&t[0][2]===t[1][1]&&t[0][2]===t[2][0]}}},function(t,e,n){n(2),t.exports=n(0)},function(t,e,n){\\"use strict\\";n.r(e);var r=n(0);let l,o;for(;!l;)l=window.prompt(\\"Enter player 1 name:\\");for(;!o&&l!==o;)o=window.prompt(l===o?\`Please enter a different name than \${l}.\`:\\"Enter player 2 name:\\");window.onload=()=>{const t=new r.default(l,o),e=document.getElementById(\\"turn\\"),n=document.getElementById(\\"player\\");n.innerText=t.player,document.querySelectorAll(\\"td\\").forEach(r=>{r.onclick=l=>{r.onclick=void 0,l.target.innerText=t.sym,l.target.onclick=void 0;const[o,i]=l.target.classList;t.turn(o,i),t.hasWinner()?(e.innerText=\`\${t.player} wins!\`,document.querySelectorAll(\\"td\\").forEach(t=>{t.onclick=void 0})):(t.nextPlayer(),n.innerText=t.player)}})}}]);"`; diff --git a/__test__/game.test.js b/__test__/game.test.js index acf7552..e8aa3a8 100644 --- a/__test__/game.test.js +++ b/__test__/game.test.js @@ -1,4 +1,15 @@ const Game = require('../src/game').default +const fs = require('fs') + +describe('App', () => { + it('Contains the compiled JavaScript', async (done) => { + fs.readFile('./public/main.js', 'utf8', (err, data) => { + expect(err).toBe(null) + expect(data).toMatchSnapshot() + done() + }) + }) +}) describe('Game', () => { let game, p1, p2 From bec4e2dd8886bb932c1be6d394269603d9378a76 Mon Sep 17 00:00:00 2001 From: Lia Keston Date: Mon, 21 Sep 2020 14:42:52 -0400 Subject: [PATCH 4/7] bump node-forge --- package.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 96e99be..bcc0483 100644 --- a/package.json +++ b/package.json @@ -33,5 +33,7 @@ "webpack-cli": "^3.2.1", "webpack-dev-server": "^3.1.14" }, - "dependencies": {} + "dependencies": { + "node-forge": "^0.10.0" + } } From a0559a85f6b7177e415ec668a3f4d763ca5ec04f Mon Sep 17 00:00:00 2001 From: Kazumi OHIRA Date: Tue, 1 Jun 2021 16:10:11 +0900 Subject: [PATCH 5/7] Fix test case - Fix the error "Test functions cannot both take a 'done' callback and return something. Either use a 'done' callback, or return a promise." --- __test__/game.test.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/__test__/game.test.js b/__test__/game.test.js index e8aa3a8..13a9f54 100644 --- a/__test__/game.test.js +++ b/__test__/game.test.js @@ -2,11 +2,10 @@ const Game = require('../src/game').default const fs = require('fs') describe('App', () => { - it('Contains the compiled JavaScript', async (done) => { + it('Contains the compiled JavaScript', async () => { fs.readFile('./public/main.js', 'utf8', (err, data) => { expect(err).toBe(null) expect(data).toMatchSnapshot() - done() }) }) }) From 05904b262ebad779f5502e5fe245755d61c28a6f Mon Sep 17 00:00:00 2001 From: Kazumi OHIRA Date: Fri, 11 Jun 2021 13:43:08 +0900 Subject: [PATCH 6/7] Fix the test recognizes snapshot is obsolete --- __test__/__snapshots__/game.test.js.snap | 2 +- __test__/game.test.js | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/__test__/__snapshots__/game.test.js.snap b/__test__/__snapshots__/game.test.js.snap index 228f65e..75241a6 100644 --- a/__test__/__snapshots__/game.test.js.snap +++ b/__test__/__snapshots__/game.test.js.snap @@ -1,3 +1,3 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`App Contains the compiled JavaScript 1`] = `"!function(t){var e={};function n(r){if(e[r])return e[r].exports;var l=e[r]={i:r,l:!1,exports:{}};return t[r].call(l.exports,l,l.exports,n),l.l=!0,l.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){\\"undefined\\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:\\"Module\\"}),Object.defineProperty(t,\\"__esModule\\",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&\\"object\\"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,\\"default\\",{enumerable:!0,value:t}),2&e&&\\"string\\"!=typeof t)for(var l in t)n.d(r,l,function(e){return t[e]}.bind(null,l));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,\\"a\\",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p=\\"\\",n(n.s=1)}([function(t,e,n){\\"use strict\\";n.r(e),n.d(e,\\"default\\",(function(){return r}));class r{constructor(t,e){this.p1=t,this.p2=e,this.board=[[null,null,null],[null,null,null],[null,null,null]],this.player=Math.random()<.5?this.p1:this.p2,this.sym=\\"X\\"}turn(t,e){e=e||t,this.board[t][e]=this.sym}nextPlayer(){this.player=this.player===this.p1?this.p2:this.p1,this.sym=\\"X\\"===this.sym?\\"O\\":\\"X\\"}hasWinner(){return this.rowWin()||this.colWin()||this.diagWin()}rowWin(){let t=!1;for(let e=0;e<3;e++){const n=this.board[e];null!==n[0]&&(t=t||n[0]===n[1]&&n[0]===n[2])}return t}colWin(){let t=!1;for(let e=0;e<3;e++){const n=this.board;null!==n[0][e]&&(t=t||n[0][e]===n[1][e]&&n[0][e]===n[2][e])}return t}diagWin(){const t=this.board;return null!==t[0][0]&&t[0][0]===t[1][1]&&t[0][0]===t[2][2]||null!==t[0][2]&&t[0][2]===t[1][1]&&t[0][2]===t[2][0]}}},function(t,e,n){n(2),t.exports=n(0)},function(t,e,n){\\"use strict\\";n.r(e);var r=n(0);let l,o;for(;!l;)l=window.prompt(\\"Enter player 1 name:\\");for(;!o&&l!==o;)o=window.prompt(l===o?\`Please enter a different name than \${l}.\`:\\"Enter player 2 name:\\");window.onload=()=>{const t=new r.default(l,o),e=document.getElementById(\\"turn\\"),n=document.getElementById(\\"player\\");n.innerText=t.player,document.querySelectorAll(\\"td\\").forEach(r=>{r.onclick=l=>{r.onclick=void 0,l.target.innerText=t.sym,l.target.onclick=void 0;const[o,i]=l.target.classList;t.turn(o,i),t.hasWinner()?(e.innerText=\`\${t.player} wins!\`,document.querySelectorAll(\\"td\\").forEach(t=>{t.onclick=void 0})):(t.nextPlayer(),n.innerText=t.player)}})}}]);"`; +exports[`App Contains the compiled JavaScript 1`] = `"!function(t){var e={};function n(r){if(e[r])return e[r].exports;var l=e[r]={i:r,l:!1,exports:{}};return t[r].call(l.exports,l,l.exports,n),l.l=!0,l.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){\\"undefined\\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:\\"Module\\"}),Object.defineProperty(t,\\"__esModule\\",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&\\"object\\"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,\\"default\\",{enumerable:!0,value:t}),2&e&&\\"string\\"!=typeof t)for(var l in t)n.d(r,l,function(e){return t[e]}.bind(null,l));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,\\"a\\",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p=\\"\\",n(n.s=1)}([function(t,e,n){\\"use strict\\";n.r(e),n.d(e,\\"default\\",(function(){return r}));class r{constructor(t,e){this.p1=t,this.p2=e,this.board=[[null,null,null],[null,null,null],[null,null,null]],this.player=Math.random()<.5?this.p1:this.p2,this.sym=\\"X\\"}turn(t,e){e=e||t,this.board[t][e]=this.sym}nextPlayer(){this.player=this.player===this.p1?this.p2:this.p1,this.sym=\\"X\\"===this.sym?\\"O\\":\\"X\\"}hasWinner(){return this.rowWin()||this.colWin()||this.diagWin()}rowWin(){let t=!1;for(let e=0;e<3;e++){const n=this.board[e];null!==n[0]&&(t=t||n[0]===n[1]&&n[0]===n[2])}return t}colWin(){let t=!1;for(let e=0;e<3;e++){const n=this.board;null!==n[0][e]&&(t=t||n[0][e]===n[1][e]&&n[0][e]===n[2][e])}return t}diagWin(){const t=this.board;return null!==t[0][0]&&t[0][0]===t[1][1]&&t[0][0]===t[2][2]||null!==t[0][2]&&t[0][2]===t[1][1]&&t[0][2]===t[2][0]}}},function(t,e,n){n(2),t.exports=n(0)},function(t,e,n){\\"use strict\\";n.r(e);var r=n(0);let l,o;for(;!l;)l=window.prompt(\\"Enter player 1 name:\\");for(;!o&&l!==o;)o=window.prompt(l===o?\`Please enter a different name than \${l}.\`:\\"Enter player 2 name:\\");window.onload=()=>{const t=new r.default(l,o),e=document.getElementById(\\"turn\\"),n=document.getElementById(\\"player\\");n.innerText=t.player,document.querySelectorAll(\\"td\\").forEach(r=>{r.onclick=l=>{r.onclick=void 0,l.target.innerText=t.sym,l.target.onclick=void 0;const[o,i]=l.target.classList;t.turn(o,i),t.hasWinner()?(e.innerText=t.player+\\" wins!\\",document.querySelectorAll(\\"td\\").forEach(t=>{t.onclick=void 0})):(t.nextPlayer(),n.innerText=t.player)}})}}]);"`; diff --git a/__test__/game.test.js b/__test__/game.test.js index 13a9f54..4cd7760 100644 --- a/__test__/game.test.js +++ b/__test__/game.test.js @@ -3,10 +3,8 @@ const fs = require('fs') describe('App', () => { it('Contains the compiled JavaScript', async () => { - fs.readFile('./public/main.js', 'utf8', (err, data) => { - expect(err).toBe(null) - expect(data).toMatchSnapshot() - }) + const data = fs.readFileSync('./public/main.js', 'utf8') + expect(data).toMatchSnapshot() }) }) From 06070c426e031523c41ecef07920ff1ba4a2fc99 Mon Sep 17 00:00:00 2001 From: Kazumi OHIRA Date: Wed, 16 Jun 2021 14:03:17 +0900 Subject: [PATCH 7/7] Revert the snapshot to suit `@babel/core@7.6.2` --- __test__/__snapshots__/game.test.js.snap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/__test__/__snapshots__/game.test.js.snap b/__test__/__snapshots__/game.test.js.snap index 75241a6..228f65e 100644 --- a/__test__/__snapshots__/game.test.js.snap +++ b/__test__/__snapshots__/game.test.js.snap @@ -1,3 +1,3 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`App Contains the compiled JavaScript 1`] = `"!function(t){var e={};function n(r){if(e[r])return e[r].exports;var l=e[r]={i:r,l:!1,exports:{}};return t[r].call(l.exports,l,l.exports,n),l.l=!0,l.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){\\"undefined\\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:\\"Module\\"}),Object.defineProperty(t,\\"__esModule\\",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&\\"object\\"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,\\"default\\",{enumerable:!0,value:t}),2&e&&\\"string\\"!=typeof t)for(var l in t)n.d(r,l,function(e){return t[e]}.bind(null,l));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,\\"a\\",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p=\\"\\",n(n.s=1)}([function(t,e,n){\\"use strict\\";n.r(e),n.d(e,\\"default\\",(function(){return r}));class r{constructor(t,e){this.p1=t,this.p2=e,this.board=[[null,null,null],[null,null,null],[null,null,null]],this.player=Math.random()<.5?this.p1:this.p2,this.sym=\\"X\\"}turn(t,e){e=e||t,this.board[t][e]=this.sym}nextPlayer(){this.player=this.player===this.p1?this.p2:this.p1,this.sym=\\"X\\"===this.sym?\\"O\\":\\"X\\"}hasWinner(){return this.rowWin()||this.colWin()||this.diagWin()}rowWin(){let t=!1;for(let e=0;e<3;e++){const n=this.board[e];null!==n[0]&&(t=t||n[0]===n[1]&&n[0]===n[2])}return t}colWin(){let t=!1;for(let e=0;e<3;e++){const n=this.board;null!==n[0][e]&&(t=t||n[0][e]===n[1][e]&&n[0][e]===n[2][e])}return t}diagWin(){const t=this.board;return null!==t[0][0]&&t[0][0]===t[1][1]&&t[0][0]===t[2][2]||null!==t[0][2]&&t[0][2]===t[1][1]&&t[0][2]===t[2][0]}}},function(t,e,n){n(2),t.exports=n(0)},function(t,e,n){\\"use strict\\";n.r(e);var r=n(0);let l,o;for(;!l;)l=window.prompt(\\"Enter player 1 name:\\");for(;!o&&l!==o;)o=window.prompt(l===o?\`Please enter a different name than \${l}.\`:\\"Enter player 2 name:\\");window.onload=()=>{const t=new r.default(l,o),e=document.getElementById(\\"turn\\"),n=document.getElementById(\\"player\\");n.innerText=t.player,document.querySelectorAll(\\"td\\").forEach(r=>{r.onclick=l=>{r.onclick=void 0,l.target.innerText=t.sym,l.target.onclick=void 0;const[o,i]=l.target.classList;t.turn(o,i),t.hasWinner()?(e.innerText=t.player+\\" wins!\\",document.querySelectorAll(\\"td\\").forEach(t=>{t.onclick=void 0})):(t.nextPlayer(),n.innerText=t.player)}})}}]);"`; +exports[`App Contains the compiled JavaScript 1`] = `"!function(t){var e={};function n(r){if(e[r])return e[r].exports;var l=e[r]={i:r,l:!1,exports:{}};return t[r].call(l.exports,l,l.exports,n),l.l=!0,l.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){\\"undefined\\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:\\"Module\\"}),Object.defineProperty(t,\\"__esModule\\",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&\\"object\\"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,\\"default\\",{enumerable:!0,value:t}),2&e&&\\"string\\"!=typeof t)for(var l in t)n.d(r,l,function(e){return t[e]}.bind(null,l));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,\\"a\\",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p=\\"\\",n(n.s=1)}([function(t,e,n){\\"use strict\\";n.r(e),n.d(e,\\"default\\",(function(){return r}));class r{constructor(t,e){this.p1=t,this.p2=e,this.board=[[null,null,null],[null,null,null],[null,null,null]],this.player=Math.random()<.5?this.p1:this.p2,this.sym=\\"X\\"}turn(t,e){e=e||t,this.board[t][e]=this.sym}nextPlayer(){this.player=this.player===this.p1?this.p2:this.p1,this.sym=\\"X\\"===this.sym?\\"O\\":\\"X\\"}hasWinner(){return this.rowWin()||this.colWin()||this.diagWin()}rowWin(){let t=!1;for(let e=0;e<3;e++){const n=this.board[e];null!==n[0]&&(t=t||n[0]===n[1]&&n[0]===n[2])}return t}colWin(){let t=!1;for(let e=0;e<3;e++){const n=this.board;null!==n[0][e]&&(t=t||n[0][e]===n[1][e]&&n[0][e]===n[2][e])}return t}diagWin(){const t=this.board;return null!==t[0][0]&&t[0][0]===t[1][1]&&t[0][0]===t[2][2]||null!==t[0][2]&&t[0][2]===t[1][1]&&t[0][2]===t[2][0]}}},function(t,e,n){n(2),t.exports=n(0)},function(t,e,n){\\"use strict\\";n.r(e);var r=n(0);let l,o;for(;!l;)l=window.prompt(\\"Enter player 1 name:\\");for(;!o&&l!==o;)o=window.prompt(l===o?\`Please enter a different name than \${l}.\`:\\"Enter player 2 name:\\");window.onload=()=>{const t=new r.default(l,o),e=document.getElementById(\\"turn\\"),n=document.getElementById(\\"player\\");n.innerText=t.player,document.querySelectorAll(\\"td\\").forEach(r=>{r.onclick=l=>{r.onclick=void 0,l.target.innerText=t.sym,l.target.onclick=void 0;const[o,i]=l.target.classList;t.turn(o,i),t.hasWinner()?(e.innerText=\`\${t.player} wins!\`,document.querySelectorAll(\\"td\\").forEach(t=>{t.onclick=void 0})):(t.nextPlayer(),n.innerText=t.player)}})}}]);"`;