soc.server
Class SOCGameBoardReset

java.lang.Object
  extended bysoc.server.SOCGameBoardReset

public class SOCGameBoardReset
extends java.lang.Object

This class holds data the server needs, related to a "board reset" of a game being played.

Author:
Jeremy D. Monin
See Also:
SOCGameList.resetBoard(String), SOCGame.resetAsCopy()

Field Summary
 boolean hadRobots
          Were there robots in the old game?
 StringConnection[] humanConns
          Human and robot connections; both arrays null at vacant seats.
 SOCGame newGame
          The new game, created from an old game by SOCGame.resetAsCopy()
 StringConnection[] robotConns
          Human and robot connections; both arrays null at vacant seats.
 boolean[] wasRobot
          Was this player position a robot? Indexed 0 to SOCGame.MAXPLAYERS-1
 
Constructor Summary
SOCGameBoardReset(SOCGame oldGame, java.util.Vector memberConns)
          Create a SOCGameReset: Extract data, reset the old game, and gather new data.
 
Method Summary
static int sortPlayerConnections(SOCGame newGame, SOCGame oldGame, java.util.Vector memberConns, StringConnection[] humanConns, StringConnection[] robotConns)
          Grab connection information for this game's humans and robots.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

newGame

public SOCGame newGame
The new game, created from an old game by SOCGame.resetAsCopy()


hadRobots

public boolean hadRobots
Were there robots in the old game?


humanConns

public StringConnection[] humanConns
Human and robot connections; both arrays null at vacant seats. SOCGame.resetAsCopy() will duplicate human players in the new game, but not robot players. Indexed 0 to SOCGame.MAXPLAYERS-1


robotConns

public StringConnection[] robotConns
Human and robot connections; both arrays null at vacant seats. SOCGame.resetAsCopy() will duplicate human players in the new game, but not robot players. Indexed 0 to SOCGame.MAXPLAYERS-1


wasRobot

public boolean[] wasRobot
Was this player position a robot? Indexed 0 to SOCGame.MAXPLAYERS-1

Constructor Detail

SOCGameBoardReset

public SOCGameBoardReset(SOCGame oldGame,
                         java.util.Vector memberConns)
Create a SOCGameReset: Extract data, reset the old game, and gather new data. Adjust game member list to remove robots.

Parameters:
oldGame - Game to reset - SOCGame.resetAsCopy() will be called. The old game's state will be changed to RESET_OLD.
memberConns - Game members (StringConnections), as retrieved by SOCGameList.getMembers(String). Contents of this vector will be changed to remove any robot members.
Method Detail

sortPlayerConnections

public static int sortPlayerConnections(SOCGame newGame,
                                        SOCGame oldGame,
                                        java.util.Vector memberConns,
                                        StringConnection[] humanConns,
                                        StringConnection[] robotConns)
Grab connection information for this game's humans and robots. memberConns is from _old_ game, so robots are included. Robots aren't copied to the new game, and must re-join.

Two modes:

If currently copying a game, assumes newGame is from oldGame via SOCGame.resetAsCopy(), and newGame contains only the human players, oldGame also will contain robot players.

If not copying a game, oldGame is null, and assumes newGame has all players (both human and robot).

Parameters:
newGame - New game (if resetting), or only game
oldGame - Old game (if resetting), or null
memberConns - Members of old game, from SOCGameList.getMembers(String); a Vector of StringConnections
humanConns - Array to fill with human players; indexed 0 to SOCGame.MAXPLAYERS-1
robotConns - Array to fill with robot players; indexed 0 to SOCGame.MAXPLAYERS-1
Returns:
The number of human players in newGame