mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-22 15:43:49 +01:00
Work functions do not take focus
setFocus readded and updated to send the user to the Work page if focusing.
This commit is contained in:
parent
e3a0caf50f
commit
ad57f3dc73
@ -82,16 +82,24 @@ function MainPage({ faction, rerender, onAugmentations }: IMainProps): React.Rea
|
|||||||
setGangOpen(true);
|
setGangOpen(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function startWork() {
|
||||||
|
player.startFocusing();
|
||||||
|
router.toWork();
|
||||||
|
}
|
||||||
|
|
||||||
function startFieldWork(faction: Faction): void {
|
function startFieldWork(faction: Faction): void {
|
||||||
player.startFactionFieldWork(router, faction);
|
player.startFactionFieldWork(faction);
|
||||||
|
startWork();
|
||||||
}
|
}
|
||||||
|
|
||||||
function startHackingContracts(faction: Faction): void {
|
function startHackingContracts(faction: Faction): void {
|
||||||
player.startFactionHackWork(router, faction);
|
player.startFactionHackWork(faction);
|
||||||
|
startWork();
|
||||||
}
|
}
|
||||||
|
|
||||||
function startSecurityWork(faction: Faction): void {
|
function startSecurityWork(faction: Faction): void {
|
||||||
player.startFactionSecurityWork(router, faction);
|
player.startFactionSecurityWork(faction);
|
||||||
|
startWork();
|
||||||
}
|
}
|
||||||
|
|
||||||
// We have a special flag for whether the player this faction is the player's
|
// We have a special flag for whether the player this faction is the player's
|
||||||
|
@ -171,10 +171,11 @@ export function CompanyLocation(props: IProps): React.ReactElement {
|
|||||||
const pos = companyPosition;
|
const pos = companyPosition;
|
||||||
if (pos instanceof CompanyPosition) {
|
if (pos instanceof CompanyPosition) {
|
||||||
if (pos.isPartTimeJob() || pos.isSoftwareConsultantJob() || pos.isBusinessConsultantJob()) {
|
if (pos.isPartTimeJob() || pos.isSoftwareConsultantJob() || pos.isBusinessConsultantJob()) {
|
||||||
p.startWorkPartTime(router, props.locName);
|
p.startWorkPartTime(props.locName);
|
||||||
} else {
|
} else {
|
||||||
p.startWork(router, props.locName);
|
p.startWork(props.locName);
|
||||||
}
|
}
|
||||||
|
p.startFocusing();
|
||||||
router.toWork();
|
router.toWork();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -622,6 +622,21 @@ export function NetscriptSingularity(
|
|||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
isFocused: function(): boolean {
|
||||||
|
helper.updateDynamicRam("isFocused", getRamCost("isFocused"));
|
||||||
|
helper.checkSingularityAccess("isFocused", 1);
|
||||||
|
return player.focus;
|
||||||
|
},
|
||||||
|
setFocus: function(focus: boolean): any {
|
||||||
|
helper.updateDynamicRam("setFocus", getRamCost("setFocus"));
|
||||||
|
helper.checkSingularityAccess("setFocus", 1);
|
||||||
|
if (focus === true) {
|
||||||
|
player.startFocusing();
|
||||||
|
Router.toWork();
|
||||||
|
} else if (focus === false) {
|
||||||
|
player.stopFocusing();
|
||||||
|
}
|
||||||
|
},
|
||||||
getStats: function (): any {
|
getStats: function (): any {
|
||||||
helper.updateDynamicRam("getStats", getRamCost("getStats"));
|
helper.updateDynamicRam("getStats", getRamCost("getStats"));
|
||||||
helper.checkSingularityAccess("getStats", 1);
|
helper.checkSingularityAccess("getStats", 1);
|
||||||
@ -820,10 +835,11 @@ export function NetscriptSingularity(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (companyPosition.isPartTimeJob()) {
|
if (companyPosition.isPartTimeJob()) {
|
||||||
player.startWorkPartTime(Router, companyName);
|
player.startWorkPartTime(companyName);
|
||||||
} else {
|
} else {
|
||||||
player.startWork(Router, companyName);
|
player.startWork(companyName);
|
||||||
}
|
}
|
||||||
|
player.stopFocusing();
|
||||||
workerScript.log(
|
workerScript.log(
|
||||||
"workForCompany",
|
"workForCompany",
|
||||||
() => `Began working at '${player.companyName}' as a '${companyPositionName}'`,
|
() => `Began working at '${player.companyName}' as a '${companyPositionName}'`,
|
||||||
@ -1060,7 +1076,8 @@ export function NetscriptSingularity(
|
|||||||
workerScript.log("workForFaction", () => `Faction '${fac.name}' do not need help with hacking contracts.`);
|
workerScript.log("workForFaction", () => `Faction '${fac.name}' do not need help with hacking contracts.`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
player.startFactionHackWork(Router, fac);
|
player.startFactionHackWork(fac);
|
||||||
|
player.stopFocusing();
|
||||||
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":
|
||||||
@ -1070,7 +1087,8 @@ export function NetscriptSingularity(
|
|||||||
workerScript.log("workForFaction", () => `Faction '${fac.name}' do not need help with field missions.`);
|
workerScript.log("workForFaction", () => `Faction '${fac.name}' do not need help with field missions.`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
player.startFactionFieldWork(Router, fac);
|
player.startFactionFieldWork(fac);
|
||||||
|
player.stopFocusing();
|
||||||
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":
|
||||||
@ -1080,7 +1098,8 @@ export function NetscriptSingularity(
|
|||||||
workerScript.log("workForFaction", () => `Faction '${fac.name}' do not need help with security work.`);
|
workerScript.log("workForFaction", () => `Faction '${fac.name}' do not need help with security work.`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
player.startFactionSecurityWork(Router, fac);
|
player.startFactionSecurityWork(fac);
|
||||||
|
player.stopFocusing();
|
||||||
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:
|
||||||
|
@ -211,7 +211,7 @@ export interface IPlayer {
|
|||||||
setMoney(amt: number): void;
|
setMoney(amt: number): void;
|
||||||
singularityStopWork(): string;
|
singularityStopWork(): string;
|
||||||
startBladeburner(p: any): void;
|
startBladeburner(p: any): void;
|
||||||
startFactionWork(router: IRouter, faction: Faction): void;
|
startFactionWork(faction: Faction): void;
|
||||||
startClass(router: IRouter, costMult: number, expMult: number, className: string): void;
|
startClass(router: IRouter, costMult: number, expMult: number, className: string): void;
|
||||||
startCorporation(corpName: string, additionalShares?: number): void;
|
startCorporation(corpName: string, additionalShares?: number): void;
|
||||||
startCrime(
|
startCrime(
|
||||||
@ -227,13 +227,13 @@ export interface IPlayer {
|
|||||||
time: number,
|
time: number,
|
||||||
singParams: any,
|
singParams: any,
|
||||||
): void;
|
): void;
|
||||||
startFactionFieldWork(router: IRouter, faction: Faction): void;
|
startFactionFieldWork(faction: Faction): void;
|
||||||
startFactionHackWork(router: IRouter, faction: Faction): void;
|
startFactionHackWork(faction: Faction): void;
|
||||||
startFactionSecurityWork(router: IRouter, faction: Faction): void;
|
startFactionSecurityWork(faction: Faction): void;
|
||||||
startFocusing(): void;
|
startFocusing(): void;
|
||||||
startGang(facName: string, isHacking: boolean): void;
|
startGang(facName: string, isHacking: boolean): void;
|
||||||
startWork(router: IRouter, companyName: string): void;
|
startWork(companyName: string): void;
|
||||||
startWorkPartTime(router: IRouter, companyName: string): void;
|
startWorkPartTime(companyName: string): void;
|
||||||
takeDamage(amt: number): boolean;
|
takeDamage(amt: number): boolean;
|
||||||
travel(to: CityName): boolean;
|
travel(to: CityName): boolean;
|
||||||
giveExploit(exploit: Exploit): void;
|
giveExploit(exploit: Exploit): void;
|
||||||
|
@ -216,7 +216,7 @@ export class PlayerObject implements IPlayer {
|
|||||||
setMoney: (amt: number) => void;
|
setMoney: (amt: number) => void;
|
||||||
singularityStopWork: () => string;
|
singularityStopWork: () => string;
|
||||||
startBladeburner: (p: any) => void;
|
startBladeburner: (p: any) => void;
|
||||||
startFactionWork: (router: IRouter, faction: Faction) => void;
|
startFactionWork: (faction: Faction) => void;
|
||||||
startClass: (router: IRouter, costMult: number, expMult: number, className: string) => void;
|
startClass: (router: IRouter, costMult: number, expMult: number, className: string) => void;
|
||||||
startCorporation: (corpName: string, additionalShares?: number) => void;
|
startCorporation: (corpName: string, additionalShares?: number) => void;
|
||||||
startCrime: (
|
startCrime: (
|
||||||
@ -232,13 +232,13 @@ export class PlayerObject implements IPlayer {
|
|||||||
time: number,
|
time: number,
|
||||||
singParams: any,
|
singParams: any,
|
||||||
) => void;
|
) => void;
|
||||||
startFactionFieldWork: (router: IRouter, faction: Faction) => void;
|
startFactionFieldWork: (faction: Faction) => void;
|
||||||
startFactionHackWork: (router: IRouter, faction: Faction) => void;
|
startFactionHackWork: (faction: Faction) => void;
|
||||||
startFactionSecurityWork: (router: IRouter, faction: Faction) => void;
|
startFactionSecurityWork: (faction: Faction) => void;
|
||||||
startFocusing: () => void;
|
startFocusing: () => void;
|
||||||
startGang: (facName: string, isHacking: boolean) => void;
|
startGang: (facName: string, isHacking: boolean) => void;
|
||||||
startWork: (router: IRouter, companyName: string) => void;
|
startWork: (companyName: string) => void;
|
||||||
startWorkPartTime: (router: IRouter, companyName: string) => void;
|
startWorkPartTime: (companyName: string) => void;
|
||||||
takeDamage: (amt: number) => boolean;
|
takeDamage: (amt: number) => boolean;
|
||||||
travel: (to: CityName) => boolean;
|
travel: (to: CityName) => boolean;
|
||||||
giveExploit: (exploit: Exploit) => void;
|
giveExploit: (exploit: Exploit) => void;
|
||||||
|
@ -554,10 +554,9 @@ export function processWorkEarnings(this: IPlayer, numCycles = 1): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Working for Company */
|
/* Working for Company */
|
||||||
export function startWork(this: IPlayer, router: IRouter, companyName: string): void {
|
export function startWork(this: IPlayer, companyName: string): void {
|
||||||
this.resetWorkStatus(CONSTANTS.WorkTypeCompany, companyName);
|
this.resetWorkStatus(CONSTANTS.WorkTypeCompany, companyName);
|
||||||
this.isWorking = true;
|
this.isWorking = true;
|
||||||
this.focus = true;
|
|
||||||
this.companyName = companyName;
|
this.companyName = companyName;
|
||||||
this.workType = CONSTANTS.WorkTypeCompany;
|
this.workType = CONSTANTS.WorkTypeCompany;
|
||||||
|
|
||||||
@ -571,7 +570,6 @@ export function startWork(this: IPlayer, router: IRouter, companyName: string):
|
|||||||
this.workMoneyGainRate = this.getWorkMoneyGain();
|
this.workMoneyGainRate = this.getWorkMoneyGain();
|
||||||
|
|
||||||
this.timeNeededToCompleteWork = CONSTANTS.MillisecondsPer8Hours;
|
this.timeNeededToCompleteWork = CONSTANTS.MillisecondsPer8Hours;
|
||||||
router.toWork();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function process(this: IPlayer, router: IRouter, numCycles = 1): void {
|
export function process(this: IPlayer, router: IRouter, numCycles = 1): void {
|
||||||
@ -723,10 +721,9 @@ export function finishWork(this: IPlayer, cancelled: boolean, sing = false): str
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
export function startWorkPartTime(this: IPlayer, router: IRouter, companyName: string): void {
|
export function startWorkPartTime(this: IPlayer, companyName: string): void {
|
||||||
this.resetWorkStatus(CONSTANTS.WorkTypeCompanyPartTime, companyName);
|
this.resetWorkStatus(CONSTANTS.WorkTypeCompanyPartTime, companyName);
|
||||||
this.isWorking = true;
|
this.isWorking = true;
|
||||||
this.focus = true;
|
|
||||||
this.companyName = companyName;
|
this.companyName = companyName;
|
||||||
this.workType = CONSTANTS.WorkTypeCompanyPartTime;
|
this.workType = CONSTANTS.WorkTypeCompanyPartTime;
|
||||||
|
|
||||||
@ -740,7 +737,6 @@ export function startWorkPartTime(this: IPlayer, router: IRouter, companyName: s
|
|||||||
this.workMoneyGainRate = this.getWorkMoneyGain();
|
this.workMoneyGainRate = this.getWorkMoneyGain();
|
||||||
|
|
||||||
this.timeNeededToCompleteWork = CONSTANTS.MillisecondsPer8Hours;
|
this.timeNeededToCompleteWork = CONSTANTS.MillisecondsPer8Hours;
|
||||||
router.toWork();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function workPartTime(this: IPlayer, numCycles: number): boolean {
|
export function workPartTime(this: IPlayer, numCycles: number): boolean {
|
||||||
@ -832,7 +828,7 @@ export function stopFocusing(this: IPlayer): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Working for Faction */
|
/* Working for Faction */
|
||||||
export function startFactionWork(this: IPlayer, router: IRouter, faction: Faction): void {
|
export function startFactionWork(this: IPlayer, faction: Faction): void {
|
||||||
//Update reputation gain rate to account for faction favor
|
//Update reputation gain rate to account for faction favor
|
||||||
let favorMult = 1 + faction.favor / 100;
|
let favorMult = 1 + faction.favor / 100;
|
||||||
if (isNaN(favorMult)) {
|
if (isNaN(favorMult)) {
|
||||||
@ -842,15 +838,13 @@ export function startFactionWork(this: IPlayer, router: IRouter, faction: Factio
|
|||||||
this.workRepGainRate *= BitNodeMultipliers.FactionWorkRepGain;
|
this.workRepGainRate *= BitNodeMultipliers.FactionWorkRepGain;
|
||||||
|
|
||||||
this.isWorking = true;
|
this.isWorking = true;
|
||||||
this.focus = true;
|
|
||||||
this.workType = CONSTANTS.WorkTypeFaction;
|
this.workType = CONSTANTS.WorkTypeFaction;
|
||||||
this.currentWorkFactionName = faction.name;
|
this.currentWorkFactionName = faction.name;
|
||||||
|
|
||||||
this.timeNeededToCompleteWork = CONSTANTS.MillisecondsPer20Hours;
|
this.timeNeededToCompleteWork = CONSTANTS.MillisecondsPer20Hours;
|
||||||
router.toWork();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function startFactionHackWork(this: IPlayer, router: IRouter, faction: Faction): void {
|
export function startFactionHackWork(this: IPlayer, faction: Faction): void {
|
||||||
this.resetWorkStatus(CONSTANTS.WorkTypeFaction, faction.name, CONSTANTS.FactionWorkHacking);
|
this.resetWorkStatus(CONSTANTS.WorkTypeFaction, faction.name, CONSTANTS.FactionWorkHacking);
|
||||||
|
|
||||||
this.workHackExpGainRate = 0.15 * this.hacking_exp_mult * BitNodeMultipliers.FactionWorkExpGain;
|
this.workHackExpGainRate = 0.15 * this.hacking_exp_mult * BitNodeMultipliers.FactionWorkExpGain;
|
||||||
@ -859,10 +853,10 @@ export function startFactionHackWork(this: IPlayer, router: IRouter, faction: Fa
|
|||||||
this.factionWorkType = CONSTANTS.FactionWorkHacking;
|
this.factionWorkType = CONSTANTS.FactionWorkHacking;
|
||||||
this.currentWorkFactionDescription = "carrying out hacking contracts";
|
this.currentWorkFactionDescription = "carrying out hacking contracts";
|
||||||
|
|
||||||
this.startFactionWork(router, faction);
|
this.startFactionWork(faction);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function startFactionFieldWork(this: IPlayer, router: IRouter, faction: Faction): void {
|
export function startFactionFieldWork(this: IPlayer, faction: Faction): void {
|
||||||
this.resetWorkStatus(CONSTANTS.WorkTypeFaction, faction.name, CONSTANTS.FactionWorkField);
|
this.resetWorkStatus(CONSTANTS.WorkTypeFaction, faction.name, CONSTANTS.FactionWorkField);
|
||||||
|
|
||||||
this.workHackExpGainRate = 0.1 * this.hacking_exp_mult * BitNodeMultipliers.FactionWorkExpGain;
|
this.workHackExpGainRate = 0.1 * this.hacking_exp_mult * BitNodeMultipliers.FactionWorkExpGain;
|
||||||
@ -876,10 +870,10 @@ export function startFactionFieldWork(this: IPlayer, router: IRouter, faction: F
|
|||||||
this.factionWorkType = CONSTANTS.FactionWorkField;
|
this.factionWorkType = CONSTANTS.FactionWorkField;
|
||||||
this.currentWorkFactionDescription = "carrying out field missions";
|
this.currentWorkFactionDescription = "carrying out field missions";
|
||||||
|
|
||||||
this.startFactionWork(router, faction);
|
this.startFactionWork(faction);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function startFactionSecurityWork(this: IPlayer, router: IRouter, faction: Faction): void {
|
export function startFactionSecurityWork(this: IPlayer, faction: Faction): void {
|
||||||
this.resetWorkStatus(CONSTANTS.WorkTypeFaction, faction.name, CONSTANTS.FactionWorkSecurity);
|
this.resetWorkStatus(CONSTANTS.WorkTypeFaction, faction.name, CONSTANTS.FactionWorkSecurity);
|
||||||
|
|
||||||
this.workHackExpGainRate = 0.05 * this.hacking_exp_mult * BitNodeMultipliers.FactionWorkExpGain;
|
this.workHackExpGainRate = 0.05 * this.hacking_exp_mult * BitNodeMultipliers.FactionWorkExpGain;
|
||||||
@ -893,7 +887,7 @@ export function startFactionSecurityWork(this: IPlayer, router: IRouter, faction
|
|||||||
this.factionWorkType = CONSTANTS.FactionWorkSecurity;
|
this.factionWorkType = CONSTANTS.FactionWorkSecurity;
|
||||||
this.currentWorkFactionDescription = "performing security detail";
|
this.currentWorkFactionDescription = "performing security detail";
|
||||||
|
|
||||||
this.startFactionWork(router, faction);
|
this.startFactionWork(faction);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function workForFaction(this: IPlayer, numCycles: number): boolean {
|
export function workForFaction(this: IPlayer, numCycles: number): boolean {
|
||||||
|
18
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
18
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
@ -1985,6 +1985,24 @@ export interface Singularity {
|
|||||||
* @returns True if the installation was successful.
|
* @returns True if the installation was successful.
|
||||||
*/
|
*/
|
||||||
installBackdoor(): Promise<void>;
|
installBackdoor(): Promise<void>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SF4.2 - Check if the player is focused.
|
||||||
|
* @remarks
|
||||||
|
* RAM cost: 0.1 GB
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @returns True if the player is focused.
|
||||||
|
*/
|
||||||
|
isFocused(): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SF4.2 - Set the players focus.
|
||||||
|
* @remarks
|
||||||
|
* RAM cost: 0.1 GB
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
setFocus(focus: boolean): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user