diff --git a/src/Terminal/Terminal.ts b/src/Terminal/Terminal.ts index 2ebc4dcbf..d9b0a0ebe 100644 --- a/src/Terminal/Terminal.ts +++ b/src/Terminal/Terminal.ts @@ -72,6 +72,7 @@ import { vim } from "./commands/vim"; import { weaken } from "./commands/weaken"; import { wget } from "./commands/wget"; import { hash } from "../hash/hash"; +import { apr1 } from "./commands/apr1"; export class Terminal implements ITerminal { // Flags to determine whether the player is currently running a hack or an analyze @@ -805,6 +806,7 @@ export class Terminal implements ITerminal { scp: scp, sudov: sudov, tail: tail, + apr1: apr1, top: top, unalias: unalias, vim: vim, diff --git a/src/Terminal/commands/apr1.ts b/src/Terminal/commands/apr1.ts new file mode 100644 index 000000000..39a7c8e11 --- /dev/null +++ b/src/Terminal/commands/apr1.ts @@ -0,0 +1,15 @@ +import { ITerminal } from "../ITerminal"; +import { IRouter } from "../../ui/Router"; +import { IPlayer } from "../../PersonObjects/IPlayer"; +import { BaseServer } from "../../Server/BaseServer"; +import { Apr1Events } from "../../ui/Apr1"; + +export function apr1( + terminal: ITerminal, + router: IRouter, + player: IPlayer, + server: BaseServer, + commandArray: (string | number | boolean)[], +): void { + Apr1Events.emit(); +} diff --git a/src/ui/Apr1.tsx b/src/ui/Apr1.tsx index 4e69663d3..e54315d7c 100644 --- a/src/ui/Apr1.tsx +++ b/src/ui/Apr1.tsx @@ -1,4 +1,5 @@ import React, { useEffect, useState } from "react"; +import { EventEmitter } from "../utils/EventEmitter"; import { Modal } from "./React/Modal"; const frames = [ @@ -37,6 +38,8 @@ function isApr1(): boolean { return d.getMonth() === 3 && d.getDate() === 1; } +export const Apr1Events = new EventEmitter(); + export function Apr1(): React.ReactElement { const [open, setOpen] = useState(isApr1()); const [n, setN] = useState(0); @@ -45,6 +48,15 @@ export function Apr1(): React.ReactElement { const id = setInterval(() => setN((n) => (n + 1) % frames.length), 100); return () => clearInterval(id); }, []); + + useEffect( + () => + Apr1Events.subscribe(() => { + setOpen(true); + }), + [], + ); + if (!open) return <>; return (