mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-20 16:22:56 +02:00
work on sleeve new work system
This commit is contained in:
@@ -147,13 +147,13 @@ export class ClassWork extends Work {
|
||||
}
|
||||
|
||||
calculateRates(player: IPlayer): WorkStats {
|
||||
return calculateClassEarningsRate(player, this);
|
||||
return calculateClassEarningsRate(player, player, this.classType, this.location);
|
||||
}
|
||||
|
||||
process(player: IPlayer, cycles: number): boolean {
|
||||
this.cyclesWorked += cycles;
|
||||
const rate = this.calculateRates(player);
|
||||
const earnings = applyWorkStats(player, rate, cycles, "class");
|
||||
const earnings = applyWorkStats(player, player, rate, cycles, "class");
|
||||
this.earnings = sumWorkStats(this.earnings, earnings);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ import { applyWorkStats, WorkStats } from "./WorkStats";
|
||||
import { Company } from "../Company/Company";
|
||||
import { dialogBoxCreate } from "../ui/React/DialogBox";
|
||||
import { Reputation } from "../ui/React/Reputation";
|
||||
import { AugmentationNames } from "../Augmentation/data/AugmentationNames";
|
||||
import { CONSTANTS } from "../Constants";
|
||||
|
||||
interface CompanyWorkParams {
|
||||
companyName: string;
|
||||
@@ -32,14 +34,18 @@ export class CompanyWork extends Work {
|
||||
}
|
||||
|
||||
getGainRates(player: IPlayer): WorkStats {
|
||||
return calculateCompanyWorkStats(player, this.getCompany());
|
||||
let focusBonus = 1;
|
||||
if (!player.hasAugmentation(AugmentationNames.NeuroreceptorManager)) {
|
||||
focusBonus = player.focus ? 1 : CONSTANTS.BaseFocusBonus;
|
||||
}
|
||||
return calculateCompanyWorkStats(player, player, this.getCompany());
|
||||
}
|
||||
|
||||
process(player: IPlayer, cycles: number): boolean {
|
||||
this.cyclesWorked += cycles;
|
||||
const company = this.getCompany();
|
||||
const gains = this.getGainRates(player);
|
||||
applyWorkStats(player, gains, cycles, "work");
|
||||
applyWorkStats(player, player, gains, cycles, "work");
|
||||
company.playerReputation += gains.reputation * cycles;
|
||||
influenceStockThroughCompanyWork(company, gains.reputation, cycles);
|
||||
return false;
|
||||
|
||||
@@ -5,7 +5,7 @@ import { IPlayer } from "../PersonObjects/IPlayer";
|
||||
import { FactionNames } from "../Faction/data/FactionNames";
|
||||
import { Factions } from "../Faction/Factions";
|
||||
import { Faction } from "../Faction/Faction";
|
||||
import { applyWorkStats, WorkStats } from "./WorkStats";
|
||||
import { applyWorkStats, scaleWorkStats, WorkStats } from "./WorkStats";
|
||||
import { dialogBoxCreate } from "../ui/React/DialogBox";
|
||||
import { Reputation } from "../ui/React/Reputation";
|
||||
import {
|
||||
@@ -58,7 +58,12 @@ export class FactionWork extends Work {
|
||||
}
|
||||
|
||||
getExpRates(player: IPlayer): WorkStats {
|
||||
return calculateFactionExp(player, this.factionWorkType);
|
||||
let focusBonus = 1;
|
||||
if (!player.hasAugmentation(AugmentationNames.NeuroreceptorManager)) {
|
||||
focusBonus = player.focus ? 1 : CONSTANTS.BaseFocusBonus;
|
||||
}
|
||||
const rate = calculateFactionExp(player, this.factionWorkType);
|
||||
return scaleWorkStats(rate, focusBonus, false);
|
||||
}
|
||||
|
||||
process(player: IPlayer, cycles: number): boolean {
|
||||
@@ -66,7 +71,7 @@ export class FactionWork extends Work {
|
||||
this.getFaction().playerReputation += this.getReputationRate(player) * cycles;
|
||||
|
||||
const rate = this.getExpRates(player);
|
||||
applyWorkStats(player, rate, cycles, "class");
|
||||
applyWorkStats(player, player, rate, cycles, "class");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
+36
-11
@@ -1,3 +1,4 @@
|
||||
import { IPerson } from "src/PersonObjects/IPerson";
|
||||
import { IPlayer } from "../PersonObjects/IPlayer";
|
||||
|
||||
export interface WorkStats {
|
||||
@@ -52,9 +53,10 @@ export const sumWorkStats = (w0: WorkStats, w1: WorkStats): WorkStats => {
|
||||
};
|
||||
};
|
||||
|
||||
export const scaleWorkStats = (w: WorkStats, n: number): WorkStats => {
|
||||
export const scaleWorkStats = (w: WorkStats, n: number, scaleMoney = true): WorkStats => {
|
||||
const m = scaleMoney ? n : 1;
|
||||
return {
|
||||
money: w.money * n,
|
||||
money: w.money * m,
|
||||
reputation: w.reputation * n,
|
||||
hackExp: w.hackExp * n,
|
||||
strExp: w.strExp * n,
|
||||
@@ -66,10 +68,34 @@ export const scaleWorkStats = (w: WorkStats, n: number): WorkStats => {
|
||||
};
|
||||
};
|
||||
|
||||
export const applyWorkStats = (player: IPlayer, workStats: WorkStats, cycles: number, source: string): WorkStats => {
|
||||
export const applyWorkStats = (
|
||||
player: IPlayer,
|
||||
target: IPerson,
|
||||
workStats: WorkStats,
|
||||
cycles: number,
|
||||
source: string,
|
||||
): WorkStats => {
|
||||
const expStats = applyWorkStatsExp(target, workStats, cycles);
|
||||
const gains = {
|
||||
money: workStats.money * cycles,
|
||||
reputation: 0,
|
||||
hackExp: expStats.hackExp,
|
||||
strExp: expStats.strExp,
|
||||
defExp: expStats.defExp,
|
||||
dexExp: expStats.dexExp,
|
||||
agiExp: expStats.agiExp,
|
||||
chaExp: expStats.chaExp,
|
||||
intExp: expStats.intExp,
|
||||
};
|
||||
player.gainMoney(gains.money, source);
|
||||
|
||||
return gains;
|
||||
};
|
||||
|
||||
export const applyWorkStatsExp = (target: IPerson, workStats: WorkStats, cycles: number): WorkStats => {
|
||||
const gains = {
|
||||
money: 0,
|
||||
reputation: 0,
|
||||
hackExp: workStats.hackExp * cycles,
|
||||
strExp: workStats.strExp * cycles,
|
||||
defExp: workStats.defExp * cycles,
|
||||
@@ -78,13 +104,12 @@ export const applyWorkStats = (player: IPlayer, workStats: WorkStats, cycles: nu
|
||||
chaExp: workStats.chaExp * cycles,
|
||||
intExp: workStats.intExp * cycles,
|
||||
};
|
||||
player.gainHackingExp(gains.hackExp);
|
||||
player.gainStrengthExp(gains.strExp);
|
||||
player.gainDefenseExp(gains.defExp);
|
||||
player.gainDexterityExp(gains.dexExp);
|
||||
player.gainAgilityExp(gains.agiExp);
|
||||
player.gainCharismaExp(gains.chaExp);
|
||||
player.gainIntelligenceExp(gains.intExp);
|
||||
player.gainMoney(gains.money, source);
|
||||
target.gainHackingExp(gains.hackExp);
|
||||
target.gainStrengthExp(gains.strExp);
|
||||
target.gainDefenseExp(gains.defExp);
|
||||
target.gainDexterityExp(gains.dexExp);
|
||||
target.gainAgilityExp(gains.agiExp);
|
||||
target.gainCharismaExp(gains.chaExp);
|
||||
target.gainIntelligenceExp(gains.intExp);
|
||||
return gains;
|
||||
};
|
||||
|
||||
+22
-11
@@ -3,11 +3,13 @@ import { Location } from "../../Locations/Location";
|
||||
import { BitNodeMultipliers } from "../../BitNode/BitNodeMultipliers";
|
||||
import { CONSTANTS } from "../../Constants";
|
||||
import { IPlayer } from "../../PersonObjects/IPlayer";
|
||||
import { Class, Classes, ClassWork } from "../ClassWork";
|
||||
import { Class, Classes, ClassType } from "../ClassWork";
|
||||
import { WorkStats } from "../WorkStats";
|
||||
import { Server } from "../../Server/Server";
|
||||
import { GetServer } from "../../Server/AllServers";
|
||||
import { serverMetadata } from "../../Server/data/servers";
|
||||
import { IPerson } from "../../PersonObjects/IPerson";
|
||||
import { LocationName } from "../../Locations/data/LocationNames";
|
||||
|
||||
const gameCPS = 1000 / CONSTANTS._idleSpeed; // 5 cycles per second
|
||||
|
||||
@@ -18,13 +20,22 @@ export function calculateCost(classs: Class, location: Location): number {
|
||||
return classs.earnings.money * location.costMult * discount;
|
||||
}
|
||||
|
||||
export function calculateClassEarnings(player: IPlayer, work: ClassWork): WorkStats {
|
||||
export function calculateClassEarnings(
|
||||
player: IPlayer,
|
||||
target: IPerson,
|
||||
type: ClassType,
|
||||
locationName: LocationName,
|
||||
): WorkStats {
|
||||
//Find cost and exp gain per game cycle
|
||||
const hashManager = player.hashManager;
|
||||
const classs = Classes[work.classType];
|
||||
const location = Locations[work.location];
|
||||
const classs = Classes[type];
|
||||
const location = Locations[locationName];
|
||||
|
||||
const hashMult = work.isGym() ? hashManager.getTrainingMult() : hashManager.getStudyMult();
|
||||
const hashMult = [ClassType.GymAgility, ClassType.GymDefense, ClassType.GymStrength, ClassType.GymDexterity].includes(
|
||||
type,
|
||||
)
|
||||
? hashManager.getTrainingMult()
|
||||
: hashManager.getStudyMult();
|
||||
|
||||
const cost = calculateCost(classs, location) / gameCPS;
|
||||
const hackExp = ((classs.earnings.hackExp * location.expMult) / gameCPS) * hashMult;
|
||||
@@ -36,12 +47,12 @@ export function calculateClassEarnings(player: IPlayer, work: ClassWork): WorkSt
|
||||
return {
|
||||
money: cost,
|
||||
reputation: 0,
|
||||
hackExp: hackExp * player.mults.hacking_exp * BitNodeMultipliers.ClassGymExpGain,
|
||||
strExp: strExp * player.mults.strength_exp * BitNodeMultipliers.ClassGymExpGain,
|
||||
defExp: defExp * player.mults.defense_exp * BitNodeMultipliers.ClassGymExpGain,
|
||||
dexExp: dexExp * player.mults.dexterity_exp * BitNodeMultipliers.ClassGymExpGain,
|
||||
agiExp: agiExp * player.mults.agility_exp * BitNodeMultipliers.ClassGymExpGain,
|
||||
chaExp: chaExp * player.mults.charisma_exp * BitNodeMultipliers.ClassGymExpGain,
|
||||
hackExp: hackExp * target.mults.hacking_exp * BitNodeMultipliers.ClassGymExpGain,
|
||||
strExp: strExp * target.mults.strength_exp * BitNodeMultipliers.ClassGymExpGain,
|
||||
defExp: defExp * target.mults.defense_exp * BitNodeMultipliers.ClassGymExpGain,
|
||||
dexExp: dexExp * target.mults.dexterity_exp * BitNodeMultipliers.ClassGymExpGain,
|
||||
agiExp: agiExp * target.mults.agility_exp * BitNodeMultipliers.ClassGymExpGain,
|
||||
chaExp: chaExp * target.mults.charisma_exp * BitNodeMultipliers.ClassGymExpGain,
|
||||
intExp: 0,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -5,16 +5,12 @@ import { WorkStats } from "../WorkStats";
|
||||
import { BitNodeMultipliers } from "../../BitNode/BitNodeMultipliers";
|
||||
import { CONSTANTS } from "../../Constants";
|
||||
import { AugmentationNames } from "../../Augmentation/data/AugmentationNames";
|
||||
import { IPerson } from "src/PersonObjects/IPerson";
|
||||
|
||||
export const calculateCompanyWorkStats = (player: IPlayer, company: Company): WorkStats => {
|
||||
export const calculateCompanyWorkStats = (player: IPlayer, worker: IPerson, company: Company): WorkStats => {
|
||||
const companyPositionName = player.jobs[company.name];
|
||||
const companyPosition = CompanyPositions[companyPositionName];
|
||||
|
||||
let focusBonus = 1;
|
||||
if (!player.hasAugmentation(AugmentationNames.NeuroreceptorManager)) {
|
||||
focusBonus = player.focus ? 1 : CONSTANTS.BaseFocusBonus;
|
||||
}
|
||||
|
||||
// If player has SF-11, calculate salary multiplier from favor
|
||||
let favorMult = 1 + company.favor / 100;
|
||||
if (isNaN(favorMult)) {
|
||||
@@ -27,60 +23,53 @@ export const calculateCompanyWorkStats = (player: IPlayer, company: Company): Wo
|
||||
}
|
||||
|
||||
let jobPerformance = companyPosition.calculateJobPerformance(
|
||||
player.skills.hacking,
|
||||
player.skills.strength,
|
||||
player.skills.defense,
|
||||
player.skills.dexterity,
|
||||
player.skills.agility,
|
||||
player.skills.charisma,
|
||||
worker.skills.hacking,
|
||||
worker.skills.strength,
|
||||
worker.skills.defense,
|
||||
worker.skills.dexterity,
|
||||
worker.skills.agility,
|
||||
worker.skills.charisma,
|
||||
);
|
||||
|
||||
jobPerformance += player.skills.intelligence / CONSTANTS.MaxSkillLevel;
|
||||
jobPerformance += worker.skills.intelligence / CONSTANTS.MaxSkillLevel;
|
||||
|
||||
return {
|
||||
money:
|
||||
focusBonus *
|
||||
companyPosition.baseSalary *
|
||||
company.salaryMultiplier *
|
||||
player.mults.work_money *
|
||||
worker.mults.work_money *
|
||||
BitNodeMultipliers.CompanyWorkMoney *
|
||||
bn11Mult,
|
||||
reputation: focusBonus * jobPerformance * player.mults.company_rep * favorMult,
|
||||
reputation: jobPerformance * worker.mults.company_rep * favorMult,
|
||||
hackExp:
|
||||
focusBonus *
|
||||
companyPosition.hackingExpGain *
|
||||
company.expMultiplier *
|
||||
player.mults.hacking_exp *
|
||||
worker.mults.hacking_exp *
|
||||
BitNodeMultipliers.CompanyWorkExpGain,
|
||||
strExp:
|
||||
focusBonus *
|
||||
companyPosition.strengthExpGain *
|
||||
company.expMultiplier *
|
||||
player.mults.strength_exp *
|
||||
worker.mults.strength_exp *
|
||||
BitNodeMultipliers.CompanyWorkExpGain,
|
||||
defExp:
|
||||
focusBonus *
|
||||
companyPosition.defenseExpGain *
|
||||
company.expMultiplier *
|
||||
player.mults.defense_exp *
|
||||
worker.mults.defense_exp *
|
||||
BitNodeMultipliers.CompanyWorkExpGain,
|
||||
dexExp:
|
||||
focusBonus *
|
||||
companyPosition.dexterityExpGain *
|
||||
company.expMultiplier *
|
||||
player.mults.dexterity_exp *
|
||||
worker.mults.dexterity_exp *
|
||||
BitNodeMultipliers.CompanyWorkExpGain,
|
||||
agiExp:
|
||||
focusBonus *
|
||||
companyPosition.agilityExpGain *
|
||||
company.expMultiplier *
|
||||
player.mults.agility_exp *
|
||||
worker.mults.agility_exp *
|
||||
BitNodeMultipliers.CompanyWorkExpGain,
|
||||
chaExp:
|
||||
focusBonus *
|
||||
companyPosition.charismaExpGain *
|
||||
company.expMultiplier *
|
||||
player.mults.charisma_exp *
|
||||
worker.mults.charisma_exp *
|
||||
BitNodeMultipliers.CompanyWorkExpGain,
|
||||
intExp: 0,
|
||||
};
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { AugmentationNames } from "../../Augmentation/data/AugmentationNames";
|
||||
import { IPerson } from "../../PersonObjects/IPerson";
|
||||
import { BitNodeMultipliers } from "../../BitNode/BitNodeMultipliers";
|
||||
import { CONSTANTS } from "../../Constants";
|
||||
import { IPlayer } from "../../PersonObjects/IPlayer";
|
||||
import { FactionWorkType } from "../data/FactionWorkType";
|
||||
import { newWorkStats, WorkStats } from "../WorkStats";
|
||||
|
||||
@@ -26,27 +25,17 @@ export const FactionWorkStats: Record<FactionWorkType, WorkStats> = {
|
||||
}),
|
||||
};
|
||||
|
||||
export function calculateFactionExp(player: IPlayer, tpe: FactionWorkType): WorkStats {
|
||||
let focusBonus = 1;
|
||||
if (!player.hasAugmentation(AugmentationNames.NeuroreceptorManager)) {
|
||||
focusBonus = player.focus ? 1 : CONSTANTS.BaseFocusBonus;
|
||||
}
|
||||
export function calculateFactionExp(person: IPerson, tpe: FactionWorkType): WorkStats {
|
||||
const baseStats = FactionWorkStats[tpe];
|
||||
return {
|
||||
money: 0,
|
||||
reputation: 0,
|
||||
hackExp:
|
||||
(focusBonus * (baseStats.hackExp * player.mults.hacking_exp * BitNodeMultipliers.FactionWorkExpGain)) / gameCPS,
|
||||
strExp:
|
||||
(focusBonus * (baseStats.strExp * player.mults.strength_exp * BitNodeMultipliers.FactionWorkExpGain)) / gameCPS,
|
||||
defExp:
|
||||
(focusBonus * (baseStats.defExp * player.mults.defense_exp * BitNodeMultipliers.FactionWorkExpGain)) / gameCPS,
|
||||
dexExp:
|
||||
(focusBonus * (baseStats.dexExp * player.mults.dexterity_exp * BitNodeMultipliers.FactionWorkExpGain)) / gameCPS,
|
||||
agiExp:
|
||||
(focusBonus * (baseStats.agiExp * player.mults.agility_exp * BitNodeMultipliers.FactionWorkExpGain)) / gameCPS,
|
||||
chaExp:
|
||||
(focusBonus * (baseStats.chaExp * player.mults.charisma_exp * BitNodeMultipliers.FactionWorkExpGain)) / gameCPS,
|
||||
hackExp: (baseStats.hackExp * person.mults.hacking_exp * BitNodeMultipliers.FactionWorkExpGain) / gameCPS,
|
||||
strExp: (baseStats.strExp * person.mults.strength_exp * BitNodeMultipliers.FactionWorkExpGain) / gameCPS,
|
||||
defExp: (baseStats.defExp * person.mults.defense_exp * BitNodeMultipliers.FactionWorkExpGain) / gameCPS,
|
||||
dexExp: (baseStats.dexExp * person.mults.dexterity_exp * BitNodeMultipliers.FactionWorkExpGain) / gameCPS,
|
||||
agiExp: (baseStats.agiExp * person.mults.agility_exp * BitNodeMultipliers.FactionWorkExpGain) / gameCPS,
|
||||
chaExp: (baseStats.chaExp * person.mults.charisma_exp * BitNodeMultipliers.FactionWorkExpGain) / gameCPS,
|
||||
intExp: 0,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user