mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-18 20:25:45 +01:00
parent
82ba5f1f13
commit
426ad5f296
@ -18,6 +18,7 @@ export function determineCrimeSuccess(type: string): boolean {
|
||||
}
|
||||
|
||||
export function findCrime(roughName: string): Crime | null {
|
||||
if (checkEnum(CrimeType, roughName)) return Crimes[roughName];
|
||||
roughName = roughName.toLowerCase();
|
||||
if (roughName.includes("shoplift")) {
|
||||
return Crimes[CrimeType.SHOPLIFT];
|
||||
|
@ -49,9 +49,6 @@ import { CompanyWork } from "../Work/CompanyWork";
|
||||
import { canGetBonus, onExport } from "../ExportBonus";
|
||||
import { saveObject } from "../SaveObject";
|
||||
import { calculateCrimeWorkStats } from "../Work/Formulas";
|
||||
import { checkEnum } from "../utils/helpers/checkEnum";
|
||||
import { Crimes } from "../Crime/Crimes";
|
||||
import { CrimeType } from "../utils/WorkType";
|
||||
|
||||
export function NetscriptSingularity(): InternalAPI<ISingularity> {
|
||||
const getAugmentation = function (ctx: NetscriptContext, name: string): Augmentation {
|
||||
@ -1118,7 +1115,7 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
|
||||
Player.gotoLocation(LocationName.Slums);
|
||||
|
||||
// If input isn't a crimeType, use search using roughname.
|
||||
const crime = checkEnum(CrimeType, crimeType) ? Crimes[crimeType] : findCrime(crimeType);
|
||||
const crime = findCrime(crimeType);
|
||||
if (crime == null) throw helpers.makeRuntimeErrorMsg(ctx, `Invalid crime: '${crimeType}'`);
|
||||
|
||||
helpers.log(ctx, () => `Attempting to commit ${crime.name}...`);
|
||||
@ -1137,7 +1134,7 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
|
||||
const crimeType = helpers.string(ctx, "crimeType", _crimeType);
|
||||
|
||||
// If input isn't a crimeType, use search using roughname.
|
||||
const crime = checkEnum(CrimeType, crimeType) ? Crimes[crimeType] : findCrime(crimeType);
|
||||
const crime = findCrime(crimeType);
|
||||
if (crime == null) throw helpers.makeRuntimeErrorMsg(ctx, `Invalid crime: '${crimeType}'`);
|
||||
|
||||
return crime.successRate(Player);
|
||||
@ -1147,7 +1144,7 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
|
||||
const crimeType = helpers.string(ctx, "crimeType", _crimeType);
|
||||
|
||||
// If input isn't a crimeType, use search using roughname.
|
||||
const crime = checkEnum(CrimeType, crimeType) ? Crimes[crimeType] : findCrime(crimeType);
|
||||
const crime = findCrime(crimeType);
|
||||
if (crime == null) throw helpers.makeRuntimeErrorMsg(ctx, `Invalid crime: '${crimeType}'`);
|
||||
|
||||
const crimeStatsWithMultipliers = calculateCrimeWorkStats(Player, crime);
|
||||
|
@ -11,8 +11,6 @@ import { isSleeveBladeburnerWork } from "../PersonObjects/Sleeve/Work/SleeveBlad
|
||||
import { isSleeveFactionWork } from "../PersonObjects/Sleeve/Work/SleeveFactionWork";
|
||||
import { isSleeveCompanyWork } from "../PersonObjects/Sleeve/Work/SleeveCompanyWork";
|
||||
import { helpers } from "../Netscript/NetscriptHelpers";
|
||||
import { Crimes } from "../Crime/Crimes";
|
||||
import { CrimeType } from "../utils/WorkType";
|
||||
import { cloneDeep } from "lodash";
|
||||
|
||||
export function NetscriptSleeve(): InternalAPI<sleeve> {
|
||||
@ -55,7 +53,7 @@ export function NetscriptSleeve(): InternalAPI<sleeve> {
|
||||
const crimeType = helpers.string(ctx, "crimeType", _crimeType);
|
||||
checkSleeveAPIAccess(ctx);
|
||||
checkSleeveNumber(ctx, sleeveNumber);
|
||||
const crime = checkEnum(CrimeType, crimeType) ? Crimes[crimeType] : findCrime(crimeType);
|
||||
const crime = findCrime(crimeType);
|
||||
if (crime == null) return false;
|
||||
return Player.sleeves[sleeveNumber].commitCrime(crime.type);
|
||||
},
|
||||
|
@ -94,7 +94,7 @@ export class Sleeve extends Person implements ISleeve {
|
||||
}
|
||||
|
||||
/** Commit crimes */
|
||||
commitCrime(type: CrimeType): boolean {
|
||||
commitCrime(type: CrimeType) {
|
||||
this.startWork(new SleeveCrimeWork(type));
|
||||
return true;
|
||||
}
|
||||
|
@ -46,8 +46,7 @@ export function SleeveElem(props: IProps): React.ReactElement {
|
||||
props.sleeve.workForFaction(abc[1], abc[2]);
|
||||
break;
|
||||
case "Commit Crime":
|
||||
const crimeType = findCrime(abc[1])?.type ?? CrimeType.SHOPLIFT;
|
||||
props.sleeve.commitCrime(crimeType);
|
||||
props.sleeve.commitCrime(findCrime(abc[1])?.type ?? CrimeType.SHOPLIFT);
|
||||
break;
|
||||
case "Take University Course":
|
||||
props.sleeve.takeUniversityCourse(abc[2], abc[1]);
|
||||
|
Loading…
Reference in New Issue
Block a user