CS1331 Homework 06 - EXTREME Poker

EXTREME Poker is a Card Game based on Texas Holdem that you will create the UI for.

Download zip

Table of Contents

Introduction

The creators of Poker are long gone and the game’s rules are now a mystery. Passed down through the years by word of mouth; the game has had many different versions pop up. Your mission if you choose to accept it (which you must unless you want a 0) is to create an implementation of Poker to rule them all called EXTREME Poker.

Problem Description

The logic of EXTREME Poker has already been coded and provided for you. So you don’t have to worry about the logic behind the game!! Although knowing it might help with testing. You only need to write the code that creates the UI. Note that there are up to 100 possible bonus points on this assignment.

Background

The rules for EXTREME Poker are very similar to Texas Holdem and are as follows:

Game Flow

  1. Two Cards are dealt to each player.
  2. A betting round ensues.
    • In a betting round each player, in order, is given the option to Raise, Call, or Fold
    • A raise happens when the player adds more chips to the pot than the previous player.
    • A call happens when the player adds the same amount of chips to the pot as the previous player.
    • A fold happens when a player decides they don’t want to continue adding chips and so they quit for that round (forfeiting any chips they have already bet).
    • A player may not raise by more chips than any other player has bet.
    • A betting round ends once every player has called or folded except for the last player that raised.
  3. After the first betting round three cards are put down on the middle of the table which any player can use to build their poker hand.
  4. Then another betting round happens.
  5. Next, one more card is added to the middle of the table which any player can use to build their poker hand.
  6. Another betting round.
  7. The final card is dealt to the middle of the table.
  8. The final betting round occurs.
  9. All Cards are revealed and the winner receives the pot or the pot is split amongst winners.
  10. The cards are cleared from the table and we go back to step 1.

Determining the winner

The winner(s) is/are the player(s) with the best poker hand. A poker hand is made by combining 5 cards. These cards can come from the Player’s two cards or from the Cards on the board. Not from other Player’s cards. If two players have the same poker hand, then they tie.

The types of poker hands are (in order from best to worst):

MVC design

MVC stands for model, view, and controller (or view controller).

This style of programming is very powerful and is used widely. If you want to learn more you can read this article or google it.

MVC

JavaFx API

JavaFx is a massive Library that contains everything you might need for this assignment. Please look for a solution to any problem using JavaDocs before you ask on Piazza.

Helpful Classes

If you ever get stuck, try looking at these classes in JavaDocs they are very useful!

Solution Description

Make sure you read the entire document before starting. Feel free to change any provided files even in the model or viewcontroller. Just realize that major changes in provided files will make it harder to give partial credit.

Viewcontroller:

Everything in the viewcontroller package is provided! But you do need to know about some of the classes.

GameState.java

GameState is an enum that represents the different states the game can be in

PokerGameController.java

PokerGameController has a lot of methods but here are the ones you need to know about:

Model:

Everything in the model package is provided! But you do need to know about some of the classes.

Suit.java

Suit is an enum that represents the suit of a Card. The possible Suits are: HEART, DIAMOND, CLUB, SPADE

Suit has one important method:

CardValue.java

CardValue is an enum that represents the rank of a Card. The possible CardValues are: ACE, KING, QUEEN, JACK, TEN, NINE, EIGHT, SEVEN, SIX, FIVE, FOUR, THREE, TWO

CardValue has one important method:

Card.java

Card has the following methods that you need to use:

Player.java

Player has the following methods that you need to use:

Board.java

Board has the following important methods:

View:

This is what you have to write.

PokerGame.java

PokerGame is an Application and is the class where your main method will reside. PokerGame has four methods: main(), start(), startGame(), and updatesMade().

StartScreen.java

StartScreen is a StackPane that is displayed first when the program is run.

When displayed StartScreen should look similar to this:

StartScreen

StartScreen input

GameScreen.java

GameScreen is a BorderPane and contains all of the UI related to playing the Game.

GameScreen start

GameScreen 3 cards

GameScreen 4 cards

GameScreen 5 cards

GameScreen end

Note also that AI_3 has folded and is therefore out of play so its cards were hidden.

GameScreen has a constructor and two methods, updatesMade() and endOfRound()

PlayerArea.java

PlayerArea owns a Pane where all of its contents will be added and contains all of the UI related to any individual Player.

PlayerArea

