Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid Hand Calculations? #9

Closed
1 of 4 tasks
hailwood opened this issue Mar 21, 2018 · 2 comments
Closed
1 of 4 tasks

Invalid Hand Calculations? #9

hailwood opened this issue Mar 21, 2018 · 2 comments
Assignees
Labels

Comments

@hailwood
Copy link
Contributor

hailwood commented Mar 21, 2018

I'm submitting a ...

  • bug report
  • feature request
  • question about the decisions made in the repository
  • question about how to use this project

Summary

Hey @mitch-b,

It looks like we might have an issue with calculating the winning hands.
I only came across this last night at about 1am... so I haven't had a chance to debug it properly, so I'll provide some more information or a PR to fix it tonight but figure depending on your timezone you might get there first. This is using the new poker-hand-details branch, so I'm not sure if it's on the main branch yet.

Try running this game through:

Community cards: 7S 3S 4C 5H 6D
Player 1's name and two cards: Bob 2C 8D
Player 2's name and two cards: Joe 8S 9C

Result:
1 Joe High Card Nine
2 Bob High Card Eight

...what? Shouldn't that be a straight for both players?

`${result.toString()} ${result.scoringHandCardNames.map(cn => CardName[cn]).join(' ')}`
@mitch-b mitch-b self-assigned this Mar 21, 2018
@mitch-b mitch-b added the bug label Mar 21, 2018
@mitch-b
Copy link
Owner

mitch-b commented Mar 21, 2018

You're right ... something's definitely wrong with how it's reporting the hand type.

https://runkit.com/mitch-b/poker-scoring-scratchpad-9

It has the proper value, but the handType is not being set as we'd expect. Strange, and a critical bug, but shouldn't be too hard to dig into. Weird that tests are passing, but in-practice, I can't seem to get the proper result out.

@mitch-b
Copy link
Owner

mitch-b commented Mar 22, 2018

Sorry to keep bundling these into the feature/poker-hand-details branch, but this bug was definitely there, and it was due to improper combination building.

I've adjusted this to use same Combination producing function as elsewhere in the code and it works as I expected. I added a new unit test to capture this.

I will close this issue once this branch gets merged in.

Thanks for your help with this library. 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants