mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-18 05:33:54 +01:00
fix more bugs
This commit is contained in:
parent
3112dc60c0
commit
c0d28c17e7
34
dist/vendor.bundle.js
vendored
34
dist/vendor.bundle.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -134,6 +134,8 @@ export interface IPlayer {
|
|||||||
className: string;
|
className: string;
|
||||||
currentWorkFactionName: string;
|
currentWorkFactionName: string;
|
||||||
workType: string;
|
workType: string;
|
||||||
|
workCostMult: number;
|
||||||
|
workExpMult: number;
|
||||||
currentWorkFactionDescription: string;
|
currentWorkFactionDescription: string;
|
||||||
timeWorked: number;
|
timeWorked: number;
|
||||||
workMoneyGained: number;
|
workMoneyGained: number;
|
||||||
|
@ -139,6 +139,8 @@ export class PlayerObject implements IPlayer {
|
|||||||
className: string;
|
className: string;
|
||||||
currentWorkFactionName: string;
|
currentWorkFactionName: string;
|
||||||
workType: string;
|
workType: string;
|
||||||
|
workCostMult: number;
|
||||||
|
workExpMult: number;
|
||||||
currentWorkFactionDescription: string;
|
currentWorkFactionDescription: string;
|
||||||
timeWorked: number;
|
timeWorked: number;
|
||||||
workMoneyGained: number;
|
workMoneyGained: number;
|
||||||
@ -377,6 +379,8 @@ export class PlayerObject implements IPlayer {
|
|||||||
this.isWorking = false;
|
this.isWorking = false;
|
||||||
this.focus = false;
|
this.focus = false;
|
||||||
this.workType = "";
|
this.workType = "";
|
||||||
|
this.workCostMult = 1;
|
||||||
|
this.workExpMult = 1;
|
||||||
|
|
||||||
this.currentWorkFactionName = "";
|
this.currentWorkFactionName = "";
|
||||||
this.currentWorkFactionDescription = "";
|
this.currentWorkFactionDescription = "";
|
||||||
|
@ -59,6 +59,7 @@ import { Money } from "../../ui/React/Money";
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { serverMetadata } from "../../Server/data/servers";
|
import { serverMetadata } from "../../Server/data/servers";
|
||||||
import { SnackbarEvents } from "../../ui/React/Snackbar";
|
import { SnackbarEvents } from "../../ui/React/Snackbar";
|
||||||
|
import { calculateClassEarnings } from "../formulas/work";
|
||||||
|
|
||||||
export function init(this: IPlayer): void {
|
export function init(this: IPlayer): void {
|
||||||
/* Initialize Player's home computer */
|
/* Initialize Player's home computer */
|
||||||
@ -1296,84 +1297,36 @@ export function finishCreateProgramWork(this: IPlayer, cancelled: boolean): stri
|
|||||||
this.resetWorkStatus();
|
this.resetWorkStatus();
|
||||||
return "You've finished creating " + programName + "! The new program can be found on your home computer.";
|
return "You've finished creating " + programName + "! The new program can be found on your home computer.";
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Studying/Taking Classes */
|
/* Studying/Taking Classes */
|
||||||
export function startClass(this: IPlayer, router: IRouter, costMult: number, expMult: number, className: string): void {
|
export function startClass(this: IPlayer, router: IRouter, costMult: number, expMult: number, className: string): void {
|
||||||
this.resetWorkStatus();
|
this.resetWorkStatus();
|
||||||
this.isWorking = true;
|
this.isWorking = true;
|
||||||
this.focus = true;
|
this.focus = true;
|
||||||
this.workType = CONSTANTS.WorkTypeStudyClass;
|
this.workType = CONSTANTS.WorkTypeStudyClass;
|
||||||
|
this.workCostMult = costMult;
|
||||||
|
this.workExpMult = expMult;
|
||||||
this.className = className;
|
this.className = className;
|
||||||
|
const earnings = calculateClassEarnings(this);
|
||||||
const gameCPS = 1000 / CONSTANTS._idleSpeed;
|
this.workMoneyLossRate = earnings.workMoneyLossRate;
|
||||||
|
this.workHackExpGainRate = earnings.workHackExpGainRate;
|
||||||
//Find cost and exp gain per game cycle
|
this.workStrExpGainRate = earnings.workStrExpGainRate;
|
||||||
let cost = 0;
|
this.workDefExpGainRate = earnings.workDefExpGainRate;
|
||||||
let hackExp = 0,
|
this.workDexExpGainRate = earnings.workDexExpGainRate;
|
||||||
strExp = 0,
|
this.workAgiExpGainRate = earnings.workAgiExpGainRate;
|
||||||
defExp = 0,
|
this.workChaExpGainRate = earnings.workChaExpGainRate;
|
||||||
dexExp = 0,
|
|
||||||
agiExp = 0,
|
|
||||||
chaExp = 0;
|
|
||||||
const hashManager = this.hashManager;
|
|
||||||
switch (className) {
|
|
||||||
case CONSTANTS.ClassStudyComputerScience:
|
|
||||||
hackExp = ((CONSTANTS.ClassStudyComputerScienceBaseExp * expMult) / gameCPS) * hashManager.getStudyMult();
|
|
||||||
break;
|
|
||||||
case CONSTANTS.ClassDataStructures:
|
|
||||||
cost = (CONSTANTS.ClassDataStructuresBaseCost * costMult) / gameCPS;
|
|
||||||
hackExp = ((CONSTANTS.ClassDataStructuresBaseExp * expMult) / gameCPS) * hashManager.getStudyMult();
|
|
||||||
break;
|
|
||||||
case CONSTANTS.ClassNetworks:
|
|
||||||
cost = (CONSTANTS.ClassNetworksBaseCost * costMult) / gameCPS;
|
|
||||||
hackExp = ((CONSTANTS.ClassNetworksBaseExp * expMult) / gameCPS) * hashManager.getStudyMult();
|
|
||||||
break;
|
|
||||||
case CONSTANTS.ClassAlgorithms:
|
|
||||||
cost = (CONSTANTS.ClassAlgorithmsBaseCost * costMult) / gameCPS;
|
|
||||||
hackExp = ((CONSTANTS.ClassAlgorithmsBaseExp * expMult) / gameCPS) * hashManager.getStudyMult();
|
|
||||||
break;
|
|
||||||
case CONSTANTS.ClassManagement:
|
|
||||||
cost = (CONSTANTS.ClassManagementBaseCost * costMult) / gameCPS;
|
|
||||||
chaExp = ((CONSTANTS.ClassManagementBaseExp * expMult) / gameCPS) * hashManager.getStudyMult();
|
|
||||||
break;
|
|
||||||
case CONSTANTS.ClassLeadership:
|
|
||||||
cost = (CONSTANTS.ClassLeadershipBaseCost * costMult) / gameCPS;
|
|
||||||
chaExp = ((CONSTANTS.ClassLeadershipBaseExp * expMult) / gameCPS) * hashManager.getStudyMult();
|
|
||||||
break;
|
|
||||||
case CONSTANTS.ClassGymStrength:
|
|
||||||
cost = (CONSTANTS.ClassGymBaseCost * costMult) / gameCPS;
|
|
||||||
strExp = (expMult / gameCPS) * hashManager.getTrainingMult();
|
|
||||||
break;
|
|
||||||
case CONSTANTS.ClassGymDefense:
|
|
||||||
cost = (CONSTANTS.ClassGymBaseCost * costMult) / gameCPS;
|
|
||||||
defExp = (expMult / gameCPS) * hashManager.getTrainingMult();
|
|
||||||
break;
|
|
||||||
case CONSTANTS.ClassGymDexterity:
|
|
||||||
cost = (CONSTANTS.ClassGymBaseCost * costMult) / gameCPS;
|
|
||||||
dexExp = (expMult / gameCPS) * hashManager.getTrainingMult();
|
|
||||||
break;
|
|
||||||
case CONSTANTS.ClassGymAgility:
|
|
||||||
cost = (CONSTANTS.ClassGymBaseCost * costMult) / gameCPS;
|
|
||||||
agiExp = (expMult / gameCPS) * hashManager.getTrainingMult();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new Error("ERR: Invalid/unrecognized class name");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.workMoneyLossRate = cost;
|
|
||||||
this.workHackExpGainRate = hackExp * this.hacking_exp_mult * BitNodeMultipliers.ClassGymExpGain;
|
|
||||||
this.workStrExpGainRate = strExp * this.strength_exp_mult * BitNodeMultipliers.ClassGymExpGain;
|
|
||||||
this.workDefExpGainRate = defExp * this.defense_exp_mult * BitNodeMultipliers.ClassGymExpGain;
|
|
||||||
this.workDexExpGainRate = dexExp * this.dexterity_exp_mult * BitNodeMultipliers.ClassGymExpGain;
|
|
||||||
this.workAgiExpGainRate = agiExp * this.agility_exp_mult * BitNodeMultipliers.ClassGymExpGain;
|
|
||||||
this.workChaExpGainRate = chaExp * this.charisma_exp_mult * BitNodeMultipliers.ClassGymExpGain;
|
|
||||||
router.toWork();
|
router.toWork();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function takeClass(this: IPlayer, numCycles: number): boolean {
|
export function takeClass(this: IPlayer, numCycles: number): boolean {
|
||||||
this.timeWorked += CONSTANTS._idleSpeed * numCycles;
|
this.timeWorked += CONSTANTS._idleSpeed * numCycles;
|
||||||
|
const earnings = calculateClassEarnings(this);
|
||||||
|
this.workMoneyLossRate = earnings.workMoneyLossRate;
|
||||||
|
this.workHackExpGainRate = earnings.workHackExpGainRate;
|
||||||
|
this.workStrExpGainRate = earnings.workStrExpGainRate;
|
||||||
|
this.workDefExpGainRate = earnings.workDefExpGainRate;
|
||||||
|
this.workDexExpGainRate = earnings.workDexExpGainRate;
|
||||||
|
this.workAgiExpGainRate = earnings.workAgiExpGainRate;
|
||||||
|
this.workChaExpGainRate = earnings.workChaExpGainRate;
|
||||||
this.processWorkEarnings(numCycles);
|
this.processWorkEarnings(numCycles);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
80
src/PersonObjects/formulas/work.ts
Normal file
80
src/PersonObjects/formulas/work.ts
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
import { CONSTANTS } from "../../Constants";
|
||||||
|
import { BitNodeMultipliers } from "../../BitNode/BitNodeMultipliers";
|
||||||
|
import { IPlayer } from "../IPlayer";
|
||||||
|
|
||||||
|
export interface WorkEarnings {
|
||||||
|
workMoneyLossRate: number;
|
||||||
|
workHackExpGainRate: number;
|
||||||
|
workStrExpGainRate: number;
|
||||||
|
workDefExpGainRate: number;
|
||||||
|
workDexExpGainRate: number;
|
||||||
|
workAgiExpGainRate: number;
|
||||||
|
workChaExpGainRate: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function calculateClassEarnings(player: IPlayer): WorkEarnings {
|
||||||
|
const gameCPS = 1000 / CONSTANTS._idleSpeed;
|
||||||
|
|
||||||
|
//Find cost and exp gain per game cycle
|
||||||
|
let cost = 0;
|
||||||
|
let hackExp = 0,
|
||||||
|
strExp = 0,
|
||||||
|
defExp = 0,
|
||||||
|
dexExp = 0,
|
||||||
|
agiExp = 0,
|
||||||
|
chaExp = 0;
|
||||||
|
const hashManager = player.hashManager;
|
||||||
|
switch (player.className) {
|
||||||
|
case CONSTANTS.ClassStudyComputerScience:
|
||||||
|
hackExp =
|
||||||
|
((CONSTANTS.ClassStudyComputerScienceBaseExp * player.workExpMult) / gameCPS) * hashManager.getStudyMult();
|
||||||
|
break;
|
||||||
|
case CONSTANTS.ClassDataStructures:
|
||||||
|
cost = (CONSTANTS.ClassDataStructuresBaseCost * player.workCostMult) / gameCPS;
|
||||||
|
hackExp = ((CONSTANTS.ClassDataStructuresBaseExp * player.workExpMult) / gameCPS) * hashManager.getStudyMult();
|
||||||
|
break;
|
||||||
|
case CONSTANTS.ClassNetworks:
|
||||||
|
cost = (CONSTANTS.ClassNetworksBaseCost * player.workCostMult) / gameCPS;
|
||||||
|
hackExp = ((CONSTANTS.ClassNetworksBaseExp * player.workExpMult) / gameCPS) * hashManager.getStudyMult();
|
||||||
|
break;
|
||||||
|
case CONSTANTS.ClassAlgorithms:
|
||||||
|
cost = (CONSTANTS.ClassAlgorithmsBaseCost * player.workCostMult) / gameCPS;
|
||||||
|
hackExp = ((CONSTANTS.ClassAlgorithmsBaseExp * player.workExpMult) / gameCPS) * hashManager.getStudyMult();
|
||||||
|
break;
|
||||||
|
case CONSTANTS.ClassManagement:
|
||||||
|
cost = (CONSTANTS.ClassManagementBaseCost * player.workCostMult) / gameCPS;
|
||||||
|
chaExp = ((CONSTANTS.ClassManagementBaseExp * player.workExpMult) / gameCPS) * hashManager.getStudyMult();
|
||||||
|
break;
|
||||||
|
case CONSTANTS.ClassLeadership:
|
||||||
|
cost = (CONSTANTS.ClassLeadershipBaseCost * player.workCostMult) / gameCPS;
|
||||||
|
chaExp = ((CONSTANTS.ClassLeadershipBaseExp * player.workExpMult) / gameCPS) * hashManager.getStudyMult();
|
||||||
|
break;
|
||||||
|
case CONSTANTS.ClassGymStrength:
|
||||||
|
cost = (CONSTANTS.ClassGymBaseCost * player.workCostMult) / gameCPS;
|
||||||
|
strExp = (player.workExpMult / gameCPS) * hashManager.getTrainingMult();
|
||||||
|
break;
|
||||||
|
case CONSTANTS.ClassGymDefense:
|
||||||
|
cost = (CONSTANTS.ClassGymBaseCost * player.workCostMult) / gameCPS;
|
||||||
|
defExp = (player.workExpMult / gameCPS) * hashManager.getTrainingMult();
|
||||||
|
break;
|
||||||
|
case CONSTANTS.ClassGymDexterity:
|
||||||
|
cost = (CONSTANTS.ClassGymBaseCost * player.workCostMult) / gameCPS;
|
||||||
|
dexExp = (player.workExpMult / gameCPS) * hashManager.getTrainingMult();
|
||||||
|
break;
|
||||||
|
case CONSTANTS.ClassGymAgility:
|
||||||
|
cost = (CONSTANTS.ClassGymBaseCost * player.workCostMult) / gameCPS;
|
||||||
|
agiExp = (player.workExpMult / gameCPS) * hashManager.getTrainingMult();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new Error("ERR: Invalid/unrecognized class name");
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
workMoneyLossRate: cost,
|
||||||
|
workHackExpGainRate: hackExp * player.hacking_exp_mult * BitNodeMultipliers.ClassGymExpGain,
|
||||||
|
workStrExpGainRate: strExp * player.strength_exp_mult * BitNodeMultipliers.ClassGymExpGain,
|
||||||
|
workDefExpGainRate: defExp * player.defense_exp_mult * BitNodeMultipliers.ClassGymExpGain,
|
||||||
|
workDexExpGainRate: dexExp * player.dexterity_exp_mult * BitNodeMultipliers.ClassGymExpGain,
|
||||||
|
workAgiExpGainRate: agiExp * player.agility_exp_mult * BitNodeMultipliers.ClassGymExpGain,
|
||||||
|
workChaExpGainRate: chaExp * player.charisma_exp_mult * BitNodeMultipliers.ClassGymExpGain,
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user