goldfire / pokersolver

Javascript poker hand solver.
MIT License
373 stars 93 forks source link

Adding Support for Wild Cards and More Games #2

Closed wschmrdr closed 8 years ago

wschmrdr commented 8 years ago

James, I know you have been looking to add Video Poker and other games to CasinoRPG. As a community contribution, I would like to offer an update to your pokersolver that handles different games with different rules.

UPDATE SUMMARY: Added support for Jokers, notated here as 'Or' Added support for Wild Cards in general, as deuces may be considered wild. Added Game class to tell Hand what rule set to use. Added game support: Jacks or Better, Joker Poker, Deuces Wild, Three Card Poker, Four Card Poker, Pai Gow Poker. Added new hand solvers to account for new possible hands. Added Pai Gow Poker Helper class to support Pai Gow Poker rules. Unit tests are included for all games expected to be played.

goldfire commented 8 years ago

Wow, this is fantastic! I'm blown away by this PR and can't fully express how appreciative we are of all of the hard work that clearly went into this. We've been talking about wanting support for wilds and other game types, but weren't sure if we'd have time to get it implemented anytime soon with everything else we've got going on, so now that question has been answered :smile:

I've done some basic cleanup and also tweaked the API so that the game type was optional and only needed to be entered as a string and added it to https://github.com/goldfire/pokersolver/tree/wschmrdr-add_joker_support.

Before merging this in, I'm curious on what you think about splitting Pai Gow support into its own file that depends on pokersolver.js so that it is a little more modular.

wschmrdr commented 8 years ago

Glad to be of help with the project. I've been looking for ways to give back to the open source development community, and I'm happy to have the opportunity here. :)

Changes look just fine. :)

Regarding the Pai Gow support, I was a little torn on whether or not I should put this into a different file myself. I chose what I did on the basis of how intertwined it is with everything else in pokersolver.js before I even started developing Pai Gow Poker. Obviously usage of require.js handles most of that, but I had to take into account values, which PaiGowPokerHelper uses, but isn't in any class. I can fully understand separating it and finding a way to get values accessible by both files, as pokersolver.js is over 1000 lines. I'd be happy with either way.

goldfire commented 8 years ago

That is true, I think it might make sense to break it up some more in a future update, but this seems to work great as-is right now. Thanks again, really great contribution!