fixed piece timer, added openers.src, cleaning

This commit is contained in:
PolicyChanges1@gmail.com 2021-05-26 12:56:25 -04:00
parent ec67be500d
commit fd83da7ebd
6 changed files with 169 additions and 32 deletions

26
dist/tetrion.js vendored
View File

@ -595,7 +595,7 @@ var UserInputs = {
if(this.prevKeyboardKeys[key] != this.keyboardKeys[key]) {
// Not being held yet
this.isPassedDelayKeyboardShift = false;
this.isDelayAutoShiftStarted = false;
this.keyboardShiftTimer = new Date();
// Do shift if key has been pushed down
@ -605,11 +605,11 @@ var UserInputs = {
var deltaTime = (new Date()).getTime() - this.keyboardShiftTimer.getTime();
if (!this.isPassedDelayKeyboardShift) {
if (!this.isDelayAutoShiftStarted) {
if (deltaTime >= DAS) {
this.keyboardShiftTimer = new Date();
this.isPassedDelayKeyboardShift = true;
this.isDelayAutoShiftStarted = true;
}
}
else if(deltaTime >= ARR && this.keyboardKeys[key] == true) {
@ -644,7 +644,7 @@ var UserInputs = {
this.prevKeyboardKeys = {...this.keyboardKeys};
},
// button states
isPassedDelayKeyboardShift: false,
isDelayAutoShiftStarted: false,
isPassedDelayKeyboardKey: false,
isPassedDelayGamepadShift: false,
isPassedDelayGamepadButton: false,
@ -1171,7 +1171,7 @@ Tetris.prototype = {
this.isSequenceCompleted = true;
// Recursion warning
if(this.currentOpener < 1000) // getting real hacky
if(this.currentOpener < 1000/*magic num*/) // getting real hacky
this._restartHandler();
else clearMatrix(this.matrix);
// this.reset();
@ -1219,7 +1219,7 @@ Tetris.prototype = {
// lockdown timer with centisecond resolution
resetLockdown: function() {
if(this.shape.canDown(this.matrix) == false) {
if(this.landed == false && this.shape.canDown(this.matrix) == false) {
this.landed = true;
this.manipulationCounter = 0;
}
@ -1227,13 +1227,14 @@ Tetris.prototype = {
this.lockDownTimer = 0;
if(this.landed)
//if(UserInput.isPreDelayAutoShiftKeyboardKeyPressed() == false)
this.manipulationCounter++;
},
// Return if the piece can be shifted or rotated
isPieceLocked: function() {
if(this.manipulationCounter > 15) return true;
if(this.lockDownTimer >= 5) return true;
if(this.lockDownTimer >= 30) {console.log("lockdown timer >= 30"); return true;}
return false;
},
@ -1638,7 +1639,7 @@ var openerGenerator = {
break;
case 12:
this.shapeQueue = new Array(
shapes.getShape(0), shapes.getShape(1), shapes.getShape(2), shapes.getShape(3));
shapes.getShape(6), shapes.getShape(2), shapes.getShape(4), shapes.getShape(1), shapes.getShape(3), shapes.getShape(0), shapes.getShape(5), shapes.getShape(6), shapes.getShape(0), shapes.getShape(2), shapes.getShape(0), shapes.getShape(3), shapes.getShape(4), shapes.getShape(3));
break;
case 13:
this.shapeQueue = new Array(
@ -1828,12 +1829,15 @@ var openerGenerator = {
var hintDataList = [3,17,1,6,18,0,1,17,3,5,17,3,2,16,3,-1,17,1,4,15,0,5,13,1,3,14,0,-1,14,3,8,15,3,-1,15,0,0,13,0,6,16,2,0,13,2,4,14,0,2,13,3,6,17,1,7,18,0,3,16,1,7,17,2,6,18,0,1,18,0,-1,17,1,2,16,2,5,17,0,0,15,2,3,15,2,6,15,2,8,16,3];
this.createHintQueue(hintDataList);
break
case 12:
this.hintQueue = new Array(
shapes.getShape(0), shapes.getShape(1), shapes.getShape(2), shapes.getShape(3));
var hintDataList = [3,17,1,6,18,0,5,17,2,1,18,0];
shapes.getShape(6), shapes.getShape(2), shapes.getShape(4), shapes.getShape(1), shapes.getShape(3), shapes.getShape(0), shapes.getShape(5), shapes.getShape(6), shapes.getShape(0), shapes.getShape(2), shapes.getShape(0), shapes.getShape(3), shapes.getShape(4), shapes.getShape(3));
var hintDataList = [0,18,0,4,18,0,7,18,0,6,17,0,0,17,0,0,15,2,5,16,3,0,14,0,4,13,3,5,14,1,7,15,2,2,16,2,8,15,3,3,17,3];
this.createHintQueue(hintDataList);
break;
case 13:
this.hintQueue = new Array(
shapes.getShape(4), shapes.getShape(6), shapes.getShape(1), shapes.getShape(2), shapes.getShape(3), shapes.getShape(5), shapes.getShape(0), shapes.getShape(1), shapes.getShape(0), shapes.getShape(6), shapes.getShape(0), shapes.getShape(5), shapes.getShape(4), shapes.getShape(3), shapes.getShape(4), shapes.getShape(3), shapes.getShape(4));
@ -2831,7 +2835,7 @@ var RandomGenerator = {
newBag.push(minoes[mino]);
newBag = newBag.filter(this.onlyUnique);
}
console.log("New bag: " + newBag.toString());
return newBag;
},
reset() {

View File

@ -162,7 +162,7 @@ var UserInputs = {
if(this.prevKeyboardKeys[key] != this.keyboardKeys[key]) {
// Not being held yet
this.isPassedDelayKeyboardShift = false;
this.isDelayAutoShiftStarted = false;
this.keyboardShiftTimer = new Date();
// Do shift if key has been pushed down
@ -172,11 +172,11 @@ var UserInputs = {
var deltaTime = (new Date()).getTime() - this.keyboardShiftTimer.getTime();
if (!this.isPassedDelayKeyboardShift) {
if (!this.isDelayAutoShiftStarted) {
if (deltaTime >= DAS) {
this.keyboardShiftTimer = new Date();
this.isPassedDelayKeyboardShift = true;
this.isDelayAutoShiftStarted = true;
}
}
else if(deltaTime >= ARR && this.keyboardKeys[key] == true) {
@ -211,7 +211,7 @@ var UserInputs = {
this.prevKeyboardKeys = {...this.keyboardKeys};
},
// button states
isPassedDelayKeyboardShift: false,
isDelayAutoShiftStarted: false,
isPassedDelayKeyboardKey: false,
isPassedDelayGamepadShift: false,
isPassedDelayGamepadButton: false,

View File

@ -487,7 +487,7 @@ Tetris.prototype = {
this.isSequenceCompleted = true;
// Recursion warning
if(this.currentOpener < 1000) // getting real hacky
if(this.currentOpener < 1000/*magic num*/) // getting real hacky
this._restartHandler();
else clearMatrix(this.matrix);
// this.reset();
@ -535,7 +535,7 @@ Tetris.prototype = {
// lockdown timer with centisecond resolution
resetLockdown: function() {
if(this.shape.canDown(this.matrix) == false) {
if(this.landed == false && this.shape.canDown(this.matrix) == false) {
this.landed = true;
this.manipulationCounter = 0;
}
@ -543,13 +543,14 @@ Tetris.prototype = {
this.lockDownTimer = 0;
if(this.landed)
//if(UserInput.isPreDelayAutoShiftKeyboardKeyPressed() == false)
this.manipulationCounter++;
},
// Return if the piece can be shifted or rotated
isPieceLocked: function() {
if(this.manipulationCounter > 15) return true;
if(this.lockDownTimer >= 5) return true;
if(this.lockDownTimer >= 30) {console.log("lockdown timer >= 30"); return true;}
return false;
},

View File

@ -73,7 +73,7 @@ var openerGenerator = {
break;
case 12:
this.shapeQueue = new Array(
shapes.getShape(0), shapes.getShape(1), shapes.getShape(2), shapes.getShape(3));
shapes.getShape(6), shapes.getShape(2), shapes.getShape(4), shapes.getShape(1), shapes.getShape(3), shapes.getShape(0), shapes.getShape(5), shapes.getShape(6), shapes.getShape(0), shapes.getShape(2), shapes.getShape(0), shapes.getShape(3), shapes.getShape(4), shapes.getShape(3));
break;
case 13:
this.shapeQueue = new Array(
@ -263,12 +263,15 @@ var openerGenerator = {
var hintDataList = [3,17,1,6,18,0,1,17,3,5,17,3,2,16,3,-1,17,1,4,15,0,5,13,1,3,14,0,-1,14,3,8,15,3,-1,15,0,0,13,0,6,16,2,0,13,2,4,14,0,2,13,3,6,17,1,7,18,0,3,16,1,7,17,2,6,18,0,1,18,0,-1,17,1,2,16,2,5,17,0,0,15,2,3,15,2,6,15,2,8,16,3];
this.createHintQueue(hintDataList);
break
case 12:
this.hintQueue = new Array(
shapes.getShape(0), shapes.getShape(1), shapes.getShape(2), shapes.getShape(3));
var hintDataList = [3,17,1,6,18,0,5,17,2,1,18,0];
shapes.getShape(6), shapes.getShape(2), shapes.getShape(4), shapes.getShape(1), shapes.getShape(3), shapes.getShape(0), shapes.getShape(5), shapes.getShape(6), shapes.getShape(0), shapes.getShape(2), shapes.getShape(0), shapes.getShape(3), shapes.getShape(4), shapes.getShape(3));
var hintDataList = [0,18,0,4,18,0,7,18,0,6,17,0,0,17,0,0,15,2,5,16,3,0,14,0,4,13,3,5,14,1,7,15,2,2,16,2,8,15,3,3,17,3];
this.createHintQueue(hintDataList);
break;
case 13:
this.hintQueue = new Array(
shapes.getShape(4), shapes.getShape(6), shapes.getShape(1), shapes.getShape(2), shapes.getShape(3), shapes.getShape(5), shapes.getShape(0), shapes.getShape(1), shapes.getShape(0), shapes.getShape(6), shapes.getShape(0), shapes.getShape(5), shapes.getShape(4), shapes.getShape(3), shapes.getShape(4), shapes.getShape(3), shapes.getShape(4));

129
src/openers.src Normal file
View File

@ -0,0 +1,129 @@
DT Cannon Empty Field Setups:
STANDARD DT CANNON:
case :
this.shapeQueue = new Array(shapes.getShape(0), shapes.getShape(1), shapes.getShape(4), shapes.getShape(5), shapes.getShape(6), shapes.getShape(2), shapes.getShape(3), shapes.getShape(4), shapes.getShape(5), shapes.getShape(6), shapes.getShape(0), shapes.getShape(1), shapes.getShape(3), shapes.getShape(4), shapes.getShape(5), shapes.getShape(6), shapes.getShape(3));
break;
case :
this.hintQueue = new Array(shapes.getShape(0), shapes.getShape(1), shapes.getShape(4), shapes.getShape(5), shapes.getShape(6), shapes.getShape(2), shapes.getShape(3), shapes.getShape(4), shapes.getShape(5), shapes.getShape(6), shapes.getShape(0), shapes.getShape(1), shapes.getShape(3), shapes.getShape(4), shapes.getShape(5), shapes.getShape(6), shapes.getShape(3));
var hintDataList = [3,18,0,-2,18,0,7,18,0,3,17,0,4,16,1,7,17,0,3,15,0,-1,15,1,8,15,3,6,13,3,2,13,3,3,14,0,1,16,2,5,13,3,8,15,3,3,13,3,1,17,3];
this.createHintQueue(hintDataList);
break;
TKI'S SIGNATURE:
--------------------------Basic DT--------------------------
case :
this.shapeQueue = new Array(shapes.getShape(1), shapes.getShape(3), shapes.getShape(4), shapes.getShape(5), shapes.getShape(6), shapes.getShape(0), shapes.getShape(2), shapes.getShape(4), shapes.getShape(5), shapes.getShape(6), shapes.getShape(0), shapes.getShape(2), shapes.getShape(5), shapes.getShape(3), shapes.getShape(5), shapes.getShape(6), shapes.getShape(3));
break;
case :
this.hintQueue = new Array(shapes.getShape(1), shapes.getShape(3), shapes.getShape(4), shapes.getShape(5), shapes.getShape(6), shapes.getShape(0), shapes.getShape(2), shapes.getShape(4), shapes.getShape(5), shapes.getShape(6), shapes.getShape(0), shapes.getShape(2), shapes.getShape(5), shapes.getShape(3), shapes.getShape(5), shapes.getShape(6), shapes.getShape(3));
var hintDataList = [-2,18,0,6,18,0,3,18,0,7,17,1,3,15,1,3,16,3,5,16,1,-1,15,1,8,15,3,3,12,3,2,13,3,5,14,1,8,13,3,1,16,2,5,15,0,8,12,3,1,17,3];
this.createHintQueue(hintDataList);
break;
--------------------------Bonus TST--------------------------
case :
this.shapeQueue = new Array(shapes.getShape(1), shapes.getShape(3), shapes.getShape(4), shapes.getShape(5), shapes.getShape(6), shapes.getShape(0), shapes.getShape(2), shapes.getShape(4), shapes.getShape(5), shapes.getShape(6), shapes.getShape(0), shapes.getShape(1), shapes.getShape(2), shapes.getShape(5), shapes.getShape(3), shapes.getShape(6), shapes.getShape(3));
break;
case :
this.hintQueue = new Array(shapes.getShape(1), shapes.getShape(3), shapes.getShape(4), shapes.getShape(5), shapes.getShape(6), shapes.getShape(0), shapes.getShape(2), shapes.getShape(4), shapes.getShape(5), shapes.getShape(6), shapes.getShape(0), shapes.getShape(1), shapes.getShape(2), shapes.getShape(5), shapes.getShape(3), shapes.getShape(6), shapes.getShape(3));
var hintDataList = [-2,18,0,6,18,0,3,18,0,8,17,3,4,15,3,3,16,3,5,16,1,-1,15,1,8,15,3,3,12,3,2,13,3,0,11,0,5,14,1,8,13,3,1,16,2,8,12,3,1,17,3];
this.createHintQueue(hintDataList);
break;
IT BALANCE:
--------------------------IT Balance 1--------------------------
case :
this.shapeQueue = new Array(shapes.getShape(1), shapes.getShape(2), shapes.getShape(4), shapes.getShape(5), shapes.getShape(6), shapes.getShape(1), shapes.getShape(3), shapes.getShape(4), shapes.getShape(0), shapes.getShape(3), shapes.getShape(5), shapes.getShape(6), shapes.getShape(0), shapes.getShape(1), shapes.getShape(3), shapes.getShape(4), shapes.getShape(5), shapes.getShape(6), shapes.getShape(3), shapes.getShape(4), shapes.getShape(5), shapes.getShape(6), shapes.getShape(0));
break;
case :
this.hintQueue = new Array(shapes.getShape(1), shapes.getShape(2), shapes.getShape(4), shapes.getShape(5), shapes.getShape(6), shapes.getShape(1), shapes.getShape(3), shapes.getShape(4), shapes.getShape(0), shapes.getShape(3), shapes.getShape(5), shapes.getShape(6), shapes.getShape(0), shapes.getShape(1), shapes.getShape(3), shapes.getShape(4), shapes.getShape(5), shapes.getShape(6), shapes.getShape(3), shapes.getShape(4), shapes.getShape(5), shapes.getShape(6), shapes.getShape(0));
var hintDataList = [-2,18,0,6,18,0,-1,15,1,8,17,3,3,18,0,4,16,0,3,17,0,4,15,1,2,14,1,8,15,3,7,14,0,3,12,3,5,13,0,0,12,0,1,16,2,8,13,3,5,14,0,6,11,1,1,17,3,0,18,0,0,17,3,1,17,0,5,17,2];
this.createHintQueue(hintDataList);
break;
--------------------------IT Balance 2--------------------------
case :
this.shapeQueue = new Array(shapes.getShape(1), shapes.getShape(6), shapes.getShape(4), shapes.getShape(5), shapes.getShape(4), shapes.getShape(3), shapes.getShape(0), shapes.getShape(1), shapes.getShape(3), shapes.getShape(2), shapes.getShape(1), shapes.getShape(3), shapes.getShape(4), shapes.getShape(6), shapes.getShape(3));
break;
case :
this.hintQueue = new Array(shapes.getShape(1), shapes.getShape(6), shapes.getShape(4), shapes.getShape(5), shapes.getShape(4), shapes.getShape(3), shapes.getShape(0), shapes.getShape(1), shapes.getShape(3), shapes.getShape(2), shapes.getShape(1), shapes.getShape(3), shapes.getShape(4), shapes.getShape(6), shapes.getShape(3));
var hintDataList = [-2,18,0,3,18,0,7,18,0,5,16,3,-1,15,1,3,17,0,3,14,3,6,17,0,6,15,2,5,13,1,0,12,0,1,16,2,7,16,2,4,14,3,1,17,2];
this.createHintQueue(hintDataList);
break;
--------------------------IT Balance 3--------------------------
case :
this.shapeQueue = new Array(shapes.getShape(0), shapes.getShape(1), shapes.getShape(2), shapes.getShape(6), shapes.getShape(3), shapes.getShape(4), shapes.getShape(1), shapes.getShape(2), shapes.getShape(3), shapes.getShape(5), shapes.getShape(3), shapes.getShape(4), shapes.getShape(6), shapes.getShape(3));
break;
case :
this.hintQueue = new Array(shapes.getShape(0), shapes.getShape(1), shapes.getShape(2), shapes.getShape(6), shapes.getShape(3), shapes.getShape(4), shapes.getShape(1), shapes.getShape(2), shapes.getShape(3), shapes.getShape(5), shapes.getShape(3), shapes.getShape(4), shapes.getShape(6), shapes.getShape(3));
var hintDataList = [7,18,0,-2,18,0,7,16,1,3,18,0,3,17,0,-1,15,1,1,15,0,5,17,0,6,15,2,2,12,3,1,16,2,4,16,1,6,15,2,1,17,3];
this.createHintQueue(hintDataList);
break;
--------------------------Overhang Variation--------------------------
case :
this.shapeQueue = new Array(shapes.getShape(0), shapes.getShape(1), shapes.getShape(6), shapes.getShape(3), shapes.getShape(4), shapes.getShape(1), shapes.getShape(3), shapes.getShape(5), shapes.getShape(1), shapes.getShape(2), shapes.getShape(3), shapes.getShape(1), shapes.getShape(4), shapes.getShape(3));
break;
case :
this.hintQueue = new Array(shapes.getShape(0), shapes.getShape(1), shapes.getShape(6), shapes.getShape(3), shapes.getShape(4), shapes.getShape(1), shapes.getShape(3), shapes.getShape(5), shapes.getShape(1), shapes.getShape(2), shapes.getShape(3), shapes.getShape(1), shapes.getShape(4), shapes.getShape(3));
var hintDataList = [7,18,0,-2,18,0,3,18,0,3,17,0,-1,15,1,1,15,0,7,16,2,2,12,3,6,15,0,5,16,2,1,16,2,4,17,0,4,16,1,1,17,3];
this.createHintQueue(hintDataList);
break;
BT CANNON:
--------------------------Variation 1--------------------------
case :
this.shapeQueue = new Array(shapes.getShape(6), shapes.getShape(4), shapes.getShape(2), shapes.getShape(1), shapes.getShape(3), shapes.getShape(5), shapes.getShape(0), shapes.getShape(2), shapes.getShape(6), shapes.getShape(0), shapes.getShape(1), shapes.getShape(0), shapes.getShape(3), shapes.getShape(3));
break;
case :
this.hintQueue = new Array(shapes.getShape(6), shapes.getShape(4), shapes.getShape(2), shapes.getShape(1), shapes.getShape(3), shapes.getShape(5), shapes.getShape(0), shapes.getShape(2), shapes.getShape(6), shapes.getShape(0), shapes.getShape(1), shapes.getShape(0), shapes.getShape(3), shapes.getShape(3));
var hintDataList = [0,18,0,7,18,0,4,18,0,6,17,0,0,17,0,5,16,3,0,15,2,5,14,1,0,14,0,7,15,2,6,14,0,4,13,3,2,16,2,3,17,3];
this.createHintQueue(hintDataList);
break;
--------------------------Variation 2--------------------------
case :
this.shapeQueue = new Array(shapes.getShape(1), shapes.getShape(6), shapes.getShape(3), shapes.getShape(4), shapes.getShape(5), shapes.getShape(0), shapes.getShape(2), shapes.getShape(1), shapes.getShape(6), shapes.getShape(2), shapes.getShape(5), shapes.getShape(0), shapes.getShape(3), shapes.getShape(3));
break;
case :
this.hintQueue = new Array(shapes.getShape(1), shapes.getShape(6), shapes.getShape(3), shapes.getShape(4), shapes.getShape(5), shapes.getShape(0), shapes.getShape(2), shapes.getShape(1), shapes.getShape(6), shapes.getShape(2), shapes.getShape(5), shapes.getShape(0), shapes.getShape(3), shapes.getShape(3));
var hintDataList = [6,18,0,0,18,0,0,17,0,7,16,0,6,17,3,0,15,2,4,18,0,6,15,0,0,14,0,4,15,1,6,13,3,4,13,3,2,16,2,3,17,3];
this.createHintQueue(hintDataList);
break;
TEST: //BT cannon
case :
this.shapeQueue = new Array(shapes.getShape(6), shapes.getShape(2), shapes.getShape(4), shapes.getShape(1), shapes.getShape(3), shapes.getShape(0), shapes.getShape(5), shapes.getShape(6), shapes.getShape(0), shapes.getShape(2), shapes.getShape(0), shapes.getShape(3), shapes.getShape(4), shapes.getShape(3));
break;
case :
this.hintQueue = new Array(shapes.getShape(6), shapes.getShape(2), shapes.getShape(4), shapes.getShape(1), shapes.getShape(3), shapes.getShape(0), shapes.getShape(5), shapes.getShape(6), shapes.getShape(0), shapes.getShape(2), shapes.getShape(0), shapes.getShape(3), shapes.getShape(4), shapes.getShape(3));
var hintDataList = [0,18,0,4,18,0,7,18,0,6,17,0,0,17,0,0,15,2,5,16,3,0,14,0,4,13,3,5,14,1,7,15,2,2,16,2,8,15,3,3,17,3];
this.createHintQueue(hintDataList);
break;
PC OPENERS:

View File

@ -878,7 +878,7 @@ var RandomGenerator = {
newBag.push(minoes[mino]);
newBag = newBag.filter(this.onlyUnique);
}
console.log("New bag: " + newBag.toString());
return newBag;
},
reset() {