Complete the Look: Building on the Framework
We haven't tackled a number of things with our framework so far that are required for a full-featured game system. We discuss some of them here but leave the implementation up to you.
We wrote only a console-based client for our RPS game because we wanted to focus on the networking and logic code. Clearly, though, most games these days require a graphical client. Adding a GUI and connecting it to the underlying code is fairly trivial. Our event-based design allows us to just have the GUI drop events into the outgoing EventQueue just like RPSConsoleEventReader does. Similarly, the GameClient can pass incoming events to a GUI if it implements the EventHandler interface.
One important aspect of game servers we haven't touched on yet is persistence. Most games require at least some amount of game data to be stored, usually in a relational database. Typical needs are to store player data, high scores, game statistics, buddy lists, and other game-specific data. Because we are using a standalone Java app as the GameServer, we don't have the luxury of relying on built-in persistence mechanisms that are found in modern J2EE app servers. So what are the options? Many developers choose to go with the lowest common denominator of using the JDBC APIs directly. The benefit is speed, and if your data needs are small, this might be a fine choice. However, a recent trend has been toward the use of object/relational mapping APIs. Sun has a specification for Java Data Objects (JDO, available at http://java.oracle.com/products/jdo). Two other competing APIs are Castor JDO (www.castor.org) and Jakarta OJB (http://db.apache.org/ojb), both of which are in active development.
Buddy Lists, Lobbies, and Chat
Multi-player servers need mechanisms for players to find friends, arrange games, and chat with one another. These are referred to collectively as community features. Friend finding often involves a buddy list feature, similar to the functionality found in instant-messaging clients. This notifies you when a friend logs in and shows you which game lobby or server that person is on. Player-matching features depend highly on the genre but often involve lobbies where players of similar skill, game interest, or other criteria can meet, chat, and challenge one another to games. Chat is a requirement for just about any game genre. In addition to basic chat functionality, you need features for administrators to be able to kick out or ban users (features found in IRC servers). Players want the ability to ignore either certain players—or all chat—to avoid offensive or obnoxious players.