mirror of
https://github.com/KeyZox71/knl_meowscendence.git
synced 2025-12-31 21:56:41 +01:00
「✨」 feat(front): added tetris front and some minor fixes
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
import Aview from "./Aview.ts";
|
||||
import { isLogged } from "../main.js";
|
||||
import { dragElement } from "./drag.js";
|
||||
import { setOnekoState, setBallPos, setOnekoOffset } from "../oneko.ts"
|
||||
import { setOnekoState, setBallPos, setOnekoOffset } from "../oneko.ts";
|
||||
|
||||
export default class extends Aview {
|
||||
running: boolean;
|
||||
@ -538,12 +539,12 @@ export default class extends Aview {
|
||||
else if (e.code === "Space") {
|
||||
e.preventDefault();
|
||||
this.hardDrop();
|
||||
} else if (e.code === "ShiftLeft") {
|
||||
} else if (e.key === "Shift" || e.key === "c" || e.key === "C") {
|
||||
e.preventDefault();
|
||||
this.hold();
|
||||
} else if (e.key === "x" || e.key === "X" || e.key === "ArrowUp")
|
||||
this.rotatePiece("cw");
|
||||
else if (e.key === "z" || e.key === "Z" || e.code === "ControlLeft")
|
||||
else if (e.key === "z" || e.key === "Z" || e.key === "Control")
|
||||
this.rotatePiece("ccw");
|
||||
});
|
||||
|
||||
@ -552,7 +553,7 @@ export default class extends Aview {
|
||||
});
|
||||
}
|
||||
|
||||
loop(timestamp: number) {
|
||||
async loop(timestamp: number) {
|
||||
if (!this.lastDrop) this.lastDrop = timestamp;
|
||||
if (!this.isPaused)
|
||||
{
|
||||
@ -580,6 +581,22 @@ export default class extends Aview {
|
||||
|
||||
if (this.isGameOver)
|
||||
{
|
||||
if (await isLogged())
|
||||
{
|
||||
let uuid = document.cookie.match(new RegExp('(^| )' + "uuid" + '=([^;]+)'))[2];
|
||||
fetch(`http://localhost:3002/users/${uuid}/matchHistory?game=tetris`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json", },
|
||||
credentials: "include",
|
||||
body: JSON.stringify({
|
||||
"game": "tetris",
|
||||
"opponent": "xd",
|
||||
"myScore": this.score,
|
||||
"opponentScore": 0,
|
||||
"date": Date.now(),
|
||||
}),
|
||||
});
|
||||
}
|
||||
document.getElementById("game-buttons")?.classList.remove("hidden");
|
||||
return ;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user