mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-23 08:03:48 +01:00
Add focus parameter to workForCompany/workForFaction
Defaults to true to keep previous behavior.
This commit is contained in:
parent
009bae5870
commit
d873f7279b
@ -819,7 +819,7 @@ export function NetscriptSingularity(
|
|||||||
|
|
||||||
return player.getUpgradeHomeRamCost();
|
return player.getUpgradeHomeRamCost();
|
||||||
},
|
},
|
||||||
workForCompany: function (companyName: any): any {
|
workForCompany: function (companyName: any, focus: boolean = true): any {
|
||||||
helper.updateDynamicRam("workForCompany", getRamCost("workForCompany"));
|
helper.updateDynamicRam("workForCompany", getRamCost("workForCompany"));
|
||||||
helper.checkSingularityAccess("workForCompany", 2);
|
helper.checkSingularityAccess("workForCompany", 2);
|
||||||
|
|
||||||
@ -848,7 +848,6 @@ export function NetscriptSingularity(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const wasWorking = player.isWorking;
|
|
||||||
const wasFocused = player.focus;
|
const wasFocused = player.focus;
|
||||||
if (player.isWorking) {
|
if (player.isWorking) {
|
||||||
const txt = player.singularityStopWork();
|
const txt = player.singularityStopWork();
|
||||||
@ -861,8 +860,14 @@ export function NetscriptSingularity(
|
|||||||
player.startWork(companyName);
|
player.startWork(companyName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wasWorking || (wasWorking && !wasFocused)) player.stopFocusing();
|
if (focus) {
|
||||||
else if (wasWorking && wasFocused) player.startFocusing();
|
player.startFocusing();
|
||||||
|
Router.toWork();
|
||||||
|
}
|
||||||
|
else if (wasFocused) {
|
||||||
|
player.stopFocusing();
|
||||||
|
Router.toTerminal();
|
||||||
|
}
|
||||||
workerScript.log(
|
workerScript.log(
|
||||||
"workForCompany",
|
"workForCompany",
|
||||||
() => `Began working at '${player.companyName}' as a '${companyPositionName}'`,
|
() => `Began working at '${player.companyName}' as a '${companyPositionName}'`,
|
||||||
@ -986,7 +991,7 @@ export function NetscriptSingularity(
|
|||||||
workerScript.log("joinFaction", () => `Joined the '${name}' faction.`);
|
workerScript.log("joinFaction", () => `Joined the '${name}' faction.`);
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
workForFaction: function (name: any, type: any): any {
|
workForFaction: function (name: any, type: any, focus: boolean = true): any {
|
||||||
helper.updateDynamicRam("workForFaction", getRamCost("workForFaction"));
|
helper.updateDynamicRam("workForFaction", getRamCost("workForFaction"));
|
||||||
helper.checkSingularityAccess("workForFaction", 2);
|
helper.checkSingularityAccess("workForFaction", 2);
|
||||||
getFaction("workForFaction", name);
|
getFaction("workForFaction", name);
|
||||||
@ -1002,8 +1007,7 @@ export function NetscriptSingularity(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const wasWorking = player.isWorking;
|
const wasFocusing = player.focus;
|
||||||
const wasFocused = player.focus;
|
|
||||||
if (player.isWorking) {
|
if (player.isWorking) {
|
||||||
const txt = player.singularityStopWork();
|
const txt = player.singularityStopWork();
|
||||||
workerScript.log("workForFaction", () => txt);
|
workerScript.log("workForFaction", () => txt);
|
||||||
@ -1102,8 +1106,14 @@ export function NetscriptSingularity(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
player.startFactionHackWork(fac);
|
player.startFactionHackWork(fac);
|
||||||
if (!wasWorking || (wasWorking && !wasFocused)) player.stopFocusing();
|
if (focus)
|
||||||
else if (wasWorking && wasFocused) player.startFocusing();
|
{
|
||||||
|
player.startFocusing();
|
||||||
|
Router.toWork();
|
||||||
|
} else if (wasFocusing) {
|
||||||
|
player.stopFocusing();
|
||||||
|
Router.toTerminal();
|
||||||
|
}
|
||||||
workerScript.log("workForFaction", () => `Started carrying out hacking contracts for '${fac.name}'`);
|
workerScript.log("workForFaction", () => `Started carrying out hacking contracts for '${fac.name}'`);
|
||||||
return true;
|
return true;
|
||||||
case "field":
|
case "field":
|
||||||
@ -1114,8 +1124,14 @@ export function NetscriptSingularity(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
player.startFactionFieldWork(fac);
|
player.startFactionFieldWork(fac);
|
||||||
if (!wasWorking || (wasWorking && !wasFocused)) player.stopFocusing();
|
if (focus)
|
||||||
else if (wasWorking && wasFocused) player.startFocusing();
|
{
|
||||||
|
player.startFocusing();
|
||||||
|
Router.toWork();
|
||||||
|
} else if (wasFocusing) {
|
||||||
|
player.stopFocusing();
|
||||||
|
Router.toTerminal();
|
||||||
|
}
|
||||||
workerScript.log("workForFaction", () => `Started carrying out field missions for '${fac.name}'`);
|
workerScript.log("workForFaction", () => `Started carrying out field missions for '${fac.name}'`);
|
||||||
return true;
|
return true;
|
||||||
case "security":
|
case "security":
|
||||||
@ -1126,8 +1142,14 @@ export function NetscriptSingularity(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
player.startFactionSecurityWork(fac);
|
player.startFactionSecurityWork(fac);
|
||||||
if (!wasWorking || (wasWorking && !wasFocused)) player.stopFocusing();
|
if (focus)
|
||||||
else if (wasWorking && wasFocused) player.startFocusing();
|
{
|
||||||
|
player.startFocusing();
|
||||||
|
Router.toWork();
|
||||||
|
} else if (wasFocusing) {
|
||||||
|
player.stopFocusing();
|
||||||
|
Router.toTerminal();
|
||||||
|
}
|
||||||
workerScript.log("workForFaction", () => `Started carrying out security work for '${fac.name}'`);
|
workerScript.log("workForFaction", () => `Started carrying out security work for '${fac.name}'`);
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
|
6
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
6
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
@ -1493,9 +1493,10 @@ export interface Singularity {
|
|||||||
* //This way, your company reputation will be updated every minute.
|
* //This way, your company reputation will be updated every minute.
|
||||||
* ```
|
* ```
|
||||||
* @param companyName - Name of company to work for. Must be an exact match. Optional. If not specified, this argument defaults to the last job that you worked
|
* @param companyName - Name of company to work for. Must be an exact match. Optional. If not specified, this argument defaults to the last job that you worked
|
||||||
|
* @param focus - Acquire player focus on this work operation. Optional. Defaults to true.
|
||||||
* @returns True if the player starts working, and false otherwise.
|
* @returns True if the player starts working, and false otherwise.
|
||||||
*/
|
*/
|
||||||
workForCompany(companyName?: string): boolean;
|
workForCompany(companyName?: string, focus?: boolean): boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SF4.2 - Apply for a job at a company.
|
* SF4.2 - Apply for a job at a company.
|
||||||
@ -1612,9 +1613,10 @@ export interface Singularity {
|
|||||||
* ```
|
* ```
|
||||||
* @param faction - Name of faction to work for.
|
* @param faction - Name of faction to work for.
|
||||||
* @param workType - Type of work to perform for the faction.
|
* @param workType - Type of work to perform for the faction.
|
||||||
|
* @param focus - Acquire player focus on this work operation. Optional. Defaults to true.
|
||||||
* @returns True if the player starts working, and false otherwise.
|
* @returns True if the player starts working, and false otherwise.
|
||||||
*/
|
*/
|
||||||
workForFaction(faction: string, workType: string): boolean;
|
workForFaction(faction: string, workType: string, focus?: boolean): boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SF4.2 - Get faction reputation.
|
* SF4.2 - Get faction reputation.
|
||||||
|
Loading…
Reference in New Issue
Block a user