|
| 1 | +import React, { useState } from 'react'; |
| 2 | +import { |
| 3 | + Button, |
| 4 | + Card, |
| 5 | + Container, |
| 6 | + Divider, |
| 7 | + Image, |
| 8 | + Message, |
| 9 | +} from 'semantic-ui-react'; |
| 10 | +import SudokuBaseEx from 'assets/sudoku_example.jpg'; |
| 11 | +import SudokuSolutionEx from 'assets/sudoku_example_1.jpg'; |
| 12 | +import InvitationPopup from './InvitationPopup'; |
| 13 | +import { v4 as uuidv4 } from 'uuid'; |
| 14 | +import { useHistory } from 'react-router'; |
| 15 | +import { useUserContext } from 'contexts/WithUserProfile'; |
| 16 | + |
| 17 | +const Introduction = () => { |
| 18 | + const [showModal, setShowModal] = useState(false); |
| 19 | + const history = useHistory(); |
| 20 | + const [, , setUserName] = useUserContext(); |
| 21 | + const sessionID = uuidv4(); |
| 22 | + const initiateGame = (userId) => { |
| 23 | + setUserName(userId); |
| 24 | + history.push(`start/${sessionID}`); |
| 25 | + }; |
| 26 | + return ( |
| 27 | + <Container> |
| 28 | + <Message size="big"> |
| 29 | + <Message.Header> |
| 30 | + <div className="flex justify-between"> |
| 31 | + <span className="text-3xl">Rules of Twodoku</span> |
| 32 | + <Button primary size="large" onClick={() => setShowModal(true)}> |
| 33 | + Start Game |
| 34 | + </Button> |
| 35 | + </div> |
| 36 | + </Message.Header> |
| 37 | + <Divider /> |
| 38 | + <p> |
| 39 | + It's like Sudoku, but two people work together to solve a single |
| 40 | + puzzle! |
| 41 | + </p> |
| 42 | + <p> |
| 43 | + Sudoku is a number puzzle game played using 81 squares laid out on a |
| 44 | + 9×9 grid. The grid is further broken down into 9 3×3 boxes. When you |
| 45 | + start a sudoku puzzle, some of the numbers will have already been |
| 46 | + placed. All you have to do is fill in the missing numbers by following |
| 47 | + some simple rules: |
| 48 | + </p> |
| 49 | + <div className="pl-20"> |
| 50 | + <ol className="list-decimal"> |
| 51 | + <li> |
| 52 | + Every box must contain each number 1-9. The boxes are 3×3 grids |
| 53 | + and their outlines are marked with thicker line. |
| 54 | + </li> |
| 55 | + <li>Every row must contain each number 1-9</li> |
| 56 | + <li>Every column must contain each number 1-9</li> |
| 57 | + </ol> |
| 58 | + </div> |
| 59 | + |
| 60 | + <p> |
| 61 | + Each sudoku board has only one solution, which means that each square |
| 62 | + has only one possible correct number. This allows you to use logic to |
| 63 | + find the correct number to place in each square. You can find the |
| 64 | + correct number to write either by eliminating every other number as a |
| 65 | + possibility or by eliminating that number as a possibility in that |
| 66 | + square’s shared row, column, or box. |
| 67 | + </p> |
| 68 | + <p>When you start a puzzle, it will look like something this:</p> |
| 69 | + <Card centered> |
| 70 | + <Image src={SudokuBaseEx} /> |
| 71 | + <Card.Content> |
| 72 | + <Card.Description className="text-center"> |
| 73 | + Some of the squares have values, your job is to fill in the blank |
| 74 | + squares. |
| 75 | + </Card.Description> |
| 76 | + </Card.Content> |
| 77 | + </Card> |
| 78 | + |
| 79 | + <p>When solved, the puzzle will look like this:</p> |
| 80 | + <Card centered> |
| 81 | + <Image src={SudokuSolutionEx} /> |
| 82 | + <Card.Content> |
| 83 | + <Card.Description className="text-center"> |
| 84 | + Notice how every row, column, and box contains every number 1-9. |
| 85 | + </Card.Description> |
| 86 | + </Card.Content> |
| 87 | + </Card> |
| 88 | + <p> |
| 89 | + Sudoku instructions were written by{' '} |
| 90 | + <a href="http://www.sudokubeginner.com/rules-of-sudoku/"> |
| 91 | + sudokubeginner.com |
| 92 | + </a> |
| 93 | + </p> |
| 94 | + </Message> |
| 95 | + <InvitationPopup |
| 96 | + open={showModal} |
| 97 | + onClose={() => setShowModal(false)} |
| 98 | + onStart={initiateGame} |
| 99 | + uuid={sessionID} |
| 100 | + /> |
| 101 | + </Container> |
| 102 | + ); |
| 103 | +}; |
| 104 | +export default Introduction; |
0 commit comments