UNPKG

slp-enforcer

Version:

Finds violations of the Melee Controller Ruleset by inspecting SLP files

24 lines (23 loc) 1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const date_fns_1 = require("date-fns"); const types_1 = require("../types"); const exists_1 = require("./exists"); function frameToGameTimer(frame, options) { const { timerType, startingTimerSeconds } = options; if (timerType === types_1.TimerType.DECREASING) { if (!exists_1.exists(startingTimerSeconds)) { return "Unknown"; } const centiseconds = Math.ceil((((60 - (frame % 60)) % 60) * 99) / 59); const date = new Date(0, 0, 0, 0, 0, startingTimerSeconds - frame / 60, centiseconds * 10); return date_fns_1.format(date, "mm:ss.SS"); } if (timerType === types_1.TimerType.INCREASING) { const centiseconds = Math.floor(((frame % 60) * 99) / 59); const date = new Date(0, 0, 0, 0, 0, frame / 60, centiseconds * 10); return date_fns_1.format(date, "mm:ss.SS"); } return "Infinite"; } exports.frameToGameTimer = frameToGameTimer;