goldfire / pokersolver

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

h.qualifiesHigh is not a function #25

Closed Swidjit closed 2 years ago

Swidjit commented 2 years ago

Hand.solve() seems to be working fine, but when trying to compare hands with Hand.winners(), I get the following error: 'h.qualifiesHigh is not a function'

console.log(hand1, hand2) // ['9h', '4s', '5s', 'Ts', '7d', 'Jh', 'Jc'] (7) ['9h', '4s', '5s', 'Ts', '7d', 'As', 'Ks']

console.log(Hand.solve(hand1), Hand.solve(hand2)) // OnePair {cardPool: Array(7), cards: Array(5), suits: {…}, values: Array(11), wilds: Array(0), …} // Flush {cardPool: Array(7), cards: Array(5), suits: {…}, values: Array(14), wilds: Array(0), …}

console.log(Hand.winners([hand1, hand2])) // TypeError: h.qualifiesHigh is not a function

error seems to stem from the following lines of code

  hands = hands.filter(function(h) {
    return h.qualifiesHigh();
  });
Swidjit commented 2 years ago

Oops, I see what I was doing wrong - passing a raw hand array, rather than the results of Hand.solve(). My bad.