reset rng array

pull/1/head
PolicyChanges1@gmail.com 2021-02-27 17:13:32 -05:00
parent f6180db2fb
commit 3a48117175
2 changed files with 6 additions and 12 deletions

9
dist/tetrion.js vendored
View File

@ -2641,13 +2641,8 @@ function getRandomInt(max) {
var RandomGenerator = { var RandomGenerator = {
returnBag: [], returnBag: [],
getTetrimino() { getTetrimino() {
if(this.returnBag.length < 7) if(this.returnBag.length < 7)
this.returnBag.push.apply(this.returnBag, this.generateNewBag()); this.returnBag.push.apply(this.returnBag, this.generateNewBag());
console.log("return bag: " + this.returnBag);
return parseInt(this.returnBag.shift()); return parseInt(this.returnBag.shift());
}, },
onlyUnique(value, index, self) { onlyUnique(value, index, self) {
@ -2665,10 +2660,12 @@ var RandomGenerator = {
newBag.push(minoes[mino]); newBag.push(minoes[mino]);
newBag = newBag.filter(this.onlyUnique); newBag = newBag.filter(this.onlyUnique);
} }
return newBag; return newBag;
}, },
reset() { reset() {
returnBag = 0; if(this.returnBag != undefined)
this.returnBag.splice(0, returnBag.length);
} }
}; };

View File

@ -840,13 +840,8 @@ function getRandomInt(max) {
var RandomGenerator = { var RandomGenerator = {
returnBag: [], returnBag: [],
getTetrimino() { getTetrimino() {
if(this.returnBag.length < 7) if(this.returnBag.length < 7)
this.returnBag.push.apply(this.returnBag, this.generateNewBag()); this.returnBag.push.apply(this.returnBag, this.generateNewBag());
console.log("return bag: " + this.returnBag);
return parseInt(this.returnBag.shift()); return parseInt(this.returnBag.shift());
}, },
onlyUnique(value, index, self) { onlyUnique(value, index, self) {
@ -864,10 +859,12 @@ var RandomGenerator = {
newBag.push(minoes[mino]); newBag.push(minoes[mino]);
newBag = newBag.filter(this.onlyUnique); newBag = newBag.filter(this.onlyUnique);
} }
return newBag; return newBag;
}, },
reset() { reset() {
returnBag = 0; if(this.returnBag != undefined)
this.returnBag.splice(0, returnBag.length);
} }
}; };