MISC: Rework reputation bonus after installing a backdoor (#1236)

This commit is contained in:
catloversg 2024-04-29 08:35:56 +07:00 committed by GitHub
parent 4d3dbf169d
commit d4bdb8de2b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 33 additions and 8 deletions

@ -1,4 +1,6 @@
import type { CompanyName, LocationName } from "@enums";
import { CONSTANTS } from "../Constants";
import { isBackdoorInstalledInCompanyServer } from "../Server/ServerHelpers";
type LocationNameString = `${LocationName}`;
type CompanyNameString = `${CompanyName}`;
@ -9,3 +11,9 @@ export function companyNameAsLocationName(companyName: CompanyName): LocationNam
// Due to the check above, we know that all company names are valid location names.
return companyName as unknown as LocationName;
}
export function calculateEffectiveRequiredReputation(companyName: CompanyName, reputation: number): number {
return (
reputation * (isBackdoorInstalledInCompanyServer(companyName) ? CONSTANTS.CompanyRequiredReputationMultiplier : 1)
);
}

@ -53,6 +53,7 @@ export const CONSTANTS: {
SoARepMult: number;
EntropyEffect: number;
Donations: number; // number of blood/plasma/palette donation the dev have verified., boosts NFG
CompanyRequiredReputationMultiplier: number; // Only use this if a backdoor is installed in the company's server
LatestUpdate: string;
} = {
VersionString: "2.6.1dev",
@ -153,6 +154,8 @@ export const CONSTANTS: {
Donations: 151,
CompanyRequiredReputationMultiplier: 0.75,
// Also update doc/source/changelog.rst
LatestUpdate: `
## v2.6.1 dev - last updated 23 Apr 2024

@ -31,6 +31,8 @@
### Megacorporations
If you install a backdoor on a company's server, the required reputation of that company faction is reduced by 25%.
| Faction Name | Requirements |
| --------------------------- | ----------------------------------------------------------------------------------------------------- |
| ECorp | \* Have 400k reputation with the Corporation |

@ -3,7 +3,6 @@ import { ServerName } from "../Types/strings";
import { Server } from "../Server/Server";
import { GetServer } from "../Server/AllServers";
import { HacknetServer } from "../Hacknet/HacknetServer";
import { serverMetadata } from "../Server/data/servers";
import { Companies } from "../Company/Companies";
import { formatReputation, formatMoney, formatRam } from "../ui/formatNumber";
import type { PlayerObject } from "../PersonObjects/Player/PlayerObject";
@ -29,6 +28,7 @@ import type {
SomeRequirement,
EveryRequirement,
} from "@nsdefs";
import { calculateEffectiveRequiredReputation } from "../Company/utils";
/**
* Declarative format for checking that the player satisfies some condition, such as the requirements for being invited to a faction.
@ -69,18 +69,19 @@ export const employedBy = (companyName: CompanyName): PlayerCondition => ({
export const haveCompanyRep = (companyName: CompanyName, rep: number): PlayerCondition => ({
toString(): string {
return `${formatReputation(rep)} reputation with ${companyName}`;
return `${formatReputation(calculateEffectiveRequiredReputation(companyName, rep))} reputation with ${companyName}`;
},
toJSON(): CompanyReputationRequirement {
return { type: "companyReputation", company: companyName, reputation: rep };
return {
type: "companyReputation",
company: companyName,
reputation: calculateEffectiveRequiredReputation(companyName, rep),
};
},
isSatisfied(): boolean {
const company = Companies[companyName];
if (!company) return false;
const serverMeta = serverMetadata.find((s) => s.specialName === companyName);
const server = GetServer(serverMeta ? serverMeta.hostname : "");
const bonus = server?.backdoorInstalled ? 100e3 : 0;
return company.playerReputation + bonus >= rep;
return company.playerReputation >= calculateEffectiveRequiredReputation(companyName, rep);
},
});

@ -57,6 +57,7 @@ import { getRecordEntries } from "../Types/Record";
import { JobTracks } from "../Company/data/JobTracks";
import { ServerConstants } from "../Server/data/Constants";
import { blackOpsArray } from "../Bladeburner/data/BlackOperations";
import { calculateEffectiveRequiredReputation } from "../Company/utils";
export function NetscriptSingularity(): InternalAPI<ISingularity> {
const runAfterReset = function (cbScript: ScriptFilePath) {
@ -691,7 +692,7 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
field: job.field,
nextPosition: job.nextPosition,
salary: job.baseSalary * company.salaryMultiplier,
requiredReputation: job.requiredReputation,
requiredReputation: calculateEffectiveRequiredReputation(companyName, job.requiredReputation),
requiredSkills: job.requiredSkills(company.jobStatReqOffset),
};
return res;

@ -10,6 +10,7 @@ import { Person as IPerson } from "@nsdefs";
import { Server as IServer } from "@nsdefs";
import { workerScripts } from "../Netscript/WorkerScripts";
import { killWorkerScriptByPid } from "../Netscript/killWorkerScript";
import { serverMetadata } from "./data/servers";
/**
* Constructs a new server, while also ensuring that the new server
@ -236,6 +237,15 @@ export function isBackdoorInstalled(server: BaseServer): boolean {
return false;
}
export function isBackdoorInstalledInCompanyServer(companyName: string): boolean {
const serverMeta = serverMetadata.find((s) => s.specialName === companyName);
const server = GetServer(serverMeta ? serverMeta.hostname : "");
if (!server) {
return false;
}
return isBackdoorInstalled(server);
}
export function getCoreBonus(cores = 1): number {
const coreBonus = 1 + (cores - 1) / 16;
return coreBonus;