1game-texas-holdem
v1.12.1
Published
Texas Hold'em developed in NodeJS by 1game
Downloads
84
Readme
Texas Hold'em by 1game
Installation
npm i 1game-texas-holdem --save
Usage
import the library
var th = require('1game-texas-holdem');
starts a sample game
// sample game supports 0-11 players
var numOfPlayers = 5;
// API - `sample`
var new_sample = th.sample(numOfPlayers);
// reveal the Board
// sample game stores the Board as an array of 5 Cards.
var board = new_sample.board;
console.log('The Board: ', board);
// reveal the players' Hands
// sample game stores the players' Hands in a two-dimensional array.
var hands = new_sample.hands;
console.log('The Hands: ', hands);
// reveal the 5th Player's Hands
var playerIndex = 4;
var pHands = [ hands[0][playerIndex], hands[1][playerIndex] ];
console.log('The 5th Player\'s Hands: ', pHands);
counting
// after you retrieve the Hands and the Board.
// API - `rule` -> `count`
var input = pHands.concat(board);
var output = th.rule.count(input);
// show what the player hits
console.log(output.rank);
// show the related indexs of the `best` five cards.
console.log(output.ix);
// construct the value string
var val = th.rule.value(input, output);
console.log(val);
API
poker
- SuitNames (Suits' Names)
- StSuitNames (ShortNames for SuitNames)
- RankNames (Ranks' Names)
- StRankNames (ShortNames for RankNames)
- Suits (4 Suits)
- Ranks (13 Ranks from Ace to Two)
- Deck (52 Cards in initial order)
- Card (Card prototype)
- Rank (Rank prototype)
rule
- count (5 to 7 card hands evaluation)
- rankings (Names for Hand Ranks)
- value
sample
a simple game structure