whar?
This commit is contained in:
parent
1c29cce71b
commit
d34b072fcd
|
@ -282,7 +282,10 @@ void main() async {
|
|||
int rot = 0;
|
||||
bool spinWasLastMove = false;
|
||||
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");
|
||||
Tetromino current = queue.removeAt(0);
|
||||
|
@ -305,6 +308,10 @@ void main() async {
|
|||
}
|
||||
//developer.log("Next queue is $queue");
|
||||
rot = 0;
|
||||
lockResets = 15;
|
||||
lockDelay = 30;
|
||||
floored = false;
|
||||
gravityBucket = 1.0;
|
||||
return queue.removeAt(0);
|
||||
}
|
||||
|
||||
|
@ -322,18 +329,63 @@ void main() async {
|
|||
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){
|
||||
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;
|
||||
if (gravityBucket >= 1.0){
|
||||
gravityImpact = gravityBucket.truncate();
|
||||
gravityBucket -= gravityBucket.truncate();
|
||||
}
|
||||
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--;
|
||||
}
|
||||
if (floored) lockDelay -= frames;
|
||||
if (lockDelay <= 0 && floored){
|
||||
handleHardDrop();
|
||||
}
|
||||
}
|
||||
|
||||
void handleMovement(double frames){
|
||||
|
@ -364,7 +416,8 @@ void main() async {
|
|||
case EventType.full:
|
||||
settings = (nextEvent as EventFull).data.options;
|
||||
handling = HandlingHandler(settings!.handling!.das.toDouble(), settings.handling!.arr.toDouble());
|
||||
print(handling);
|
||||
lockDelay = settings.locktime!.toDouble();
|
||||
lockResets = settings.lockresets!;
|
||||
break;
|
||||
case EventType.keydown:
|
||||
nextEvent as EventKeyPress;
|
||||
|
@ -393,43 +446,7 @@ void main() async {
|
|||
break;
|
||||
case KeyType.hardDrop:
|
||||
coords.y = sonicDrop();
|
||||
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];
|
||||
handleHardDrop();
|
||||
case KeyType.hold:
|
||||
switch (hold){
|
||||
case null:
|
||||
|
@ -441,10 +458,14 @@ void main() async {
|
|||
temp = hold;
|
||||
hold = current;
|
||||
current = temp;
|
||||
rot = 0;
|
||||
lockResets = 15;
|
||||
lockDelay = 30;
|
||||
gravityBucket = 1.0;
|
||||
floored = false;
|
||||
coords = Coords(3, 21) + spawnPositionFixes[current.index];
|
||||
break;
|
||||
}
|
||||
rot = 0;
|
||||
coords = Coords(3, 21) + spawnPositionFixes[current.index];
|
||||
break;
|
||||
case KeyType.chat:
|
||||
// TODO: Handle this case.
|
||||
|
|
|
@ -80,6 +80,9 @@
|
|||
font-weight: 500;
|
||||
font-style: normal;
|
||||
}
|
||||
a{
|
||||
color: aqua;
|
||||
}
|
||||
#preloader{
|
||||
display: flex;
|
||||
width: fit-content;
|
||||
|
@ -111,6 +114,15 @@
|
|||
padding-top: 8px;
|
||||
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){
|
||||
#preloader{
|
||||
flex-direction: column;
|
||||
|
@ -130,24 +142,44 @@
|
|||
<p id="progress">Loading...</p>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
<p id="tip"></p>
|
||||
<script>
|
||||
window.addEventListener('load', function(ev) {
|
||||
let progress = document.querySelector("#progress");
|
||||
let preloader = document.querySelector("#preloader");
|
||||
// Download main.dart.js
|
||||
_flutter.loader.loadEntrypoint({
|
||||
serviceWorker: {
|
||||
serviceWorkerVersion: serviceWorkerVersion,
|
||||
},
|
||||
onEntrypointLoaded: async function(engineInitializer) {
|
||||
console.log(serviceWorkerVersion);
|
||||
let appRunner = await engineInitializer.initializeEngine();
|
||||
progress.innerHTML = "Booting...";
|
||||
await appRunner.runApp();
|
||||
preloader.classList.add("hidden");
|
||||
}
|
||||
});
|
||||
});
|
||||
let progress = document.querySelector("#progress");
|
||||
let preloader = document.querySelector("#preloader");
|
||||
let tip = document.querySelector("#tip");
|
||||
const tips = [
|
||||
// Promoting Tetra Stats "native"
|
||||
"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",
|
||||
"Welcome to fullscreen canvas",
|
||||
|
||||
// An actual tips
|
||||
"You can interact with most objects that have an accent color",
|
||||
"Like Sheetbot graphs? Go to three dots menu → Settings → Customization",
|
||||
"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>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in New Issue