chenosaurus / poker-evaluator

poker hand evaluator
248 stars 58 forks source link

Royal flush is recognized as straight flush #29

Open y0unghe opened 1 year ago

y0unghe commented 1 year ago

I am trying to get a royal flush using below code, but it returned as straight flush. From 10 to A, it's all Spade. It should be royal flush, right?

const evaluator = require('../lib/PokerEvaluator');

const royalFlush = evaluator.evalHand(["As", "Ks", "Qs", "Js", "Ts", "3c", "7h"]);
console.log(royalFlush);
rorymcgit commented 1 year ago

Hi @y0unghe

You’re right, although in this library there is no technical difference between a straight flush and a royal flush, apart from the latter being higher/beating the former.

See hand types here https://github.com/chenosaurus/poker-evaluator/blob/master/lib/PokerEvaluator.js#L16

Technically a royal flush is just the nut straight flush, so I think this is correct, although it would perhaps be an improvement to distinguish between the two.

In any case the library does correctly evaluate your hand beating a (lower) straight flush. If you were to submit a pull request updating the hand rankings I’m sure it would be considered