|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object soc.game.SOCInventoryItem soc.game.SOCDevCard
public class SOCDevCard
A single Dev Card, probably within a player's SOCInventory
.
Field Summary | |
---|---|
private static java.lang.String[][] |
GETCARDTYPENAME_KEYS
Resource type-and-count text keys for getCardTypeName(int, SOCGame, boolean, SOCStringManager) . |
private boolean |
nameKeyPrecalc
If true, getItemName(SOCGame, boolean, SOCStringManager) can just use the
strKey or aStrKey
keys already looked up for the constructor super call. |
Fields inherited from class soc.game.SOCInventoryItem |
---|
aStrKey, canCancelPlay, itype, strKey |
Fields inherited from interface soc.game.SOCDevCardConstants |
---|
CAP, DESTROY, DISC, KNIGHT, KNIGHT_FOR_VERS_1_X, LIB, MAXPLUSONE, MIN, MIN_KNOWN, MONO, ROADS, SWAP, TEMP, TOW, UNIV, UNKNOWN, UNKNOWN_FOR_VERS_1_X, VERSION_FOR_NEW_TYPES |
Constructor Summary | |
---|---|
|
SOCDevCard(int type,
boolean isNew)
Create a new card. |
private |
SOCDevCard(int type,
boolean isVPCard,
boolean isNew)
constructor to call super, to avoid 3 isVPCard(type) calls |
Method Summary | |
---|---|
static java.lang.String |
getCardTypeName(int ctype,
SOCGame game,
boolean withArticle,
SOCStringManager strings)
Get a card type's name. |
static java.lang.String |
getCardTypeNameKey(int ctype,
SOCGame game,
boolean withArticle)
Get a card type's name key. |
java.lang.String |
getItemName(SOCGame game,
boolean withArticle,
SOCStringManager strings)
Get the item's name. |
static boolean |
isVPCard(int ctype)
Is this card type a Victory Point card? |
java.lang.String |
toString()
Get a human-readable description, including type, isPlayable, isVP. |
Methods inherited from class soc.game.SOCInventoryItem |
---|
clone, createForScenario, isKept, isNew, isPlayable, isPlayForPlacement, isVPItem, newToOld |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private final boolean nameKeyPrecalc
getItemName(SOCGame, boolean, SOCStringManager)
can just use the
strKey
or aStrKey
keys already looked up for the constructor super call.
If false, the item text varies by game options and must be calculated each time
getItemName(SOCGame, boolean, SOCStringManager)
is called.
private static final java.lang.String[][] GETCARDTYPENAME_KEYS
getCardTypeName(int, SOCGame, boolean, SOCStringManager)
.
Each subarray's indexes are the same values as SOCDevCardConstants.UNKNOWN
to SOCDevCardConstants.TOW
.
Constructor Detail |
---|
public SOCDevCard(int type, boolean isNew)
type
- Card type, such as SOCDevCardConstants.ROADS
isNew
- Is this card newly given to a player, or old from a previous turn?private SOCDevCard(int type, boolean isVPCard, boolean isNew)
Method Detail |
---|
public static boolean isVPCard(int ctype)
ctype
- A constant such as SOCDevCardConstants.TOW
or SOCDevCardConstants.ROADS
SOCInventoryItem.isVPItem()
public static java.lang.String getCardTypeNameKey(int ctype, SOCGame game, boolean withArticle)
ctype
- A constant such as SOCDevCardConstants.TOW
or SOCDevCardConstants.ROADS
game
- Game data, or null
; some game options might change a card name.
For example, _SC_PIRI
renames "Knight" to "Warship".withArticle
- If true, format is: "a Market (+1VP)"; if false, is "Market (1VP)"
ctype
and withArticle
; unknown ctypes return "spec.dcards.unknown" / "spec.dcards.aunknown".getCardTypeName(int, SOCGame, boolean, SOCStringManager)
public static java.lang.String getCardTypeName(int ctype, SOCGame game, boolean withArticle, SOCStringManager strings)
ctype
- A constant such as SOCDevCardConstants.TOW
or SOCDevCardConstants.ROADS
game
- Game data, or null
; some game options might change a card name.
For example, _SC_PIRI
renames "Knight" to "Warship".withArticle
- If true, format is: "a Market (+1VP)"; if false, is "Market (1VP)"strings
- StringManager to get i18n localized text
ctype
and withArticle
;
unknown ctypes return "Unknown card type #"getCardTypeNameKey(int, SOCGame, boolean)
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getItemName(SOCGame game, boolean withArticle, SOCStringManager strings)
SOCInventoryItem
Called at server and at client, so any i18n name keys used must be in properties files at server and client.
SOCInventoryItem's implementation just calls strings.get(key)
with the
string keys passed to the constructor. If you need something more dynamic, override this in your subclass.
getItemName
in class SOCInventoryItem
game
- Game data, or null
; some game options might change an item name.
For example, _SC_PIRI
renames "Knight" to "Warship".withArticle
- If true, format is: "a Market (+1VP)"; if false, is "Market (1VP)"strings
- StringManager to get i18n localized text
withArticle
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |