whar?
This commit is contained in:
parent
1c29cce71b
commit
d34b072fcd
|
@ -282,7 +282,10 @@ void main() async {
|
||||||
int rot = 0;
|
int rot = 0;
|
||||||
bool spinWasLastMove = false;
|
bool spinWasLastMove = false;
|
||||||
Coords coords = Coords(3, 21);
|
Coords coords = Coords(3, 21);
|
||||||
double gravityBucket = 0.00000000000000;
|
double lockDelay = 30; // frames
|
||||||
|
int lockResets = 15;
|
||||||
|
bool floored = false;
|
||||||
|
double gravityBucket = 1.0;
|
||||||
|
|
||||||
developer.log("Seed is ${replay.stats[0][0].seed}, first bag is $queue");
|
developer.log("Seed is ${replay.stats[0][0].seed}, first bag is $queue");
|
||||||
Tetromino current = queue.removeAt(0);
|
Tetromino current = queue.removeAt(0);
|
||||||
|
@ -305,6 +308,10 @@ void main() async {
|
||||||
}
|
}
|
||||||
//developer.log("Next queue is $queue");
|
//developer.log("Next queue is $queue");
|
||||||
rot = 0;
|
rot = 0;
|
||||||
|
lockResets = 15;
|
||||||
|
lockDelay = 30;
|
||||||
|
floored = false;
|
||||||
|
gravityBucket = 1.0;
|
||||||
return queue.removeAt(0);
|
return queue.removeAt(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,18 +329,63 @@ void main() async {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void handleHardDrop(){
|
||||||
|
board.writeToBoard(current, coords, rot);
|
||||||
|
bool tspin = board.wasATSpin(current, coords, rot);
|
||||||
|
LineClearResult lineClear = stats.processLineClear(board.clearFullLines(), current, coords, spinWasLastMove, tspin);
|
||||||
|
print("${lineClear.linesCleared} lines, ${lineClear.garbageCleared} garbage");
|
||||||
|
if (garbageQueue.isNotEmpty) {
|
||||||
|
if (lineClear.linesCleared > 0){
|
||||||
|
int garbageToDelete = lineClear.attackProduced;
|
||||||
|
for (IncomingGarbage garbage in garbageQueue){
|
||||||
|
if (garbage.data.amt! >= garbageToDelete) {
|
||||||
|
garbageToDelete -= garbage.data.amt!;
|
||||||
|
lineClear.attackProduced = garbageToDelete;
|
||||||
|
garbage.data.amt = 0;
|
||||||
|
}else{
|
||||||
|
garbage.data.amt = garbage.data.amt! - garbageToDelete;
|
||||||
|
lineClear.attackProduced = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
int needToTake = settings!.garbageCap!;
|
||||||
|
for (IncomingGarbage garbage in garbageQueue){
|
||||||
|
if ((garbage.frameOfThreat??99999999) > currentFrame) break;
|
||||||
|
if (garbage.data.amt! > needToTake) {
|
||||||
|
board.writeGarbage(garbage.data, needToTake);
|
||||||
|
garbage.data.amt = garbage.data.amt! - needToTake;
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
board.writeGarbage(garbage.data);
|
||||||
|
needToTake -= garbage.data.amt!;
|
||||||
|
garbage.data.amt = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
garbageQueue.removeWhere((element) => element.data.amt == 0);
|
||||||
|
}
|
||||||
|
current = getNewOne();
|
||||||
|
coords = Coords(3, 21) + spawnPositionFixes[current.index];
|
||||||
|
}
|
||||||
|
|
||||||
void handleGravity(double frames){
|
void handleGravity(double frames){
|
||||||
if (frames == 0) return;
|
if (frames == 0) return;
|
||||||
gravityBucket += settings != null ? (handling!.sdfActive ? settings.g! * settings.handling!.sdf : settings.g!) * frames : 0;
|
gravityBucket += settings != null ? (handling!.sdfActive ? max(settings.g! * settings.handling!.sdf, 0.05 * settings.handling!.sdf) : settings.g!) * frames : 0;
|
||||||
int gravityImpact = 0;
|
int gravityImpact = 0;
|
||||||
if (gravityBucket >= 1.0){
|
if (gravityBucket >= 1.0){
|
||||||
gravityImpact = gravityBucket.truncate();
|
gravityImpact = gravityBucket.truncate();
|
||||||
gravityBucket -= gravityBucket.truncate();
|
gravityBucket -= gravityBucket.truncate();
|
||||||
}
|
}
|
||||||
while (gravityImpact > 0){
|
while (gravityImpact > 0){
|
||||||
if (board.positionIsValid(current, Coords(coords.x, coords.y-1), rot)) coords.y -= 1;
|
if (board.positionIsValid(current, Coords(coords.x, coords.y-1), rot)) {coords.y -= 1; floored = false;}
|
||||||
|
else floored = true;
|
||||||
gravityImpact--;
|
gravityImpact--;
|
||||||
}
|
}
|
||||||
|
if (floored) lockDelay -= frames;
|
||||||
|
if (lockDelay <= 0 && floored){
|
||||||
|
handleHardDrop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleMovement(double frames){
|
void handleMovement(double frames){
|
||||||
|
@ -364,7 +416,8 @@ void main() async {
|
||||||
case EventType.full:
|
case EventType.full:
|
||||||
settings = (nextEvent as EventFull).data.options;
|
settings = (nextEvent as EventFull).data.options;
|
||||||
handling = HandlingHandler(settings!.handling!.das.toDouble(), settings.handling!.arr.toDouble());
|
handling = HandlingHandler(settings!.handling!.das.toDouble(), settings.handling!.arr.toDouble());
|
||||||
print(handling);
|
lockDelay = settings.locktime!.toDouble();
|
||||||
|
lockResets = settings.lockresets!;
|
||||||
break;
|
break;
|
||||||
case EventType.keydown:
|
case EventType.keydown:
|
||||||
nextEvent as EventKeyPress;
|
nextEvent as EventKeyPress;
|
||||||
|
@ -393,43 +446,7 @@ void main() async {
|
||||||
break;
|
break;
|
||||||
case KeyType.hardDrop:
|
case KeyType.hardDrop:
|
||||||
coords.y = sonicDrop();
|
coords.y = sonicDrop();
|
||||||
board.writeToBoard(current, coords, rot);
|
handleHardDrop();
|
||||||
bool tspin = board.wasATSpin(current, coords, rot);
|
|
||||||
LineClearResult lineClear = stats.processLineClear(board.clearFullLines(), current, coords, spinWasLastMove, tspin);
|
|
||||||
print("${lineClear.linesCleared} lines, ${lineClear.garbageCleared} garbage");
|
|
||||||
if (garbageQueue.isNotEmpty) {
|
|
||||||
if (lineClear.linesCleared > 0){
|
|
||||||
int garbageToDelete = lineClear.attackProduced;
|
|
||||||
for (IncomingGarbage garbage in garbageQueue){
|
|
||||||
if (garbage.data.amt! >= garbageToDelete) {
|
|
||||||
garbageToDelete -= garbage.data.amt!;
|
|
||||||
lineClear.attackProduced = garbageToDelete;
|
|
||||||
garbage.data.amt = 0;
|
|
||||||
}else{
|
|
||||||
garbage.data.amt = garbage.data.amt! - garbageToDelete;
|
|
||||||
lineClear.attackProduced = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
int needToTake = settings!.garbageCap!;
|
|
||||||
for (IncomingGarbage garbage in garbageQueue){
|
|
||||||
if ((garbage.frameOfThreat??99999999) > currentFrame) break;
|
|
||||||
if (garbage.data.amt! > needToTake) {
|
|
||||||
board.writeGarbage(garbage.data, needToTake);
|
|
||||||
garbage.data.amt = garbage.data.amt! - needToTake;
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
board.writeGarbage(garbage.data);
|
|
||||||
needToTake -= garbage.data.amt!;
|
|
||||||
garbage.data.amt = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
garbageQueue.removeWhere((element) => element.data.amt == 0);
|
|
||||||
}
|
|
||||||
current = getNewOne();
|
|
||||||
coords = Coords(3, 21) + spawnPositionFixes[current.index];
|
|
||||||
case KeyType.hold:
|
case KeyType.hold:
|
||||||
switch (hold){
|
switch (hold){
|
||||||
case null:
|
case null:
|
||||||
|
@ -441,10 +458,14 @@ void main() async {
|
||||||
temp = hold;
|
temp = hold;
|
||||||
hold = current;
|
hold = current;
|
||||||
current = temp;
|
current = temp;
|
||||||
|
rot = 0;
|
||||||
|
lockResets = 15;
|
||||||
|
lockDelay = 30;
|
||||||
|
gravityBucket = 1.0;
|
||||||
|
floored = false;
|
||||||
|
coords = Coords(3, 21) + spawnPositionFixes[current.index];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
rot = 0;
|
|
||||||
coords = Coords(3, 21) + spawnPositionFixes[current.index];
|
|
||||||
break;
|
break;
|
||||||
case KeyType.chat:
|
case KeyType.chat:
|
||||||
// TODO: Handle this case.
|
// TODO: Handle this case.
|
||||||
|
|
|
@ -80,6 +80,9 @@
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
}
|
}
|
||||||
|
a{
|
||||||
|
color: aqua;
|
||||||
|
}
|
||||||
#preloader{
|
#preloader{
|
||||||
display: flex;
|
display: flex;
|
||||||
width: fit-content;
|
width: fit-content;
|
||||||
|
@ -111,6 +114,15 @@
|
||||||
padding-top: 8px;
|
padding-top: 8px;
|
||||||
animation: 1s cubic-bezier(.46,.03,.52,.96) infinite alternate breathing;
|
animation: 1s cubic-bezier(.46,.03,.52,.96) infinite alternate breathing;
|
||||||
}
|
}
|
||||||
|
.error{
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
#tip{
|
||||||
|
position: absolute;
|
||||||
|
bottom: 5%;
|
||||||
|
color: gray;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
@media (max-width: 502px){
|
@media (max-width: 502px){
|
||||||
#preloader{
|
#preloader{
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
@ -130,24 +142,44 @@
|
||||||
<p id="progress">Loading...</p>
|
<p id="progress">Loading...</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<p id="tip"></p>
|
||||||
|
<script>
|
||||||
window.addEventListener('load', function(ev) {
|
window.addEventListener('load', function(ev) {
|
||||||
let progress = document.querySelector("#progress");
|
let progress = document.querySelector("#progress");
|
||||||
let preloader = document.querySelector("#preloader");
|
let preloader = document.querySelector("#preloader");
|
||||||
// Download main.dart.js
|
let tip = document.querySelector("#tip");
|
||||||
_flutter.loader.loadEntrypoint({
|
const tips = [
|
||||||
serviceWorker: {
|
// Promoting Tetra Stats "native"
|
||||||
serviceWorkerVersion: serviceWorkerVersion,
|
"Want a better perfomance?<br><a href=\"ya.ru\">Try out Tetra Stats Native</a>",
|
||||||
},
|
"Imagine a world, where Tetra Stats was written in JS",
|
||||||
onEntrypointLoaded: async function(engineInitializer) {
|
"Welcome to fullscreen canvas",
|
||||||
console.log(serviceWorkerVersion);
|
|
||||||
let appRunner = await engineInitializer.initializeEngine();
|
// An actual tips
|
||||||
progress.innerHTML = "Booting...";
|
"You can interact with most objects that have an accent color",
|
||||||
await appRunner.runApp();
|
"Like Sheetbot graphs? Go to three dots menu → Settings → Customization",
|
||||||
preloader.classList.add("hidden");
|
"Click and hold on line chart graph, then start dragging to zoom in"
|
||||||
}
|
];
|
||||||
});
|
tip.innerHTML = tips[Math.floor(Math.random() * tips.length)];
|
||||||
});
|
try{
|
||||||
|
// Download main.dart.js
|
||||||
|
_flutter.loader.loadEntrypoint({
|
||||||
|
serviceWorker: {
|
||||||
|
serviceWorkerVersion: serviceWorkerVersion,
|
||||||
|
},
|
||||||
|
onEntrypointLoaded: async function(engineInitializer) {
|
||||||
|
console.log(serviceWorkerVersion);
|
||||||
|
progress.innerHTML = "Booting...";
|
||||||
|
let appRunner = await engineInitializer.initializeEngine();
|
||||||
|
await appRunner.runApp();
|
||||||
|
preloader.classList.add("hidden");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (e){
|
||||||
|
progress.classList.add("error");
|
||||||
|
document.getAnimations()[0].cancel();
|
||||||
|
progress.innerHTML = "fuck: "+e;
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in New Issue