Merge pull request #3337 from phyzical/feature/3332

added apr1 terminal command
This commit is contained in:
hydroflame 2022-04-05 20:02:26 -04:00 committed by GitHub
commit d683fa5eda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 0 deletions

@ -72,6 +72,7 @@ import { vim } from "./commands/vim";
import { weaken } from "./commands/weaken"; import { weaken } from "./commands/weaken";
import { wget } from "./commands/wget"; import { wget } from "./commands/wget";
import { hash } from "../hash/hash"; import { hash } from "../hash/hash";
import { apr1 } from "./commands/apr1";
export class Terminal implements ITerminal { export class Terminal implements ITerminal {
// Flags to determine whether the player is currently running a hack or an analyze // 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, scp: scp,
sudov: sudov, sudov: sudov,
tail: tail, tail: tail,
apr1: apr1,
top: top, top: top,
unalias: unalias, unalias: unalias,
vim: vim, 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 React, { useEffect, useState } from "react";
import { EventEmitter } from "../utils/EventEmitter";
import { Modal } from "./React/Modal"; import { Modal } from "./React/Modal";
const frames = [ const frames = [
@ -37,6 +38,8 @@ function isApr1(): boolean {
return d.getMonth() === 3 && d.getDate() === 1; return d.getMonth() === 3 && d.getDate() === 1;
} }
export const Apr1Events = new EventEmitter();
export function Apr1(): React.ReactElement { export function Apr1(): React.ReactElement {
const [open, setOpen] = useState(isApr1()); const [open, setOpen] = useState(isApr1());
const [n, setN] = useState(0); const [n, setN] = useState(0);
@ -45,6 +48,15 @@ export function Apr1(): React.ReactElement {
const id = setInterval(() => setN((n) => (n + 1) % frames.length), 100); const id = setInterval(() => setN((n) => (n + 1) % frames.length), 100);
return () => clearInterval(id); return () => clearInterval(id);
}, []); }, []);
useEffect(
() =>
Apr1Events.subscribe(() => {
setOpen(true);
}),
[],
);
if (!open) return <></>; if (!open) return <></>;
return ( return (