UNPKG

step-sequence-generator

Version:

A step sequence generator for figure skating programs

35 lines (34 loc) 1.18 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Roulette = void 0; class Roulette { constructor(args) { this.weightCalc = args.weightCalc; this.numberGenerator = args.numberGenerator; } /** * spinWheel * @arg args * @arg args.selection элементы * @arg args.chanceRatioMap шансы на выпадение элемента в selection в процентах * @arg args.itemKeyExtractor callback для опредления ключа для weightMap * @arg args.weightKeyCreator callback для опредления ключа в weightMap */ spinWheel(args) { const { selection, chanceRatioMap, weightKeyCreator, itemKeyExtractor } = args; const weightMap = this.weightCalc.count({ selection, chanceRatioMap, itemKeyExtractor, }); return this.numberGenerator.generateNumber({ selection, weightMap, weightKeyCreator, }); } setFallbackWeight(value) { this.numberGenerator.fallbackWeight = value; } } exports.Roulette = Roulette;