2022-12-30 02:28:53 +01:00
|
|
|
import { Person as IPerson } from "@nsdefs";
|
2018-11-16 02:28:23 +01:00
|
|
|
import { CONSTANTS } from "../Constants";
|
2023-10-17 11:33:16 +02:00
|
|
|
import { JobName, JobField } from "@enums";
|
2023-12-18 13:23:47 +01:00
|
|
|
import type { Skills } from "../PersonObjects/Skills";
|
2023-07-11 15:23:17 +02:00
|
|
|
|
|
|
|
export interface CompanyPositionCtorParams {
|
2022-12-30 02:28:53 +01:00
|
|
|
nextPosition: JobName | null;
|
2023-10-17 11:33:16 +02:00
|
|
|
field: JobField;
|
2021-09-05 01:09:30 +02:00
|
|
|
baseSalary: number;
|
|
|
|
repMultiplier: number;
|
2023-12-18 13:23:47 +01:00
|
|
|
applyText?: string;
|
|
|
|
hiredText?: string;
|
|
|
|
isPartTime?: boolean;
|
2021-09-05 01:09:30 +02:00
|
|
|
|
|
|
|
reqdHacking?: number;
|
|
|
|
reqdStrength?: number;
|
|
|
|
reqdDefense?: number;
|
|
|
|
reqdDexterity?: number;
|
|
|
|
reqdAgility?: number;
|
|
|
|
reqdCharisma?: number;
|
|
|
|
reqdReputation?: number;
|
|
|
|
|
|
|
|
hackingEffectiveness?: number;
|
|
|
|
strengthEffectiveness?: number;
|
|
|
|
defenseEffectiveness?: number;
|
|
|
|
dexterityEffectiveness?: number;
|
|
|
|
agilityEffectiveness?: number;
|
|
|
|
charismaEffectiveness?: number;
|
|
|
|
|
|
|
|
hackingExpGain?: number;
|
|
|
|
strengthExpGain?: number;
|
|
|
|
defenseExpGain?: number;
|
|
|
|
dexterityExpGain?: number;
|
|
|
|
agilityExpGain?: number;
|
|
|
|
charismaExpGain?: number;
|
2018-10-31 20:57:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export class CompanyPosition {
|
2022-10-04 12:40:10 +02:00
|
|
|
/** Position title */
|
2022-12-30 02:28:53 +01:00
|
|
|
name: JobName;
|
2021-09-05 01:09:30 +02:00
|
|
|
|
2023-10-17 11:33:16 +02:00
|
|
|
/** Field type of the position (software, it, business, etc) */
|
|
|
|
field: JobField;
|
|
|
|
|
2022-10-04 12:40:10 +02:00
|
|
|
/** Title of next position to be promoted to */
|
2022-12-30 02:28:53 +01:00
|
|
|
nextPosition: JobName | null;
|
2021-09-05 01:09:30 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Base salary for this position ($ per 200ms game cycle)
|
|
|
|
* Will be multiplier by a company-specific multiplier for final salary
|
|
|
|
*/
|
|
|
|
baseSalary: number;
|
|
|
|
|
2022-10-04 12:40:10 +02:00
|
|
|
/** Reputation multiplier */
|
2021-09-05 01:09:30 +02:00
|
|
|
repMultiplier: number;
|
|
|
|
|
2023-12-18 13:23:47 +01:00
|
|
|
/** Text to display when applying for this job */
|
|
|
|
applyText: string;
|
|
|
|
|
|
|
|
/** Text to display when receiving this job */
|
|
|
|
hiredText: string;
|
|
|
|
|
|
|
|
/** Whether this position is part-time */
|
|
|
|
isPartTime: boolean;
|
|
|
|
|
2022-10-04 12:40:10 +02:00
|
|
|
/** Required stats to earn this position */
|
2021-09-05 01:09:30 +02:00
|
|
|
requiredAgility: number;
|
|
|
|
requiredCharisma: number;
|
|
|
|
requiredDefense: number;
|
|
|
|
requiredDexterity: number;
|
|
|
|
requiredHacking: number;
|
|
|
|
requiredStrength: number;
|
|
|
|
|
2022-10-04 12:40:10 +02:00
|
|
|
/** Required company reputation to earn this position */
|
2021-09-05 01:09:30 +02:00
|
|
|
requiredReputation: number;
|
|
|
|
|
2022-10-04 12:40:10 +02:00
|
|
|
/** Effectiveness of each stat time for job performance */
|
2021-09-05 01:09:30 +02:00
|
|
|
hackingEffectiveness: number;
|
|
|
|
strengthEffectiveness: number;
|
|
|
|
defenseEffectiveness: number;
|
|
|
|
dexterityEffectiveness: number;
|
|
|
|
agilityEffectiveness: number;
|
|
|
|
charismaEffectiveness: number;
|
|
|
|
|
2022-10-04 12:40:10 +02:00
|
|
|
/** Experience gain for performing job (per 200ms game cycle) */
|
2021-09-05 01:09:30 +02:00
|
|
|
hackingExpGain: number;
|
|
|
|
strengthExpGain: number;
|
|
|
|
defenseExpGain: number;
|
|
|
|
dexterityExpGain: number;
|
|
|
|
agilityExpGain: number;
|
|
|
|
charismaExpGain: number;
|
|
|
|
|
2023-07-11 15:23:17 +02:00
|
|
|
constructor(name: JobName, p: CompanyPositionCtorParams) {
|
|
|
|
this.name = name;
|
2023-10-17 11:33:16 +02:00
|
|
|
this.field = p.field;
|
2021-09-05 01:09:30 +02:00
|
|
|
this.nextPosition = p.nextPosition;
|
|
|
|
this.baseSalary = p.baseSalary;
|
|
|
|
this.repMultiplier = p.repMultiplier;
|
2023-12-18 13:23:47 +01:00
|
|
|
this.isPartTime = p.isPartTime ?? false;
|
|
|
|
this.applyText = p.applyText ?? `Apply for ${this.name} Job`;
|
|
|
|
this.hiredText = p.hiredText ?? `Congratulations, you are now employed as a ${this.name}`;
|
2021-09-05 01:09:30 +02:00
|
|
|
|
|
|
|
this.requiredHacking = p.reqdHacking != null ? p.reqdHacking : 0;
|
|
|
|
this.requiredStrength = p.reqdStrength != null ? p.reqdStrength : 0;
|
|
|
|
this.requiredDefense = p.reqdDefense != null ? p.reqdDefense : 0;
|
|
|
|
this.requiredDexterity = p.reqdDexterity != null ? p.reqdDexterity : 0;
|
|
|
|
this.requiredAgility = p.reqdAgility != null ? p.reqdAgility : 0;
|
|
|
|
this.requiredCharisma = p.reqdCharisma != null ? p.reqdCharisma : 0;
|
|
|
|
this.requiredReputation = p.reqdReputation != null ? p.reqdReputation : 0;
|
|
|
|
|
2021-09-09 05:47:34 +02:00
|
|
|
this.hackingEffectiveness = p.hackingEffectiveness != null ? p.hackingEffectiveness : 0;
|
|
|
|
this.strengthEffectiveness = p.strengthEffectiveness != null ? p.strengthEffectiveness : 0;
|
|
|
|
this.defenseEffectiveness = p.defenseEffectiveness != null ? p.defenseEffectiveness : 0;
|
|
|
|
this.dexterityEffectiveness = p.dexterityEffectiveness != null ? p.dexterityEffectiveness : 0;
|
|
|
|
this.agilityEffectiveness = p.agilityEffectiveness != null ? p.agilityEffectiveness : 0;
|
|
|
|
this.charismaEffectiveness = p.charismaEffectiveness != null ? p.charismaEffectiveness : 0;
|
2021-09-05 01:09:30 +02:00
|
|
|
|
|
|
|
if (
|
|
|
|
Math.round(
|
|
|
|
this.hackingEffectiveness +
|
|
|
|
this.strengthEffectiveness +
|
|
|
|
this.defenseEffectiveness +
|
|
|
|
this.dexterityEffectiveness +
|
|
|
|
this.agilityEffectiveness +
|
|
|
|
this.charismaEffectiveness,
|
|
|
|
) !== 100
|
|
|
|
) {
|
2021-09-09 05:47:34 +02:00
|
|
|
console.error(`CompanyPosition ${this.name} parameters do not sum to 100`);
|
2018-10-31 20:57:47 +01:00
|
|
|
}
|
|
|
|
|
2021-09-05 01:09:30 +02:00
|
|
|
this.hackingExpGain = p.hackingExpGain != null ? p.hackingExpGain : 0;
|
|
|
|
this.strengthExpGain = p.strengthExpGain != null ? p.strengthExpGain : 0;
|
|
|
|
this.defenseExpGain = p.defenseExpGain != null ? p.defenseExpGain : 0;
|
|
|
|
this.dexterityExpGain = p.dexterityExpGain != null ? p.dexterityExpGain : 0;
|
|
|
|
this.agilityExpGain = p.agilityExpGain != null ? p.agilityExpGain : 0;
|
|
|
|
this.charismaExpGain = p.charismaExpGain != null ? p.charismaExpGain : 0;
|
|
|
|
}
|
|
|
|
|
2023-12-18 13:23:47 +01:00
|
|
|
requiredSkills(jobStatReqOffset: number): Skills {
|
|
|
|
return {
|
|
|
|
hacking: this.requiredHacking > 0 ? this.requiredHacking + jobStatReqOffset : 0,
|
|
|
|
strength: this.requiredStrength > 0 ? this.requiredStrength + jobStatReqOffset : 0,
|
|
|
|
defense: this.requiredDefense > 0 ? this.requiredDefense + jobStatReqOffset : 0,
|
|
|
|
dexterity: this.requiredDexterity > 0 ? this.requiredDexterity + jobStatReqOffset : 0,
|
|
|
|
agility: this.requiredAgility > 0 ? this.requiredAgility + jobStatReqOffset : 0,
|
|
|
|
charisma: this.requiredCharisma > 0 ? this.requiredCharisma + jobStatReqOffset : 0,
|
|
|
|
intelligence: 0,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-11-09 13:26:26 +01:00
|
|
|
calculateJobPerformance(worker: IPerson): number {
|
2022-11-06 23:27:04 +01:00
|
|
|
const hackRatio: number = (this.hackingEffectiveness * worker.skills.hacking) / CONSTANTS.MaxSkillLevel;
|
|
|
|
const strRatio: number = (this.strengthEffectiveness * worker.skills.strength) / CONSTANTS.MaxSkillLevel;
|
|
|
|
const defRatio: number = (this.defenseEffectiveness * worker.skills.defense) / CONSTANTS.MaxSkillLevel;
|
|
|
|
const dexRatio: number = (this.dexterityEffectiveness * worker.skills.dexterity) / CONSTANTS.MaxSkillLevel;
|
|
|
|
const agiRatio: number = (this.agilityEffectiveness * worker.skills.agility) / CONSTANTS.MaxSkillLevel;
|
|
|
|
const chaRatio: number = (this.charismaEffectiveness * worker.skills.charisma) / CONSTANTS.MaxSkillLevel;
|
2021-09-05 01:09:30 +02:00
|
|
|
|
|
|
|
let reputationGain: number =
|
2021-09-09 05:47:34 +02:00
|
|
|
(this.repMultiplier * (hackRatio + strRatio + defRatio + dexRatio + agiRatio + chaRatio)) / 100;
|
2021-09-05 01:09:30 +02:00
|
|
|
if (isNaN(reputationGain)) {
|
|
|
|
console.error("Company reputation gain calculated to be NaN");
|
|
|
|
reputationGain = 0;
|
2018-10-31 20:57:47 +01:00
|
|
|
}
|
2022-11-06 23:27:04 +01:00
|
|
|
reputationGain += worker.skills.intelligence / CONSTANTS.MaxSkillLevel;
|
2021-09-05 01:09:30 +02:00
|
|
|
return reputationGain;
|
|
|
|
}
|
2018-10-31 20:57:47 +01:00
|
|
|
}
|