Created
April 19, 2023 12:12
-
-
Save ironboy/c7ad4ecb0acdd1d463ef288376710aa9 to your computer and use it in GitHub Desktop.
Straights.... (pokerhand test - example loop)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ranks = '23456789TJQKA'; | |
const suits = '♥♦♣♠'; | |
// Fake class for hand | |
// replace with importing real class | |
class Hand { | |
constructor() { | |
console.log([...arguments]) | |
} | |
} | |
// Move to straight test | |
for (let suit of suits) { | |
for (let rank of 'A23456789T') { | |
let ranksForHand = ''; | |
if (rank === 'A') { ranksForHand = 'A2345'; } | |
else { | |
let index = ranks.indexOf(rank); | |
ranksForHand += ranks.slice(index, index + 5); | |
} | |
new Hand(...[...ranksForHand].map(x => suit + x)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment