1.0.0 • Published 10 months ago

winning-hand v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
10 months ago

Poker Hand Evaluation Functions

This code provides several functions to evaluate poker hands. Each function checks for a specific hand combination and returns a Boolean value indicating whether the hand contains that combination or not.

Functions

hasStraight(hand)

Checks if the given hand contains a straight, which is a sequence of five cards in consecutive order.

  • Parameters:

    • hand (Array): An array of card values representing a poker hand.
  • Returns:

    • Boolean: true if the hand contains a straight, false otherwise.

hasOfAKind(hand)

Checks if the given hand contains a set of cards with the same value, also known as "of a kind."

  • Parameters:

    • hand (Array): An array of card values representing a poker hand.
  • Returns:

    • Number: The highest count of cards with the same value in the hand.

hasFullHouse(hand)

Checks if the given hand contains a full house, which consists of three cards of one value and two cards of another value.

  • Parameters:

    • hand (Array): An array of card values representing a poker hand.
  • Returns:

    • Boolean: true if the hand contains a full house, false otherwise.

hasFlush(hand)

Checks if the given hand contains a flush, which is a set of five cards of the same suit.

  • Parameters:

    • hand (Array): An array of card values representing a poker hand.
  • Returns:

    • Boolean: true if the hand contains a flush, false otherwise.

Usage

The provided functions can be used to evaluate poker hands by passing an array of card values representing the hand to the respective function.

Example usage:

const hand = ['AH', '2H', '3H', '4H', '5H'];

console.log(hasStraight(hand)); // Output: true
console.log(hasOfAKind(hand)); // Output: 1
console.log(hasFullHouse(hand)); // Output: false
console.log(hasFlush(hand)); // Output: true
1.0.0

10 months ago