UNPKG

slp-enforcer

Version:

Finds violations of the Melee Controller Ruleset by inspecting SLP files

27 lines (26 loc) 1.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const index_1 = require("./index"); function hasDisallowedCStickCoords(game, playerIndex, coords) { // If we're on analog, then it always passes // NOTE: We inspect C-Stick coords for this check, so we have to get the main stick coords for this conditional if (!index_1.isBoxController(index_1.getCoordListFromGame(game, playerIndex, true))) { return new index_1.CheckResult(false); } let violations = getCStickViolations(coords); return new index_1.CheckResult(violations.length !== 0, violations); } exports.hasDisallowedCStickCoords = hasDisallowedCStickCoords; function getCStickViolations(coords) { let violations = []; for (const [index, coordinate] of coords.entries()) { if (index_1.FloatEquals(Math.abs(coordinate.x), 0.8)) { violations.push(new index_1.Violation(index, "Disallowed C-Stick Coordinate", [coordinate])); } if (index_1.FloatEquals(Math.abs(coordinate.x), 0.6625)) { violations.push(new index_1.Violation(index, "Disallowed C-Stick Coordinate", [coordinate])); } } return violations; } exports.getCStickViolations = getCStickViolations;