Git Product home page Git Product logo

dotsandboxes's Introduction

Netlify Status Storybook

DotsAndBoxes

The dots and boxes game made in react.

In storybook you can view all components used to make this game and play with knobs to understand their behaviour.

Requirements

Creating the game dots and boxes. Players take turns joining two horizontally or vertically adjacent dots by a line. A player that completes the fourth side of a square (a box) colors that box and must play again. When all boxes have been colored, the game ends and the player who has colored more boxes wins.

Approach

Game constitutes mainly of grid. The grid is made up of smaller blocks GridBlock(component). It composed of a box div (component) with a bar div (component) one on its left and another on its top. ( you can view these in storybook for better understanding )

These GridBlocks put side-by-side create rows and columns for Grid. When a user clicks on a bar in a GridBlock we dispatch an action UPDATE_GRID with payload { row, column, type }. Row and column define the position of GridBlock and type tells is it the top bar or left bar of the GridBlock. Based on if it is bar on top or bar on left of GridBlock we check if enabling this bar leads to completion of current box or adjacent boxes. We swap turns and wait until total score of both players becomes equal to max score possible and finish the game.

Technologies used

  1. React ( hooks, useReducer used to setup Redux like action, reducer lifecycle. )
  2. Storybook - can be used to view all basic components used to create app.
  3. Netlify for deployment
  4. Travis CI for continuous integration - It runs tests and check if the build is stable.

Getting started

  1. npm start To run the app in the development mode . Browse to http://localhost:3000 to view it in the browser. The page will reload if you make edits. You will also see any lint errors in the console.

  2. npm test Launches the test runner in the watch mode. It will run the following - a) unit tests - For actions, reducers and utils using jest. b) snapshot tests - For structural testing components using storyshot addon of storybook.

  3. npm run build Builds the app for production to the build folder.

  4. npm run storybook To start the storybook development server.

dotsandboxes's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.