mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-20 16:22:56 +02:00
CODEBASE: Fix lint errors 2 (#1756)
This commit is contained in:
@@ -624,15 +624,19 @@ export function NetscriptCorporation(): InternalAPI<NSCorporation> {
|
||||
checkAccess(ctx);
|
||||
const unlockName = getEnumHelper("CorpUnlockName").nsGetMember(ctx, _unlockName, "unlockName");
|
||||
const corporation = getCorporation();
|
||||
const message = corporation.purchaseUnlock(unlockName);
|
||||
if (message) throw new Error(`Could not unlock ${unlockName}: ${message}`);
|
||||
const result = corporation.purchaseUnlock(unlockName);
|
||||
if (!result.success) {
|
||||
throw new Error(`Could not unlock ${unlockName}: ${result.message}`);
|
||||
}
|
||||
},
|
||||
levelUpgrade: (ctx) => (_upgradeName) => {
|
||||
checkAccess(ctx);
|
||||
const upgradeName = getEnumHelper("CorpUpgradeName").nsGetMember(ctx, _upgradeName, "upgradeName");
|
||||
const corporation = getCorporation();
|
||||
const message = corporation.purchaseUpgrade(upgradeName, 1);
|
||||
if (message) throw new Error(`Could not upgrade ${upgradeName}: ${message}`);
|
||||
const result = corporation.purchaseUpgrade(upgradeName, 1);
|
||||
if (!result.success) {
|
||||
throw new Error(`Could not upgrade ${upgradeName}: ${result.message}`);
|
||||
}
|
||||
},
|
||||
issueDividends: (ctx) => (_rate) => {
|
||||
checkAccess(ctx);
|
||||
|
||||
@@ -13,6 +13,7 @@ import { Factions } from "../Faction/Factions";
|
||||
import { getEnumHelper } from "../utils/EnumHelper";
|
||||
import { helpers } from "../Netscript/NetscriptHelpers";
|
||||
import { filterTruthy } from "../utils/helpers/ArrayHelpers";
|
||||
import { exceptionAlert } from "../utils/helpers/exceptionAlert";
|
||||
|
||||
export function NetscriptInfiltration(): InternalAPI<NetscriptInfiltation> {
|
||||
const getLocationsWithInfiltrations = Object.values(Locations).filter(
|
||||
@@ -21,16 +22,29 @@ export function NetscriptInfiltration(): InternalAPI<NetscriptInfiltation> {
|
||||
|
||||
const calculateInfiltrationData = (ctx: NetscriptContext, locationName: LocationName): InfiltrationLocation => {
|
||||
const location = Locations[locationName];
|
||||
if (location === undefined) throw helpers.errorMessage(ctx, `Location '${location}' does not exists.`);
|
||||
if (location.infiltrationData === undefined)
|
||||
throw helpers.errorMessage(ctx, `Location '${location}' does not provide infiltrations.`);
|
||||
if (location === undefined) {
|
||||
throw helpers.errorMessage(ctx, `Location "${locationName}" does not exist.`);
|
||||
}
|
||||
if (location.infiltrationData === undefined) {
|
||||
throw helpers.errorMessage(ctx, `Location "${locationName}" does not provide infiltrations.`);
|
||||
}
|
||||
const locationCity = location.city;
|
||||
/**
|
||||
* location.city is only null when the location is available in all cities. This kind of location does not have
|
||||
* infiltration data.
|
||||
*/
|
||||
if (locationCity === null) {
|
||||
const errorMessage = `Location "${locationName}" is available in all cities, but it still has infiltration data.`;
|
||||
exceptionAlert(new Error(errorMessage));
|
||||
throw helpers.errorMessage(ctx, errorMessage);
|
||||
}
|
||||
const startingSecurityLevel = location.infiltrationData.startingSecurityLevel;
|
||||
const difficulty = calculateDifficulty(startingSecurityLevel);
|
||||
const reward = calculateReward(startingSecurityLevel);
|
||||
const maxLevel = location.infiltrationData.maxClearanceLevel;
|
||||
return {
|
||||
location: {
|
||||
city: location.city!,
|
||||
city: locationCity,
|
||||
name: location.name,
|
||||
},
|
||||
reward: {
|
||||
|
||||
Reference in New Issue
Block a user