com.planet_ink.coffee_mud.Items.MiscMagic
Class StdHandOfCards

java.lang.Object
  extended by com.planet_ink.coffee_mud.Items.Basic.StdItem
      extended by com.planet_ink.coffee_mud.Items.Basic.StdContainer
          extended by com.planet_ink.coffee_mud.Items.MiscMagic.StdHandOfCards
All Implemented Interfaces:
Affectable, Behavable, CloseableLockable, CMObject, Contingent, DBIdentifiable, Environmental, Modifiable, MsgListener, Physical, PhysicalAgent, Readable, Rider, StatsAffecting, Tickable, Container, HandOfCards, Item, MiscMagic, Wearable, java.lang.Cloneable, java.lang.Comparable<CMObject>
Direct Known Subclasses:
StdDeckOfCards

public class StdHandOfCards
extends StdContainer
implements MiscMagic, HandOfCards


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.planet_ink.coffee_mud.Items.interfaces.Wearable
Wearable.CODES
 
Field Summary
 
Fields inherited from class com.planet_ink.coffee_mud.Items.Basic.StdContainer
capacity, containType, defaultsClosed, defaultsLocked, hasALid, hasALock, isLocked, isOpen, openDelayTicks
 
Fields inherited from class com.planet_ink.coffee_mud.Items.Basic.StdItem
affectPhyStats, affects, baseGoldValue, basePhyStats, behaviors, cachedImageName, CODES, databaseID, description, destroyed, displayText, dispossessionTime, material, me, miscText, myContainer, myUses, myWornCode, name, owner, phyStats, properWornBitmap, rawImageName, riding, scripts, secretIdentity, tickCtr, tickStatus, wornLogicalAnd, xtraValues
 
Fields inherited from interface com.planet_ink.coffee_mud.Items.interfaces.Container
CONTAIN_ANYTHING, CONTAIN_BODIES, CONTAIN_CAGED, CONTAIN_CLOTHES, CONTAIN_COINS, CONTAIN_DAGGERS, CONTAIN_DESCS, CONTAIN_DRINKABLES, CONTAIN_EATABLES, CONTAIN_FOOTWEAR, CONTAIN_KEYS, CONTAIN_LIQUID, CONTAIN_ONEHANDWEAPONS, CONTAIN_OTHERWEAPONS, CONTAIN_RAWMATERIALS, CONTAIN_READABLES, CONTAIN_SCROLLS, CONTAIN_SMOKEABLES, CONTAIN_SSCOMPONENTS, CONTAIN_SWORDS
 
Fields inherited from interface com.planet_ink.coffee_mud.Items.interfaces.Wearable
DEFAULT_WORN_CODES, DEFAULT_WORN_DEPENDENCYGRID, DEFAULT_WORN_DESCS, DEFAULT_WORN_ORDER, DEFAULT_WORN_USUAL_NAMES, DEFAULT_WORN_WEIGHT_POINTS, DEFAULT_WORN_WEIGHTS, FILTER_ANY, FILTER_MOBINVONLY, FILTER_ROOMONLY, FILTER_UNWORNONLY, FILTER_WORNONLY, HIGHEST_WORN_CODE, IN_INVENTORY, WORN_ABOUT_BODY, WORN_ARMS, WORN_BACK, WORN_EARS, WORN_EYES, WORN_FEET, WORN_FLOATING_NEARBY, WORN_HANDS, WORN_HEAD, WORN_HELD, WORN_LEFT_FINGER, WORN_LEFT_WRIST, WORN_LEGS, WORN_MOUTH, WORN_NECK, WORN_RIGHT_FINGER, WORN_RIGHT_WRIST, WORN_TORSO, WORN_WAIST, WORN_WIELD
 
Constructor Summary
StdHandOfCards()
           
 
Method Summary
 boolean addCard(PlayingCard card)
          Returns the given card item object to the deck by removing it from its current owner and adding it back to the decks owner and container.
 boolean canContain(Item I)
          Returns whether this container is allowed to contain the given object.
 boolean containsAtLeastOneOfSuit(int cardBitCode)
          Returns whether a PlayingCard in this deck or hand of the given suit is to be found herein.
 boolean containsAtLeastOneOfSuit(java.lang.String cardStringCode)
          Returns whether a PlayingCard in this deck or hand of the given suit is to be found herein.
 boolean containsAtLeastOneOfValue(int cardBitCode)
          Returns whether a PlayingCard in this deck or hand of the given value is to be found herein.
 boolean containsAtLeastOneOfValue(java.lang.String cardStringCode)
          Returns whether a PlayingCard in this deck or hand of the given value is to be found herein.
 boolean containsCard(int cardBitCode)
          Returns whether this hand contains a card of the given bit code value.
 boolean containsCard(java.lang.String cardStringCode)
          Returns whether this hand contains a card of the given string code value.
 HandOfCards createEmptyHand(Environmental player)
          Creates an empty HandOfCards object if the player passed in is not null, it will add the new hand to the inventory of the given hand-holder.
 void executeMsg(Environmental host, CMMsg msg)
          The general message event handler for the object.
 PlayingCard getCard(int cardBitCode)
          Returns the PlayingCard from this deck or hand if it is to be found herein.
 PlayingCard getCard(java.lang.String cardStringCode)
          Gets the PlayingCard from this deck or hand if it is to be found herein.
 ReadOnlyList<Item> getContents()
          Returns all the immediate items in this container, including other containers, but not the contents of those innner containers.
 java.lang.String[] getContentsEncoded()
          This method builds a string array equal in size to the deck.
 PlayingCard getFirstCardOfSuit(int cardBitCode)
          Returns the first PlayingCard from this deck or hand of the given suit is to be found herein.
 PlayingCard getFirstCardOfSuit(java.lang.String cardStringCode)
          Returns the first PlayingCard from this deck or hand of the given suit is to be found herein.
 PlayingCard getFirstCardOfValue(int cardBitCode)
          Returns the first PlayingCard from this deck or hand of the given value is to be found herein.
 PlayingCard getFirstCardOfValue(java.lang.String cardStringCode)
          Returns the first PlayingCard from this deck or hand of the given value is to be found herein.
 PlayingCard getTopCardFromDeck()
          Returns the top card item object from the deck
 java.lang.String ID()
          The CoffeeMud Java Class ID shared by all instances of this object.
 int numberOfCards()
          Returns the current number of cards in the deck.
 boolean removeAllCards()
          Removes all cards from the deck and places them in limbo.
 boolean removeCard(PlayingCard card)
          Removes the given card from the deck and places it in limbo.
 boolean shuffleDeck()
          Shuffles the hand of cards, randomizing them.
 void sortByValueAceHigh()
          This method is a sort of anti-shuffle.
 void sortByValueAceLow()
          This method is a sort of anti-shuffle.
 
Methods inherited from class com.planet_ink.coffee_mud.Items.Basic.StdContainer
capacity, containTypes, defaultsClosed, defaultsLocked, emptyPlease, getDeepContents, hasADoor, hasALock, hasContent, isInside, isLocked, isOpen, keyName, numberOfItems, okMessage, openDelayTicks, recursiveWeight, setCapacity, setContainTypes, setDoorsNLocks, setKeyName, setMiscText, setOpenDelayTicks, tick
 
Methods inherited from class com.planet_ink.coffee_mud.Items.Basic.StdItem
abilityImbuesMagic, addBehavior, addEffect, addNonUninvokableEffect, addScript, affectCharState, affectCharStats, affectPhyStats, alreadyWornMsg, amBeingWornProperly, amDestroyed, amWearingAt, baseGoldValue, basePhyStats, behaviors, canSaveDatabaseID, canWear, canWearComplete, cloneFix, compareProperLocations, compareTo, container, copyOf, databaseID, delAllBehaviors, delAllEffects, delAllScripts, delBehavior, delEffect, delScript, description, description, destroy, displayText, displayText, eachBehavior, eachEffect, eachScript, effects, expirationDate, fetchBehavior, fetchBehavior, fetchEffect, fetchEffect, fetchScript, fitsOn, getCodeNum, getSaveStatIndex, getStat, getStatCodes, getTickStatus, I, image, initializeClass, isGeneric, isReadable, isSavable, isStat, L, material, maxRange, minRange, miscTextFormat, name, Name, name, newInstance, numBehaviors, numEffects, numScripts, owner, phyStats, rawImage, rawLogicalAnd, rawProperLocationBitmap, rawSecretIdentity, rawWornCode, readableText, recoverPhyStats, removeFromOwnerContainer, riding, sameAs, scripts, secretIdentity, setBasePhyStats, setBaseValue, setContainer, setDatabaseID, setDescription, setDisplayText, setExpirationDate, setImage, setMaterial, setName, setOwner, setRawLogicalAnd, setRawProperLocationBitmap, setRawWornCode, setReadable, setReadableText, setRiding, setSavable, setSecretIdentity, setStat, setUsesRemaining, stopTicking, subjectToWearAndTear, tackOns, text, ultimateContainer, unWear, usesRemaining, value, wearAt, wearEvenIfImpossible, wearIfPossible, wearIfPossible, whereCantWear
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.planet_ink.coffee_mud.Items.interfaces.Container
capacity, containTypes, emptyPlease, getDeepContents, hasContent, isInside, setCapacity, setContainTypes
 
Methods inherited from interface com.planet_ink.coffee_mud.Items.interfaces.Item
baseGoldValue, container, material, numberOfItems, owner, rawSecretIdentity, recursiveWeight, removeFromOwnerContainer, secretIdentity, setBaseValue, setContainer, setMaterial, setOwner, setSecretIdentity, setUsesRemaining, stopTicking, subjectToWearAndTear, ultimateContainer, usesRemaining, value
 
Methods inherited from interface com.planet_ink.coffee_mud.core.interfaces.Rider
riding, setRiding
 
Methods inherited from interface com.planet_ink.coffee_mud.core.interfaces.CMObject
copyOf, initializeClass, newInstance
 
Methods inherited from interface java.lang.Comparable
compareTo
 
Methods inherited from interface com.planet_ink.coffee_mud.core.interfaces.DBIdentifiable
canSaveDatabaseID, databaseID, setDatabaseID
 
Methods inherited from interface com.planet_ink.coffee_mud.Items.interfaces.Wearable
amBeingWornProperly, amWearingAt, canWear, compareProperLocations, fitsOn, rawLogicalAnd, rawProperLocationBitmap, rawWornCode, setRawLogicalAnd, setRawProperLocationBitmap, setRawWornCode, unWear, wearAt, wearEvenIfImpossible, wearIfPossible, wearIfPossible, whereCantWear
 
Methods inherited from interface com.planet_ink.coffee_mud.core.interfaces.Readable
isReadable, readableText, setReadable, setReadableText
 
Methods inherited from interface com.planet_ink.coffee_mud.core.interfaces.CloseableLockable
defaultsClosed, defaultsLocked, hasADoor, hasALock, isLocked, isOpen, keyName, openDelayTicks, setDoorsNLocks, setKeyName, setOpenDelayTicks
 

Constructor Detail

StdHandOfCards

public StdHandOfCards()
Method Detail

ID

public java.lang.String ID()
Description copied from interface: CMObject
The CoffeeMud Java Class ID shared by all instances of this object. Unlike the Java Class name, this method does not include package information. However, it must return a String value unique to its class category in the ClassLoader. Class categories include Libraries, Common, Areas, Abilities, Behaviors, CharClasses, Commands, Exits Locales, MOBS, Races, WebMacros, Basic Items, Armor, Weapons, ClanItems, Tech. The name is typically identical to the class name.

Specified by:
ID in interface CMObject
Overrides:
ID in class StdContainer
Returns:
the name of this class

getContents

public ReadOnlyList<Item> getContents()
Description copied from interface: Container
Returns all the immediate items in this container, including other containers, but not the contents of those innner containers. Just the first level contents of this container.

Specified by:
getContents in interface Container
Overrides:
getContents in class StdContainer
Returns:
all the immediate items in this container
See Also:
Container.getDeepContents()

shuffleDeck

public boolean shuffleDeck()
Description copied from interface: HandOfCards
Shuffles the hand of cards, randomizing them.

Specified by:
shuffleDeck in interface HandOfCards
Returns:
the hand of cards, randomizing them.

getTopCardFromDeck

public PlayingCard getTopCardFromDeck()
Description copied from interface: HandOfCards
Returns the top card item object from the deck

Specified by:
getTopCardFromDeck in interface HandOfCards
Returns:
the top card item object from the deck

addCard

public boolean addCard(PlayingCard card)
Description copied from interface: HandOfCards
Returns the given card item object to the deck by removing it from its current owner and adding it back to the decks owner and container. If doing this causes a players hand to be devoid of cards, the hand container is destroyed.

Specified by:
addCard in interface HandOfCards
Parameters:
card - the card to remove
Returns:
true if the card was moved, false if pigs fly

numberOfCards

public int numberOfCards()
Description copied from interface: HandOfCards
Returns the current number of cards in the deck.

Specified by:
numberOfCards in interface HandOfCards
Returns:
number of cards in the deck

removeCard

public boolean removeCard(PlayingCard card)
Description copied from interface: HandOfCards
Removes the given card from the deck and places it in limbo. Calls to this method should be followed by an addCard method on another deck.

Specified by:
removeCard in interface HandOfCards
Parameters:
card - the card to remove
Returns:
true if the card was there to remove, false otherwise

removeAllCards

public boolean removeAllCards()
Description copied from interface: HandOfCards
Removes all cards from the deck and places them in limbo. Calls to this method should be followed by either a destroy method on the cards themselves or an addCard method on another deck.

Specified by:
removeAllCards in interface HandOfCards
Returns:
true if there were any cards removed, false otherwise

getContentsEncoded

public java.lang.String[] getContentsEncoded()
Description copied from interface: HandOfCards
This method builds a string array equal in size to the deck. It then returns the contents of the deck encoded in cardStringCode format. See convertCardBitCodeToCardStringCode

Specified by:
getContentsEncoded in interface HandOfCards
Returns:
string encoded list of the cards

sortByValueAceHigh

public void sortByValueAceHigh()
Description copied from interface: HandOfCards
This method is a sort of anti-shuffle. It puts the cards in order, first by value, then by suit, with ace considered high.

Specified by:
sortByValueAceHigh in interface HandOfCards

sortByValueAceLow

public void sortByValueAceLow()
Description copied from interface: HandOfCards
This method is a sort of anti-shuffle. It puts the cards in order, first by value, then by suit, with ace low.

Specified by:
sortByValueAceLow in interface HandOfCards

createEmptyHand

public HandOfCards createEmptyHand(Environmental player)
Description copied from interface: HandOfCards
Creates an empty HandOfCards object if the player passed in is not null, it will add the new hand to the inventory of the given hand-holder. Either way, it will return the empty hand object.

Specified by:
createEmptyHand in interface HandOfCards
Parameters:
player - the holder can be a mob or a room
Returns:
the new empty hand of cards created.

containsCard

public boolean containsCard(java.lang.String cardStringCode)
Description copied from interface: HandOfCards
Returns whether this hand contains a card of the given string code value. A string code is a single letter suit followed by a single letter for face cards and the ace, or a number for other cards.

Specified by:
containsCard in interface HandOfCards
Parameters:
cardStringCode - the encoded card string
Returns:
true if that card is here, false otherwise.

getCard

public PlayingCard getCard(java.lang.String cardStringCode)
Description copied from interface: HandOfCards
Gets the PlayingCard from this deck or hand if it is to be found herein. DOES NOT REMOVE! removeCard should be called next to do that. a string code is a single letter suit followed by a single letter for face cards and the ace, or a number for other cards.

Specified by:
getCard in interface HandOfCards
Parameters:
cardStringCode - the encoded card string
Returns:
the card object, or null.

getFirstCardOfValue

public PlayingCard getFirstCardOfValue(java.lang.String cardStringCode)
Description copied from interface: HandOfCards
Returns the first PlayingCard from this deck or hand of the given value is to be found herein. DOES NOT REMOVE! removeCard should be called next to do that. a string code is a single letter for face cards and the ace, or a number for other cards.

Specified by:
getFirstCardOfValue in interface HandOfCards
Parameters:
cardStringCode - the encoded card string
Returns:
the card object, or null.

containsAtLeastOneOfValue

public boolean containsAtLeastOneOfValue(java.lang.String cardStringCode)
Description copied from interface: HandOfCards
Returns whether a PlayingCard in this deck or hand of the given value is to be found herein. A string code is a single letter for face cards and the ace, or a number for other cards.

Specified by:
containsAtLeastOneOfValue in interface HandOfCards
Parameters:
cardStringCode - the encoded card string
Returns:
true if one was found, false otherwise

containsAtLeastOneOfSuit

public boolean containsAtLeastOneOfSuit(java.lang.String cardStringCode)
Description copied from interface: HandOfCards
Returns whether a PlayingCard in this deck or hand of the given suit is to be found herein. A string code is a single letter suit.

