mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-18 12:15:44 +01:00
add argument for commitCrime focus
This commit is contained in:
parent
810f3a87b9
commit
83c26903c0
4
dist/main.bundle.js
vendored
4
dist/main.bundle.js
vendored
File diff suppressed because one or more lines are too long
2
dist/main.bundle.js.map
vendored
2
dist/main.bundle.js.map
vendored
File diff suppressed because one or more lines are too long
@ -97,7 +97,7 @@ export class Crime {
|
|||||||
this.kills = params.kills ? params.kills : 0;
|
this.kills = params.kills ? params.kills : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
commit(router: IRouter, p: IPlayer, div = 1, workerScript: WorkerScript | null = null): number {
|
commit(p: IPlayer, div = 1, workerScript: WorkerScript | null = null): number {
|
||||||
if (div <= 0) {
|
if (div <= 0) {
|
||||||
div = 1;
|
div = 1;
|
||||||
}
|
}
|
||||||
@ -107,8 +107,6 @@ export class Crime {
|
|||||||
singularity: workerScript !== null,
|
singularity: workerScript !== null,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
p.focus = true;
|
|
||||||
router.toWork();
|
|
||||||
|
|
||||||
return this.time;
|
return this.time;
|
||||||
}
|
}
|
||||||
|
@ -20,84 +20,108 @@ export function SlumsLocation(): React.ReactElement {
|
|||||||
if (!e.isTrusted) {
|
if (!e.isTrusted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Crimes.Shoplift.commit(router, player);
|
Crimes.Shoplift.commit(player);
|
||||||
|
router.toWork();
|
||||||
|
player.focus = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function robStore(e: React.MouseEvent<HTMLElement>): void {
|
function robStore(e: React.MouseEvent<HTMLElement>): void {
|
||||||
if (!e.isTrusted) {
|
if (!e.isTrusted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Crimes.RobStore.commit(router, player);
|
Crimes.RobStore.commit(player);
|
||||||
|
router.toWork();
|
||||||
|
player.focus = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function mug(e: React.MouseEvent<HTMLElement>): void {
|
function mug(e: React.MouseEvent<HTMLElement>): void {
|
||||||
if (!e.isTrusted) {
|
if (!e.isTrusted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Crimes.Mug.commit(router, player);
|
Crimes.Mug.commit(player);
|
||||||
|
router.toWork();
|
||||||
|
player.focus = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function larceny(e: React.MouseEvent<HTMLElement>): void {
|
function larceny(e: React.MouseEvent<HTMLElement>): void {
|
||||||
if (!e.isTrusted) {
|
if (!e.isTrusted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Crimes.Larceny.commit(router, player);
|
Crimes.Larceny.commit(player);
|
||||||
|
router.toWork();
|
||||||
|
player.focus = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function dealDrugs(e: React.MouseEvent<HTMLElement>): void {
|
function dealDrugs(e: React.MouseEvent<HTMLElement>): void {
|
||||||
if (!e.isTrusted) {
|
if (!e.isTrusted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Crimes.DealDrugs.commit(router, player);
|
Crimes.DealDrugs.commit(player);
|
||||||
|
router.toWork();
|
||||||
|
player.focus = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function bondForgery(e: React.MouseEvent<HTMLElement>): void {
|
function bondForgery(e: React.MouseEvent<HTMLElement>): void {
|
||||||
if (!e.isTrusted) {
|
if (!e.isTrusted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Crimes.BondForgery.commit(router, player);
|
Crimes.BondForgery.commit(player);
|
||||||
|
router.toWork();
|
||||||
|
player.focus = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function traffickArms(e: React.MouseEvent<HTMLElement>): void {
|
function traffickArms(e: React.MouseEvent<HTMLElement>): void {
|
||||||
if (!e.isTrusted) {
|
if (!e.isTrusted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Crimes.TraffickArms.commit(router, player);
|
Crimes.TraffickArms.commit(player);
|
||||||
|
router.toWork();
|
||||||
|
player.focus = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function homicide(e: React.MouseEvent<HTMLElement>): void {
|
function homicide(e: React.MouseEvent<HTMLElement>): void {
|
||||||
if (!e.isTrusted) {
|
if (!e.isTrusted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Crimes.Homicide.commit(router, player);
|
Crimes.Homicide.commit(player);
|
||||||
|
router.toWork();
|
||||||
|
player.focus = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function grandTheftAuto(e: React.MouseEvent<HTMLElement>): void {
|
function grandTheftAuto(e: React.MouseEvent<HTMLElement>): void {
|
||||||
if (!e.isTrusted) {
|
if (!e.isTrusted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Crimes.GrandTheftAuto.commit(router, player);
|
Crimes.GrandTheftAuto.commit(player);
|
||||||
|
router.toWork();
|
||||||
|
player.focus = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function kidnap(e: React.MouseEvent<HTMLElement>): void {
|
function kidnap(e: React.MouseEvent<HTMLElement>): void {
|
||||||
if (!e.isTrusted) {
|
if (!e.isTrusted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Crimes.Kidnap.commit(router, player);
|
Crimes.Kidnap.commit(player);
|
||||||
|
router.toWork();
|
||||||
|
player.focus = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function assassinate(e: React.MouseEvent<HTMLElement>): void {
|
function assassinate(e: React.MouseEvent<HTMLElement>): void {
|
||||||
if (!e.isTrusted) {
|
if (!e.isTrusted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Crimes.Assassination.commit(router, player);
|
Crimes.Assassination.commit(player);
|
||||||
|
router.toWork();
|
||||||
|
player.focus = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function heist(e: React.MouseEvent<HTMLElement>): void {
|
function heist(e: React.MouseEvent<HTMLElement>): void {
|
||||||
if (!e.isTrusted) {
|
if (!e.isTrusted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Crimes.Heist.commit(router, player);
|
Crimes.Heist.commit(player);
|
||||||
|
router.toWork();
|
||||||
|
player.focus = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const shopliftChance = Crimes.Shoplift.successRate(player);
|
const shopliftChance = Crimes.Shoplift.successRate(player);
|
||||||
|
@ -1170,9 +1170,11 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
commitCrime: (_ctx: NetscriptContext) =>
|
commitCrime: (_ctx: NetscriptContext) =>
|
||||||
function (_crimeRoughName: unknown): number {
|
function (_crimeRoughName: unknown, _focus: unknown = true): number {
|
||||||
_ctx.helper.checkSingularityAccess();
|
_ctx.helper.checkSingularityAccess();
|
||||||
const crimeRoughName = _ctx.helper.string("crimeRoughName", _crimeRoughName);
|
const crimeRoughName = _ctx.helper.string("crimeRoughName", _crimeRoughName);
|
||||||
|
const focus = _ctx.helper.boolean(_focus);
|
||||||
|
const wasFocusing = player.focus;
|
||||||
|
|
||||||
if (player.currentWork !== null) {
|
if (player.currentWork !== null) {
|
||||||
player.finishWork(true);
|
player.finishWork(true);
|
||||||
@ -1187,7 +1189,14 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
|
|||||||
throw _ctx.helper.makeRuntimeErrorMsg(`Invalid crime: '${crimeRoughName}'`);
|
throw _ctx.helper.makeRuntimeErrorMsg(`Invalid crime: '${crimeRoughName}'`);
|
||||||
}
|
}
|
||||||
_ctx.log(() => `Attempting to commit ${crime.name}...`);
|
_ctx.log(() => `Attempting to commit ${crime.name}...`);
|
||||||
return crime.commit(Router, player, 1, workerScript);
|
if (focus) {
|
||||||
|
player.startFocusing();
|
||||||
|
Router.toWork();
|
||||||
|
} else if (wasFocusing) {
|
||||||
|
player.stopFocusing();
|
||||||
|
Router.toTerminal();
|
||||||
|
}
|
||||||
|
return crime.commit(player, 1, workerScript);
|
||||||
},
|
},
|
||||||
getCrimeChance: (_ctx: NetscriptContext) =>
|
getCrimeChance: (_ctx: NetscriptContext) =>
|
||||||
function (_crimeRoughName: unknown): number {
|
function (_crimeRoughName: unknown): number {
|
||||||
|
@ -55,7 +55,7 @@ export namespace Reviver {
|
|||||||
// Returns: The structure (which will then be turned into a string
|
// Returns: The structure (which will then be turned into a string
|
||||||
// as part of the JSON.stringify algorithm)
|
// as part of the JSON.stringify algorithm)
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||||
export function Generic_toJSON(ctorName: string, obj: any, keys?: string[]): IReviverValue {
|
export function Generic_toJSON(ctorName: string, obj: Record<string, any>, keys?: string[]): IReviverValue {
|
||||||
if (!keys) {
|
if (!keys) {
|
||||||
keys = Object.keys(obj); // Only "own" properties are included
|
keys = Object.keys(obj); // Only "own" properties are included
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user