From e93be42e7c36863545eb2f366b27e25f823d43f9 Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Wed, 16 Mar 2022 14:34:05 -0400 Subject: [PATCH] 2 new exploits --- src/Arcade/ui/BBCabinet.tsx | 12 +++++++++++- src/Exploits/Exploit.ts | 4 ++++ src/NetscriptFunctions/Extra.ts | 14 ++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/Arcade/ui/BBCabinet.tsx b/src/Arcade/ui/BBCabinet.tsx index d88d7b61b..137b579d9 100644 --- a/src/Arcade/ui/BBCabinet.tsx +++ b/src/Arcade/ui/BBCabinet.tsx @@ -1,5 +1,7 @@ -import React from "react"; +import React, { useEffect } from "react"; import Typography from "@mui/material/Typography"; +import { use } from "../../ui/Context"; +import { Exploit } from "../../Exploits/Exploit"; const metaBB = "https://bitburner-official.github.io/bitburner-legacy/"; @@ -10,6 +12,14 @@ const style = { } as any; export function BBCabinetRoot(): React.ReactElement { + const player = use.Player(); + useEffect(() => { + window.addEventListener("message", function (this: Window, ev: MessageEvent) { + if (ev.isTrusted && ev.origin == "https://bitburner-official.github.io" && ev.data) { + player.giveExploit(Exploit.TrueRecursion); + } + }); + }); // prettier-ignore const joystick = <> diff --git a/src/Exploits/Exploit.ts b/src/Exploits/Exploit.ts index d25b0d756..d6f097636 100644 --- a/src/Exploits/Exploit.ts +++ b/src/Exploits/Exploit.ts @@ -19,6 +19,8 @@ export enum Exploit { RealityAlteration = "RealityAlteration", N00dles = "N00dles", YoureNotMeantToAccessThis = "YoureNotMeantToAccessThis", + TrueRecursion = "TrueRecursion", + INeedARainbow = "INeedARainbow", // To the players reading this. Yes you're supposed to add EditSaveFile by // editing your save file, yes you could add them all, no we don't care // that's not the point. @@ -37,6 +39,8 @@ const names: { RealityAlteration: "by altering reality to suit your whims.", N00dles: "by harnessing the power of the n00dles.", YoureNotMeantToAccessThis: "by accessing the dev menu.", + TrueRecursion: "by truly recursing.", + INeedARainbow: "by using the power of the rainbow.", }; export function ExploitName(exploit: string): string { diff --git a/src/NetscriptFunctions/Extra.ts b/src/NetscriptFunctions/Extra.ts index 495e93974..9c1dd3d81 100644 --- a/src/NetscriptFunctions/Extra.ts +++ b/src/NetscriptFunctions/Extra.ts @@ -1,6 +1,7 @@ import { WorkerScript } from "../Netscript/WorkerScript"; import { IPlayer } from "../PersonObjects/IPlayer"; import { Exploit } from "../Exploits/Exploit"; +import * as bcrypt from "bcryptjs"; export interface INetscriptExtra { heart: { @@ -9,6 +10,7 @@ export interface INetscriptExtra { exploit(): void; bypass(doc: Document): void; alterReality(): void; + rainbow(guess: string): void; } export function NetscriptExtra(player: IPlayer, workerScript: WorkerScript): INetscriptExtra { @@ -50,5 +52,17 @@ export function NetscriptExtra(player: IPlayer, workerScript: WorkerScript): INe player.giveExploit(Exploit.RealityAlteration); } }, + rainbow: function (guess: unknown): void { + async function tryGuess(): Promise { + const verified = await bcrypt.compare( + guess + "", + "$2a$10$aertxDEkgor8baVtQDZsLuMwwGYmkRM/ohcA6FjmmzIHQeTCsrCcO", + ); + if (verified) { + player.giveExploit(Exploit.INeedARainbow); + } + } + tryGuess(); + }, }; }