Small package to easily make connect 4 games in your project.
Connect 4 is a two-player connection board game, in which the player choose a colorand then take turns dropping colored discs into a seven-column, six-row vertically suspended grid. The objective of the game is to be the first to form a horizontal, vertical, or diagonal line of four of one's own discs. Read more in Wikipedia
With npm
npm install git+https://github.com/Guaxinim5573/connect4.git
const {Game} = require("connect4")
const game = new Game("player 1 name", "player 2 name")
game.insert(0) // Player 1 put a disk in first column
game.insert(6) // Player 2 put a disk in the last column
game.insert(5) // Player 1 put a disk in the 6th column
game.currentPlayer // Player: {name: "player 2 name", id: 1, game: game}
const valid = game.insert(9) // Player 1 make a invalid move
if(!valid) {
// Invalid move
}
game.status // IN_PROGRESS, TIE, WIN
game.winner // Who won the game, if there's a winner
game.board // Game board
Guaxinim
5antos