Assignment 6: 9 Card Golf

For this assignment, we will finish the interactive version of the 9 Card Golf game. You will bring your working code from Assignment 5 into a new Windows Forms Application and create a GUI for the game that allows two players to play against each other on the same screen.

Commit your work to this new repository:

https://cssvn.utrgv.edu/svn_etomai/201810_3328/assn06_golf/<username>

The User Experience

Display a form to the players with two textboxes for their player names and a Start button. When clicked, hide that form and show the game form.

The game form should display the two 3x3 hands, the draw deck and the discard pile. The player names must be above their hands, and there must be an indicator of whose turn it is. Images for all the cards are included in the starter repo.

Each player in turn flips up any three cards in their hand by clicking on them.

The player whose turn it is takes the mouse and clicks either the draw deck or discard pile. If the former, flip the top card face up so they can see what it is. Put a highlight around the card that was selected (either on the draw or discard pile) so the player knows that their click was registered. The player then clicks on the card in their hand to replace, the hand and discard are updated, and the turn indicator moves to the next player.

When the game ends, flip up all the cards and display the score for each player, who won, and the number of games each player has won. They still need to be able to see the hands, so that they can recognize why they got that score. Display buttons for Play Again and Quit. The former should start a new game with the same players, while the latter goes back to the start form.

Add sounds to the user actions and game events so that the players know things are happening. Immediate feedback is critical to an effective interactive application.

Design

You may need to make changes to the game classes to support this new functionality, but maintain the same basic class structure of Game, Player, Hand, Deck and Card. The event handlers you add to your forms must work with these classes to play the game (separation of UI from game logic).

Bring your Unit Tests over from Assignment 5 as well, and use/update them to confirm that the logic is still working as you make changes and get the GUI to work. You don't need to try and create tests for the GUI event handlers for this assignment.

As discussed in lab today, you'll need to store information on the form labels that represent the cards so that you can tell which one was clicked. The label control has a tag property that's specifically for storing informative strings. I'd suggest you just set the tags to indicate which player and position the label represents (e.g. "A12" for player A, row 1, column 2). You could alternatively subclass label and add data members to that subclass, but that seems a bit out of scope to me here.

There are a few new things here you'll need to learn, like how to use multiple forms in a program, how to hide and show form controls, and how to work with image files. The card images are provided, including the card back and joker, and named with a standard convention. That means you should not be hardcoding all 54 card file names in your code! Write a method that grabs the right file for whichever Card you're displaying.

For the "highlight" requirement, you can look at functionality in the controls already, but you can also use standard tricks like putting a second, slightly larger colored rectangle behind a card image to create a "border", or a semi-transparent colored rectangle over a card image to shade it a different color.

Committing

Again, you'll need to commit the whole solution here. Please delete the obj and bin directories from both, and the VS2017 frameworks subdirectory.

Be sure to commit any sounds and images that you add!