Thursday 22 December 2011

Java: Texas Hold Em (27)

Okay, back for a second post, it's late and I'm busy though, so deal with it being short! Four short methods totaling about 30 lines of code! We'll be covering a method to deal with each of the blinds and 2 for dealing out cards:



postSmallBlind: Yay, we get to deal with the small blind first! Work our way up and all that.
    Line 101 is simple. The small blind should be half the big, so store that value.
    Line 102 makes sure the active player posts that amount as the small blind. I know it uses the same method name, but actor.post...() is part of the player class! Not this one, so it's okay! Perhaps a little confusing, but still perfectly valid.
    Line 103 increases the pot by the specified amount and...
    Line 104 actually notifies people that some stuff happened.

postBigBlind: This one is easier, now. Not only do we not need to half the big blind, but we've seen all this stuff in the above method! No need to go through it twice, eh?

dealHoleCards: Hole cards! A silly name, I keep thinking they're the community cards, since the pit in front of all the players is visible to everyone. But it isn't, it's the personal cards! Like a personal hole? I'll definitely remember it now.
    Lines 114-117 loops through each present player in the game. For each player, it sets the hand to 2 cards dealt from the deck, then has the client update the player info based on what just happened.
    Line 118 is just a general message to everyone, specifying who the dealer is, and giving them false credit. Everything's corrupt nowadays. But hey, look, it's making use of string formatting!

dealCommunityCards: Ooh, this one takes parameters. The phasename is some bullshit name. For the phase. There's no real use for it, functionality-wise. noOfCards should speak for itself.
    Lines 122-124 goes through, and for each card required, just adds one from the deck. Simple enough.
    Line 125 makes sure the board is updated!
    Line 126 gives more false credit through more string formatting!

That WAS short. Shorter than I expected, maybe I can even have a minute or 2 to myself today, then! See you tomorrow! Questions/comments welcome!

5 comments:

  1. That was short? I dunno man, it took me a while to read. I ran up and down with the picture, everything is fairly (relatively..) clear.

    ReplyDelete
  2. Well, standard posts covering 40-60 lines of code make this relatively short! :P Good to know you can follow along!

    ReplyDelete
  3. This makes me want to study programming.

    ReplyDelete
  4. Aw yeah, double post, time to get down to the meat and taters of this game.

    ReplyDelete