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

open-hand-tracker

v1.0.9

Published

A package for creating and managing poker hand histories

Downloads

630

Readme

Open Hand History

A TypeScript library for creating and managing poker hand histories following the Open Hand History standard.

Installation | Quick Start | API Reference | Development | Contributing

Installation

npm install open-hand-tracker

Quick Start

import { OpenHandHistory } from 'open-hand-tracker';

// Initialize hand history
const ohh = new OpenHandHistory({
  siteName: 'MyPokerSite',
  tableSize: 6
  // other properties...
});

// Add a player
ohh.addPlayer({
  name: 'Player 1',
  id: 1,
  starting_stack: 1000,
  seat: 1
});

// Add a round
ohh.addRound({
  id: 1,
  street: 'PREFLOP',
  actions: []
});

// Add action to round
ohh.addActionToRound(1, {
  action_number: 1,
  player_id: 1,
  action: 'RAISE',
  amount: 100
});

// Calcuatle winnings
win_amount = ohh.calculateWinningAmount(1, 50); // Pass the player ID 

// Add pot 
ohh.addPot({
  number: 1,
  amount: 50,
  player_wins: [{ player_id: 1, win_amount: win_amount }],
});

// Get JSON representation
ohh.getJSON()

// Save to file
ohh.saveToFile('hand_history.json');

API Reference

OpenHandHistory

Constructor Options

{
  specVersion?: string;         // Default: '1.4.6'
  internalVersion?: string;     // Default: '1.4.6'
  networkName?: string;         // Default: 'CustomGame'
  siteName?: string;            // Default: 'HomeGame'
  gameType?: string;            // Default: 'Holdem'
  tableName?: string;           // Default: 'Sample Table'
  tableSize?: number;           // Default: 3
  gameNumber?: string;          // Default: '1'
  startDateUTC?: string;        // Default: current date
  currency?: string;            // Default: 'Chips'
  anteAmount?: number;          // Default: 0
  smallBlindAmount?: number;    // Default: 1
  bigBlindAmount?: number;      // Default: 2
  betCap?: number;              // Default: 0
  betType?: string;             // Default: 'NL'
  dealerSeat?: number;          // Default: 1
  heroPlayerId?: number;        // Default: 0
}

Methods

addPlayer(player: Player): void

Add a player to the hand history.

interface Player {
  name: string;
  id: number;
  starting_stack: number;
  seat: number;
  cards?: string[];
}
addRound(round: Round): void

Add a new round to the hand history.

interface Round {
  id: number;
  cards?: string[];
  street: "Preflop" | "Flop" | "Turn" | "River" | "Showdown"
  actions: Action[];
}
addActionToRound(roundId: number, action: Action): void

Add an action to a specific round.

interface Action {
  action_number: number;
  player_idd: number;
  action: string;
  amount?: number;
  is_allin?: boolean;
}
addPot(pot: Pot): void

Add a pot to the hand history.

interface Pot {
  rake?: number;
  number: number;
  amount: number;
  player_wins: { player_id: number; win_amount: number }[];
}
calculateWinningAmount(player_id: number, totalPot: number): number

Calculates the winners winnings

toJSON(): string

Convert the hand history to JSON string.

saveToFile(filename: string): void

Save the hand history to a file.

Development

Setup

git clone https://github.com/yourusername/open-hand-history.git
cd open-hand-history
npm install

Testing

npm test

Building

npm run build

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

MIT