Merge branch 'dev' of github.com:danielyxie/bitburner into feature/grafting

This commit is contained in:
nickofolas
2022-03-18 23:23:11 -05:00
10 changed files with 389 additions and 696 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -18,6 +18,7 @@ export interface IConstructorParams {
name: string;
prereqs?: string[];
repCost: number;
factions: string[];
hacking_mult?: number;
strength_mult?: number;
@ -393,12 +394,16 @@ export class Augmentation {
// Initial cost. Doesn't change when you purchase multiple Augmentation
startingCost = 0;
// Factions that offer this aug.
factions: string[] = [];
constructor(
params: IConstructorParams = {
info: "",
moneyCost: 0,
name: "",
repCost: 0,
factions: [],
},
) {
this.name = params.name;
@ -408,6 +413,7 @@ export class Augmentation {
this.baseRepRequirement = params.repCost * BitNodeMultipliers.AugmentationRepCost;
this.baseCost = params.moneyCost * BitNodeMultipliers.AugmentationMoneyCost;
this.startingCost = this.baseCost;
this.factions = params.factions;
if (params.isSpecial) {
this.isSpecial = true;

File diff suppressed because it is too large Load Diff

View File

@ -191,7 +191,7 @@ export class Gang implements IGang {
}
// Then process territory
const gangs = GangConstants.Names.filter((g) => AllGangs[g].territory > 0);
const gangs = GangConstants.Names.filter((g) => AllGangs[g].territory > 0 || g === gangName);
if (gangs.length > 1) {
for (let i = 0; i < gangs.length; ++i) {
const others = gangs.filter((e) => {
@ -225,9 +225,9 @@ export class Gang implements IGang {
if (AllGangs[otherGang].territory <= 0) return;
const territoryGain = calculateTerritoryGain(thisGang, otherGang);
AllGangs[thisGang].territory += territoryGain;
if (AllGangs[thisGang].territory > 1) AllGangs[thisGang].territory = 1;
if (AllGangs[thisGang].territory > 0.999) AllGangs[thisGang].territory = 1;
AllGangs[otherGang].territory -= territoryGain;
if (AllGangs[thisGang].territory < 0) AllGangs[thisGang].territory = 0;
if (AllGangs[thisGang].territory < 0.001) AllGangs[thisGang].territory = 0;
if (thisGang === gangName) {
this.clash(true); // Player won
AllGangs[otherGang].power *= 1 / 1.01;
@ -240,9 +240,9 @@ export class Gang implements IGang {
if (AllGangs[thisGang].territory <= 0) return;
const territoryGain = calculateTerritoryGain(otherGang, thisGang);
AllGangs[thisGang].territory -= territoryGain;
if (AllGangs[otherGang].territory < 0) AllGangs[otherGang].territory = 0;
if (AllGangs[otherGang].territory < 0.001) AllGangs[otherGang].territory = 0;
AllGangs[otherGang].territory += territoryGain;
if (AllGangs[otherGang].territory > 1) AllGangs[otherGang].territory = 1;
if (AllGangs[otherGang].territory > 0.999) AllGangs[otherGang].territory = 1;
if (thisGang === gangName) {
this.clash(false); // Player lost
} else if (otherGang === gangName) {

View File

@ -208,6 +208,7 @@ export const RamCosts: IMap<any> = {
getScriptExpGain: RamCostConstants.ScriptGetScriptRamCost,
getRunningScript: RamCostConstants.ScriptGetRunningScriptRamCost,
nFormat: 0,
tFormat: 0,
getTimeSinceLastAug: RamCostConstants.ScriptGetHackTimeRamCost,
prompt: 0,
wget: 0,
@ -215,6 +216,8 @@ export const RamCosts: IMap<any> = {
getPlayer: RamCostConstants.ScriptSingularityFn1RamCost / 4,
mv: 0,
getOwnedSourceFiles: RamCostConstants.ScriptGetOwnedSourceFiles,
tail: 0,
toast: 0,
// Singularity Functions
universityCourse: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost),

View File

@ -3,6 +3,7 @@ import { IPlayer } from "../PersonObjects/IPlayer";
import { Exploit } from "../Exploits/Exploit";
import * as bcrypt from "bcryptjs";
import { INetscriptHelper } from "./INetscriptHelper";
import { Augmentations } from "../Augmentation/Augmentations";
export interface INetscriptExtra {
heart: {

View File

@ -91,25 +91,25 @@ export function NetscriptHacknet(player: IPlayer, workerScript: WorkerScript, he
return res;
},
upgradeLevel: function (_i: unknown, _n: unknown): boolean {
upgradeLevel: function (_i: unknown, _n: unknown = 1): boolean {
const i = helper.number("upgradeLevel", "i", _i);
const n = helper.number("upgradeLevel", "n", _n);
const node = getHacknetNode(i, "upgradeLevel");
return purchaseLevelUpgrade(player, node, n);
},
upgradeRam: function (_i: unknown, _n: unknown): boolean {
upgradeRam: function (_i: unknown, _n: unknown = 1): boolean {
const i = helper.number("upgradeRam", "i", _i);
const n = helper.number("upgradeRam", "n", _n);
const node = getHacknetNode(i, "upgradeRam");
return purchaseRamUpgrade(player, node, n);
},
upgradeCore: function (_i: unknown, _n: unknown): boolean {
upgradeCore: function (_i: unknown, _n: unknown = 1): boolean {
const i = helper.number("upgradeCore", "i", _i);
const n = helper.number("upgradeCore", "n", _n);
const node = getHacknetNode(i, "upgradeCore");
return purchaseCoreUpgrade(player, node, n);
},
upgradeCache: function (_i: unknown, _n: unknown): boolean {
upgradeCache: function (_i: unknown, _n: unknown = 1): boolean {
const i = helper.number("upgradeCache", "i", _i);
const n = helper.number("upgradeCache", "n", _n);
if (!hasHacknetServers(player)) {
@ -126,25 +126,25 @@ export function NetscriptHacknet(player: IPlayer, workerScript: WorkerScript, he
}
return res;
},
getLevelUpgradeCost: function (_i: unknown, _n: unknown): number {
getLevelUpgradeCost: function (_i: unknown, _n: unknown = 1): number {
const i = helper.number("getLevelUpgradeCost", "i", _i);
const n = helper.number("getLevelUpgradeCost", "n", _n);
const node = getHacknetNode(i, "upgradeLevel");
return node.calculateLevelUpgradeCost(n, player.hacknet_node_level_cost_mult);
},
getRamUpgradeCost: function (_i: unknown, _n: unknown): number {
getRamUpgradeCost: function (_i: unknown, _n: unknown = 1): number {
const i = helper.number("getRamUpgradeCost", "i", _i);
const n = helper.number("getRamUpgradeCost", "n", _n);
const node = getHacknetNode(i, "upgradeRam");
return node.calculateRamUpgradeCost(n, player.hacknet_node_ram_cost_mult);
},
getCoreUpgradeCost: function (_i: unknown, _n: unknown): number {
getCoreUpgradeCost: function (_i: unknown, _n: unknown = 1): number {
const i = helper.number("getCoreUpgradeCost", "i", _i);
const n = helper.number("getCoreUpgradeCost", "n", _n);
const node = getHacknetNode(i, "upgradeCore");
return node.calculateCoreUpgradeCost(n, player.hacknet_node_core_cost_mult);
},
getCacheUpgradeCost: function (_i: unknown, _n: unknown): number {
getCacheUpgradeCost: function (_i: unknown, _n: unknown = 1): number {
const i = helper.number("getCacheUpgradeCost", "i", _i);
const n = helper.number("getCacheUpgradeCost", "n", _n);
if (!hasHacknetServers(player)) {
@ -177,10 +177,9 @@ export function NetscriptHacknet(player: IPlayer, workerScript: WorkerScript, he
return player.hashManager.getUpgradeCost(upgName);
},
spendHashes: function (_upgName: unknown, _upgTarget: unknown): boolean {
spendHashes: function (_upgName: unknown, _upgTarget: unknown = ""): boolean {
const upgName = helper.string("spendHashes", "upgName", _upgName);
let upgTarget = "";
if (_upgTarget !== undefined) upgTarget = helper.string("spendHashes", "upgTarget", _upgTarget);
const upgTarget = helper.string("spendHashes", "upgTarget", _upgTarget);
if (!hasHacknetServers(player)) {
return false;
}

View File

@ -289,6 +289,10 @@ export function NetscriptSleeve(player: IPlayer, workerScript: WorkerScript, hel
checkSleeveAPIAccess("purchaseSleeveAug");
checkSleeveNumber("purchaseSleeveAug", sleeveNumber);
if (player.sleeves[sleeveNumber].shock > 0){
throw helper.makeRuntimeErrorMsg("sleeve.purchaseSleeveAug", `Sleeve shock too high: Sleeve ${sleeveNumber}`);
}
const aug = Augmentations[augName];
if (!aug) {
throw helper.makeRuntimeErrorMsg("sleeve.purchaseSleeveAug", `Invalid aug: ${augName}`);

View File

@ -52,7 +52,9 @@ export function PromptManager(): React.ReactElement {
return (
<Modal open={true} onClose={close}>
<Typography>{prompt.txt}</Typography>
<pre>
<Typography>{prompt.txt}</Typography>
</pre>
<PromptContent prompt={prompt} resolve={resolve} />
</Modal>
);