bga-cards
    Preparing search index...

    Class VoidStock<T>

    A stock to make cards disappear (to automatically remove discarded cards, or to represent a bag)

    Type Parameters

    • T

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    cards: T[] = []
    counter: CardCounter<T> = null
    element: HTMLElement

    the stock element (should be an empty HTML Element)

    manager: CardManager<T>

    the card manager

    onCardAdded?: (card: T) => void

    Called when a card is added to the stock. Returns the added card.

    card: the added card

    onCardClick?: (card: T) => void

    Called when a card is clicked. Returns the clicked card.

    card: the clicked card (can be selected or unselected)

    onCardCountChange?: (cardCount: number) => void

    Called when card count change. Returns the clicked card.

    card: the clicked card (can be selected or unselected)

    onCardRemoved?: (card: T) => void

    Called when a card is removed from the stock. Returns the removed card.

    card: the removed card

    onSelectionChange?: (selection: T[], lastChange: T) => void

    Called when selection change. Returns the selection.

    selection: the selected cards of the stock
    lastChange: the last change on selection card (can be selected or unselected)

    selectableCards: T[] = []
    selectedCards: T[] = []
    selectionMode: CardSelectionMode = 'none'
    settings?: CardStockSettings<T>

    the optional stock settings

    sort?: SortFunction<T>

    Methods

    • Add a card to the stock.

      Parameters

      Returns Promise<boolean>

      the promise when the animation is done (true if it was animated, false if it wasn't)

    • Add an array of cards to the stock.

      Parameters

      • cards: T[]

        the cards to add

      • Optionalsettings: AddCardToVoidStockSettings

        a AddCardToVoidStockSettings object

      • shift: number | boolean = false

        if number, the number of milliseconds between each card. if true, chain animations

      Returns Promise<boolean>

    • Parameters

      • card: T
      • element: HTMLElement

        The element to animate. The element is added to the destination stock before the animation starts.

      • fromElement: HTMLElement
      • toElement: HTMLElement

        The HTMLElement to attach the card to.

      • insertBefore: HTMLElement
      • settings: AddCardSettings

      Returns Promise<boolean>

    • Returns void

    • Checks if the card can be added. By default, only if it isn't already present in the stock.

      Parameters

      Returns boolean

      if the card can be added

    • Parameters

      • card: T

      Returns void

    • Updates the cards number, if the counter is visible.

      Returns void

    • Triggered after card order is changed, when setting a new sort function.

      Returns void

    • Parameters

      • card: T

        a card

      Returns boolean

      if the card is present in the stock

    • Returns the card count in the deck (what the player think there is, for decks, the real number of cards for all visible card stocks).

      Returns number

      the number of card in the stock

    • Parameters

      • card: T

        a card in the stock

      Returns HTMLElement

      the HTML element generated for the card

    • Returns T[]

      the cards on the stock

    • Parameters

      • card: T

      Returns number

    • Returns T[]

      the selected cards

    • Returns boolean

      if the stock is empty

    • Parameters

      • card: T

      Returns boolean

      if the card is selectable

    • Parameters

      • card: T

      Returns boolean

      if the card is selected

    • Removes the stock and unregister it on the manager.

      Returns void

    • Remove a card from the stock.

      Parameters

      Returns Promise<boolean>

    • Remove a set of card from the stock.

      Parameters

      Returns Promise<boolean>

    • Remove the mark of the last play cards.

      Parameters

      • OptionalcardClass: string

      Returns void

    • Select all cards

      Parameters

      • silent: boolean = false

      Returns void

    • Set selected state to a card.

      Parameters

      • card: T

        the card to select

      • silent: boolean = false

      Returns void

    • Set the card to its front (visible) or back (not visible) side.

      Parameters

      Returns void

    • Mark the last play cards. Remove the other last play card classes.

      Parameters

      • cards: T[]

        the cards to mark as last played

      • Optionalcolor: string

        the color to use to mark the last played card, usually the player color

      • OptionalcardClass: string

        a class applied on this type of cards, to limit removal to these type of cards.

      Returns void

    • Parameters

      • card: T
      • selectable: boolean

      Returns void

    • Set the selectable class for each card.

      Parameters

      • OptionalselectableCards: T[]

        the selectable cards. If unset, all cards are marked selectable. Default unset.

      Returns void

    • Set if the stock is selectable, and if yes if it can be multiple. If set to 'none', it will unselect all selected cards.

      Parameters

      • selectionMode: CardSelectionMode

        the selection mode

      • OptionalselectableCards: T[]

        the selectable cards (all if unset). Calls setSelectableCards method

      Returns void

    • Parameters

      • element: HTMLElement

      Returns void

    • Changes the sort function of the stock.

      Parameters

      • Optionalsort: SortFunction<T>

        the new sort function. If defined, the stock will be sorted with this new function.

      Returns void

    • Returns if a card should be placed on this stock (with the autoPlace setting).

      Parameters

      • card: T

      Returns boolean

    • Unselect all cards

      Parameters

      • silent: boolean = false

      Returns void

    • Set unselected state to a card.

      Parameters

      • card: T

        the card to unselect

      • silent: boolean = false

      Returns void