mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-21 16:52:55 +02:00
MISC: Remove fuzzy matching when checking params (#2091)
This commit is contained in:
@@ -26,7 +26,7 @@ import {
|
||||
calculateGrowTime,
|
||||
calculateWeakenTime,
|
||||
} from "../Hacking";
|
||||
import { CityName, CompletedProgramName, FactionWorkType, GymType, LocationName, UniversityClassType } from "@enums";
|
||||
import { CityName, CompletedProgramName, LocationName } from "@enums";
|
||||
import { Formulas as IFormulas, Player as IPlayer, Person as IPerson } from "@nsdefs";
|
||||
import {
|
||||
calculateRespectGain,
|
||||
@@ -47,12 +47,11 @@ import { calculateClassEarnings } from "../Work/Formulas";
|
||||
import { calculateFactionExp, calculateFactionRep } from "../Work/Formulas";
|
||||
|
||||
import { defaultMultipliers } from "../PersonObjects/Multipliers";
|
||||
import { findEnumMember } from "../utils/helpers/enum";
|
||||
import { getEnumHelper } from "../utils/EnumHelper";
|
||||
import { CompanyPositions } from "../Company/CompanyPositions";
|
||||
import { findCrime } from "../Crime/CrimeHelpers";
|
||||
import { Skills } from "../Bladeburner/data/Skills";
|
||||
import type { PositiveNumber } from "../types";
|
||||
import { Crimes } from "../Crime/Crimes";
|
||||
import { calculateEffectiveSharedThreads, calculateShareBonus } from "../NetworkShare/Share";
|
||||
|
||||
export function NetscriptFormulas(): InternalAPI<IFormulas> {
|
||||
@@ -395,38 +394,39 @@ export function NetscriptFormulas(): InternalAPI<IFormulas> {
|
||||
crimeSuccessChance: (ctx) => (_person, _crimeType) => {
|
||||
checkFormulasAccess(ctx);
|
||||
const person = helpers.person(ctx, _person);
|
||||
const crime = findCrime(helpers.string(ctx, "crimeType", _crimeType));
|
||||
if (!crime) throw new Error(`Invalid crime type: ${_crimeType}`);
|
||||
const crime = Crimes[getEnumHelper("CrimeType").nsGetMember(ctx, _crimeType)];
|
||||
if (!crime) {
|
||||
throw new Error(`Invalid crime type: ${_crimeType}`);
|
||||
}
|
||||
return crime.successRate(person);
|
||||
},
|
||||
crimeGains: (ctx) => (_person, _crimeType) => {
|
||||
checkFormulasAccess(ctx);
|
||||
const person = helpers.person(ctx, _person);
|
||||
const crime = findCrime(helpers.string(ctx, "crimeType", _crimeType));
|
||||
if (!crime) throw new Error(`Invalid crime type: ${_crimeType}`);
|
||||
const crime = Crimes[getEnumHelper("CrimeType").nsGetMember(ctx, _crimeType)];
|
||||
if (!crime) {
|
||||
throw new Error(`Invalid crime type: ${_crimeType}`);
|
||||
}
|
||||
return calculateCrimeWorkStats(person, crime);
|
||||
},
|
||||
gymGains: (ctx) => (_person, _classType, _locationName) => {
|
||||
checkFormulasAccess(ctx);
|
||||
const person = helpers.person(ctx, _person);
|
||||
const classType = findEnumMember(GymType, helpers.string(ctx, "classType", _classType));
|
||||
if (!classType) throw new Error(`Invalid gym training type: ${_classType}`);
|
||||
const classType = getEnumHelper("GymType").nsGetMember(ctx, _classType);
|
||||
const locationName = getEnumHelper("LocationName").nsGetMember(ctx, _locationName);
|
||||
return calculateClassEarnings(person, classType, locationName);
|
||||
},
|
||||
universityGains: (ctx) => (_person, _classType, _locationName) => {
|
||||
checkFormulasAccess(ctx);
|
||||
const person = helpers.person(ctx, _person);
|
||||
const classType = findEnumMember(UniversityClassType, helpers.string(ctx, "classType", _classType));
|
||||
if (!classType) throw new Error(`Invalid university class type: ${_classType}`);
|
||||
const classType = getEnumHelper("UniversityClassType").nsGetMember(ctx, _classType);
|
||||
const locationName = getEnumHelper("LocationName").nsGetMember(ctx, _locationName);
|
||||
return calculateClassEarnings(person, classType, locationName);
|
||||
},
|
||||
factionGains: (ctx) => (_player, _workType, _favor) => {
|
||||
checkFormulasAccess(ctx);
|
||||
const player = helpers.person(ctx, _player);
|
||||
const workType = findEnumMember(FactionWorkType, helpers.string(ctx, "_workType", _workType));
|
||||
if (!workType) throw new Error(`Invalid faction work type: ${_workType}`);
|
||||
const workType = getEnumHelper("FactionWorkType").nsGetMember(ctx, _workType);
|
||||
const favor = helpers.number(ctx, "favor", _favor);
|
||||
const exp = calculateFactionExp(player, workType);
|
||||
const rep = calculateFactionRep(player, workType, favor);
|
||||
|
||||
Reference in New Issue
Block a user