Added sf minus 1, exploits

This commit is contained in:
Olivier Gagnon 2021-03-08 20:31:34 -05:00
parent d9aef91ea3
commit 250841df66
11 changed files with 145 additions and 0 deletions

@ -10,6 +10,7 @@ import * as React from "react";
import { InstalledAugmentations } from "./InstalledAugmentations";
import { ListConfiguration } from "./ListConfiguration";
import { OwnedSourceFiles } from "./OwnedSourceFiles";
import { SourceFileMinus1 } from "./SourceFileMinus1";
import { Settings } from "../../Settings/Settings";
import { OwnedAugmentationsOrderSetting } from "../../Settings/SettingEnums";
@ -98,6 +99,7 @@ export class InstalledAugmentationsAndSourceFiles extends React.Component<IProps
sortInOrderFn={this.sortInOrder}
/>
<ul className="augmentations-list" ref={this.listRef}>
<SourceFileMinus1 />
<OwnedSourceFiles />
<InstalledAugmentations />
</ul>

@ -0,0 +1,44 @@
/**
* React Component for displaying a list of the player's Source-Files
* on the Augmentations UI
*/
import * as React from "react";
import { Player } from "../../Player";
import { Settings } from "../../Settings/Settings";
import { OwnedAugmentationsOrderSetting } from "../../Settings/SettingEnums";
import { SourceFiles } from "../../SourceFile/SourceFiles";
import { Exploit, ExploitName } from "../../Exploits/Exploit";
import { Accordion } from "../../ui/React/Accordion";
export function SourceFileMinus1(): React.ReactElement {
let exploits = Player.exploits;
if(exploits.length === 0) {
return <></>
}
return (<li key={-1}>
<Accordion
headerContent={
<>
Source-File -1: Exploits in the BitNodes
<br />
Level {exploits.length} / ?
</>
}
panelContent={
<>
<p>This Source-File can only be acquired with obscure knowledge of the game, javascript, and the web ecosystem.</p>
<p>It increases all of the player's multipliers by 0.1%</p><br />
<p>You have found the following exploits:</p>
<ul>
{exploits.map((c: Exploit) => <li key={c}>* {ExploitName(c)}</li>)}
</ul>
</>
}
/>
</li>)
}

25
src/Exploits/Exploit.ts Normal file

@ -0,0 +1,25 @@
/*
*/
export enum Exploit {
UndocumentedFunctionCall = 'UndocumentedFunctionCall',
EditSaveFile = 'EditSaveFile',
PrototypeTampering = 'PrototypeTampering'
}
const names: {
[key: string]: string;
} = {
'UndocumentedFunctionCall': 'by looking beyond the documentation.',
'EditSaveFile': 'by editing your save file.',
'PrototypeTampering': 'by tampering with Numbers prototype.',
}
export function ExploitName(exploit: string): string {
return names[exploit];
}
export function sanitizeExploits(exploits: string[]): string[] {
return exploits.filter((e: string) => Object.keys(Exploit).includes(e));
}

@ -0,0 +1,42 @@
import { Player } from "../Player";
export function applyExploit() {
if (Player.exploits && Player.exploits.length === 0) {
return;
}
const inc = Math.pow(1.0001, Player.exploits.length);
const dec = Math.pow(0.9999, Player.exploits.length);
Player.hacking_chance_mult *= inc;
Player.hacking_speed_mult *= inc;
Player.hacking_money_mult *= inc;
Player.hacking_grow_mult *= inc;
Player.hacking_mult *= inc;
Player.strength_mult *= inc;
Player.defense_mult *= inc;
Player.dexterity_mult *= inc;
Player.agility_mult *= inc;
Player.charisma_mult *= inc;
Player.hacking_exp_mult *= inc;
Player.strength_exp_mult *= inc;
Player.defense_exp_mult *= inc;
Player.dexterity_exp_mult *= inc;
Player.agility_exp_mult *= inc;
Player.charisma_exp_mult *= inc;
Player.company_rep_mult *= inc;
Player.faction_rep_mult *= inc;
Player.crime_money_mult *= inc;
Player.crime_success_mult *= inc;
Player.hacknet_node_money_mult *= inc;
Player.hacknet_node_purchase_cost_mult *= dec;
Player.hacknet_node_ram_cost_mult *= dec;
Player.hacknet_node_core_cost_mult *= dec;
Player.hacknet_node_level_cost_mult *= dec;
Player.work_money_mult *= inc;
}

