Okay, in the receding phase of my migraine, which means I can stick around longer, but I'm still not at full operating capacity! Still, I figure we can get through the huge method, which will actually take a little bit OVER the 2 screenshots I wanted to limit my posts to, but only by like, 2-3 lines.
The reason the method is so large is that it's responsible for the entire round of betting, so there's a big chunk of stuff and a switch statement to boot. Also, switch statements make use of "break;" so that inflates the length of the code a bit.
Here it is:
When you see comments in the code, its when I didn't quite get something on the first go-through, so I just kept the original commentary in. I should be doing this anyway, but eh. I (mostly) take them out for screenshots, then feel too lazy to put them back in, so I'm chucking the blame on you guys.
Line 165 speaks for itself, determining the number of players to act in this round.
While I won't be able to get what these lines do at any later date, lines 166-175 ARE commented, so bear no further mention here!
Line 176 makes use of that method we've seen before, notifying everyone that something happened! (Bets being set in above statements) and line 177 sets the small blind.
Lines 178 onward cover the while loop, which will loop as long as there's still a player to take their turn this round. This basically covers each person's turn in the round, and is huge (more in the next 2 screens!).
First off, lines 179-183 get through the basics. Rotating the actor so the same person doesn't go twice, grabbing a boolean to determine if the player is in the small blind position or not, then telling the player to act, based on the determined list of allowed actions.
Lines 184-190 is a barrier to ensure that the player picks a move in the list of allowed actions. If not, throw the error!
Line 191 just lowers the players left to act by 1, ensuring the loop will eventually end.
Now that we've got all that sorted, we need to go through the switch statement that takes care of whatever action the player picked in the first part of this method!
Okay, lets go through these by case instead of lines!
Case: Check - This is just the act of...not acting. Move on.
Case: Call - Increase the pot by bet amount, unless you're in the small blind position, in which case increase the pot by (bet - small blind), which will be half the bet.
Case: Bet - bet the minimum amount, then increase the pot by that amount. This also means that everyone gets to act again, so that value will be reset for the while loop (line 204)
Case: Raise - Increase the current bet by the minimum to raise, then put that amount into the pot. At this point, if the raise limit hasn't been reached, reset the players to act counter. If the limit HAS been reached, set the acting players to 1 less than everyone (so it doesn't loop back to this player, who's ended their turn).
Case: Fold - Remove all the player's cards, then kick the player off the active players. If you were the second last player, and folded, then the if-statement sets the acting players to 0 (preventing the loop executing again) and declares the final player as winner!
Default - Just in case something goes wrong, the default throws an error!
To finish this method off, if the current player is broke, set their all-in to the current pot, then let everyone know the player has acted.
END. FUCKING. LOOP.
My fingers are tired, I'm off to chill out in bed until my head is totally chilled out! See ya tomorrow, questions and comments welcome. And just so you know, I did not like this method. It's big and a little unwieldy, even if it is sorta manageable. Blah!