Battleship -- CS 351 Fall 2002 Final Project
Prev Next

3. Requirements

3.1 Game

Battleship is a two player game. Since it'd be a little hard not to cheat if you played against your friend on the same computer, your Battleship program will be network-enabled, and allow you or your opponent to connect to each other. In order to find and pick an opponent, Battleship will connect to a simple program running on a web server using HTTP, and download a list of online players currently waiting for someone to connect to them. On the other hand, if you'd like to listen for a connection from someone interested in playing you, you need to register with the server yourself. Both the listing and registrations operations are simple and are described in detail here.

This will be the only client-server interaction your program will perform. However, the actual client-client interaction with your opponent will be far more complex, and its details are described here.

When the game is launched, and once all the windows are painted, the only operations the user is able to perform will be a) listing online players, or b) registering with the server. At this point, mouse clicks on any part of the client area should be ignored - no game is in progress, after all. Let's assume the player registers himself or herself with the server first. Battleship will connect to the web server and request a specific URL that will instruct the program running on the web server to perform the registration. If the operation is successfull, Battleship will spawn a new thread and instruct it to wait for connection on a specific port (35102). Once a connection is established - an opponent connected - the thread will inform the main window of the event and exit. In case the player asks for the opponent listing, Battleship will connect to the web server, this time with a different URL, read back the response, and parse it. The response is described here. Once the data is parsed, a dialog box will be created consisting of two elements. A listbox will list all the online opponents, and let the user select one by clicking on their name. A Connect button, once clicked, will establish a connection to the IP address associated with the opponent's name.

As soon as the connection is established and the initial handshake (as described in the network implementation) completed, the player will be prompted to place his or her ships on the battlefield (the player's field is the field on the left). The 5-hitter is placed first, then the 4-hitter, and so on. Once the ships are placed, Battleship will send a message to the opponent informing them the player is ready to play. When both parties sent this message, the game begins. The player who initiated the connection gets to fire first.

At this point, Battleship should process clicks on the opponent's field, but only when it's the player's turn, and only as long as the game is in progress. During game play, the player should also be able to disconnect, or start a new game. In both cases, the opponent is informed that the player is disconnecting, and Battleship reinitializes.

Whoever sinks all of their opponent's ships first wins.

3.2 Layout

When the program starts, the main window and all its child windows will be painted. The main menu will have appropriate menu options grayed out and disabled, and the log window will display a "Battleship initialized." message.

  1. The Main Menu    There will be three main menu items: Battleship, Server, and Help. Using the Battleship submenu, the player will be able to start a New Game, Disconnect from a current game, or Exit the program. The Server submenu lets a player List opponents registered with the server, Register or Unregister themselves on the server. The Help submenu has a single menu item About Battleship... that brings up the About dialog box.

        

  2. The Battlefield Areas    The battlefield areas consists of two identical 10x10 grids. The grid on the left represents your ships, and the grid on the right represents the area of 'water' where you are trying to find your apponents ships.

    These grids are all the user (you) are able to see during the course of a game. You will see your ships marked on your grid, as well as all the places where your apponent has tried to hit you. You will also, of course see the hits that your opponent has inflicted on your ships. (see examples below)

        

        

  3. Timer WindowLegendGame Status Window   A series of 3 windows will also be required to exist in some form in your projects (yes you should make each a seperate window). The Timer Window will display the elapsed time of the actual game. The Legend will be for purposes of identification. For all we care you could make your sea red and your ships blue. This window is what is going to tell us what all the colors mean. Last but definately the most important of these 3 is the Status Window. When playing over the network, with a turn based game, it often becomes difficult to convey to the user what your program is doing as well as just whose turn it is to play. Your status window should not only be capable of displaying the current state of your game, but also whose turn it is (more on the possible states here).

  4. Log Window    A "log window" will be placed along the bottom of your main parent window. This log window, which must have a functional scrollbar, is to display different events that happen within your program. For instance, whenever a ship is sunk, text should be written to your log window telling the user exactly what has happened. Connection information is also to be logged (i.e. when a player connects your log window should tell you that). Any other information you wish to display during the course of game play should be output here as well. Note: the log window may not be an edit control. It has to be a regular child window with your own scrollbar logic. Use TextOut to print your lines. Do not use the regular system font, the Log Window should use one of the widely available TrueType fonts (like Arial). And please use the ScrollInfo type of scrollbars which adjusts appropriately to exactly how much data is actually displayed.

3.3 Other Issues


Prev Home Next
Help Implementation