Home

Awesome

Texas Holdem Poker

This is the module for creating own Texas Holdem poker game! It allows you to track cards, compose hands, compare hands by combination and even calculate draw combinations.

Browsers support

Since version 0.2.2 tx-holdem is available for browsers! See demo app

import * as txHoldem from 'tx-holdem/browser';
// OR
var txHoldem = require('tx-holdem/browser');

Usage

Compare combinations:

const { Pack, Hand } = require('tx-holdem');

const pack = new Pack();

const pairHand = new Hand(
	pack.createCard('clubs', 3),
	pack.createCard('diamonds', 3)
);
const fourOfAKindHand = new Hand(
	pack.createCard('clubs', 4),
	pack.createCard('diamonds', 4),
	pack.createCard('hearts', 4),
	pack.createCard('spades', 4),
);

const pairIsLower = pairHand.compare(fourOfAKindHand) === -1;
console.log('Pair is lower than four of a kind:', pairIsLower);

Select highest combination from two hands (board and pocket cards):

const { Pack, Hand, HandsCollection } = require('tx-holdem');

const pack = new Pack();

const board = new Hand([
	pack.createCard('clubs', 5),
	pack.createCard('diamonds', 6),
	pack.createCard('spades', 8),
	pack.createCard('hearts', 2),
	pack.createCard('hearts', 9),
]);

const pocket = new Hand([
	pack.createCard('spades', 7),
	pack.createCard('spades', 9),
]);

const coll = HandsCollection.createCombinations(board, pocket);

console.log('Highest is', coll.highestCombination.name);

API

Card

Methods:

Properties:

Hand

Methods:

Properties:

Pack

Methods:

Properties:

HandsCollection

Methods:

Properties:

DrawCombination

Properties:

Combination

Methods:

Properties: