cards
Adds a CardDeck class that can be shuffled, drawn from,
discarded to, and so forth. This can simulate existing card decks
from the game or arbitrary deck-like collections of objects.
Although a CardDeck may hold any kind of object, the
class provides special support for GameItem objects.
Create a new, empty deck of cards.
Returns a string consisting of a comma separated list of the cards in
this card deck.
returns a string listing the contents of this CardDeck
Create a deck of cards that contains all of the cards in a standard
item deck of the type specified by itemType, which must be
one of the following values:
resources.GameData.ITEM_COMMON
resources.GameData.ITEM_UNIQUE
resources.GameData.ITEM_EXHIBIT
resources.GameData.ITEM_SPELL
resources.GameData.ITEM_ALLY
resources.GameData.ITEM_SKILL
The expansions variable controls which expansions
are included using an array of boolean flags. If the flag value at a
given index is true, then the cards from the expansion at the same
index in resources.GameData.getExpansions() will be included in
the deck. If expansions contains fewer entries than
there are expansions, a value of false is assumed for all missing
entries. If expansions is not defined, all expansions are included.
Example: Print an unshuffled common item deck for the base game with
no expansions.
println( CardDeck.createItemDeck( resources.GameData.ITEM_COMMON, [true] ) );
| itemType | the type of item deck to create |
| expansions | an array of flags indicating the expansions to include |
returns a CardDeck which includes the requested cards
Create a new deck, using items from an array to populate it.
| arrayLikeObject | an array or array-like object to copy from |
returns a card deck consisting of objects copied from arrayLikeObject
Shuffle the cards in a deck into random order.
Draw the top card off the deck. This removes the card from the deck;
to return the card, use CardDeck.discard. Drawing from an
empty deck throws an exception.
removes and returns the top card from the deck
Search the deck for the first card for which matchFunction(card)
returns true. If a matching card is found, remove it from the deck and
return it. If there is no matching card, return null.
| matchFunction | a function that takes a card and returns true if it is the type of card you wish to draw |
returns the matching card (which is removed from the deck), or null
A match function that can be used with CardDeck.drawFirst to draw
the first Tome in a deck of GameItems.
A match function that can be used with CardDeck.drawFirst to draw
the first Mask in a deck of GameItems.
A match function that can be used with CardDeck.drawFirst to draw
the first Task or Mission in a deck of GameItems.
A match function that can be used with CardDeck.drawFirst to draw
the first Weapon in a deck of GameItems.
Adds card to the bottom of the deck.
It is not required that card have previously been drawn from
the deck. If copies is defined, then
that many copies are added, all identical.
The default value is 1.
| card | the card to add to the deck |
| copies | the optional number of copies to add to the deck |
places card(s) on the bottom of the deck
Return a card from the deck without removing it. If index
is not defined, then the card at the top of the deck is returned.
Otherwise, if index is 0 or positive, then the card at position
index is returned, where a position of 0 is the top of the deck,
1 is the next card from the top, and so on. If index is negative,
then the cards are counted from the bottom of the deck: -1 is the last card,
-2 is the penultimate card, and so on.
| index | the position of the card to peek at within the deck |
returns the card at index
Pull a card from the deck from any position. The card at the requested position
is removed from the deck and returned. As with CardDeck.peek(),
a negative index may be used to count from the bottom of the deck.
If called without an index argument, this method is equivalent to
CardDeck.draw().
| index | the optional position of the card to remove from the deck |
returns and removes the card at index
Returns the number of cards currently in this deck.
Index Contents