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 🙏

© 2025 – Pkg Stats / Ryan Hefner

skiano.president

v1.1.4

Published

Implementation of card game president

Readme

President

An implementation of the cardgame President.

Installation

$ npm install skiano.president

The Rules

This describes the rules as implemented, ignoring other variations

  • Setup

    • Between 3 and 8 players
    • All cards are dealt to players (as evenly as possible)
    • Players can only see their own hand
    • Whoever has the 4 of clubs begins by placing it on the table (automatic)
    • Gameplay rotates through the players (beginning clockwise)
  • Goals

    • Players are trying to get rid of all their cards
    • Players exit the game when the run out of cards
    • The last player holding cards looses
  • Rules

    • You can play a single card or multiples if they are all the same numeric value
    • You must always play an equal or higher value than the preivious play
    • Value follows this heirarchy
      • Ace is high
      • Higher numbers are more valuable: 4 > 3 and [4,4] > [3,3]
      • Doubles are higher than singles, tripples higher than doubles: [4,4,4,4] > [9,9] > 13
    • If you play the same value as the previos player, the next player is skipped
    • No matter what, you can always play a 2 or 3
    • Playing a 2 resets the table to the lowest value
    • Playing a 3 reverses the direction of gameplay
    • If you cannot play a higher card you must pass
    • If all the players pass (full circle) the table is cleared.
    • When the table is cleared the following player may play anything they have

The interface

Running a single game

president is a function that takes players creators, runs them to create players, and returns the result of one game.

var president = require('skiano.president');
var createPlayer = require(/* your player creator */);
var results = president(createPlayer, createPlayer, createPlayer);
  • results {object} the result of a single game. It has the following properties:
    • winner {string} The id of the winning player
    • rank {list} A list of player ids sorted from winner to loser
    • events {list} The complete history of the game

Creating a Player

To play the game, you create a function that returns a player function. The player function will be called for each game event. When it is your turn you may return cards from your hand. (more on this below)


function createPlayer(setName) {
  setName('myStrategy')

  return function player(isMyPlay, myView) {
    if (isMyPlay) {
    } else {
    }
  }
}
  • setName {function} (optional) allows you to set a custom name prefix for your player

  • isMyPlay {boolean} lets you know if you need to play

  • myView {object} a snapshot of the game with the following properties:

    • hand {list} The cards you currently hold
    • players {number} The number of players still in the game (including you)
    • table {array} The card(s) on the table. There are times when the array is empty
    • getValidPlays {function} returns all valid plays for your current hand

Note: myView does not expose the history of the game to you. So if you are interested in using previous plays in your strategy you must collect the data you want within createPlayer()

The Deck

Cards are represented as strings. Face cards are represented by their numerical value. Your hand is a list of card strings. For Example:

var yourHand = ['4h','11d','2s','14c'];

Represents the following:

  • Four of hearts
  • Jack of Diamonds
  • Two of Spades
  • Ace of clubs