soc.game
Class SOCSpecialItem.Requirement

java.lang.Object
  extended by soc.game.SOCSpecialItem.Requirement
Enclosing class:
SOCSpecialItem

public static final class SOCSpecialItem.Requirement
extends java.lang.Object

Data structure and parser for a special item's requirements.

A requirement is a minimum count of items (Settlements, Cities, Victory Points, or Length of player's longest route) with an optional required position (at a Port, or at a list of special nodes) for at least one of the Settlement or City items.

At the client, requirements are rendered in SOCSpecialItemDialog.buildRequirementsText; if new fields or requirement types are added, please update that method.

See Also:
parse(String), SOCSpecialItem.checkRequirements(SOCPlayer, boolean)

Field Summary
 java.lang.String atCoordList
          Board layout coordinate list such as "N1", or null.
 boolean atPort
          If true, a reqType piece must be at a 3:1 or 2:1 port.
 int count
          Number of pieces, victory points, or length of route required
 char reqType
          'S' for settlement, 'C' for city, 'V' for victory points, 'L' for length of player's longest route
 
Constructor Summary
SOCSpecialItem.Requirement(char reqType, int count, boolean atPort, java.lang.String atCoordList)
          Create a Requirement item with these field values.
 
Method Summary
static java.util.List<SOCSpecialItem.Requirement> parse(java.lang.String req)
          Parse a requirement specification string into SOCSpecialItem.Requirement objects.
 java.lang.String toString()
          String representation for debugging; same format as parse(String).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

reqType

public final char reqType
'S' for settlement, 'C' for city, 'V' for victory points, 'L' for length of player's longest route


count

public final int count
Number of pieces, victory points, or length of route required


atPort

public final boolean atPort
If true, a reqType piece must be at a 3:1 or 2:1 port. Currently, only reqType C (City) is supported here, because no current scenario justified the extra coding for S-or-C.


atCoordList

public final java.lang.String atCoordList
Board layout coordinate list such as "N1", or null. If non-null, a reqType piece must be at a node coordinate in this named list within the board layout's getAddedLayoutParts.

Constructor Detail

SOCSpecialItem.Requirement

public SOCSpecialItem.Requirement(char reqType,
                                  int count,
                                  boolean atPort,
                                  java.lang.String atCoordList)
Create a Requirement item with these field values. See each field's javadoc for meaning of parameter named from that field. Parameter values are not validated here.

Parameters:
reqType - See reqType
count - See count
atPort - See atPort
atCoordList - See atCoordList
Method Detail

parse

public static java.util.List<SOCSpecialItem.Requirement> parse(java.lang.String req)
                                                        throws java.lang.IllegalArgumentException
Parse a requirement specification string into SOCSpecialItem.Requirement objects.

Requirements are a comma-separated list of items, each item having this syntax:
[count] itemType [@ location]

Examples:

Parameters:
req - Requirements string following the syntax given above
Returns:
List of SOCSpecialItem.Requirements, or null if req is ""
Throws:
java.lang.IllegalArgumentException - if req isn't a syntactically valid specification

toString

public java.lang.String toString()
String representation for debugging; same format as parse(String).

Overrides:
toString in class java.lang.Object