siavashg87 / poker-odds-calc

Fastest and most accurate node module for calculating odds of poker games Texas Hold'em, Texas Shortdeck/Sixplus and Omaha.
MIT License
91 stars 32 forks source link

Identified Issue and Suggested Fix in Odds Calculation Tool (5 Card Omaha Variant) #15

Open Utkarsh-1803 opened 9 months ago

Utkarsh-1803 commented 9 months ago

I want to express my appreciation for the excellent work on the odds calculation tool. It has proven to be a valuable asset in our poker-related endeavors. During our usage, we encountered a potential flaw in the tool, specifically in the handling of 5-card Omaha scenarios. After a thorough investigation, we believe we have identified a particular code segment that may be causing an unintended error.

In the Player.js file, located at the path /poker-odds-calc/dist/lib/Player.js, we observed the following lines of code:

setHand(hand) {
    const game = this.Table.getGame();
    if ((game.isTexasHoldem() || game.isSixPlusTexasHoldem()) && hand.length !== 2)
        throw new Error("A Texas hold'em hand must contain exactly 2 cards!");
     if (game.isOmaha() && hand.length !== 4)
        throw new Error("An Omaha hand must contain exactly 4 cards!");
    this.hand = hand.map(c => {
        const card = this.Table.getDeck().getCards().find(card => card.toString() === c);
        if (!card)
            throw new Error(`Card "${c}" not found!`);
        return card.setOwner(this);
    });
    return this;
}

We believe that the condition checking for the length of the hand in Omaha games might be causing unnecessary issues. To address this, we suggest commenting out the relevant lines, as shown below:

setHand(hand) {
    const game = this.Table.getGame();
    if ((game.isTexasHoldem() || game.isSixPlusTexasHoldem()) && hand.length !== 2)
        throw new Error("A Texas hold'em hand must contain exactly 2 cards!");
   // Commenting out the condition for Omaha hand length
    //  if (game.isOmaha() && hand.length !== 4)
       // throw new Error("An Omaha hand must contain exactly 4 cards!");
    this.hand = hand.map(c => {
        const card = this.Table.getDeck().getCards().find(card => card.toString() === c);
        if (!card)
            throw new Error(`Card "${c}" not found!`);
        return card.setOwner(this);
    });
    return this;
}

This modification allows for a smoother handling of 5-card Omaha scenarios. We hope you find this information helpful in maintaining and improving the overall functionality of the odds calculation tool.