2.0.0 • Published 7 years ago
connect4-lib v2.0.0
Connect Four Library []
(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.