A stock with fixed slots (some can be empty)

Hierarchy

Constructors

Properties

dice: BgaDie[] = []
element: HTMLElement

the stock element (should be an empty HTML Element)

manager: DiceManager

the die manager

mapDieToSlot?: ((die) => SlotId)

Type declaration

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'
slotClasses: string[]
slots: HTMLDivElement[] = []
slotsIds: SlotId[] = []

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)

  • 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

  • Change the slots ids. Will empty the stock before re-creating the slots.

    Parameters

    • slotsIds: SlotId[]

      the new slotsIds. Will replace the old ones.

    Returns void

  • Swap dice inside the slot stock.

    Parameters

    • dice: BgaDie[]

      the dice to swap

    • Optional settings: AddDieSettings

      for updateInformations and selectable

    Returns Promise<boolean[]>

Generated using TypeDoc