Luckily, a lot of the time, coding involves modifying someone else's code instead of creating stuff from scratch, so you have the option of looking at what steps are being taken, then thinking of how you can do whatever you want from that point onward. Here's today's code:
Okay, so we (probably) know that a Flush is all cards sharing the same suit. This means that the rank of each card can be anything, without even relative value to each other, meaning each and every one of the cards will count as a tie-breaker in the event of 2 people getting flushes. See Line 218? I didn't think it through and just thought the highest card would matter, the others be damned, so I had that to replace the entire for-loop just underneath. Turns out I was wrong! Let's go through the method then!
Line 214-217: We've seen these lines before. If the flushSuit variable isn't -1, we have a flush, so set the type to that and place it in the ranking array. Then start the loop index at 1.
Lines 219-221: For every card in the given hand, if the card's suit is that of the flush (Just in case! Weird errors -can- pop up), store the card's rank in a variable...
Line 225: Then put the integer representation of that rank into the rankings array.
Lines 222-224: This just makes sure the first card iterated over counts as the highest ranking card!
And the rest, we've seen before! Next up, the Full House.
Okay, so we (probably) know that a Flush is all cards sharing the same suit. This means that the rank of each card can be anything, without even relative value to each other, meaning each and every one of the cards will count as a tie-breaker in the event of 2 people getting flushes. See Line 218? I didn't think it through and just thought the highest card would matter, the others be damned, so I had that to replace the entire for-loop just underneath. Turns out I was wrong! Let's go through the method then!
Line 214-217: We've seen these lines before. If the flushSuit variable isn't -1, we have a flush, so set the type to that and place it in the ranking array. Then start the loop index at 1.
Lines 219-221: For every card in the given hand, if the card's suit is that of the flush (Just in case! Weird errors -can- pop up), store the card's rank in a variable...
Line 225: Then put the integer representation of that rank into the rankings array.
Lines 222-224: This just makes sure the first card iterated over counts as the highest ranking card!
And the rest, we've seen before! Next up, the Full House.
Ooh, look, another short one. This is because the full house, being a triple and a double (damned if I'm typing out the proper name for 'em) fill up the hand, leaving no room for tie-breakers (or as they're called elsewhere, kickers). So no for-loop to go over the cards to extract then! Huzzah.
Line 235: If there's a triple, and a pair...
Line 236: Set the hand type to a full house...
Line 237-239: Then grab the rank of the triple and pair, and add then to the ranking array.
And the rest has become too tedious to type out! But hey, we're done with this for today!
See you tomorrow for more, questions and comments welcome!
Wish I knew as much as you!
ReplyDeleteYou continue to amaze me!
ReplyDelete