Tuesday, 22 November 2011

Java: Texas Hold Em (7)

In response to a question from yesterday's post: I don't think the evaluation will be the toughest part, since the player clients all need to come together, or the GUI itself, using actual graphics might be a pain in the ass. We'll see, though.

For today: Action class! I'm gonna follow the example program for this one, since it looks simple, and much easier than what I was planning to do with it, but since the example program isn't fully functional (because I'm stupid and take inspiration from all the wrong places), it may need some tweaking later on.

This guy (I'll provide a source to his actual work at the end, since I'll do that anyway, and it seems a little redundant to do so at every point. Just sayin') used a simple enumeration to hold all the actions (I actually do not know what the blinds are. Never used them).

Lines 8-15 are the actual actions, followed by their parameters. As we can see from the private strings as well as the constructor below (on lines 25-28), those parameters are just the actual name of the action, in string form, and then the verb associated with it.

If we create a new Action object in a main method, or the main class or wherever in the package, we can see that what we make that action already sets the values. For instance,
Action a = Action.RAISE;     results in a.getVerb() returning "raises". Just illustrating that the constructor takes care of that in an enumeration, I'm not sure if we've used the 2 together before.

Here's our standard get methods, and toString. Note that getName and toString are the same thing, but from a writers point of view, it's probably best to have both!

That's all for tonight. I hope it works, since I like this much simpler way of creating all the actions. I suppose the Table class will actually handle them, we'll see! See you tomorrow, questions and comments welcome!


  1. Looks like it's coming along nicely

  2. So you're setting up the actual core of the game, and then adding players and GUI later, right?

  3. I know a little bit about java but my favourite is the good and old C
    anyway, congrtas for the blog!

  4. blinds are the minimum bet to keep the money entering in the game, normally you have big ones and small ones rotating.