-
+
|
rusty
tetris-guideline.pdf
diff --git a/src/front/static/ts/main.ts b/src/front/static/ts/main.ts
index 831d203..5ac2396 100644
--- a/src/front/static/ts/main.ts
+++ b/src/front/static/ts/main.ts
@@ -142,3 +142,30 @@ updateClock();
setInterval(pingClock, 30000);
oneko();
+
+async function startMenuPP() {
+ const profileButton = document.getElementById("start-img") as HTMLImageElement;
+ try {
+ if(document.cookie.match(new RegExp('(^| )' + "token" + '=([^;]+)'))) {
+ throw "not today, thank you";
+ }
+ let uuid: String;
+ uuid = document.cookie.match(new RegExp('(^| )' + "uuid" + '=([^;]+)'))[2];
+
+
+ const a = await fetch(`http://localhost:3002/users/${uuid}/avatar`, {
+ method: "GET",
+ credentials: "include"
+ });
+
+ profileButton.src = a.status === 200
+ ? `http://localhost:3002/users/${uuid}/avatar?t=${Date.now()}`
+ : "https://api.kanel.ovh/pp";
+ } catch (err){
+ // console.log("not yet logged, going default for start icon...");
+ profileButton.src = "https://api.kanel.ovh/id?id=65";
+ }
+}
+
+setInterval(startMenuPP, 3000);
+startMenuPP();
diff --git a/src/front/static/ts/oneko.ts b/src/front/static/ts/oneko.ts
index a2a159b..57670eb 100644
--- a/src/front/static/ts/oneko.ts
+++ b/src/front/static/ts/oneko.ts
@@ -22,7 +22,7 @@ export function setOnekoState(state: string) {
}
export function setOnekoOffset() {
- if (oneko_state != 0)
+ if (oneko_state === 1)
{
offsetX = document.getElementById("window").offsetLeft + 44;
offsetY = document.getElementById("window").offsetTop + 44 + 24;
@@ -30,6 +30,11 @@ export function setOnekoOffset() {
return;
}
+export function setSleepPos() {
+ mousePosX = document.getElementById("window")?.offsetLeft + 120;
+ mousePosY = document.getElementById("window")?.offsetTop + 400;
+}
+
export function setBallPos(x: number, y: number)
{
mousePosX = x + offsetX;
diff --git a/src/front/static/ts/views/Tetris.ts b/src/front/static/ts/views/Tetris.ts
index f5a20d3..72cfacb 100644
--- a/src/front/static/ts/views/Tetris.ts
+++ b/src/front/static/ts/views/Tetris.ts
@@ -1,7 +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, setSleepPos } from "../oneko.ts";
export default class extends Aview {
running: boolean;
@@ -42,6 +42,7 @@ export default class extends Aview {
}
async run() {
+ setSleepPos();
dragElement(document.getElementById("window"));
const COLS = 10;
const ROWS = 20;
@@ -874,6 +875,7 @@ export default class extends Aview {
this.drawPiece();
this.drawHUD();
this.drawQueue();
+ setSleepPos();
}
}