Okay, post 1 of 2 for today! I'll take a break after this to type up the second, since I had this prepared for yesterday! This one contains a few administrative methods, the main game loop, a way to add players and a way to start the game over. The second screenshot is a huge method to take care of actually playing an individual hand. Here goes:
So, 3 methods in our first screenshot, let's go through them:
addPlayer: This one is very simple. Since the players are just an array (the class variables, remember), we can just add a new player to the game by adding one to the array, and nothing else!
start: If you remember the text-clock we wrote a while back, you'll remember that the start method is the main loop for the program to run.
Line 48 resets the game (using a method defined later. Next, in fact) so that when the game is started there's nothing left over from the previous one.
Line 49-50 is the main loop. Here, we see that while the game isn't over (the game over boolean switch in the class variables), we'll play a hand (the method for which is defined later in this post).
Line 52 is executed when the main loop is dead, which happens when the game is over. This just notifies players that, hey, its game over!
resetGame: This method just has to reset a few variables to the default so when a new game starts, everything goes smooth.
Lines 56-58 reset the dealer, the current player and the gameOver switch.
Lines 59-60 uh...does something. For each player. It looks like, from the wording alone, that for each player, it makes them rejoin the table? I'm honestly not sure though. I've flagged this in my IDE so I can test it out once the ConsoleClient is done with! Got any ideas in the meantime?
Here's our doozy of a method. All methods you don't recognize will be defined later on in this class, or in the console client, just infer what they do from what they're called!
Line 68-73 starts the pre-dealing actions. Reset the hand, move to the next player (from the dealer. Who doesn't deal, because the computer does that...hm...), do the small blind dealy, move to the next player to deal with the big blind, then set the bet!
Line 75 will simply deal the hole cards so that players have something to work with!
Line 76 presumably deals with a betting round. Circling the players, making them raise or whatever.
Lines 77-80 say that if there's more than 1 player, deal the community cards out. Then go through another round of bets.
Lines 81-84 go through the main part of the turn, dealing community cards (again? We'll have to inspect that method later!) and going through another betting round.
Lines 85-89 Okay, what's a river? Also, what's Google? Guess we'll find out later! The bet is doubled and another betting round occurs.
Lines 90+ Oh god, a showdown?? The suspense is killing me!
So that's the post! I'll make a short one for today, since I'm busy, it should be up in an hour or so! See ya later, Questions & comments welcome.
What's.. google? I feel like I shouldn't be confused.
ReplyDelete