bga-dice
    Preparing search index...

    Class SlotStock<T>

    A stock with fixed slots (some can be empty)

    Type Parameters

    • T

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    dice: T[] = []
    element: HTMLElement

    the stock element (should be an empty HTML Element)

    manager: DiceManager<T>

    the die manager

    mapDieToSlot?: (die: T) => SlotId
    onDieClick?: (die: T) => void

    Called when selection change. Returns the clicked die.

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

    onSelectionChange?: (selection: T[], lastChange: T) => 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)

    selectableDice: T[] = []
    selectedDice: T[] = []
    selectionMode: DiceSelectionMode = 'none'
    slotClasses: string[]
    slots: HTMLDivElement[] = []
    slotsIds: SlotId[] = []
    sort?: SortFunction<T>

    Methods

    • Add an array of dice to the stock.

      Parameters

      • dice: T[]

        the dice to add

      • Optionalsettings: 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

      Returns Promise<void>

    • Parameters

      • die: 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 die to.

      • insertBefore: HTMLElement
      • settings: AddDieSettings

      Returns Promise<boolean>

    • Returns void

    • 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

    • Parameters

      • die: T

        a die

      Returns boolean

      if the die is present in the stock

    • Parameters

      Returns void

    • Parameters

      • die: T

      Returns void

    • Notify the stock that a die is removed.

      Parameters

      • die: T

        the die to remove

      Returns void

    • Returns T[]

      the dice on the stock

    • Parameters

      • die: T

        a die in the stock

      Returns HTMLElement

      the HTML element generated for the die

    • Parameters

      • die: T

      Returns number

    • Parameters

      • min: number
      • max: number

      Returns number

    • Parameters

      • element: Element
      • duration: number
      • deltaYFrom: number = 0
      • deltaYTo: number = 0
      • moveHorizontally: boolean = true
      • angle: number = 0

      Returns Promise<void>

    • 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 T[]

      the selected dice

    • Returns string

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

    • Returns boolean

      if the stock is empty

    • Parameters

      • die: T

      Returns boolean

      if the card is selectable

    • Parameters

      • die: T

      Returns boolean

      the selected dice

    • Remove a set of dice from the stock.

      Parameters

      • dice: T[]

        the dice to remove

      • Optionalsettings: RemoveDieSettings

        a RemoveDieSettings object

      Returns void

    • Start the rolling dice animation. Usually, you want to change the dice faces just before rolling them.

      Parameters

      Returns void

    • Start the rolling die animation. Usually, you want to change the die face just before rolling it.

      Parameters

      Returns Promise<void>

    • Select all dice

      Parameters

      • silent: boolean = false

      Returns void

    • Set selected state to a die.

      Parameters

      • die: T

        the die to select

      • silent: boolean = false

      Returns void

    • Set the selectable class for each die.

      Parameters

      • OptionalselectableDice: T[]

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

      Returns void

    • Parameters

      • die: T
      • selectable: boolean

      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

      • OptionalselectableDice: T[]

        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

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

      Parameters

      • die: T

      Returns boolean

    • Swap dice inside the slot stock.

      Parameters

      • dice: T[]

        the dice to swap

      • Optionalsettings: AddDieSettings

        for updateInformations and selectable

      Returns any

    • Unelect all dice

      Parameters

      • silent: boolean = false

      Returns void

    • Set unselected state to a die.

      Parameters

      • die: T

        the die to unselect

      • silent: boolean = false

      Returns void