UNPKG

step-sequence-generator

Version:

A step sequence generator for figure skating programs

54 lines (53 loc) 1.89 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.StepContext = void 0; const movement_enums_js_1 = require("../../shared/enums/movement-enums.js"); class StepContext { constructor() { this._currentStep = null; } resetCurrentStep() { this._currentStep = null; } set currentStep(step) { this._currentStep = step; } get currentStep() { return this._currentStep; } get endCoordinate() { return this._currentStep === null || this._currentStep.coordinates === null ? null : this._currentStep.coordinates.end; } get vector() { return this._currentStep === null || this._currentStep.coordinates === null ? null : this._currentStep.coordinates.vector; } get currentLeg() { return this.currentStep ? this.currentStep.endLeg : movement_enums_js_1.Leg.BOTH; } get currentEdge() { return this.currentStep ? this.currentStep.endEdge : movement_enums_js_1.Edge.TWO_EDGES; } get currentDirection() { if (this.currentStep === null) return movement_enums_js_1.TransitionDirection.NONE; const { rotationDirection, rotationDegree, transitionDirection } = this.currentStep; if (rotationDirection === movement_enums_js_1.RotationDirection.NONE) { return transitionDirection; } if (this.isFullTurn(rotationDegree)) { return transitionDirection; } return transitionDirection === movement_enums_js_1.TransitionDirection.BACKWARD ? movement_enums_js_1.TransitionDirection.FORWARD : movement_enums_js_1.TransitionDirection.BACKWARD; } isFullTurn(degrees) { const FULL_TURN = 360; return degrees % FULL_TURN === 0; } } exports.StepContext = StepContext;