slp-enforcer
Version:
Finds violations of the Melee Controller Ruleset by inspecting SLP files
42 lines (41 loc) • 2.28 kB
JavaScript
;
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const globals_1 = require("@jest/globals");
const index_1 = require("../index");
const crouch_uptilt_1 = require("../crouch_uptilt");
const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
globals_1.test('Test Crouch Uptilt (nonlegal)', async () => {
let data = fs.readFileSync(path.join(__dirname, '../../test_data/nonlegal/digital/crouch_uptilt/crouch_uptilt_unnerfed.slp'), null);
let game = new index_1.SlippiGame(index_1.toArrayBuffer(data));
globals_1.expect(game).not.toBeNull();
let coords = index_1.getCoordListFromGame(game, 3, true);
let checkResult = crouch_uptilt_1.hasIllegalCrouchUptilt(game, 3, coords);
globals_1.expect(checkResult.result).toEqual(true);
globals_1.expect(checkResult.violations.length).toEqual(6);
for (let violation of checkResult.violations) {
globals_1.expect(violation.evidence[0]).toEqual({ "x": 0, "y": -1 });
}
});
globals_1.test('Test Crouch Uptilt (legal)', async () => {
let data = fs.readFileSync(path.join(__dirname, '../../test_data/legal/digital/crouch_uptilt_r18_v2.slp'), null);
let game = new index_1.SlippiGame(index_1.toArrayBuffer(data));
globals_1.expect(game).not.toBeNull();
let coords = index_1.getCoordListFromGame(game, 0, true);
globals_1.expect(crouch_uptilt_1.hasIllegalCrouchUptilt(game, 0, coords).result).toEqual(false);
});
// Doubles sometimes has blank entries for players. Handle this without crashing
globals_1.test('Test Crouch Uptilt (breaking?)', async () => {
let data = fs.readFileSync(path.join(__dirname, '../../test_data/legal/doubles_with_blank_player.slp'), null);
let game = new index_1.SlippiGame(index_1.toArrayBuffer(data));
globals_1.expect(game).not.toBeNull();
let coords = index_1.getCoordListFromGame(game, 0, true);
globals_1.expect(crouch_uptilt_1.hasIllegalCrouchUptilt(game, 0, coords).result).toEqual(false);
});