Texas Holdem Hand Ranker
This component ranks poker hands. For example, you can give it an array of hands and it resolves the winning one for you.
Installation
npm install holdemhandranker --save
Usage
HoldemRanker presents very simple API. The API has two methods:
HoldemRanker.valueOfHand(communityCards, holeCards)
Returns a representation of the value of given hand
@param {Array(5)} communityCards - Array of five cards on board
@param {Array(2)} holeCards - Array of two cards player is holding
@returns {Object} - Returns object containing info about the hand (see examples)
HoldemRanker.getWinners(communityCards, arrayOfHoleCards)
Given an array of hands, returns the winning hands. If one hand is superior to all the rest,
return value is Array(1). Otherwise Array(x) where x is num of hands sharing the win.
@param {Array(5)} communityCards - Array of five cards on board
@param {Array(x)} arrayOfHoleCards - Array of hand objects of each player's hole cards
@returns {Array} - Returns Array containing winning hands (see examples)
- Note: hand object is simply a object with at least two keys: id and cards.
Examples
Example: valueOfHand
var handRanker = ; var handValue = handRanker; todeep;
Example: getWinners (1)
var handRanker = ; var winningHands = handRanker; // winningHands is now Array of hands that share the win.// Using passed-in hand objects with 'id'-keys we can now check which player won. // One winnerto;// P4 winsto;
Example: getWinners (2)
var handRanker = ; var winningHands = handRanker; // Two winnersto;// P2 and P3 winvar winnerIDs = _todeep;
Tests
Uses Mocha. Run:
npm test
Dependencies
Uses Lodash as only depedency.
MIT License and so on
Todo:
- Ranking hands from best -> worst (currently only returns best hand(s))
- Async hand resolving?
- Omaha hand resolving?