soc.game
Class SOCResourceConstants

java.lang.Object
  extended by soc.game.SOCResourceConstants

public class SOCResourceConstants
extends java.lang.Object

This is a list of constants for representing types of resources in Settlers of Catan.

Warning: Many pieces of code depend on these values and their count. Clay is first (1), Wood is last (5), Unknown is after wood. Those are the 5 resource types (count==5 or ==6 (unknown) is also assumed). Adding a new resource type would require changes in many places. SOCRobotBrain.estimateResourceRarity is one of many examples. Constants in other places (like SOCPlayerElement.CLAY) have the same hardcoded values.

Before 1.1.08, this was an interface. Changing to a class allowed adding methods such as resName(int).

See Also:
SOCResourceSet

Field Summary
static int CLAY
          Warning: Don't mess with these constants, other pieces of code depend on these numbers staying like this.
static int CLOTH_STOLEN_LOCAL
          Some code, internal to the soc.game or soc.server packages, uses this value (7) to represent stolen cloth (SOCPlayer.getCloth()) for scenario game option _SC_CLVI.
static int GOLD_LOCAL
          Some code, internal to the soc.game or soc.robot packages, uses this value (6) to represent SOCBoardLarge.GOLD_HEX tiles; same numeric value as UNKNOWN.
static int MAXPLUSONE
          One past maximum value (7; max value is 6 == UNKNOWN)
static int MIN
          Minimum value (1 == CLAY)
static int ORE
           
static int SHEEP
           
static int UNKNOWN
          Unknown resource type (6).
static int WHEAT
           
static int WOOD
           
 
Constructor Summary
SOCResourceConstants()
           
 
Method Summary
static java.lang.String aResName(int rtype)
          Get the indefinite article of the resource type name for this number, such as "a clay" or "an ore".
static java.lang.String resName(int rtype)
          Get the resource type name for this resource type number, such as "clay" or "ore".
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLAY

public static final int CLAY
Warning: Don't mess with these constants, other pieces of code depend on these numbers staying like this. CLAY is first (1), WOOD is last (5), UNKNOWN is after wood.

Some code also takes advantage that CLAY == SOCBoard.CLAY_HEX, SHEEP == SOCBoard.SHEEP_HEX, etc.

See Also:
MIN, Constant Field Values

ORE

public static final int ORE
See Also:
Constant Field Values

SHEEP

public static final int SHEEP
See Also:
Constant Field Values

WHEAT

public static final int WHEAT
See Also:
Constant Field Values

WOOD

public static final int WOOD
See Also:
Constant Field Values

UNKNOWN

public static final int UNKNOWN
Unknown resource type (6). Occurs after WOOD (5). Sometimes also used as a "MAX+1" for array sizing for per-resource-type arrays that contain CLAY through WOOD but don't contain UNKNOWN.

Same numeric value as GOLD_LOCAL.

See Also:
MAXPLUSONE, Constant Field Values

GOLD_LOCAL

public static final int GOLD_LOCAL
Some code, internal to the soc.game or soc.robot packages, uses this value (6) to represent SOCBoardLarge.GOLD_HEX tiles; same numeric value as UNKNOWN. Occurs after WOOD (5).

Gold is not a resource, and GOLD_LOCAL should not be sent over the network or used externally.

Since:
2.0.00
See Also:
Constant Field Values

CLOTH_STOLEN_LOCAL

public static final int CLOTH_STOLEN_LOCAL
Some code, internal to the soc.game or soc.server packages, uses this value (7) to represent stolen cloth (SOCPlayer.getCloth()) for scenario game option _SC_CLVI.

Cloth is not a resource, and CLOTH_STOLEN_LOCAL should not be sent over the network or used for anything except internally reporting stolen cloth. So, this value can be changed between versions. Numerically higher than GOLD_LOCAL.

Since:
2.0.00
See Also:
Constant Field Values

MIN

public static final int MIN
Minimum value (1 == CLAY)

See Also:
Constant Field Values

MAXPLUSONE

public static final int MAXPLUSONE
One past maximum value (7; max value is 6 == UNKNOWN)

See Also:
Constant Field Values
Constructor Detail

SOCResourceConstants

public SOCResourceConstants()
Method Detail

resName

public static java.lang.String resName(int rtype)
Get the resource type name for this resource type number, such as "clay" or "ore".

Parameters:
rtype - Resource type, such as CLAY or WOOD. UNKNOWN / GOLD_LOCAL is out of range.
Returns:
Lowercase resource name, or null if rtype is out of range.
Since:
1.1.08

aResName

public static java.lang.String aResName(int rtype)
Get the indefinite article of the resource type name for this number, such as "a clay" or "an ore".

Parameters:
rtype - Resource type, such as CLAY or SHEEP.
Returns:
Lowercase resource name, or null if rtype is out of range (CLAY - WOOD)
Since:
1.1.08