11
src/Exploits/tampering.ts Normal file

@ -0,0 +1,11 @@
import { Player } from "../Player";
import { Exploit } from "./Exploit";
(function() {
const a = 55;
setInterval(function() {
if (a.toExponential() !== "5.5e+1") {
Player.giveExploit(Exploit.PrototypeTampering);
}
}, 15*60*1000); // 15 minutes
})()

@ -142,6 +142,7 @@ import {
import { NetscriptPort } from "./NetscriptPort";
import { SleeveTaskType } from "./PersonObjects/Sleeve/SleeveTaskTypesEnum";
import { findSleevePurchasableAugs } from "./PersonObjects/Sleeve/SleeveHelpers";
import { Exploit } from './Exploits/Exploit.ts';
import { Page, routing } from "./ui/navigationTracking";
import { numeralWrapper } from "./ui/numeralFormat";
@ -4713,6 +4714,9 @@ function NetscriptFunctions(workerScript) {
break: function() {
return Player.karma;
}
},
exploit: function() {
Player.giveExploit(Exploit.UndocumentedFunctionCall);
}
} // End return
} // End NetscriptFunction()

@ -19,6 +19,7 @@ import { LocationName } from "../Locations/data/LocationNames";
import { Server } from "../Server/Server";
import { IPlayerOwnedSourceFile } from "../SourceFile/PlayerOwnedSourceFile";
import { MoneySourceTracker } from "../utils/MoneySourceTracker";
import { Exploit } from "../Exploits/Exploit";
export interface IPlayer {
// Class members
@ -56,6 +57,7 @@ export interface IPlayer {
sleeves: Sleeve[];
sleevesFromCovenant: number;
sourceFiles: IPlayerOwnedSourceFile[];
exploits: Exploit[];
totalPlaytime: number;
// Stats
@ -173,4 +175,5 @@ export interface IPlayer {
startWork(companyName: string): void;
startWorkPartTime(companyName: string): void;
travel(to: CityName): boolean;
giveExploit(exploit: Exploit): void;
}

@ -201,6 +201,8 @@ export function PlayerObject() {
// Production since last Augmentation installation
this.scriptProdSinceLastAug = 0;
this.exploits = [];
};
// Apply player methods to the prototype using Object.assign()

@ -37,6 +37,7 @@ import { safetlyCreateUniqueServer } from "../../Server/ServerHelpers";
import { Settings } from "../../Settings/Settings";
import { SpecialServerIps, SpecialServerNames } from "../../Server/SpecialServerIps";
import { applySourceFile } from "../../SourceFile/applySourceFile";
import { applyExploit } from "../../Exploits/applyExploits";
import { SourceFiles } from "../../SourceFile/SourceFiles";
import { SourceFileFlags } from "../../SourceFile/SourceFileFlags";
import { influenceStockThroughCompanyWork } from "../../StockMarket/PlayerInfluencing";
@ -1866,6 +1867,7 @@ export function reapplyAllSourceFiles() {
}
applySourceFile(this.sourceFiles[i]);
}
applyExploit();
}
/*************** Check for Faction Invitations *************/
@ -2298,3 +2300,9 @@ export function gotoLocation(to) {
export function canAccessResleeving() {
return this.bitNodeN === 10 || (SourceFileFlags[10] > 0);
}
export function giveExploit(exploit) {
if(!this.exploits.includes(exploit)) {
this.exploits.push(exploit);
}
}

@ -1,5 +1,6 @@
import { Corporation } from "./Corporation/Corporation";
import { PlayerObject } from "./PersonObjects/Player/PlayerObject";
import { sanitizeExploits } from "./Exploits/Exploit";
import { Reviver } from "../utils/JSONReviver";
@ -26,4 +27,6 @@ export function loadPlayer(saveString) {
ind.thisCycleExpenses = new Decimal(ind.thisCycleExpenses);
}
}
Player.exploits = sanitizeExploits(Player.exploits);
}

@ -102,6 +102,7 @@ import { createElement } from "../utils/uiHelpers/createElement";
import { exceptionAlert } from "../utils/helpers/exceptionAlert";
import { removeLoadingScreen } from "../utils/uiHelpers/removeLoadingScreen";
import { KEY } from "../utils/helpers/keyCodes";
import "./Exploits/tampering";
import React from "react";
import ReactDOM from "react-dom";