mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-22 17:23:00 +02:00
refactor some stuff
This commit is contained in:
@@ -155,7 +155,7 @@ export const GraftingRoot = (): React.ReactElement => {
|
||||
open={graftOpen}
|
||||
onClose={() => setGraftOpen(false)}
|
||||
onConfirm={() => {
|
||||
player.startNEWWork(
|
||||
player.startWork(
|
||||
new GraftingWork({
|
||||
augmentation: selectedAug,
|
||||
singularity: false,
|
||||
|
||||
@@ -25,12 +25,10 @@ import { ICorporation } from "../Corporation/ICorporation";
|
||||
import { IGang } from "../Gang/IGang";
|
||||
import { IBladeburner } from "../Bladeburner/IBladeburner";
|
||||
import { ICodingContractReward } from "../CodingContracts";
|
||||
import { IRouter } from "../ui/Router";
|
||||
import { HacknetServer } from "../Hacknet/HacknetServer";
|
||||
import { ISkillProgress } from "./formulas/skill";
|
||||
import { PlayerAchievement } from "../Achievements/Achievements";
|
||||
import { IPerson } from "./IPerson";
|
||||
import { WorkType } from "../utils/WorkType";
|
||||
import { Work } from "src/Work/Work";
|
||||
|
||||
export interface IPlayer extends IPerson {
|
||||
@@ -51,7 +49,6 @@ export interface IPlayer extends IPerson {
|
||||
hasWseAccount: boolean;
|
||||
hp: number;
|
||||
jobs: IMap<string>;
|
||||
init: () => void;
|
||||
karma: number;
|
||||
numPeopleKilled: number;
|
||||
location: LocationName;
|
||||
@@ -129,9 +126,10 @@ export interface IPlayer extends IPerson {
|
||||
entropy: number;
|
||||
|
||||
// Methods
|
||||
startNEWWork(w: Work): void;
|
||||
processNEWWork(cycles: number): void;
|
||||
finishNEWWork(cancelled: boolean): void;
|
||||
init: () => void;
|
||||
startWork(w: Work): void;
|
||||
processWork(cycles: number): void;
|
||||
finishWork(cancelled: boolean): void;
|
||||
applyForAgentJob(sing?: boolean): boolean;
|
||||
applyForBusinessConsultantJob(sing?: boolean): boolean;
|
||||
applyForBusinessJob(sing?: boolean): boolean;
|
||||
@@ -201,4 +199,5 @@ export interface IPlayer extends IPerson {
|
||||
canAccessCotMG(): boolean;
|
||||
sourceFileLvl(n: number): number;
|
||||
applyEntropy(stacks?: number): void;
|
||||
focusPenalty(): number;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
export interface Multipliers {
|
||||
hacking_chance: number;
|
||||
hacking_speed: number;
|
||||
hacking_money: number;
|
||||
hacking_grow: number;
|
||||
hacking: number;
|
||||
hacking_exp: number;
|
||||
strength: number;
|
||||
strength_exp: number;
|
||||
defense: number;
|
||||
defense_exp: number;
|
||||
dexterity: number;
|
||||
dexterity_exp: number;
|
||||
agility: number;
|
||||
agility_exp: number;
|
||||
charisma: number;
|
||||
charisma_exp: number;
|
||||
hacknet_node_money: number;
|
||||
hacknet_node_purchase_cost: number;
|
||||
hacknet_node_ram_cost: number;
|
||||
hacknet_node_core_cost: number;
|
||||
hacknet_node_level_cost: number;
|
||||
company_rep: number;
|
||||
faction_rep: number;
|
||||
work_money: number;
|
||||
crime_success: number;
|
||||
crime_money: number;
|
||||
bladeburner_max_stamina: number;
|
||||
bladeburner_stamina_gain: number;
|
||||
bladeburner_analysis: number;
|
||||
bladeburner_success_chance: number;
|
||||
}
|
||||
|
||||
export const defaultMultipliers = (): Multipliers => {
|
||||
return {
|
||||
hacking_chance: 1,
|
||||
hacking_speed: 1,
|
||||
hacking_money: 1,
|
||||
hacking_grow: 1,
|
||||
hacking: 1,
|
||||
hacking_exp: 1,
|
||||
strength: 1,
|
||||
strength_exp: 1,
|
||||
defense: 1,
|
||||
defense_exp: 1,
|
||||
dexterity: 1,
|
||||
dexterity_exp: 1,
|
||||
agility: 1,
|
||||
agility_exp: 1,
|
||||
charisma: 1,
|
||||
charisma_exp: 1,
|
||||
hacknet_node_money: 1,
|
||||
hacknet_node_purchase_cost: 1,
|
||||
hacknet_node_ram_cost: 1,
|
||||
hacknet_node_core_cost: 1,
|
||||
hacknet_node_level_cost: 1,
|
||||
company_rep: 1,
|
||||
faction_rep: 1,
|
||||
work_money: 1,
|
||||
crime_success: 1,
|
||||
crime_money: 1,
|
||||
bladeburner_max_stamina: 1,
|
||||
bladeburner_stamina_gain: 1,
|
||||
bladeburner_analysis: 1,
|
||||
bladeburner_success_chance: 1,
|
||||
};
|
||||
};
|
||||
@@ -140,9 +140,9 @@ export class PlayerObject implements IPlayer {
|
||||
entropy: number;
|
||||
|
||||
// Methods
|
||||
startNEWWork: (w: Work) => void;
|
||||
processNEWWork: (cycles: number) => void;
|
||||
finishNEWWork: (cancelled: boolean) => void;
|
||||
startWork: (w: Work) => void;
|
||||
processWork: (cycles: number) => void;
|
||||
finishWork: (cancelled: boolean) => void;
|
||||
applyForAgentJob: (sing?: boolean) => boolean;
|
||||
applyForBusinessConsultantJob: (sing?: boolean) => boolean;
|
||||
applyForBusinessJob: (sing?: boolean) => boolean;
|
||||
@@ -226,6 +226,7 @@ export class PlayerObject implements IPlayer {
|
||||
canAccessCotMG: () => boolean;
|
||||
sourceFileLvl: (n: number) => number;
|
||||
applyEntropy: (stacks?: number) => void;
|
||||
focusPenalty: () => number;
|
||||
|
||||
constructor() {
|
||||
//Skills and stats
|
||||
@@ -409,9 +410,9 @@ export class PlayerObject implements IPlayer {
|
||||
this.gainIntelligenceExp = generalMethods.gainIntelligenceExp;
|
||||
this.gainStats = generalMethods.gainStats;
|
||||
this.queryStatFromString = generalMethods.queryStatFromString;
|
||||
this.startNEWWork = workMethods.start;
|
||||
this.processNEWWork = workMethods.process;
|
||||
this.finishNEWWork = workMethods.finish;
|
||||
this.startWork = workMethods.start;
|
||||
this.processWork = workMethods.process;
|
||||
this.finishWork = workMethods.finish;
|
||||
this.startFocusing = generalMethods.startFocusing;
|
||||
this.stopFocusing = generalMethods.stopFocusing;
|
||||
this.takeDamage = generalMethods.takeDamage;
|
||||
@@ -477,6 +478,7 @@ export class PlayerObject implements IPlayer {
|
||||
this.sourceFileLvl = generalMethods.sourceFileLvl;
|
||||
|
||||
this.applyEntropy = augmentationMethods.applyEntropy;
|
||||
this.focusPenalty = generalMethods.focusPenalty;
|
||||
}
|
||||
|
||||
whoAmI(): string {
|
||||
|
||||
+9
-10
@@ -37,21 +37,13 @@ import { SpecialServers } from "../../Server/data/SpecialServers";
|
||||
import { applySourceFile } from "../../SourceFile/applySourceFile";
|
||||
import { applyExploit } from "../../Exploits/applyExploits";
|
||||
import { SourceFiles } from "../../SourceFile/SourceFiles";
|
||||
import { influenceStockThroughCompanyWork } from "../../StockMarket/PlayerInfluencing";
|
||||
import { getHospitalizationCost } from "../../Hospital/Hospital";
|
||||
import { HacknetServer } from "../../Hacknet/HacknetServer";
|
||||
|
||||
import { numeralWrapper } from "../../ui/numeralFormat";
|
||||
import { IRouter } from "../../ui/Router";
|
||||
import { MoneySourceTracker } from "../../utils/MoneySourceTracker";
|
||||
import { dialogBoxCreate } from "../../ui/React/DialogBox";
|
||||
import { convertTimeMsToTimeElapsedString } from "../../utils/StringHelperFunctions";
|
||||
|
||||
import { Reputation } from "../../ui/React/Reputation";
|
||||
import { Money } from "../../ui/React/Money";
|
||||
|
||||
import React from "react";
|
||||
import { serverMetadata } from "../../Server/data/servers";
|
||||
import { SnackbarEvents, ToastVariant } from "../../ui/React/Snackbar";
|
||||
import { achievements } from "../../Achievements/Achievements";
|
||||
import { FactionNames } from "../../Faction/data/FactionNames";
|
||||
@@ -59,7 +51,6 @@ import { ITaskTracker } from "../ITaskTracker";
|
||||
import { IPerson } from "../IPerson";
|
||||
import { Player } from "../../Player";
|
||||
|
||||
import { WorkType } from "../../utils/WorkType";
|
||||
import { isCompanyWork } from "../../Work/CompanyWork";
|
||||
|
||||
export function init(this: IPlayer): void {
|
||||
@@ -617,7 +608,7 @@ export function getNextCompanyPosition(
|
||||
|
||||
export function quitJob(this: IPlayer, company: string, _sing = false): void {
|
||||
if (isCompanyWork(this.currentWork) && this.currentWork.companyName === company) {
|
||||
this.finishNEWWork(true);
|
||||
this.finishWork(true);
|
||||
}
|
||||
delete this.jobs[company];
|
||||
if (this.companyName === company) {
|
||||
@@ -1487,3 +1478,11 @@ export function sourceFileLvl(this: IPlayer, n: number): number {
|
||||
if (!sf) return 0;
|
||||
return sf.lvl;
|
||||
}
|
||||
|
||||
export function focusPenalty(this: IPlayer): number {
|
||||
let focus = 1;
|
||||
if (!this.hasAugmentation(AugmentationNames["NeuroreceptorManager"])) {
|
||||
focus = this.focus ? 1 : CONSTANTS.BaseFocusBonus;
|
||||
}
|
||||
return focus;
|
||||
}
|
||||
@@ -11,7 +11,7 @@ export function process(this: IPlayer, cycles = 1): void {
|
||||
if (this.currentWork === null) return;
|
||||
const finished = this.currentWork.process(this, cycles);
|
||||
if (finished) {
|
||||
this.finishNEWWork(false);
|
||||
this.finishWork(false);
|
||||
}
|
||||
}
|
||||
export function finish(this: IPlayer, cancelled: boolean): void {
|
||||
|
||||
Reference in New Issue
Block a user