11 Commits

Author SHA1 Message Date
5cb323a1d2 remove useless import
Some checks failed
CI / build (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / create-and-publish-docker-image (push) Has been cancelled
2025-09-03 14:57:57 +02:00
8314c4daf8 fix sorting of chores 2025-09-03 14:57:35 +02:00
cb4ce4188e Amogus cleanup
All checks were successful
CI / build (pull_request) Successful in 12s
CI / lint (pull_request) Successful in 10s
CI / create-and-publish-docker-image (pull_request) Successful in 14s
CI / build (push) Successful in 12s
CI / lint (push) Successful in 9s
CI / create-and-publish-docker-image (push) Successful in 12s
2025-09-01 20:24:19 +02:00
53db7e795c Bad collision 2025-09-01 20:24:19 +02:00
3606f9b043 restart firefox after pull 2025-09-01 20:24:19 +02:00
5da900c1c3 Enhance Amogus 2025-09-01 20:24:19 +02:00
8653365af1 rename github folder
All checks were successful
CI / build (push) Successful in 13s
CI / lint (push) Successful in 9s
CI / create-and-publish-docker-image (push) Successful in 14s
2025-08-31 23:55:45 +02:00
d914f47640 Merge branch 'better-deploy'
Some checks failed
CI / build (push) Successful in 15s
CI / lint (push) Successful in 13s
CI / create-and-publish-docker-image (push) Has been cancelled
2025-08-31 21:04:52 +02:00
668d260fd6 fix typo in ci
All checks were successful
CI / build (push) Successful in 15s
CI / lint (push) Successful in 10s
CI / create-and-publish-docker-image (push) Successful in 18s
2025-08-31 18:36:41 +02:00
03dc0984f3 quic commit
Some checks failed
CI / build (push) Successful in 13s
CI / lint (push) Successful in 9s
CI / create-and-publish-docker-image (push) Failing after 16s
2025-08-31 18:26:33 +02:00
0d94904c50 set HYPRLAND_INSTANCE_SIGNATURE
Some checks failed
CI / build (push) Successful in 13s
CI / create-and-publish-docker-image (push) Failing after 7s
CI / lint (push) Successful in 8s
2025-08-31 18:25:32 +02:00
7 changed files with 164 additions and 134 deletions

View File

@@ -69,11 +69,13 @@ jobs:
password: ${{ secrets.GARRISON_DOCKER_PASSWORD }}
script: |
cd monitor-im-flur
hyprctl dispatch exec 'pkill firefox'
hyprctl dispatch exec 'firefox -kiosk localhost:9123'
git clean -dfx
git reset --hard HEAD
git pull
docker-compose pull
docker-compose down
docker-compose up -d
export HYPRLAND_INSTANCE_SIGNATURE=$(hyprctl instances -j | jq '.[0].instance' | tr -d "'\"")
hyprctl dispatch exec 'pkill firefox'
hyprctl dispatch exec 'firefox -kiosk localhost:9123'

View File

@@ -11,81 +11,122 @@ type Amogus = {
speedY: number;
};
const amogusWidth = 70;
const amogusHeight = 70;
const { innerWidth: width, innerHeight: height } = window;
const getImage = (sus: Amogus) => (sus.isImposter ? imposter : amogus);
const initialCrewmates: Amogus[] = [
{ key: "a", isImposter: true, posX: 10, posY: 20, speedX: 10, speedY: 30 },
{
key: "b",
isImposter: false,
posX: 400,
posY: 200,
speedX: 10,
speedY: -20,
},
{
key: "c",
isImposter: false,
posX: 900,
posY: 200,
speedX: -20,
speedY: 10,
},
];
const makeCrewmate = (crewmate: Amogus) => {
const image = getImage(crewmate);
return (
<div
key={crewmate.key}
className={style.container}
style={{ top: crewmate.posY, left: crewmate.posX }}
>
<img src={image} alt="Amogus" />
</div>
);
const makeInitialCrewmates = (): Amogus[] => {
return [
makeCrewmate(true),
makeCrewmate(false),
makeCrewmate(false),
makeCrewmate(false),
makeCrewmate(false),
makeCrewmate(false),
makeCrewmate(false),
makeCrewmate(false),
makeCrewmate(false),
];
};
const stepCrewmates = (list: Amogus[]) => {
const { innerWidth: width, innerHeight: height } = window;
const newCrewmates = list.slice();
for (const c of newCrewmates) {
let newX = c.posX + c.speedX;
let newY = c.posY + c.speedY;
if (newX > width - 90) {
newX = width - 90;
c.speedX *= -1;
const randNum = (min: number, max: number): number =>
Math.random() * (max - min) + min;
const makeCrewmate = (imposter: boolean): Amogus => ({
isImposter: imposter,
posX: randNum(0, width - amogusWidth),
posY: randNum(0, height - amogusHeight),
speedX: Math.random() > 0.5 ? randNum(3, 10) : randNum(-3, -10),
speedY: Math.random() > 0.5 ? randNum(3, 10) : randNum(-3, -10),
});
const intersect = (c1: Amogus, c2: Amogus): boolean =>
Math.abs(c1.posX - c2.posX) < amogusWidth - 20 &&
Math.abs(c1.posY - c2.posY) < amogusHeight - 20;
const doMove = (crewmates: Amogus[]) =>
crewmates.map((c) => ({
...c,
posX: c.posX + c.speedX,
posY: c.posY + c.speedY,
}));
const doCollisionWalls = (crewmates: Amogus[]) =>
crewmates.map((c) => {
if (c.posX > width - amogusWidth) {
return {
...c,
posX: width - amogusWidth,
speedX: c.speedX * -1,
};
} else if (c.posX < -20) {
return { ...c, posX: -20, speedX: c.speedX * -1 };
} else if (c.posY > height - amogusHeight) {
return {
...c,
posY: height - amogusHeight,
speedY: c.speedY * -1,
};
} else if (c.posY < -20) {
return { ...c, posY: -20, speedY: c.speedY * -1 };
} else return c;
});
// TODO: This is ugly
const doCollisionOthers = (crewmates: Amogus[]) =>
crewmates.map((c) => {
const intersections = crewmates
.filter((o) => o !== c) // don't collide with yourself pls
.filter((o) => intersect(c, o));
if (intersections.some((o) => Math.abs(o.posX - c.posX) < 50)) {
return { ...c, speedX: c.speedX * -1 };
}
if (newX < 0) {
newX = 0;
c.speedX *= -1;
if (intersections.some((o) => Math.abs(o.posY - c.posY) < 50)) {
return { ...c, speedY: c.speedY * -1 };
}
if (newY > height - 120) {
newY = height - 120;
c.speedY *= -1;
}
if (newY < 0) {
newY = 0;
c.speedY *= -1;
}
c.posX = newX;
c.posY = newY;
}
return newCrewmates;
return c;
});
const doKills = (crewmates: Amogus[]) => {
const imposters = crewmates.filter((c) => c.isImposter);
const alive = crewmates
.filter((c) => !c.isImposter)
.filter((c) => imposters.every((i) => !intersect(i, c)));
return imposters.concat(alive);
};
const checkReset = (crewmates: Amogus[]) =>
crewmates.every((c) => c.isImposter) ? makeInitialCrewmates() : crewmates;
const renderCrewmate = (crewmate: Amogus, key: number) => (
<div
key={key}
className={style.container}
style={{ top: crewmate.posY, left: crewmate.posX }}
>
<img src={getImage(crewmate)} alt="Amogus" />
</div>
);
export default function Amogus() {
const [crewmates, setCrewmates] = useState(initialCrewmates);
const [crewmates, setCrewmates] = useState(() => makeInitialCrewmates());
useEffect(() => {
const timer = setInterval(() => {
const c = crewmates;
setCrewmates(stepCrewmates(c));
}, 100);
setCrewmates((c) => doMove(c));
setCrewmates((c) => doCollisionWalls(c));
setCrewmates((c) => doCollisionOthers(c));
setCrewmates((c) => doKills(c));
setCrewmates((c) => checkReset(c));
}, 50);
return () => {
clearInterval(timer);
};
}, [crewmates]);
}, []);
return <>{crewmates.map((c) => makeCrewmate(c))}</>;
return <>{crewmates.map((c, index) => renderCrewmate(c, index))}</>;
}

View File

@@ -1,4 +1,8 @@
.container {
z-index: 100;
position: absolute;
scale: 50%;
display: flex;
justify-content: center;
align-items: center;
}

View File

@@ -1,5 +1,4 @@
import FourTwenty from "@components/FourTwenty/FourTwenty";
import classNames from "classnames";
import { useEffect, useState } from "react";
import Amogus from "@/components/Amogus/Amogus";
import Card from "@/components/Card/Card";
@@ -60,16 +59,9 @@ export default function Dashboard() {
<Weather />
</Card>
<div
className={classNames(
style.bouncingWindow,
style.hidden,
)}
>
<Card icon="🍁" name="420">
<FourTwenty />
</Card>
</div>
<Card icon="🍁" name="420">
<FourTwenty />
</Card>
</CardRow>
<Card icon="🔔" name="Terminal" active={true}>

View File

@@ -25,30 +25,3 @@
.night {
background-color: #2a3f55;
}
.amogus {
z-index: 100;
position: absolute;
scale: 60%;
animation:
x 10s linear infinite alternate,
y 7s linear infinite alternate;
}
@keyframes x {
from {
left: 0;
}
to {
left: calc(100vw - 70px);
}
}
@keyframes y {
from {
top: 0;
}
to {
top: calc(100vh - 90px);
}
}

View File

@@ -1,19 +1,53 @@
import classNames from "classnames";
import { useEffect } from "react";
import { useFlatasticStore } from "@/store/flatastic";
import type { FlatasticChore, FlatasticUser } from "@/types/flatasticChore";
import style from "./style.module.css";
function choreItem(chore: FlatasticChore, idToNameMap: Record<number, string>) {
let className = "";
let timeLeftInDays = null;
if (chore.rotationTime === -1) {
className = "irregular";
} else {
className = chore.timeLeftNext <= 0 ? "due" : "notDue";
timeLeftInDays = (
<span className={style.timeLeft}>
{Math.abs(Math.floor(chore.timeLeftNext / (60 * 60 * 24)))}d
</span>
);
}
return (
<li
key={chore.id}
className={classNames(style.chore, style[className])}
>
<span className={style.userName}>
{`${idToNameMap[chore.currentUser]}`}
</span>
: {chore.title} {timeLeftInDays} {"🪙".repeat(chore.points)}
</li>
);
}
export default function Flatastic() {
const fetchFlatasticData = useFlatasticStore((state) => state.fetch);
const flatasticData = useFlatasticStore((state) => state.flatasticData);
const chores = (flatasticData?.chores as FlatasticChore[]) || [];
const regularChores: FlatasticChore[] = [];
const irregularChores: FlatasticChore[] = [];
chores.sort(
(a, b) =>
a.timeLeftNext - b.timeLeftNext && b.rotationTime - a.rotationTime,
);
chores.forEach((chore) => {
if (chore.rotationTime === -1) {
irregularChores.push(chore);
} else {
regularChores.push(chore);
}
});
regularChores.sort((a, b) => a.lastDoneDate - b.lastDoneDate);
const users = flatasticData?.users;
const idToNameMap: Record<number, string> = {};
@@ -23,44 +57,28 @@ export default function Flatastic() {
useEffect(() => {
fetchFlatasticData();
const interval = setInterval(() => {
fetchFlatasticData();
}, 60000);
return () => clearInterval(interval);
}, [fetchFlatasticData]);
const choresRender = chores.map((chore) => {
let className = "";
let timeLeftInDays = null;
const regularChoresRender = regularChores.map((chore) => {
return choreItem(chore, idToNameMap);
});
if (chore.rotationTime === -1) {
className = "irregular";
} else {
className = chore.timeLeftNext <= 0 ? "due" : "notDue";
timeLeftInDays = (
<span className={style.timeLeft}>
{Math.abs(Math.floor(chore.timeLeftNext / (60 * 60 * 24)))}d
</span>
);
}
return (
<li
key={chore.id}
className={[style.chore, style[className]].join(" ")}
>
<span className={style.userName}>
{`${idToNameMap[chore.currentUser]}`}
</span>
: {chore.title} {timeLeftInDays} {"🪙".repeat(chore.points)}
</li>
);
const irregularChoresRender = irregularChores.map((chore) => {
return choreItem(chore, idToNameMap);
});
return (
<div className={style.container}>
<h1>Chores</h1>
<ul className={style.choreList}>{choresRender}</ul>
<ul className={style.choreList}>
{[...regularChoresRender, ...irregularChoresRender]}
</ul>
</div>
);
}

View File

@@ -16,7 +16,7 @@ interface FlatasticChore {
points: number;
rotationTime: number;
currentUser: number;
lastDoneDate: string;
lastDoneDate: number;
timeLeftNext: number;
}