mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-27 00:17:32 +01:00
Merge pull request #3337 from phyzical/feature/3332
added apr1 terminal command
This commit is contained in:
commit
d683fa5eda
@ -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,
|
||||
|
15
src/Terminal/commands/apr1.ts
Normal file
15
src/Terminal/commands/apr1.ts
Normal file
@ -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 (
|
||||
|
Loading…
Reference in New Issue
Block a user