This commit is contained in:
Olivier Gagnon 2021-12-20 15:48:26 -05:00
parent ddd0eaaf5c
commit 41a7109baa
7 changed files with 33 additions and 14 deletions

@ -233,7 +233,8 @@ const achievements: Achievement[] = [
{ {
ID: "BLADEBURNER_OVERCLOCK", ID: "BLADEBURNER_OVERCLOCK",
Condition: () => Condition: () =>
Player.bladeburner !== null && Player.bladeburner.skills[SkillNames.Overclock] === Skills[SkillNames.Overclock], Player.bladeburner !== null &&
Player.bladeburner.skills[SkillNames.Overclock] === Skills[SkillNames.Overclock].maxLvl,
}, },
{ {
ID: "BLADEBURNER_UNSPENT_100000", ID: "BLADEBURNER_UNSPENT_100000",
@ -250,12 +251,14 @@ const achievements: Achievement[] = [
Condition: () => { Condition: () => {
if (!hasHacknetServers(Player)) return false; if (!hasHacknetServers(Player)) return false;
for (const h of Player.hacknetNodes) { for (const h of Player.hacknetNodes) {
if (!(h instanceof HacknetServer)) return false; if (typeof h !== "string") return false;
const hs = GetServer(h);
if (!(hs instanceof HacknetServer)) return false;
if ( if (
h.maxRam === HacknetServerConstants.MaxRam && hs.maxRam === HacknetServerConstants.MaxRam &&
h.cores === HacknetServerConstants.MaxCores && hs.cores === HacknetServerConstants.MaxCores &&
h.level === HacknetServerConstants.MaxLevel && hs.level === HacknetServerConstants.MaxLevel &&
h.cache === HacknetServerConstants.MaxCache hs.cache === HacknetServerConstants.MaxCache
) )
return true; return true;
} }

@ -353,7 +353,7 @@ export class Gang {
const res = member.ascend(); const res = member.ascend();
this.respect = Math.max(1, this.respect - res.respect); this.respect = Math.max(1, this.respect - res.respect);
if (workerScript) { if (workerScript) {
workerScript.log("ascend", () => `Ascended Gang member ${member.name}`); workerScript.log("gang.ascend", () => `Ascended Gang member ${member.name}`);
} }
return res; return res;
} catch (e: any) { } catch (e: any) {

@ -1594,7 +1594,9 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
return cost; return cost;
}, },
purchaseServer: function (name: any, ram: any): any { purchaseServer: function (aname: any, aram: any): any {
const name = helper.string("purchaseServer", "name", aname);
const ram = helper.number("purchaseServer", "ram", aram);
updateDynamicRam("purchaseServer", getRamCost("purchaseServer")); updateDynamicRam("purchaseServer", getRamCost("purchaseServer"));
let hostnameStr = String(name); let hostnameStr = String(name);
hostnameStr = hostnameStr.replace(/\s+/g, ""); hostnameStr = hostnameStr.replace(/\s+/g, "");

@ -289,6 +289,8 @@ export interface ProcessInfo {
threads: number; threads: number;
/** Script's arguments */ /** Script's arguments */
args: string[]; args: string[];
/** Process ID */
pid: number;
} }
/** /**
@ -4098,9 +4100,6 @@ export interface NS extends Singularity {
* This only stops a function from logging when the function is successful. * This only stops a function from logging when the function is successful.
* If the function fails, it will still log the reason for failure. * If the function fails, it will still log the reason for failure.
* *
* Notable functions that cannot have their logs disabled: run,
* exec, exit.
*
* @param fn - Name of function for which to disable logging. * @param fn - Name of function for which to disable logging.
*/ */
disableLog(fn: string): void; disableLog(fn: string): void;

@ -14,7 +14,7 @@ export const TerminalHelpText: string[] = [
"clear Clear all text on the terminal ", "clear Clear all text on the terminal ",
"cls See 'clear' command ", "cls See 'clear' command ",
"connect [hostname] Connects to a remote server", "connect [hostname] Connects to a remote server",
"cp [src] [dst]: Copy a file", "cp [src] [dst] Copy a file",
"download [script/text file] Downloads scripts or text files to your computer", "download [script/text file] Downloads scripts or text files to your computer",
"expr [math expression] Evaluate a mathematical expression", "expr [math expression] Evaluate a mathematical expression",
"free Check the machine's memory (RAM) usage", "free Check the machine's memory (RAM) usage",

@ -3,6 +3,7 @@ import { IRouter } from "../../ui/Router";
import { IPlayer } from "../../PersonObjects/IPlayer"; import { IPlayer } from "../../PersonObjects/IPlayer";
import { BaseServer } from "../../Server/BaseServer"; import { BaseServer } from "../../Server/BaseServer";
import { getServerOnNetwork } from "../../Server/ServerHelpers"; import { getServerOnNetwork } from "../../Server/ServerHelpers";
import { GetServer } from "../../Server/AllServers";
export function connect( export function connect(
terminal: ITerminal, terminal: ITerminal,
@ -13,7 +14,7 @@ export function connect(
): void { ): void {
// Disconnect from current server in terminal and connect to new one // Disconnect from current server in terminal and connect to new one
if (args.length !== 1) { if (args.length !== 1) {
terminal.error("Incorrect usage of connect command. Usage: connect [ip/hostname]"); terminal.error("Incorrect usage of connect command. Usage: connect [hostname]");
return; return;
} }
@ -28,5 +29,9 @@ export function connect(
} }
} }
terminal.error("Host not found"); if (GetServer(hostname) !== null) {
terminal.error(`Cannot directly connect to ${hostname}`);
} else {
terminal.error("Host not found");
}
} }

@ -32,6 +32,16 @@ export function AlertManager(): React.ReactElement {
[], [],
); );
useEffect(() => {
function handle(this: Document, event: KeyboardEvent): void {
if (event.code === "Escape") {
setAlerts([]);
}
}
document.addEventListener("keydown", handle);
return () => document.removeEventListener("keydown", handle);
}, []);
function close(): void { function close(): void {
setAlerts((old) => { setAlerts((old) => {
return old.slice(1, 1e99); return old.slice(1, 1e99);