organized formulas
This commit is contained in:
parent
4a798b3f44
commit
1e0154ccf4
|
|
@ -1,4 +1,4 @@
|
||||||
import { Multipliers } from "./player";
|
import { Multipliers } from "@ns";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generic Game Constants
|
* Generic Game Constants
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
import { Player } from "./player";
|
|
||||||
import { clampNumber } from "./utils";
|
import { clampNumber } from "./utils";
|
||||||
|
|
||||||
export type PartialRecord<K extends string, V> = Partial<Record<K, V>>;
|
export type PartialRecord<K extends string, V> = Partial<Record<K, V>>;
|
||||||
|
|
@ -185,10 +184,112 @@ export class BitNodeMultipliers {
|
||||||
/** The multipliers currently in effect */
|
/** The multipliers currently in effect */
|
||||||
export const currentNodeMults = new BitNodeMultipliers();
|
export const currentNodeMults = new BitNodeMultipliers();
|
||||||
|
|
||||||
export function calculateIntelligenceBonus(intelligence: number, weight = 1): number {
|
/** Names of all cities */
|
||||||
const effectiveIntelligence =
|
export enum CityName {
|
||||||
Player.bitNodeOptions.intelligenceOverride !== undefined
|
Aevum = "Aevum",
|
||||||
? Math.min(Player.bitNodeOptions.intelligenceOverride, intelligence)
|
Chongqing = "Chongqing",
|
||||||
: intelligence;
|
Sector12 = "Sector-12",
|
||||||
return 1 + (weight * Math.pow(effectiveIntelligence, 0.8)) / 600;
|
NewTokyo = "New Tokyo",
|
||||||
|
Ishima = "Ishima",
|
||||||
|
Volhaven = "Volhaven",
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Names of all locations */
|
||||||
|
export enum LocationName {
|
||||||
|
AevumAeroCorp = "AeroCorp",
|
||||||
|
AevumBachmanAndAssociates = "Bachman & Associates",
|
||||||
|
AevumClarkeIncorporated = "Clarke Incorporated",
|
||||||
|
AevumCrushFitnessGym = "Crush Fitness Gym",
|
||||||
|
AevumECorp = "ECorp",
|
||||||
|
AevumFulcrumTechnologies = "Fulcrum Technologies",
|
||||||
|
AevumGalacticCybersystems = "Galactic Cybersystems",
|
||||||
|
AevumNetLinkTechnologies = "NetLink Technologies",
|
||||||
|
AevumPolice = "Aevum Police Headquarters",
|
||||||
|
AevumRhoConstruction = "Rho Construction",
|
||||||
|
AevumSnapFitnessGym = "Snap Fitness Gym",
|
||||||
|
AevumSummitUniversity = "Summit University",
|
||||||
|
AevumWatchdogSecurity = "Watchdog Security",
|
||||||
|
AevumCasino = "Iker Molina Casino",
|
||||||
|
|
||||||
|
ChongqingKuaiGongInternational = "KuaiGong International",
|
||||||
|
ChongqingSolarisSpaceSystems = "Solaris Space Systems",
|
||||||
|
ChongqingChurchOfTheMachineGod = "Church of the Machine God",
|
||||||
|
|
||||||
|
Sector12AlphaEnterprises = "Alpha Enterprises",
|
||||||
|
Sector12BladeIndustries = "Blade Industries",
|
||||||
|
Sector12CIA = "Central Intelligence Agency",
|
||||||
|
Sector12CarmichaelSecurity = "Carmichael Security",
|
||||||
|
Sector12CityHall = "Sector-12 City Hall",
|
||||||
|
Sector12DeltaOne = "DeltaOne",
|
||||||
|
Sector12FoodNStuff = "FoodNStuff",
|
||||||
|
Sector12FourSigma = "Four Sigma",
|
||||||
|
Sector12IcarusMicrosystems = "Icarus Microsystems",
|
||||||
|
Sector12IronGym = "Iron Gym",
|
||||||
|
Sector12JoesGuns = "Joe's Guns",
|
||||||
|
Sector12MegaCorp = "MegaCorp",
|
||||||
|
Sector12NSA = "National Security Agency",
|
||||||
|
Sector12PowerhouseGym = "Powerhouse Gym",
|
||||||
|
Sector12RothmanUniversity = "Rothman University",
|
||||||
|
Sector12UniversalEnergy = "Universal Energy",
|
||||||
|
|
||||||
|
NewTokyoDefComm = "DefComm",
|
||||||
|
NewTokyoGlobalPharmaceuticals = "Global Pharmaceuticals",
|
||||||
|
NewTokyoNoodleBar = "Noodle Bar",
|
||||||
|
NewTokyoVitaLife = "VitaLife",
|
||||||
|
NewTokyoArcade = "Arcade",
|
||||||
|
|
||||||
|
IshimaNovaMedical = "Nova Medical",
|
||||||
|
IshimaOmegaSoftware = "Omega Software",
|
||||||
|
IshimaStormTechnologies = "Storm Technologies",
|
||||||
|
IshimaGlitch = "0x6C1",
|
||||||
|
|
||||||
|
VolhavenCompuTek = "CompuTek",
|
||||||
|
VolhavenHeliosLabs = "Helios Labs",
|
||||||
|
VolhavenLexoCorp = "LexoCorp",
|
||||||
|
VolhavenMilleniumFitnessGym = "Millenium Fitness Gym",
|
||||||
|
VolhavenNWO = "NWO",
|
||||||
|
VolhavenOmniTekIncorporated = "OmniTek Incorporated",
|
||||||
|
VolhavenOmniaCybersystems = "Omnia Cybersystems",
|
||||||
|
VolhavenSysCoreSecurities = "SysCore Securities",
|
||||||
|
VolhavenZBInstituteOfTechnology = "ZB Institute of Technology",
|
||||||
|
|
||||||
|
Hospital = "Hospital",
|
||||||
|
Slums = "The Slums",
|
||||||
|
TravelAgency = "Travel Agency",
|
||||||
|
WorldStockExchange = "World Stock Exchange",
|
||||||
|
|
||||||
|
Void = "The Void",
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import { Player as IPerson, Server as IServer } from "@ns";
|
import { Player as IPerson, Server as IServer } from "@ns";
|
||||||
import { currentNodeMults } from "./exports";
|
|
||||||
import { clampNumber, isValidNumber } from "./utils";
|
|
||||||
import { Player } from "./player";
|
|
||||||
import { ServerConstants } from "./constants";
|
import { ServerConstants } from "./constants";
|
||||||
|
import { currentNodeMults } from "./exports";
|
||||||
|
import { Player } from "./player";
|
||||||
|
import { clampNumber, isValidNumber } from "./utils";
|
||||||
|
|
||||||
export function calculateIntelligenceBonus(intelligence: number, weight = 1): number {
|
export function calculateIntelligenceBonus(intelligence: number, weight = 1): number {
|
||||||
const effectiveIntelligence =
|
const effectiveIntelligence =
|
||||||
|
|
@ -285,3 +285,13 @@ export function numCycleForGrowthCorrected(
|
||||||
}
|
}
|
||||||
return ccycle + 1;
|
return ccycle + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getCoreBonus(cores = 1): number {
|
||||||
|
const coreBonus = 1 + (cores - 1) / 16;
|
||||||
|
return coreBonus;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getWeakenEffect(threads: number, cores: number): number {
|
||||||
|
const coreBonus = getCoreBonus(cores);
|
||||||
|
return ServerConstants.ServerWeakenAmount * threads * coreBonus * currentNodeMults.ServerWeakenRate;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,119 +14,9 @@ import {
|
||||||
type WorkStats,
|
type WorkStats,
|
||||||
} from "@ns";
|
} from "@ns";
|
||||||
import { CONSTANTS, defaultMultipliers } from "./constants";
|
import { CONSTANTS, defaultMultipliers } from "./constants";
|
||||||
import { currentNodeMults, PartialRecord } from "./exports";
|
import { CityName, currentNodeMults, LocationName, type PartialRecord } from "./exports";
|
||||||
import { calculateSkill } from "./skills";
|
import { calculateSkill } from "./skills";
|
||||||
|
|
||||||
/** Names of all cities */
|
|
||||||
enum CityName {
|
|
||||||
Aevum = "Aevum",
|
|
||||||
Chongqing = "Chongqing",
|
|
||||||
Sector12 = "Sector-12",
|
|
||||||
NewTokyo = "New Tokyo",
|
|
||||||
Ishima = "Ishima",
|
|
||||||
Volhaven = "Volhaven",
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Names of all locations */
|
|
||||||
export enum LocationName {
|
|
||||||
AevumAeroCorp = "AeroCorp",
|
|
||||||
AevumBachmanAndAssociates = "Bachman & Associates",
|
|
||||||
AevumClarkeIncorporated = "Clarke Incorporated",
|
|
||||||
AevumCrushFitnessGym = "Crush Fitness Gym",
|
|
||||||
AevumECorp = "ECorp",
|
|
||||||
AevumFulcrumTechnologies = "Fulcrum Technologies",
|
|
||||||
AevumGalacticCybersystems = "Galactic Cybersystems",
|
|
||||||
AevumNetLinkTechnologies = "NetLink Technologies",
|
|
||||||
AevumPolice = "Aevum Police Headquarters",
|
|
||||||
AevumRhoConstruction = "Rho Construction",
|
|
||||||
AevumSnapFitnessGym = "Snap Fitness Gym",
|
|
||||||
AevumSummitUniversity = "Summit University",
|
|
||||||
AevumWatchdogSecurity = "Watchdog Security",
|
|
||||||
AevumCasino = "Iker Molina Casino",
|
|
||||||
|
|
||||||
ChongqingKuaiGongInternational = "KuaiGong International",
|
|
||||||
ChongqingSolarisSpaceSystems = "Solaris Space Systems",
|
|
||||||
ChongqingChurchOfTheMachineGod = "Church of the Machine God",
|
|
||||||
|
|
||||||
Sector12AlphaEnterprises = "Alpha Enterprises",
|
|
||||||
Sector12BladeIndustries = "Blade Industries",
|
|
||||||
Sector12CIA = "Central Intelligence Agency",
|
|
||||||
Sector12CarmichaelSecurity = "Carmichael Security",
|
|
||||||
Sector12CityHall = "Sector-12 City Hall",
|
|
||||||
Sector12DeltaOne = "DeltaOne",
|
|
||||||
Sector12FoodNStuff = "FoodNStuff",
|
|
||||||
Sector12FourSigma = "Four Sigma",
|
|
||||||
Sector12IcarusMicrosystems = "Icarus Microsystems",
|
|
||||||
Sector12IronGym = "Iron Gym",
|
|
||||||
Sector12JoesGuns = "Joe's Guns",
|
|
||||||
Sector12MegaCorp = "MegaCorp",
|
|
||||||
Sector12NSA = "National Security Agency",
|
|
||||||
Sector12PowerhouseGym = "Powerhouse Gym",
|
|
||||||
Sector12RothmanUniversity = "Rothman University",
|
|
||||||
Sector12UniversalEnergy = "Universal Energy",
|
|
||||||
|
|
||||||
NewTokyoDefComm = "DefComm",
|
|
||||||
NewTokyoGlobalPharmaceuticals = "Global Pharmaceuticals",
|
|
||||||
NewTokyoNoodleBar = "Noodle Bar",
|
|
||||||
NewTokyoVitaLife = "VitaLife",
|
|
||||||
NewTokyoArcade = "Arcade",
|
|
||||||
|
|
||||||
IshimaNovaMedical = "Nova Medical",
|
|
||||||
IshimaOmegaSoftware = "Omega Software",
|
|
||||||
IshimaStormTechnologies = "Storm Technologies",
|
|
||||||
IshimaGlitch = "0x6C1",
|
|
||||||
|
|
||||||
VolhavenCompuTek = "CompuTek",
|
|
||||||
VolhavenHeliosLabs = "Helios Labs",
|
|
||||||
VolhavenLexoCorp = "LexoCorp",
|
|
||||||
VolhavenMilleniumFitnessGym = "Millenium Fitness Gym",
|
|
||||||
VolhavenNWO = "NWO",
|
|
||||||
VolhavenOmniTekIncorporated = "OmniTek Incorporated",
|
|
||||||
VolhavenOmniaCybersystems = "Omnia Cybersystems",
|
|
||||||
VolhavenSysCoreSecurities = "SysCore Securities",
|
|
||||||
VolhavenZBInstituteOfTechnology = "ZB Institute of Technology",
|
|
||||||
|
|
||||||
Hospital = "Hospital",
|
|
||||||
Slums = "The Slums",
|
|
||||||
TravelAgency = "Travel Agency",
|
|
||||||
WorldStockExchange = "World Stock Exchange",
|
|
||||||
|
|
||||||
Void = "The Void",
|
|
||||||
}
|
|
||||||
|
|
||||||
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 let Player: PlayerObject;
|
export let Player: PlayerObject;
|
||||||
|
|
||||||
// Base class representing a person-like object
|
// Base class representing a person-like object
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,18 @@ export function clampNumber(value: number, min: number = -Number.MAX_VALUE, max:
|
||||||
return Math.max(Math.min(value, max), min);
|
return Math.max(Math.min(value, max), min);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function clampInteger(value: number, min = -Number.MAX_SAFE_INTEGER, max = Number.MAX_SAFE_INTEGER) {
|
/**
|
||||||
|
* Clamps the value to an integer within a lower and an upper bound
|
||||||
|
* @param {number} value Value to clamp
|
||||||
|
* @param {number} min Lower bound, defaults to negative Number.MAX_SAFE_INTEGER
|
||||||
|
* @param {number} max Upper bound, defaults to Number.MAX_SAFE_INTEGER
|
||||||
|
* @returns {number} Clamped integer value
|
||||||
|
*/
|
||||||
|
export function clampInteger(
|
||||||
|
value: number,
|
||||||
|
min: number = -Number.MAX_SAFE_INTEGER,
|
||||||
|
max: number = Number.MAX_SAFE_INTEGER,
|
||||||
|
): number {
|
||||||
if (isNaN(value)) {
|
if (isNaN(value)) {
|
||||||
if (CONSTANTS.isDevBranch) throw new Error("NaN passed into clampInteger()");
|
if (CONSTANTS.isDevBranch) throw new Error("NaN passed into clampInteger()");
|
||||||
return min;
|
return min;
|
||||||
|
|
@ -26,6 +37,8 @@ export function clampInteger(value: number, min = -Number.MAX_SAFE_INTEGER, max
|
||||||
/**
|
/**
|
||||||
* Checks that a variable is a valid number. A valid number
|
* Checks that a variable is a valid number. A valid number
|
||||||
* must be a "number" type and cannot be NaN
|
* must be a "number" type and cannot be NaN
|
||||||
|
* @param {number} n The number to check
|
||||||
|
* @returns {boolean} True if n is a valid number, false otherwise
|
||||||
*/
|
*/
|
||||||
export function isValidNumber(n: number): boolean {
|
export function isValidNumber(n: number): boolean {
|
||||||
return typeof n === "number" && !isNaN(n);
|
return typeof n === "number" && !isNaN(n);
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
"isolatedModules": true,
|
"isolatedModules": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"inlineSourceMap": true,
|
"inlineSourceMap": true,
|
||||||
"moduleResolution": "node",
|
// "moduleResolution": "node",
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"paths": {
|
"paths": {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue