bitburner-src/src/Company/GetJobRequirementText.ts

55 lines
2.0 KiB
TypeScript
Raw Normal View History

import { Company } from "./Company";
import { CompanyPosition } from "./CompanyPosition";
/**
* Returns a string with the given CompanyPosition's stat requirements
*/
2021-09-09 05:47:34 +02:00
export function getJobRequirementText(company: Company, pos: CompanyPosition, tooltiptext = false): string {
2021-09-05 01:09:30 +02:00
let reqText = "";
const offset: number = company.jobStatReqOffset;
2021-09-09 05:47:34 +02:00
const reqHacking: number = pos.requiredHacking > 0 ? pos.requiredHacking + offset : 0;
const reqStrength: number = pos.requiredStrength > 0 ? pos.requiredStrength + offset : 0;
const reqDefense: number = pos.requiredDefense > 0 ? pos.requiredDefense + offset : 0;
const reqDexterity: number = pos.requiredDexterity > 0 ? pos.requiredDexterity + offset : 0;
const reqAgility: number = pos.requiredDexterity > 0 ? pos.requiredDexterity + offset : 0;
const reqCharisma: number = pos.requiredCharisma > 0 ? pos.requiredCharisma + offset : 0;
2021-09-05 01:09:30 +02:00
const reqRep: number = pos.requiredReputation;
if (tooltiptext) {
reqText = "Requires:<br>";
reqText += reqHacking.toString() + " hacking<br>";
reqText += reqStrength.toString() + " strength<br>";
reqText += reqDefense.toString() + " defense<br>";
reqText += reqDexterity.toString() + " dexterity<br>";
reqText += reqAgility.toString() + " agility<br>";
reqText += reqCharisma.toString() + " charisma<br>";
reqText += reqRep.toString() + " reputation";
} else {
reqText = "(Requires ";
if (reqHacking > 0) {
reqText += reqHacking + " hacking, ";
}
2021-09-05 01:09:30 +02:00
if (reqStrength > 0) {
reqText += reqStrength + " strength, ";
}
if (reqDefense > 0) {
reqText += reqDefense + " defense, ";
}
if (reqDexterity > 0) {
reqText += reqDexterity + " dexterity, ";
}
if (reqAgility > 0) {
reqText += reqAgility + " agility, ";
}
if (reqCharisma > 0) {
reqText += reqCharisma + " charisma, ";
}
if (reqRep > 1) {
reqText += reqRep + " reputation, ";
}
reqText = reqText.substring(0, reqText.length - 2);
reqText += ")";
}
return reqText;
}