Skip to content

Guaxinim5573/connect4

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Connect4

Small package to easily make connect 4 games in your project.

Connect4 Jogo

Connect4 Gameplay

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

Sumary

Install

With npm

npm install git+https://github.com/Guaxinim5573/connect4.git

Examples

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

Contributors

Guaxinim

5antos

About

Connect 4 game in JS and Discord

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published