UNPKG

@haelp/teto

Version:

A typescript-based controllable TETR.IO client.

37 lines (36 loc) 939 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "classic", { enumerable: true, get: function() { return classic; } }); const _utils = require("../../utils"); const _types = require("../types"); const classic = (seed)=>{ const TETROMINOS = [ _types.Mino.Z, _types.Mino.L, _types.Mino.O, _types.Mino.S, _types.Mino.I, _types.Mino.J, _types.Mino.T ]; let lastGenerated = null; const gen = new _utils.RNG(seed); return ()=>{ let index = Math.floor(gen.nextFloat() * (TETROMINOS.length + 1)); if (index === lastGenerated || index >= TETROMINOS.length) { index = Math.floor(gen.nextFloat() * TETROMINOS.length); } lastGenerated = index; return [ TETROMINOS[index] ]; }; }; //# sourceMappingURL=classic.js.map