mirror of
https://github.com/DustinBrett/daedalOS.git
synced 2026-01-15 12:15:02 +00:00
Allow killing sheep
This commit is contained in:
@@ -921,7 +921,9 @@ const useCommandInterpreter = (
|
||||
}
|
||||
case "sheep":
|
||||
case "esheep": {
|
||||
const { default: spawnSheep } = await import("utils/spawnSheep");
|
||||
const { countSheep, killSheep, spawnSheep } = await import(
|
||||
"utils/spawnSheep"
|
||||
);
|
||||
let [count = 1, duration = 0] = commandArgs;
|
||||
|
||||
if (!Number.isNaN(count) && !Number.isNaN(duration)) {
|
||||
@@ -936,10 +938,12 @@ const useCommandInterpreter = (
|
||||
const maxDuration =
|
||||
(duration || (count > 1 ? 1 : 0)) * MILLISECONDS_IN_SECOND;
|
||||
|
||||
Array.from({ length: count })
|
||||
Array.from({ length: count === 0 ? countSheep() : count })
|
||||
.fill(0)
|
||||
.map(() => Math.floor(Math.random() * maxDuration))
|
||||
.forEach((delay) => setTimeout(spawnSheep, delay));
|
||||
.forEach((delay) =>
|
||||
setTimeout(count === 0 ? killSheep : spawnSheep, delay)
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import {
|
||||
} from "utils/constants";
|
||||
import { getExtension, haltEvent } from "utils/functions";
|
||||
import { getIpfsFileName, getIpfsResource } from "utils/ipfs";
|
||||
import spawnSheep from "utils/spawnSheep";
|
||||
import { spawnSheep } from "utils/spawnSheep";
|
||||
import Icon from "styles/common/Icon";
|
||||
|
||||
const OPEN_ID = "open";
|
||||
|
||||
@@ -50,7 +50,7 @@ const easterEggOnClick: React.MouseEventHandler<HTMLElement> = async ({
|
||||
triggerEasterEggCountdown -= 1;
|
||||
|
||||
if (triggerEasterEggCountdown === 0) {
|
||||
const { default: spawnSheep } = await import("utils/spawnSheep");
|
||||
const { spawnSheep } = await import("utils/spawnSheep");
|
||||
|
||||
spawnSheep();
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ const StartButton: FC<StartButtonProps> = ({
|
||||
toggleStartMenu();
|
||||
|
||||
if (ctrlKey && shiftKey) {
|
||||
const { default: spawnSheep } = await import("utils/spawnSheep");
|
||||
const { spawnSheep } = await import("utils/spawnSheep");
|
||||
|
||||
spawnSheep();
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ const pickRandomPet = (): string => {
|
||||
return petPath;
|
||||
};
|
||||
|
||||
const spawnSheep = (): Promise<void> =>
|
||||
export const spawnSheep = (): Promise<void> =>
|
||||
loadFiles(["/Program Files/eSheep/eSheep.js"]).then(() => {
|
||||
if (window.Sheep) {
|
||||
const sheep = new window.Sheep({
|
||||
@@ -59,4 +59,14 @@ const spawnSheep = (): Promise<void> =>
|
||||
}
|
||||
});
|
||||
|
||||
export default spawnSheep;
|
||||
const sheepSelector =
|
||||
"main > div[style*='z-index: 2000'] > img[src^='data:image']";
|
||||
|
||||
export const killSheep = (): void => {
|
||||
const firstSheep = document.querySelector(sheepSelector) as HTMLElement;
|
||||
|
||||
firstSheep?.parentElement?.remove();
|
||||
};
|
||||
|
||||
export const countSheep = (): number =>
|
||||
document.querySelectorAll(sheepSelector).length;
|
||||
|
||||
Reference in New Issue
Block a user