The abstract stock. It shouldn't be used directly, use stocks that extends it.

Hierarchy

Constructors

Properties

dice: BgaDie[] = []
element: HTMLElement

the stock element (should be an empty HTML Element)

manager: DiceManager

the die manager

onDieClick?: ((die) => void)

Type declaration

    • (die): void
    • Called when selection change. Returns the clicked die.

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

      Parameters

      Returns void

onSelectionChange?: ((selection, lastChange) => void)

Type declaration

    • (selection, lastChange): void
    • Called when selection change. Returns the selection.

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

      Parameters

      Returns void

selectedDice: BgaDie[] = []
selectionMode: DiceSelectionMode = 'none'
settings?: DieStockSettings

Methods

  • Add an array of dice to the stock.

    Parameters

    • dice: BgaDie[]

      the dice to add

    • Optional animation: DieAnimation

      a DieAnimation object

    • Optional settings: AddDieSettings

      a AddDiceettings object

    • shift: number | boolean = false

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

    Returns Promise<boolean>

  • Add a die to the stock.

    Parameters

    Returns Promise<boolean>

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

  • Parameters

    • element: HTMLElement

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

    • fromRect: DOMRect
    • settings: DieAnimationSettings

    Returns Promise<boolean>

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

    Parameters

    Returns boolean

    if the die can be added

  • Notify the stock that a die is removed.

    Parameters

    • die: BgaDie

      the die to remove

    Returns void

  • Parameters

    • die: BgaDie

      a die in the stock

    Returns HTMLElement

    the HTML element generated for the die

  • Returns string

    the class to apply to selectable dice. Use class from manager is unset.

  • Returns string

    the class to apply to selected dice. Use class from manager is unset.

  • Returns string

    the class to apply to selectable dice. Use class from manager is unset.

  • Remove a set of dice from the stock.

    Parameters

    • dice: BgaDie[]

      the dice to remove

    Returns void

  • Parameters

    • dieElement: HTMLElement

    Returns void

  • Select all dice

    Parameters

    • silent: boolean = false

    Returns void

  • Set selected state to a die.

    Parameters

    • die: BgaDie

      the die to select

    • silent: boolean = false

    Returns void

  • Set the selectable class for each die.

    Parameters

    • Optional selectableDice: BgaDie[]

      the selectable dice. If unset, all dice 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 dice.

    Parameters

    • selectionMode: DiceSelectionMode

      the selection mode

    • Optional selectableDice: BgaDie[]

      the selectable dice (all if unset). Calls setSelectableDice method

    Returns void

  • Unelect all dice

    Parameters

    • silent: boolean = false

    Returns void

  • Set unselected state to a die.

    Parameters

    • die: BgaDie

      the die to unselect

    • silent: boolean = false

    Returns void

Generated using TypeDoc