CODEBASE: Fix lint errors 2 (#1756)

This commit is contained in:
catloversg
2024-11-07 14:09:11 +07:00
committed by GitHub
parent e3c10e9f0f
commit 36c143b687
48 changed files with 267 additions and 146 deletions
+8 -4
View File
@@ -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);
+18 -4
View File
@@ -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: {