From dfd7aa2d2e604e46b7cb3e77e680fab523403fef Mon Sep 17 00:00:00 2001 From: danielyxie Date: Tue, 19 Mar 2019 16:38:49 -0700 Subject: [PATCH] Minor fixes to new Sleeve API --- src/BitNode/BitNode.ts | 1 + src/Constants.ts | 3 ++- .../ui/CorporationUIEventHandler.js | 2 +- src/NetscriptFunctions.js | 22 ++++++++++++++++++- src/PersonObjects/Sleeve/Sleeve.ts | 7 +++--- src/Player.js | 6 ++++- 6 files changed, 33 insertions(+), 8 deletions(-) diff --git a/src/BitNode/BitNode.ts b/src/BitNode/BitNode.ts index 7ac23b188..8888e8e7c 100644 --- a/src/BitNode/BitNode.ts +++ b/src/BitNode/BitNode.ts @@ -366,6 +366,7 @@ export function initBitNodeMultipliers(p: IPlayer) { BitNodeMultipliers.PurchasedServerCost = 5; BitNodeMultipliers.PurchasedServerLimit = 0.6; BitNodeMultipliers.PurchasedServerMaxRam = 0.5; + BitNodeMultipliers.BladeburnerRank = 0.8; break; case 11: //The Big Crash BitNodeMultipliers.ServerMaxMoney = 0.1; diff --git a/src/Constants.ts b/src/Constants.ts index 916ffce55..5b3a5cdf9 100644 --- a/src/Constants.ts +++ b/src/Constants.ts @@ -303,7 +303,8 @@ export let CONSTANTS: IMap = { ** Bug Fix: An industry's products are now properly separated between different cities * Added a Netscript API for Duplicate Sleeves (by hydroflame) - * Modified BitNode-3's BN multipliers to make it slightly harder + * Modified the multipliers of BitNode-3 and BitNode-8 to make them slightly harder + * After installing Augmentations, Duplicate Sleeves will now default to Synchronize if their Shock is 0 * Bug Fix: Bladeburner's Hyperbolic Regeneration Chamber should no longer instantly refill all stamina * Bug Fix: The cost of purchasing Augmentations for Duplicate Sleeves no longer scales with how many Augs you've purchased for yourself ` diff --git a/src/Corporation/ui/CorporationUIEventHandler.js b/src/Corporation/ui/CorporationUIEventHandler.js index d6735d208..1f6edfb2a 100644 --- a/src/Corporation/ui/CorporationUIEventHandler.js +++ b/src/Corporation/ui/CorporationUIEventHandler.js @@ -348,7 +348,7 @@ export class CorporationEventHandler { clickListener:()=>{ mat.exp.splice(i, 1); //Remove export object removeElementById(popupId); - createExportPopup(); + createExportMaterialPopup(mat); } })); })(i, mat, currExports); diff --git a/src/NetscriptFunctions.js b/src/NetscriptFunctions.js index 74133fdf3..6d246a1d2 100644 --- a/src/NetscriptFunctions.js +++ b/src/NetscriptFunctions.js @@ -73,7 +73,7 @@ import {WorkerScript, workerScripts, import {makeRuntimeRejectMsg, netscriptDelay, runScriptFromScript} from "./NetscriptEvaluator"; import {NetscriptPort} from "./NetscriptPort"; -import {SleeveTaskType} from "./PersonObjects/Sleeve/SleeveTaskTypesEnum" +import { SleeveTaskType } from "./PersonObjects/Sleeve/SleeveTaskTypesEnum" import {Page, routing} from "./ui/navigationTracking"; import {numeralWrapper} from "./ui/numeralFormat"; @@ -4910,6 +4910,16 @@ function NetscriptFunctions(workerScript) { return false; } + // Cannot work at the same company that another sleeve is working at + for (let i = 0; i < Player.sleeves.length; ++i) { + if (i === sleeveNumber) { continue; } + const other = Player.sleeves[i]; + if (other.currentTask === SleeveTaskType.Company && other.currentTaskLocation === companyName) { + workerScript.log(`ERROR: sleeve.setToCompanyWork() failed for Sleeve ${sleeveNumber} because Sleeve ${i} is doing the same task`); + return false; + } + } + return Player.sleeves[sleeveNumber].workForCompany(Player, companyName); }, setToFactionWork : function(sleeveNumber=0, factionName="", workType="") { @@ -4925,6 +4935,16 @@ function NetscriptFunctions(workerScript) { return false; } + // Cannot work at the same faction that another sleeve is working at + for (let i = 0; i < Player.sleeves.length; ++i) { + if (i === sleeveNumber) { continue; } + const other = Player.sleeves[i]; + if (other.currentTask === SleeveTaskType.Faction && other.currentTaskLocation === factionName) { + workerScript.log(`ERROR: sleeve.setToFactionWork() failed for Sleeve ${sleeveNumber} because Sleeve ${i} is doing the same task`); + return false; + } + } + return Player.sleeves[sleeveNumber].workForFaction(Player, factionName, workType); }, setToGymWorkout : function(sleeveNumber=0, gymName="", stat="") { diff --git a/src/PersonObjects/Sleeve/Sleeve.ts b/src/PersonObjects/Sleeve/Sleeve.ts index 8e644e2af..6f5a27c98 100644 --- a/src/PersonObjects/Sleeve/Sleeve.ts +++ b/src/PersonObjects/Sleeve/Sleeve.ts @@ -614,7 +614,6 @@ export class Sleeve extends Person { */ travel(p: IPlayer, newCity: string): boolean { if (Cities[newCity] == null) { - console.error(`Invalid city ${newCity} passed into Sleeve.travel()`); return false; } @@ -641,8 +640,8 @@ export class Sleeve extends Person { const company: Company | null = Companies[companyName]; const companyPosition: CompanyPosition | null = CompanyPositions[p.jobs[companyName]]; - if (company == null) { throw new Error(`Invalid company name specified in Sleeve.workForCompany(): ${companyName}`); } - if (companyPosition == null) { throw new Error(`Invalid CompanyPosition data in Sleeve.workForCompany(): ${companyName}`); } + if (company == null) { return false; } + if (companyPosition == null) { return false; } this.gainRatesForTask.money = companyPosition.baseSalary * company.salaryMultiplier * this.work_money_mult * @@ -684,8 +683,8 @@ export class Sleeve extends Person { * Returns boolean indicating success */ workForFaction(p: IPlayer, factionName: string, workType: string): boolean { + if (factionName === "") { return false; } if (!(Factions[factionName] instanceof Faction) || !p.factions.includes(factionName)) { - throw new Error(`Invalid Faction specified for Sleeve.workForFaction(): ${factionName}`); return false; } diff --git a/src/Player.js b/src/Player.js index ca0c5c0ec..01903d82c 100644 --- a/src/Player.js +++ b/src/Player.js @@ -283,7 +283,11 @@ PlayerObject.prototype.prestigeAugmentation = function() { for (let i = 0; i < this.sleeves.length; ++i) { if (this.sleeves[i] instanceof Sleeve) { - this.sleeves[i].shockRecovery(this); + if (this.sleeves[i].shock >= 100) { + this.sleeves[i].synchronize(this); + } else { + this.sleeves[i].shockRecovery(this); + } } }