Above are two highlighted PlayerAreas. The PlayerArea where the user’s cards are is in blue. Only the user’s cards should be shown until the end of the round when all cards are shown.

PlayerArea

Above is highlighted a PlayerArea whose Player is out of play. Its cards have been hidden and the out of play indicator has been shown. All the other PlayerAreas’ cards have been shown because it is the end of a round.

PlayerArea has a constructor and two methods, playerPane() and update()

VerticalPlayer.java and HorizontalPlayer.java

These two classes are both PlayerAreas and are both very simple. They have been written for you and don’t need to be edited. They both have constructors that take in the Player to display.

IMPORTANT: The PlayerAreas on the left and right of your GameScreen should be instantiated as VerticalPlayers and the PlayerAreas on the top and bottom of your GameScreen should be instantiated as HorizontalPlayers.

CardView.java

CardView is mostly written for you. It has a constructor and four methods: setCard(), show(), hide(), and hideDetails().

BoardArea.java

BoardArea owns an HBox that contains all of the UI elements that have to do with the Board.

BoardArea

Above is highlighted the BoardArea. At this point in the game only four cards are shown and the fifth is hidden. Also, the pot is shown with room for the fifth card to be shown.

BoardArea has a constructor and two methods, getPane() and update().

ControlPane.java

ControlPane is an HBox that contains all of the UI for controlling the game.

ControlPane

Above is highlighted the ControlPane. It is not the end of a round so the start new round button is hidden and it is the User’s turn so the other buttons are not disabled.

ConrtolPane has a constructor and two methods, playerTurn() and endOfRound().

Console.java

Console is a ScrollPane and contains all of the UI elements for the Console at the bottom of the Stage.

Console

Above is highlighted the Console.

Console has a constructor and four methods: addText(), clear(), putMessage(), and clearLog(). It also has a static variable of type Console which should be set to the current Console.

Suggested work flow

  1. First create StartScreen.java
  2. Use PokerGame.java to display the StartScreen
  3. Then do the show() method in CardView.java
    • You’ll come back and fill in the rest of the methods later.
  4. PlayerArea.java
    • You can create the CardViews in the constructor and also the labels for name, chips, and such.
    • You can omit doing the majority of the update method in PlayerArea at first. Just make sure you appropriately use setCard() on the CardViews so you can see them when the PlayerArea is displayed and then come back later and do the rest of the update() method.
  5. At this point you can create the PlayerAreas in GameScreen.java. Instantiate them inside the constructor and make sure to update them in updatesMade().
    • You can save endOfRound() for later just make sure to come back and do it.
  6. Now you can show the GameScreen in PokerGame.java and see all of the work you’ve just done.
    • You must partially implement updatesMade() in PokerGame.java before the cards will work correctly.
    • Now that you can see what the CardViews and PlayerAreas look like you can go back and fill in the methods you omitted or only partially did.
  7. Next up is ControlPane.java. You should initialize all of the UI elements in the constructor.
    • You don’t have to do playerTurn() or endOfRound() right away these can be saved for later.
  8. Next you should fill in BoardArea.java.
    • Again not every part of the update() method must be working at 100% right away. You can fix things and add things in later.
  9. After BoardArea is finished you can finish up the GameScreen.java
    • At this point it might be smart to start going back through and fininshing anything you skipped in any of the classes you’ve worked on already.
  10. Finally, you can implement Console.java and fill anything else in that you didn’t do earlier.

Extra Credit Opportunities

Compiling and Testing

To compile the homework you can use: javac src/main/java/model/*.java src/main/java/viewcontroller/*.java src/main/java/view/*.java And to run the homework you can use: java -cp src/main/java view.PokerGame

Run these commands from outside the src directory.

JavaDocs

JavaDocs will be the same as last homework. Do not forget them!!

Checkstyle

For this homework, the checkstyle cap is 100, meaning you can lose up to 100 points on this assignment due to style errors. Run checkstyle early, and get in the habit of writing style compliant code the first time. Don’t wait until 5 minutes before the deadline to find out that you have 100+ violations. You don’t want to get a 0 because you forget to do Checkstyle.

Submitting

You should not import any libraries or packages that trivialize the assignment. Unlike previous homework this doesn’t include List, Map, Set. If you are unsure of whether something is allowed, ask on Piazza. In general, if something does a large part of the assignment for you, it is probably not allowed.