poker-odds-calc icon indicating copy to clipboard operation
poker-odds-calc copied to clipboard

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

Open Utkarsh-1803 opened this issue 5 months ago • 0 comments

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.

Utkarsh-1803 avatar Jan 30 '24 12:01 Utkarsh-1803