npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

amaurycoudr-checkers

v2.9.20

Published

checkers game

Downloads

12

Readme

Checkers Project


test coverage : | Statements | Branches | Functions | Lines | | --------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | | Statements | Branches | Functions | Lines |

the purpose of this package is to offer a simple api to be able to play to the checkers

:warning: For the moment the work is still in progress

CheckersParty

To start a party you only need to create a new instance of CheckersParty

const party = new CheckersParty(options);

To specify the rules of your party you can pass an object options.

party options

  • firstPlayer : "white" | "black"
    • The first player to play.
    • default = "white"
  • boardSize : 10 | 8
    • The Board size.
    • default = 10
  • shouldCatchPiecesMaximum : boolean
    • decides if player must capture the maximum possible number of pieces
    • default = true
  • shouldPromoteWhenMoveEnding: boolean
    • decides if pieces promote only when ending their move on the final rank
    • default = true

party.getState()

To access the state of the party you can use the method getState() this returns an object of this format :

{
  "board": {
    "A1": { "type": "Pawn", "player": "white" },
    "C1": { "type": "Pawn", "player": "white" },
    "E1": { "type": "Pawn", "player": "white" },
    "G1": { "type": "Pawn", "player": "white" },
    "I1": { "type": "Pawn", "player": "white" }
  } /* here only the first line is shown */,
  "playerTurn:": "white",
  "plays": [
    { "from": "B4", "to": "A5" },
    { "from": "B4", "to": "C5" },
    { "from": "D4", "to": "C5" },
    { "from": "D4", "to": "E5" },
    { "from": "F4", "to": "E5" },
    { "from": "F4", "to": "G5" },
    { "from": "H4", "to": "G5" },
    { "from": "H4", "to": "I5" },
    { "from": "J4", "to": "I5" }
  ]
}

:information_source: This is the result of party.getState() at the first turn

party.play(move: Movement)

Take in argument the move you want to play like { "from": "B4", "to": "A5" }. Return the state of the party (the new result for party.getState()).

getCoordinate()

An helper is provide to handle the conversion from (x,y) to te format "A1", "C3"...

const coordinate = getCoordinate(3, 2);
// coordinate === D3

Road map to functional version

  1. ~~implements a notion of options to let user choses specific rules~~
  2. ~~implements the first play option~~
  3. ~~implements the maximum catch rule~~
  4. ~~implements the fact that promote only when ending their move on the final rank~~
  5. ~~implements the win notion~~
  6. ~~correct bug can eat after travel~~
  7. ~~correct bug winner~~
  8. ~~correct bug queen transformation~~
  9. ~~correct queen movement~~
  10. ~~implements the draw notion~~
  11. ~~handle case player can't make any play~~