soc.game
Class SOCForceEndTurnResult

java.lang.Object
  extended bysoc.game.SOCForceEndTurnResult

public class SOCForceEndTurnResult
extends java.lang.Object

This class holds the results of a call to SOCGame.forceEndTurn(). Specifically, the resulting action type, and possibly list of discarded or returned resources.

The result object isn't intended to be conveyed over a network to clients; the server should translate it into standard SOCMessages which change game state.


Field Summary
private  int devCardType
          Development card type re-gained, or -1; from constants such as SOCDevCardConstants.DISC.
static int FORCE_ENDTURN_LOST_CHOICE
          Choice lost; a development card may be returned to hand, see getDevCardType().
static int FORCE_ENDTURN_MAX
          Highest valid FORCE_ENDTURN_ value for SOCGame.forceEndTurn()
static int FORCE_ENDTURN_MIN
          SOCGame.forceEndTurn() return values.
static int FORCE_ENDTURN_NONE
          Since state is already SOCGame.PLAY1, already OK to end turn.
static int FORCE_ENDTURN_RSRC_DISCARD
          Resources have been randomly discarded.
static int FORCE_ENDTURN_RSRC_DISCARD_WAIT
          Resources have been randomly discarded.
static int FORCE_ENDTURN_RSRC_RET_UNPLACE
          Sent both for placement of bought pieces, and for "free" pieces from road-building cards
static int FORCE_ENDTURN_SKIP_START_ADV
          Skip an initial road or settlement; current player has advanced forward, state changes to SOCGame.START1A.
static int FORCE_ENDTURN_SKIP_START_ADVBACK
          Skip an initial road or settlement; current player has advanced backward, state changes to SOCGame.START2A.
static int FORCE_ENDTURN_SKIP_START_TURN
          Skip an initial road or settlement; state changes to SOCGame.PLAY1, and SOCGame.endTurn() should be called.
static int FORCE_ENDTURN_UNPLACE_ROBBER
          Robber movement has been cancelled.
private  SOCResourceSet gainLoss
          Resources gained (returned to cancel piece placement) or lost (discarded), or null.
private  int result
          Result type, like FORCE_ENDTURN_NONE
private  boolean rsrcLoss
          If true, player's resources are lost (discarded), not gained (returned).
 
Constructor Summary
SOCForceEndTurnResult(int res)
          Creates a new SOCForceEndTurnResult object, no resources gained/lost.
SOCForceEndTurnResult(int res, int dtype)
          Creates a new SOCForceEndTurnResult object, with a development card regained.
SOCForceEndTurnResult(int res, SOCResourceSet gained)
          Creates a new SOCForceEndTurnResult object, with resources gained.
SOCForceEndTurnResult(int res, SOCResourceSet gainedLost, boolean isLoss)
          Creates a new SOCForceEndTurnResult object, with resources gained/lost.
 
Method Summary
 int getDevCardType()
          Is a development card being returned to the player's hand?
 SOCResourceSet getResourcesGainedLost()
          Get the resources gained (returned to cancel piece placement) or lost (discarded), if any.
 int getResult()
          Get the force result type.
 boolean isLoss()
          Is player losing, or gaining, the resources of getResourcesGainedLost()?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

result

private int result
Result type, like FORCE_ENDTURN_NONE


gainLoss

private SOCResourceSet gainLoss
Resources gained (returned to cancel piece placement) or lost (discarded), or null. Lost resources are negative values in this set.


rsrcLoss

private boolean rsrcLoss
If true, player's resources are lost (discarded), not gained (returned).


devCardType

private int devCardType
Development card type re-gained, or -1; from constants such as SOCDevCardConstants.DISC.


FORCE_ENDTURN_MIN

public static final int FORCE_ENDTURN_MIN
SOCGame.forceEndTurn() return values. FORCE_ENDTURN_MIN is the lowest valid value.

See Also:
Constant Field Values

FORCE_ENDTURN_NONE

public static final int FORCE_ENDTURN_NONE
Since state is already SOCGame.PLAY1, already OK to end turn. No action was taken by forceEndTurn.

See Also:
Constant Field Values

FORCE_ENDTURN_SKIP_START_ADV

public static final int FORCE_ENDTURN_SKIP_START_ADV
Skip an initial road or settlement; current player has advanced forward, state changes to SOCGame.START1A.

See Also:
Constant Field Values

FORCE_ENDTURN_SKIP_START_ADVBACK

public static final int FORCE_ENDTURN_SKIP_START_ADVBACK
Skip an initial road or settlement; current player has advanced backward, state changes to SOCGame.START2A.

See Also:
Constant Field Values

