From de72f53c7456f0f85992cebc986d72fb631e57bd Mon Sep 17 00:00:00 2001 From: Artur Tamborski Date: Fri, 15 Jan 2021 00:15:41 +0100 Subject: [PATCH] src: add new board, select randomly from available ones --- src/components/App/App.tsx | 3 ++- src/components/Board/Board.tsx | 4 +-- src/constants/2.json | 46 ++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 src/constants/2.json diff --git a/src/components/App/App.tsx b/src/components/App/App.tsx index e67c5a0..b06f86b 100644 --- a/src/components/App/App.tsx +++ b/src/components/App/App.tsx @@ -34,7 +34,8 @@ export default class App extends React.Component { constructor(props: object) { super(props); - this.game = require(`../../constants/1.json`) + const gameId = (Math.trunc(Math.random() * 100) % 2) + 1; + this.game = require(`../../constants/${gameId}.json`) } renderAnswers(): Array { diff --git a/src/components/Board/Board.tsx b/src/components/Board/Board.tsx index 64abe9f..9116cfa 100644 --- a/src/components/Board/Board.tsx +++ b/src/components/Board/Board.tsx @@ -92,7 +92,7 @@ export default class Board extends React.Component { renderCell(s: string, pos: Point): JSX.Element { const size = `${this.props.cellSize}px`; const padding = `${this.props.cellSize / 4}px`; - const visibility = s === " " ? "hidden" : "visible"; + const visibility = s === ' ' ? 'hidden' : 'visible'; return (