diff --git a/single-player/package.json b/single-player/package.json index c1be81690b92881f1cde2332bf5251c6982055af..12cc82b565c300d441c6c59193e50db9bc4b7f7c 100644 --- a/single-player/package.json +++ b/single-player/package.json @@ -2,7 +2,7 @@ "name": "c-sudoku", "description": "Sudoku Demo with CRDT", "version": "1.0.1", - "author": "Yannick Li <yannick.li@concordant.io>", + "author": "Concordant.io <support@concordant.io>", "license": "MIT", "homepage": "./", "dependencies": { diff --git a/single-player/src/components/Cell.test.tsx b/single-player/src/components/Cell.test.tsx index b68bc2e596b0523d60552c4a150d5fdb1395e0b2..5abe86d319b0e1fbd4417fd4a100cace74dbf4e0 100644 --- a/single-player/src/components/Cell.test.tsx +++ b/single-player/src/components/Cell.test.tsx @@ -1,7 +1,7 @@ /** * MIT License * - * Copyright (c) 2020, Concordant and contributors + * Copyright (c) 2022, Concordant and contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/single-player/src/components/Cell.tsx b/single-player/src/components/Cell.tsx index 567a9cc120235b44f9849e87c74da535b853ed37..ff1f03fad69a8df870b06a833b7d1e5746db117e 100644 --- a/single-player/src/components/Cell.tsx +++ b/single-player/src/components/Cell.tsx @@ -1,7 +1,7 @@ /** * MIT License * - * Copyright (c) 2020, Concordant and contributors + * Copyright (c) 2022, Concordant and contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/single-player/src/components/Game.tsx b/single-player/src/components/Game.tsx index fe5328ffc14d5fc0d0eb2f7146a9d00140f01b3e..3ad093e6e97ca36483eda946e8032723d63db1b1 100644 --- a/single-player/src/components/Game.tsx +++ b/single-player/src/components/Game.tsx @@ -1,7 +1,7 @@ /** * MIT License * - * Copyright (c) 2020, Concordant and contributors + * Copyright (c) 2022, Concordant and contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -43,9 +43,9 @@ class Game extends React.Component<Record<string, unknown>, IGameState> { super(props); const cells = new Array(81) .fill(null) - .map(() => ({ value: "", modifiable: false})); + .map(() => ({ value: "", modifiable: false })); this.state = { - cells: cells + cells: cells, }; } diff --git a/single-player/src/components/Grid.test.tsx b/single-player/src/components/Grid.test.tsx index acb583abb176a1ec8fbe7809450a041ac761907a..e63ddce6acc158a5bdb1ab6256ccb456f1ea1006 100644 --- a/single-player/src/components/Grid.test.tsx +++ b/single-player/src/components/Grid.test.tsx @@ -1,7 +1,7 @@ /** * MIT License * - * Copyright (c) 2020, Concordant and contributors + * Copyright (c) 2022, Concordant and contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -159,7 +159,7 @@ describe("checkLine", () => { <Grid cells={initVal.map((val) => ({ value: val, - modifiable: false + modifiable: false, }))} onChange={() => ({})} /> @@ -195,7 +195,7 @@ describe("checkColumn", () => { <Grid cells={initVal.map((val) => ({ value: val, - modifiable: false + modifiable: false, }))} onChange={() => ({})} /> @@ -231,7 +231,7 @@ describe("checkBlock", () => { <Grid cells={initVal.map((val) => ({ value: val, - modifiable: false + modifiable: false, }))} onChange={() => ({})} /> @@ -265,13 +265,15 @@ describe("checkLines", () => { "","","","","","","","","", "","","","","","","","","", "","","","","","","","",""] - const wrapper = shallow(<Grid + const wrapper = shallow( + <Grid cells={initVal.map((val) => ({ value: val, - modifiable: false + modifiable: false, }))} onChange={() => ({})} - />); + /> + ); const game = wrapper.instance(); expect(game.checkLines()).toStrictEqual([]); @@ -292,13 +294,15 @@ describe("checkLines", () => { "1","8","7","5","2","9","6","4","3", "2","3","4","6","1","8","7","9","5", "9","6","5","7","4","3","1","8","2"] - const wrapper = shallow(<Grid + const wrapper = shallow( + <Grid cells={initVal.map((val) => ({ value: val, - modifiable: false + modifiable: false, }))} onChange={() => ({})} - />); + /> + ); const game = wrapper.instance(); expect(game.checkLines()).toStrictEqual([]); @@ -318,13 +322,15 @@ describe("checkLines", () => { "1","8","7","5","2","9","","","3", "2","3","4","6","1","8","7","9","5", "","6","5","7","4","3","1","8","2"] - const wrapper = shallow(<Grid + const wrapper = shallow( + <Grid cells={initVal.map((val) => ({ value: val, - modifiable: false + modifiable: false, }))} onChange={() => ({})} - />); + /> + ); const game = wrapper.instance(); expect(game.checkLines()).toStrictEqual([]); @@ -344,13 +350,15 @@ describe("checkLines", () => { "1","8","7","5","2","9","6","4","3", "2","3","4","6","1","8","7","9","5", "9","6","5","7","4","3","1","8","2"] - const wrapper = shallow(<Grid + const wrapper = shallow( + <Grid cells={initVal.map((val) => ({ value: val, - modifiable: false + modifiable: false, }))} onChange={() => ({})} - />); + /> + ); const game = wrapper.instance(); expect(game.checkLines()).toStrictEqual([0, 1, 2, 3, 4, 5, 6, 7, 8]); @@ -370,13 +378,15 @@ describe("checkLines", () => { "1","8","7","5","2","9","","","3", "2","3","4","6","1","8","7","9","5", "","6","5","7","4","3","1","8","2"] - const wrapper = shallow(<Grid + const wrapper = shallow( + <Grid cells={initVal.map((val) => ({ value: val, - modifiable: false + modifiable: false, }))} onChange={() => ({})} - />); + /> + ); const game = wrapper.instance(); expect(game.checkLines()).toStrictEqual([]); @@ -401,13 +411,15 @@ describe("checkColumns", () => { "","","","","","","","","", "","","","","","","","","", "","","","","","","","",""] - const wrapper = shallow(<Grid + const wrapper = shallow( + <Grid cells={initVal.map((val) => ({ value: val, - modifiable: false + modifiable: false, }))} onChange={() => ({})} - />); + /> + ); const game = wrapper.instance(); expect(game.checkColumns()).toStrictEqual([]); @@ -428,13 +440,15 @@ describe("checkColumns", () => { "1","8","7","5","2","9","6","4","3", "2","3","4","6","1","8","7","9","5", "9","6","5","7","4","3","1","8","2"] - const wrapper = shallow(<Grid + const wrapper = shallow( + <Grid cells={initVal.map((val) => ({ value: val, - modifiable: false + modifiable: false, }))} onChange={() => ({})} - />); + /> + ); const game = wrapper.instance(); expect(game.checkColumns()).toStrictEqual([]); @@ -454,13 +468,15 @@ describe("checkColumns", () => { "1","8","7","5","2","9","","","3", "2","3","4","6","1","8","7","9","5", "","6","5","7","4","3","1","8","2"] - const wrapper = shallow(<Grid + const wrapper = shallow( + <Grid cells={initVal.map((val) => ({ value: val, - modifiable: false + modifiable: false, }))} onChange={() => ({})} - />); + /> + ); const game = wrapper.instance(); expect(game.checkColumns()).toStrictEqual([]); @@ -480,13 +496,15 @@ describe("checkColumns", () => { "1","8","7","5","2","9","6","4","3", "2","3","4","6","1","8","7","9","5", "9","6","5","7","4","3","1","8","2"] - const wrapper = shallow(<Grid + const wrapper = shallow( + <Grid cells={initVal.map((val) => ({ value: val, - modifiable: false + modifiable: false, }))} onChange={() => ({})} - />); + /> + ); const game = wrapper.instance(); expect(game.checkColumns()).toStrictEqual([ @@ -516,13 +534,15 @@ describe("checkColumns", () => { "1","8","7","5","2","9","","","3", "2","3","4","6","1","8","7","9","5", "","6","5","7","4","3","1","8","2"] - const wrapper = shallow(<Grid + const wrapper = shallow( + <Grid cells={initVal.map((val) => ({ value: val, - modifiable: false + modifiable: false, }))} onChange={() => ({})} - />); + /> + ); const game = wrapper.instance(); expect(game.checkColumns()).toStrictEqual([]); @@ -547,13 +567,15 @@ describe("checkBlocks", () => { "","","","","","","","","", "","","","","","","","","", "","","","","","","","",""] - const wrapper = shallow(<Grid + const wrapper = shallow( + <Grid cells={initVal.map((val) => ({ value: val, - modifiable: false + modifiable: false, }))} onChange={() => ({})} - />); + /> + ); const game = wrapper.instance(); expect(game.checkBlocks()).toStrictEqual([]); @@ -574,13 +596,15 @@ describe("checkBlocks", () => { "1","8","7","5","2","9","6","4","3", "2","3","4","6","1","8","7","9","5", "9","6","5","7","4","3","1","8","2"] - const wrapper = shallow(<Grid + const wrapper = shallow( + <Grid cells={initVal.map((val) => ({ value: val, - modifiable: false + modifiable: false, }))} onChange={() => ({})} - />); + /> + ); const game = wrapper.instance(); expect(game.checkBlocks()).toStrictEqual([]); @@ -600,13 +624,15 @@ describe("checkBlocks", () => { "1","8","7","5","2","9","","","3", "2","3","4","6","1","8","7","9","5", "","6","5","7","4","3","1","8","2"] - const wrapper = shallow(<Grid + const wrapper = shallow( + <Grid cells={initVal.map((val) => ({ value: val, - modifiable: false + modifiable: false, }))} onChange={() => ({})} - />); + /> + ); const game = wrapper.instance(); expect(game.checkBlocks()).toStrictEqual([]); @@ -626,13 +652,15 @@ describe("checkBlocks", () => { "1","8","7","5","2","9","6","4","3", "2","3","4","6","1","8","7","9","5", "9","6","5","7","4","3","1","8","2"] - const wrapper = shallow(<Grid + const wrapper = shallow( + <Grid cells={initVal.map((val) => ({ value: val, - modifiable: false + modifiable: false, }))} onChange={() => ({})} - />); + /> + ); const game = wrapper.instance(); expect(game.checkBlocks()).toStrictEqual([0, 1, 2, 9, 10, 11, 18, 19, 20]); @@ -652,13 +680,15 @@ describe("checkBlocks", () => { "1","8","7","5","2","9","","","3", "2","3","4","6","1","8","7","9","5", "","6","5","7","4","3","1","8","2"] - const wrapper = shallow(<Grid + const wrapper = shallow( + <Grid cells={initVal.map((val) => ({ value: val, - modifiable: false + modifiable: false, }))} onChange={() => ({})} - />); + /> + ); const game = wrapper.instance(); expect(game.checkBlocks()).toStrictEqual([]); @@ -683,13 +713,15 @@ describe("checkCells", () => { "","","","","","","","","", "","","","","","","","","", "","","","","","","","",""] - const wrapper = shallow(<Grid + const wrapper = shallow( + <Grid cells={initVal.map((val) => ({ value: val, - modifiable: false + modifiable: false, }))} onChange={() => ({})} - />); + /> + ); const game = wrapper.instance(); expect(game.checkCells()).toStrictEqual([]); @@ -710,13 +742,15 @@ describe("checkCells", () => { "1","8","7","5","2","9","6","4","3", "2","3","4","6","1","8","7","9","5", "9","6","5","7","4","3","1","8","2"] - const wrapper = shallow(<Grid + const wrapper = shallow( + <Grid cells={initVal.map((val) => ({ value: val, - modifiable: false + modifiable: false, }))} onChange={() => ({})} - />); + /> + ); const game = wrapper.instance(); expect(game.checkCells()).toStrictEqual([]); @@ -736,13 +770,15 @@ describe("checkCells", () => { "1","8","7","5","2","9","","","3", "2","3","4","6","1","8","7","9","5", "","6","5","7","4","3","1","8","2"] - const wrapper = shallow(<Grid + const wrapper = shallow( + <Grid cells={initVal.map((val) => ({ value: val, - modifiable: false + modifiable: false, }))} onChange={() => ({})} - />); + /> + ); const game = wrapper.instance(); expect(game.checkCells()).toStrictEqual([]); @@ -762,13 +798,15 @@ describe("checkCells", () => { "1","8","7","5","2","9","6","4","3", "2","3","4","6","1","8","7","9","5", "9","6","5","7","4","3","1","8","2"] - const wrapper = shallow(<Grid + const wrapper = shallow( + <Grid cells={initVal.map((val) => ({ value: val, - modifiable: false + modifiable: false, }))} onChange={() => ({})} - />); + /> + ); const game = wrapper.instance(); expect(game.checkCells()).toStrictEqual([]); @@ -788,13 +826,15 @@ describe("checkCells", () => { "1","8","7","5","2","9","","","3", "2","3","4","6","1","8","7","9","5", "","6","5","7","4","3","1","8","2"] - const wrapper = shallow(<Grid + const wrapper = shallow( + <Grid cells={initVal.map((val) => ({ value: val, - modifiable: false + modifiable: false, }))} onChange={() => ({})} - />); + /> + ); const game = wrapper.instance(); expect(game.checkCells()).toStrictEqual([0, 1]); diff --git a/single-player/src/components/Grid.tsx b/single-player/src/components/Grid.tsx index 2e8799f7f2caf6efcbfc41ad616ed12e36ca86ac..5cd83127c56d061e80bf7253623dfb25338ff499 100644 --- a/single-player/src/components/Grid.tsx +++ b/single-player/src/components/Grid.tsx @@ -1,7 +1,7 @@ /** * MIT License * - * Copyright (c) 2020, Concordant and contributors + * Copyright (c) 2022, Concordant and contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -39,7 +39,7 @@ interface IGridProps { * This class represent the grid of the Sudoku */ class Grid extends React.Component<IGridProps> { - errors : boolean[] = new Array(81).fill(false); + errors: boolean[] = new Array(81).fill(false); handleChange(index: number, value: string): void { this.props.onChange(index, value); @@ -120,7 +120,7 @@ class Grid extends React.Component<IGridProps> { * Check if a line respect Sudoku lines rules. * @param line The line number to be checked. */ - checkLine(line: number): boolean { + checkLine(line: number): boolean { assert.ok(line >= 0 && line < 9); const cpt = Array(9).fill(0); for (let column = 0; column < 9; column++) { @@ -231,7 +231,7 @@ class Grid extends React.Component<IGridProps> { * Check if all cells respect Sudoku rules and update cells. * @param cells Current cells values. */ - checkAll(): boolean { + checkAll(): boolean { let errorIndexList = this.checkLines(); errorIndexList = errorIndexList.concat(this.checkColumns()); errorIndexList = errorIndexList.concat(this.checkBlocks()); diff --git a/single-player/src/components/Header.tsx b/single-player/src/components/Header.tsx index fab0cb2786dd2553ccc7fdb5bb7ea5bbd31b20cb..88221b85f3ea2f930a598f8eef8d63d0cebb0b6c 100644 --- a/single-player/src/components/Header.tsx +++ b/single-player/src/components/Header.tsx @@ -1,7 +1,7 @@ /** * MIT License * - * Copyright (c) 2020, Concordant and contributors + * Copyright (c) 2022, Concordant and contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/single-player/src/index.css b/single-player/src/index.css index fd4309ad1960fc2a61eb9903862c62c578ab40b5..a0abc9812662aaa5501da4afde8500401cdc0946 100644 --- a/single-player/src/index.css +++ b/single-player/src/index.css @@ -1,7 +1,7 @@ /** * MIT License * - * Copyright (c) 2020, Concordant and contributors + * Copyright (c) 2022, Concordant and contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/single-player/src/index.tsx b/single-player/src/index.tsx index 0bcde47c6e496f92b8a6bd8d5cb6533775129d2a..0716529195ab6276f2cabc18ecc28d4ced0efec0 100644 --- a/single-player/src/index.tsx +++ b/single-player/src/index.tsx @@ -1,7 +1,7 @@ /** * MIT License * - * Copyright (c) 2020, Concordant and contributors + * Copyright (c) 2022, Concordant and contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal