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

@akomar812/craps

v3.0.4

Published

text based module for playing craps directly at the command line or for importing into other modules for single/multiplayer play

Downloads

15

Readme

Build

Contents

  1. Description
  2. System Requirements
  3. Installation
  4. Usage
  5. Game

Description

Craps game that can be installed directly and played as a command line game or imported as a 3rd party module which can be played with multiple players such as in a discord server

System Requirements

node.js (+12.0.0)
sqlite3

Installation

There are several ways to install and use this module depending on how you plan to use it. Pick one of the following methods based on your needs

From npm for use as import

npm install --save @akomar812/craps

From npm for playing on CLI

npm install -g @akomar812/craps

From git repo for playing on CLI

# clone repo and cd into it
npm install -g .

Usage

To play as CLI

Run:

craps

You should be met with the message:

player connected to craps table...
>

To import as node_module

  const game = await require('@akomar812/craps')(<opts>);
  let craps;

  craps = await game(<player>, <cmd>, <messageFn>);

  // e.g workflow: join, withdraw money, bet it on the pass line, and roll the dice
  craps = await game('player', 'join', console.log);
  craps = await game('player', 'bank withdraw 100', console.log);
  craps = await game('player', 'bet pass 100', console.log);
  craps = await game('player', 'roll', console.log);

Where:

  • <player> is the name of a player
  • <cmd> is a command from the api below
  • <messageFn> is the function you want the game to call to send output to the client
  • <opts> has the following configuration options:
  {
    dbTarget: <string (default: ":memory:")>
    // path for sqlite data file if storing data on disk
    // e.g. "var/data/db"

    dbLogStream: <object (default: process.stdout)>
    // object who's `write` method get's called when DB creates logs
    // e.g require("fs").createReadStream(`var/log/db.${someNameFunc()}.log`, { flags: 'a' });

    prefix: <string (default: "")>
    // prefix string in front of all cmds
    // e.g. "!" requires all cmds to be run with !, for example !roll
  }

Discord bot

Use this if you want to use this library as a pre-made, multi-player discord bot

https://github.com/akomar812/discord-craps

Game

  • Start game or join current game by running: join
  • There must be at least one bet on the table before the shooter can roll
  • If a player or shooter is inactive for 5 minutes they will be booted
  • New and returning players need to fetch their money from the bank in order for it to be available for wagering on the table. Players can take their winnings off of the table and store in the bank at any time. Any money on the table will automatically be banked when the player exits

Commands

exit
# Leaves game if joined, and all wagers are wiped away. The
# player's pot is automatically deposited in the bank on exit
help
# Show text interface documentation in interface display
dice
# Show possible dice rolls, chance of occurring and ways of
# occurring
status
# Shows the current state of the game
join
# Joins an active craps game or starts one if none is available
bet [name] [amount]
# Submit a wager against a bet
roll
# Roll the dice if you are the shooter. At least one wager must be
# submitted before the shooter can roll
reset cash
# Adds $100 to the caller's pot if they've fallen below $100
bank
# Displays information about the money in the bank including user
# balances and high scores
bank [action] [amount]
# Actions are `withdraw`/`deposit`. The bank is used to add/remove
# money from the table to be stored in user's personal bot.

TODO

  • Bets that still need to be implemented:
    • come
    • dont come
    • buy
    • lay