soc.util
Class SOCGameBoardReset

java.lang.Object
  extended by soc.util.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.

If the SOCGame is in state SOCGame.READY_RESET_WAIT_ROBOT_DISMISS, this object is referenced within the newly created game object.

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

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()
 int oldGameState
          gamestate of old game at reset time
 int oldRobotCount
          Are we still waiting for robots to leave the old game?
 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<StringConnection> 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<StringConnection> 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()


oldGameState

public final int oldGameState
gamestate of old game at reset time

Since:
1.1.06

hadRobots

public boolean hadRobots
Were there robots in the old game?


oldRobotCount

public int oldRobotCount
Are we still waiting for robots to leave the old game?

Since:
1.1.07

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<StringConnection> memberConns)
Create a SOCGameReset: Extract data, reset the old game, and gather new data. Adjust game member list to remove robots. If there were robots, the new game's state is set to SOCGame.READY_RESET_WAIT_ROBOT_DISMISS.

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 SOCGameListAtServer.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<StringConnection> 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 contains all human and robot players.

If not copying a game, only inspecting one, then 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 SOCGameListAtServer.getMembers(String); a Vector of StringConnections
humanConns - New array to fill with human players; indexed 0 to SOCGame.MAXPLAYERS-1. humanConns[pn] will be the human player at position pn, or null.
robotConns - New array to fill with robot players; indexed 0 to SOCGame.MAXPLAYERS-1. robotConns[pn] will be the robot player at position pn, or null.
Returns:
The number of human players in newGame