Specified by:
containsAtLeastOneOfSuit in interface HandOfCards
Parameters:
cardStringCode - the encoded card string
Returns:
true if one was found, false otherwise

getFirstCardOfSuit

public PlayingCard getFirstCardOfSuit(java.lang.String cardStringCode)
Description copied from interface: HandOfCards
Returns the first PlayingCard from this deck or hand of the given suit is to be found herein. DOES NOT REMOVE! removeCard should be called next to do that. A string code is a single letter suit.

Specified by:
getFirstCardOfSuit in interface HandOfCards
Parameters:
cardStringCode - the encoded card string
Returns:
the card object, or null.

containsCard

public boolean containsCard(int cardBitCode)
Description copied from interface: HandOfCards
Returns whether this hand contains a card of the given bit code value. A bit code is as described in PlayingCard.java

Specified by:
containsCard in interface HandOfCards
Parameters:
cardBitCode - the card bit code
Returns:
true if one was found, false otherwise
See Also:
PlayingCard.getBitEncodedValue()

getCard

public PlayingCard getCard(int cardBitCode)
Description copied from interface: HandOfCards
Returns the PlayingCard from this deck or hand if it is to be found herein. DOES NOT REMOVE! removeCard should be called next to do that. A bit code is as described in PlayingCard.java

Specified by:
getCard in interface HandOfCards
Parameters:
cardBitCode - the card bit code
Returns:
the card object, or null.
See Also:
PlayingCard.getBitEncodedValue()

getFirstCardOfValue

public PlayingCard getFirstCardOfValue(int cardBitCode)
Description copied from interface: HandOfCards
Returns the first PlayingCard from this deck or hand of the given value is to be found herein. DOES NOT REMOVE! removeCard should be called next to do that. A bit code is as described in PlayingCard.java

Specified by:
getFirstCardOfValue in interface HandOfCards
Parameters:
cardBitCode - the card bit code
Returns:
the card object, or null.
See Also:
PlayingCard.getBitEncodedValue()

containsAtLeastOneOfValue

public boolean containsAtLeastOneOfValue(int cardBitCode)
Description copied from interface: HandOfCards
Returns whether a PlayingCard in this deck or hand of the given value is to be found herein. A bit code is as described in PlayingCard.java

Specified by:
containsAtLeastOneOfValue in interface HandOfCards
Parameters:
cardBitCode - the card bit code
Returns:
true if one was found, false otherwise
See Also:
PlayingCard.getBitEncodedValue()

containsAtLeastOneOfSuit

public boolean containsAtLeastOneOfSuit(int cardBitCode)
Description copied from interface: HandOfCards
Returns whether a PlayingCard in this deck or hand of the given suit is to be found herein. A bit code is as described in PlayingCard.java

Specified by:
containsAtLeastOneOfSuit in interface HandOfCards
Parameters:
cardBitCode - the card bit code
Returns:
true if one was found, false otherwise
See Also:
PlayingCard.getBitEncodedValue()

getFirstCardOfSuit

public PlayingCard getFirstCardOfSuit(int cardBitCode)
Description copied from interface: HandOfCards
Returns the first PlayingCard from this deck or hand of the given suit is to be found herein. DOES NOT REMOVE! removeCard should be called next to do that. A bit code is as described in PlayingCard.java

Specified by:
getFirstCardOfSuit in interface HandOfCards
Parameters:
cardBitCode - the card bit code
Returns:
the card object, or null.
See Also:
PlayingCard.getBitEncodedValue()

canContain

public boolean canContain(Item I)
Description copied from interface: Container
Returns whether this container is allowed to contain the given object.

Specified by:
canContain in interface Container
Overrides:
canContain in class StdContainer
Parameters:
I - the item to check against the allowed content
Returns:
true if the given item can go in this container, false otherwise
See Also:
Container.setContainTypes(long), Container.containTypes()

executeMsg

public void executeMsg(Environmental host,
                       CMMsg msg)
Description copied from interface: MsgListener
The general message event handler for the object. Messages passed herein may not necessarily be FOR this object, or from it, but will almost always represent events happening in the same room. The messages have already been through an approval process, so this method is called only to affect the final execution of the meaning of the message. Every game event goes through these methods.

Specified by:
executeMsg in interface MsgListener
Overrides:
executeMsg in class StdContainer
Parameters:
host - either the initiator of the event, or the host of this object
msg - the CMMsg that needs to be executed
See Also:
CMMsg