2.0.0 • Published 7 years ago

connect4-lib v2.0.0

Weekly downloads
2
License
ISC
Repository
github
Last release
7 years ago

Connect Four Library [Build Status]

(https://travis-ci.org/jennypenfield/connect-four-lib)

This is a project to implement the game logic for the classic game Connect Four.

This is a collaborative project of the students of the The Iron Yard Houston front-end class.

Development Setup

Install Yarn, then from this directory:

# install node_modules folder
yarn install

# run the test suite
yarn test

API Documentation

Connect4Lib.EMPTY_BOARD

Creates a 7x6 array of null elements.

The Connect4 Library has two public functions:

gameStatus(board)

  • This method needs to receive an array (the 'board') as an argument.
  • The library uses a private method to determine the board's winning coordinates.

This method returns:

  • {status: 'winner_red', coordinates: coord} if there is a red winner.
  • {status: 'winner_yellow', coordinates: coord} if there is a yellow winner.
  • {status: 'tie'} or {status: 'in_progress'}, depending on the current status of the game.

validBoard(board)

This method needs to receive an array (the 'board') as an argument. The method returns false if the board passed is not an array, if the board does not have seven columns, or if the rows are invalid. The method returns true if preceding conditions are not met.

License

ISC License