What's up, guys? Today we're back to the card game! We can probably finish it up today, but be aware that the actual act method is long, although it is just a switch statement, so not necessarily complex. I'll leave it to last so we can get the easy stuff out of the way, first.
Okay, here's 3 of the 4 remaining methods in this class! I'll be honest, I'm not sure what the publicClone method is used for, but looking over the code it SEEMS like it's what's visible to other players, with no client so you can't be affected by them. It would make sense, but don't be surprised if I'm wrong!
Our first method is simple, the player wins a hand. The result is also simple, they get all the money!
Next, we have the publicClone which, as I said before, I'm not sure about, but have a theory! According to this theory, line 164 is where a player is created without a client to control it, made to mimic the player at all times without having any control capabilities.
Lines 165-167 would then be there to keep track of the player's stats that other players should be made aware of!
Finally, we have a toString method so we can easily display the player when printing out a message. I've kept the @Override so you know what it looks like. All it does is make sure this method overrides the default toString. This is just to let the compiler know you intentionally took a method's name, instead of accidentally doing so. It's good practice to keep it in, so I'll just keep doing that from now on!
Here we go, the huge switch statement! Guess we have to go through this slowly!
Line 123 is the method declaration, as we know, and the parameters hold a set of actions that are currently allowed (not calculated by the player) as well as what the bets are currently.
Line 124 actually sets the action of the player. Is it setting the action to a collection of actions? Hm, I'm not sure, and I can't test it until I've got my ConsoleClient in place, so we'll have to wait to find out!
Line 125 is the start of our switch statement, using the action as the actual switch, and line 156 returns that action when the switch is done operating.
Now for each of the cases. As you can see, there's one case for every potential action, let's go through them.
Line 126 - CHECK: Basically passing your turn. This does absolutely nothing other than return CHECK as your action!
Line 128 - CALL: Doing something? Madness! In this case, you're matching the table's bet, so line 129 is determining how much more you need to pay to make your current bet match the table bet..
Lines 130-131 are saying "If you have to pay more than you have to call, just throw in what you DO have"
Lines 133-134 remove the cash from the player and raise his/her bet by the corresponding amount!
Line 136 - BET: This here actually puts in the bet, with lines 137-140 determining how much to bet, or whether you need to put in all the cash you got, same as with calling.
Similar to calling, lines 141-142 remove the cash from the player, adding the amount to his/her betting pool.
Line 143 increments the number of raises that have happened. Remember that variable? I barely do! This'll probably be the first "raise" since the action is BET and not, uh, RAISE
Line 145 - RAISE: This case is pretty much the same as above, but it increases the current bet by whatever disparity existed between the current bet and your last bet. So if the current bet was 80 and it was 50 last time around, a RAISE would increase the current bet by (80 - 50 = ) 30, making it (80 + 30 = ) 110.
Line 152 - FOLD: Back to easy cases! Folding just takes you out of the round, so nothing needs be done except the elimination of your hand!
That's it for tonight, tomorrow, we move to the ConsoleClient or the Table, I guess I'll flip a coin to decide which one! See you then, questions and comments welcome!