Before users can playar multiplayer game, they must choose somebody to play against. Rather than forcing a phone call to arrange’ a game, this applet takes a.different approach. When it is first run, it prompts the user to enter his or her name This name is passed to the server, which broadcasts the player’s name to all other potential competitors. The user then sees a list of all available players .selects one, and clicks on the Challenge button. Currently, there is no way to confirm or deny a challenge; they are automatically accepted. Once a challenge is made, both players see the game board appear, and all other competitors simply see both players’ names disappear from the available list.It is quite an easy game to play, but it is very difficult to WID against a skilled .opponent. P.layers are presented with a grid of squares and given a set of seven square tiles with letters of the alphabet engraved on them (see Figure 32-3). These tiles are selected at random from a bag of 100 tiles. The tiles Can be clicked on with the mouse and dragged to a destination square on the grid. If the spot is already occupied, the tile is returned to its original position. Tiles may be adjusted on the board during a turn, but not when the turn)s over. The first player-starts placings several tiles in a line on the board to form a word ‘in the English language: The-first word must cover the center square. Subsequent . words must touch at least one tile already played on the board. The player clicks on the Done button to end the turn. If a player can’t find a valid word, the player can pass by clicking on Done twice in a row without having any tiles on the board. The two players take turns placing words of the tiles are used. The board shown in Figure 32-3 is for smaller displays, and thus the multiplier squares are marked with simple characters. 2L doubles the value of the letter on that square. 3L triples the value. 2W means the whole word gets double the points. 3W means triple the word score. If you make the applet big enough, it will use more descriptive labels for these squares.
Scores arc assessed at the end of each turn. Each tile has a small number engraved on its face next to the letter. This score may be multiplied by two or three, depending on the value (color) of the square on which it was placed. The entire sum for a word may also be multiplied by two or three if any in the word covers the appropriate square. If a word comes in contact with any other tiles to form additional words, they are counted separately. If a player uses all seven tiles inn single turn, an additional 50 points arc awarded. At the end of the game, the player with the highest score wins. shows an example of a board after a few turns have been taken, Patrick started with SIRE, worth eight points. That came from the four one-point tiles and the double-word score on the center tile. Next, Herb played HIRE, using the J from SIRE. This was worth seven points, the sum of the four tiles involved. Notice that Herb got credit for reusing Patrick’s J but not the double-word score underneath it. At the point shown in Patrick has played GREAT and is about to click the Done button to complete his turn. Notice that the tiles in play arc brighter than those that have already been played (see At any time during the players may converse by typing in the text entry area at the top of the applet These will appear one at a time in ‘the other player’S browser’s status line, typically at the bottom of the browser .
One last,word about game play before we get into the source code. The way to win
at this game is to come up with words that score in one direction and also make words in the other direction. These secondary words tend to be short, two-letter words, but they places the-Y in DEITY, which will score 21 points because he gets a face value of 9 doubled to 18, plus he gets to count the word AD, which runs vertically, f9,-r3 points. Remember that all of the words with each turn need- to Eventually, this game will need either an undo for disputed words or an automatic dictionary checker to resolve.conflicts