added apr1 terminal command

* just opens the rickroll modal
This commit is contained in:
phyzical 2022-04-02 20:08:57 +08:00
parent acfd164927
commit 61fc815a6b
3 changed files with 29 additions and 0 deletions

@ -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,

@ -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();
}

@ -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 (