here are the methods inside this Class:
calculateHand
: it will Calculates the Teen Patti hand based on an array of three cards.import { StandardDeck, CardDeck, TeenPatti } from 'card-games-utils'
let cardDeck = StandardDeck.getStandardDeck()
//logs PURE_SEQUENCE since it's first 3 cards of deck.
console.log(TeenPatti.calculateHand([cardDeck[0], cardDeck[1], cardDeck[2]]))
makeHand
: it will convert the given array of 3 cards into Hand interface.import { StandardDeck, CardDeck, TeenPatti } from 'card-games-utils'
let cardDeck = StandardDeck.getStandardDeck()
//logs the Hand interface's info
console.log(TeenPatti.makeHand([cardDeck[0], cardDeck[1], cardDeck[2]]))
calculateWinners
: it will Calculates the winner from the given array of Hands.import { StandardDeck, TeenPatti } from 'card-games-utils'
let cardDeck = StandardDeck.getStandardDeck()
//logs [0] since it's the highest of hands given
console.log(
TeenPatti.calculateWinners([
TeenPatti.makeHand([cardDeck[0], cardDeck[1], cardDeck[2]]),
TeenPatti.makeHand([cardDeck[3], cardDeck[4], cardDeck[5]]),
TeenPatti.makeHand([cardDeck[6], cardDeck[7], cardDeck[8]]),
])
)
isRankHigher
: it will Calculates the higher ranking hand from given handsimport { StandardDeck, TeenPatti } from 'card-games-utils'
let cardDeck = StandardDeck.getStandardDeck()
//logs true since first card-hand is higher then other
console.log(
TeenPatti.isRankHigher(
TeenPatti.makeHand([cardDeck[0], cardDeck[1], cardDeck[2]]),
TeenPatti.makeHand([cardDeck[3], cardDeck[4], cardDeck[5]])
)
)