mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-23 16:13:49 +01:00
fix error message with wrong reviver, refactor part of player
This commit is contained in:
parent
56c8a23631
commit
78d9c25671
@ -137,6 +137,7 @@ import { IIndustry } from "./Corporation/IIndustry";
|
|||||||
|
|
||||||
import { Faction } from "./Faction/Faction";
|
import { Faction } from "./Faction/Faction";
|
||||||
import { Augmentation } from "./Augmentation/Augmentation";
|
import { Augmentation } from "./Augmentation/Augmentation";
|
||||||
|
import { Page } from "./ui/Router";
|
||||||
|
|
||||||
import { CodingContract } from "./CodingContracts";
|
import { CodingContract } from "./CodingContracts";
|
||||||
import { Stock } from "./StockMarket/Stock";
|
import { Stock } from "./StockMarket/Stock";
|
||||||
@ -3244,12 +3245,16 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
hospitalize: function (): any {
|
hospitalize: function (): any {
|
||||||
updateDynamicRam("hospitalize", getRamCost("hospitalize"));
|
updateDynamicRam("hospitalize", getRamCost("hospitalize"));
|
||||||
checkSingularityAccess("hospitalize", 1);
|
checkSingularityAccess("hospitalize", 1);
|
||||||
|
if (Player.isWorking || Router.page() === Page.Infiltration || Router.page() === Page.BitVerse) {
|
||||||
|
workerScript.log("hospitalize", "Cannot go to the hospital because the player is busy.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
return Player.hospitalize();
|
return Player.hospitalize();
|
||||||
},
|
},
|
||||||
isBusy: function (): any {
|
isBusy: function (): any {
|
||||||
updateDynamicRam("isBusy", getRamCost("isBusy"));
|
updateDynamicRam("isBusy", getRamCost("isBusy"));
|
||||||
checkSingularityAccess("isBusy", 1);
|
checkSingularityAccess("isBusy", 1);
|
||||||
return Player.isWorking;
|
return Player.isWorking || Router.page() === Page.Infiltration || Router.page() === Page.BitVerse;
|
||||||
},
|
},
|
||||||
stopAction: function (): any {
|
stopAction: function (): any {
|
||||||
updateDynamicRam("stopAction", getRamCost("stopAction"));
|
updateDynamicRam("stopAction", getRamCost("stopAction"));
|
||||||
|
@ -201,6 +201,7 @@ export interface IPlayer {
|
|||||||
inGang(): boolean;
|
inGang(): boolean;
|
||||||
isQualified(company: Company, position: CompanyPosition): boolean;
|
isQualified(company: Company, position: CompanyPosition): boolean;
|
||||||
loseMoney(money: number): void;
|
loseMoney(money: number): void;
|
||||||
|
process(router: IRouter, numCycles?: number): void;
|
||||||
reapplyAllAugmentations(resetMultipliers?: boolean): void;
|
reapplyAllAugmentations(resetMultipliers?: boolean): void;
|
||||||
reapplyAllSourceFiles(): void;
|
reapplyAllSourceFiles(): void;
|
||||||
regenerateHp(amt: number): void;
|
regenerateHp(amt: number): void;
|
||||||
|
@ -245,6 +245,7 @@ export class PlayerObject implements IPlayer {
|
|||||||
getIntelligenceBonus: (weight: number) => number;
|
getIntelligenceBonus: (weight: number) => number;
|
||||||
getCasinoWinnings: () => number;
|
getCasinoWinnings: () => number;
|
||||||
quitJob: (company: string) => void;
|
quitJob: (company: string) => void;
|
||||||
|
process: (router: IRouter, numCycles?: number) => void;
|
||||||
createHacknetServer: () => HacknetServer;
|
createHacknetServer: () => HacknetServer;
|
||||||
startCreateProgramWork: (router: IRouter, programName: string, time: number, reqLevel: number) => void;
|
startCreateProgramWork: (router: IRouter, programName: string, time: number, reqLevel: number) => void;
|
||||||
queueAugmentation: (augmentationName: string) => void;
|
queueAugmentation: (augmentationName: string) => void;
|
||||||
@ -505,6 +506,7 @@ export class PlayerObject implements IPlayer {
|
|||||||
this.getWorkAgiExpGain = generalMethods.getWorkAgiExpGain;
|
this.getWorkAgiExpGain = generalMethods.getWorkAgiExpGain;
|
||||||
this.getWorkChaExpGain = generalMethods.getWorkChaExpGain;
|
this.getWorkChaExpGain = generalMethods.getWorkChaExpGain;
|
||||||
this.getWorkRepGain = generalMethods.getWorkRepGain;
|
this.getWorkRepGain = generalMethods.getWorkRepGain;
|
||||||
|
this.process = generalMethods.process;
|
||||||
this.startCreateProgramWork = generalMethods.startCreateProgramWork;
|
this.startCreateProgramWork = generalMethods.startCreateProgramWork;
|
||||||
this.createProgramWork = generalMethods.createProgramWork;
|
this.createProgramWork = generalMethods.createProgramWork;
|
||||||
this.finishCreateProgramWork = generalMethods.finishCreateProgramWork;
|
this.finishCreateProgramWork = generalMethods.finishCreateProgramWork;
|
||||||
|
@ -575,6 +575,37 @@ export function startWork(this: IPlayer, router: IRouter, companyName: string):
|
|||||||
router.toWork();
|
router.toWork();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function process(this: IPlayer, router: IRouter, numCycles = 1): void {
|
||||||
|
// Working
|
||||||
|
if (this.isWorking) {
|
||||||
|
if (this.workType == CONSTANTS.WorkTypeFaction) {
|
||||||
|
if (this.workForFaction(numCycles)) {
|
||||||
|
router.toFaction();
|
||||||
|
}
|
||||||
|
} else if (this.workType == CONSTANTS.WorkTypeCreateProgram) {
|
||||||
|
if (this.createProgramWork(numCycles)) {
|
||||||
|
router.toTerminal();
|
||||||
|
}
|
||||||
|
} else if (this.workType == CONSTANTS.WorkTypeStudyClass) {
|
||||||
|
if (this.takeClass(numCycles)) {
|
||||||
|
router.toCity();
|
||||||
|
}
|
||||||
|
} else if (this.workType == CONSTANTS.WorkTypeCrime) {
|
||||||
|
if (this.commitCrime(numCycles)) {
|
||||||
|
router.toLocation(Locations[LocationName.Slums]);
|
||||||
|
}
|
||||||
|
} else if (this.workType == CONSTANTS.WorkTypeCompanyPartTime) {
|
||||||
|
if (this.workPartTime(numCycles)) {
|
||||||
|
router.toCity();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (this.work(numCycles)) {
|
||||||
|
router.toCity();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function cancelationPenalty(this: IPlayer): number {
|
export function cancelationPenalty(this: IPlayer): number {
|
||||||
const server = GetServer(this.companyName);
|
const server = GetServer(this.companyName);
|
||||||
if (server instanceof Server) {
|
if (server instanceof Server) {
|
||||||
|
@ -29,4 +29,5 @@ export function loadPlayer(saveString: string): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Player.exploits = sanitizeExploits(Player.exploits);
|
Player.exploits = sanitizeExploits(Player.exploits);
|
||||||
|
console.log(Player.bladeburner);
|
||||||
}
|
}
|
||||||
|
@ -91,34 +91,7 @@ const Engine: {
|
|||||||
|
|
||||||
Terminal.process(Router, Player, numCycles);
|
Terminal.process(Router, Player, numCycles);
|
||||||
|
|
||||||
// Working
|
Player.process(Router, numCycles);
|
||||||
if (Player.isWorking) {
|
|
||||||
if (Player.workType == CONSTANTS.WorkTypeFaction) {
|
|
||||||
if (Player.workForFaction(numCycles)) {
|
|
||||||
Router.toFaction();
|
|
||||||
}
|
|
||||||
} else if (Player.workType == CONSTANTS.WorkTypeCreateProgram) {
|
|
||||||
if (Player.createProgramWork(numCycles)) {
|
|
||||||
Router.toTerminal();
|
|
||||||
}
|
|
||||||
} else if (Player.workType == CONSTANTS.WorkTypeStudyClass) {
|
|
||||||
if (Player.takeClass(numCycles)) {
|
|
||||||
Router.toCity();
|
|
||||||
}
|
|
||||||
} else if (Player.workType == CONSTANTS.WorkTypeCrime) {
|
|
||||||
if (Player.commitCrime(numCycles)) {
|
|
||||||
Router.toLocation(Locations[LocationName.Slums]);
|
|
||||||
}
|
|
||||||
} else if (Player.workType == CONSTANTS.WorkTypeCompanyPartTime) {
|
|
||||||
if (Player.workPartTime(numCycles)) {
|
|
||||||
Router.toCity();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (Player.work(numCycles)) {
|
|
||||||
Router.toCity();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update stock prices
|
// Update stock prices
|
||||||
if (Player.hasWseAccount) {
|
if (Player.hasWseAccount) {
|
||||||
|
@ -12,8 +12,7 @@ export interface IReviverValue {
|
|||||||
// off to that `fromJSON` fuunction, passing in the value.
|
// off to that `fromJSON` fuunction, passing in the value.
|
||||||
export function Reviver(key: string, value: IReviverValue | null): any {
|
export function Reviver(key: string, value: IReviverValue | null): any {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
console.log("Reviver WRONGLY called with key: " + key + ", and value: " + value);
|
return null;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof value === "object" && typeof value.ctor === "string" && typeof value.data !== "undefined") {
|
if (typeof value === "object" && typeof value.ctor === "string" && typeof value.data !== "undefined") {
|
||||||
|
Loading…
Reference in New Issue
Block a user