FORCE_ENDTURN_SKIP_START_TURN

public static final int FORCE_ENDTURN_SKIP_START_TURN
Skip an initial road or settlement; state changes to SOCGame.PLAY1, and SOCGame.endTurn() should be called.

See Also:
Constant Field Values

FORCE_ENDTURN_RSRC_RET_UNPLACE

public static final int FORCE_ENDTURN_RSRC_RET_UNPLACE
Sent both for placement of bought pieces, and for "free" pieces from road-building cards

See Also:
Constant Field Values

FORCE_ENDTURN_UNPLACE_ROBBER

public static final int FORCE_ENDTURN_UNPLACE_ROBBER
Robber movement has been cancelled.

See Also:
Constant Field Values

FORCE_ENDTURN_RSRC_DISCARD

public static final int FORCE_ENDTURN_RSRC_DISCARD
Resources have been randomly discarded. Ready to end turn.

See Also:
Constant Field Values

FORCE_ENDTURN_RSRC_DISCARD_WAIT

public static final int FORCE_ENDTURN_RSRC_DISCARD_WAIT
Resources have been randomly discarded. Cannot end turn yet; other players must discard. SOCGame.isForcingEndTurn() is set.

See Also:
Constant Field Values

FORCE_ENDTURN_LOST_CHOICE

public static final int FORCE_ENDTURN_LOST_CHOICE
Choice lost; a development card may be returned to hand, see getDevCardType().

See Also:
Constant Field Values

FORCE_ENDTURN_MAX

public static final int FORCE_ENDTURN_MAX
Highest valid FORCE_ENDTURN_ value for SOCGame.forceEndTurn()

See Also:
Constant Field Values
Constructor Detail

SOCForceEndTurnResult

public SOCForceEndTurnResult(int res)
Creates a new SOCForceEndTurnResult object, no resources gained/lost.

Parameters:
res - Result type, from constants in this class (FORCE_ENDTURN_UNPLACE_ROBBER, etc.)
Throws:
java.lang.IllegalArgumentException - If res is not in the range FORCE_ENDTURN_MIN to FORCE_ENDTURN_MAX.

SOCForceEndTurnResult

public SOCForceEndTurnResult(int res,
                             int dtype)
Creates a new SOCForceEndTurnResult object, with a development card regained.

Parameters:
res - Result type, from constants in this class (FORCE_ENDTURN_UNPLACE_ROBBER, etc.)
dtype - Development card type, like SOCDevCardConstants.DISC, or -1 for none.
Throws:
java.lang.IllegalArgumentException - If res is not in the range FORCE_ENDTURN_MIN to FORCE_ENDTURN_MAX, or if dtype is not -1 and not in the range SOCDevCardConstants.MIN to SOCDevCardConstants.MAX_KNOWN.

SOCForceEndTurnResult

public SOCForceEndTurnResult(int res,
                             SOCResourceSet gained)
Creates a new SOCForceEndTurnResult object, with resources gained.

Parameters:
res - Result type, from constants in this class (FORCE_ENDTURN_UNPLACE_ROBBER, etc.)
gained - Resources gained (returned to cancel piece placement), or null.
Throws:
java.lang.IllegalArgumentException - If res is not in the range FORCE_ENDTURN_MIN to FORCE_ENDTURN_MAX.

SOCForceEndTurnResult

public SOCForceEndTurnResult(int res,
                             SOCResourceSet gainedLost,
                             boolean isLoss)
Creates a new SOCForceEndTurnResult object, with resources gained/lost.

Parameters:
res - Result type, from constants in this class (FORCE_ENDTURN_UNPLACE_ROBBER, etc.)
gainedLost - Resources gained (returned to cancel piece placement) or lost (discarded), or null.
isLoss - Resources are lost (discarded), not gained (returned to player).
Throws:
java.lang.IllegalArgumentException - If res is not in the range FORCE_ENDTURN_MIN to FORCE_ENDTURN_MAX.
Method Detail

getResult

public int getResult()
Get the force result type.

Returns:
Result type, from constants in this class (FORCE_ENDTURN_UNPLACE_ROBBER, etc.)

getResourcesGainedLost

public SOCResourceSet getResourcesGainedLost()
Get the resources gained (returned to cancel piece placement) or lost (discarded), if any. Lost resources are signaled by isLoss().

Returns:
gained or lost resources, or null

isLoss

public boolean isLoss()
Is player losing, or gaining, the resources of getResourcesGainedLost()?

Returns:
true if resource loss, false if gain, for the player

getDevCardType

public int getDevCardType()
Is a development card being returned to the player's hand?

Returns:
Development card to return, or -1; type constants like SOCDevCardConstants.DISC.