bitburner-src/src/PersonObjects/Person.ts

65 lines
1.9 KiB
TypeScript
Raw Normal View History

import type { Skills } from "./Skills";
import type { HP } from "./HP";
import type { Person as IPerson } from "@nsdefs";
import * as personMethods from "./PersonMethods";
import { CityName } from "@enums";
import { PlayerOwnedAugmentation } from "../Augmentation/PlayerOwnedAugmentation";
import { calculateSkill } from "./formulas/skill";
import { defaultMultipliers } from "./Multipliers";
import { IReviverValue } from "../utils/JSONReviver";
// Base class representing a person-like object
NETSCRIPT: ns.sleeve.getSleeve added. getPlayer and getSleeve can both be used for formulas. (#200) * BREAKING CHANGE: Removed getSleeveStats and getSleeveInformation because this info is provided by getSleeve in a more usable form. * BREAKING CHANGE: Removed tor, inBladeburner, and hasCorporation fields from ns.getPlayer. Functionality still exists via added functions ns.hasTorRouter, ns.corporation.hasCorporation, and ns.bladeburner.inBladeburner. * Separated ns definitions for Person, Sleeve, and Player interfaces with both Player and Sleeve just extending Person. Added getSleeve, which provides a Sleeve object similar to getPlayer. * Renamed the sleeve ns layer's interface as sleeve lowercase because of name conflict. todo: May move all the ns layers interface names to lowercase for consistency * Added ns.formulas.work.crimeSuccessChance and reworked to allow both sleeve and player calculations. * Removed internal Person.getIntelligenceBonus function which was just a wrapper for calculateIntelligenceBonus. Any use of the former in formulas creates a conflict where ns-provided Person objects throw an error. * Renamed helpers.player to helpers.person for netscript person validation. Reduced number of fields validated due to Person being a smaller interface. * Fixed bug in bladeburner where Player multipliers and int were being used no matter which person was performing the task * Fixed leak of Player.jobs at ns.getPlayer * Person / Player / Sleeve classes now implement the netscript equivalent interfaces. Netscript helper for person no longer asserts that it's a real Person class member, only that it's a Person interface. Functions that use netscript persons have been changed to expect just a person interface to prevent needing this incorrect type assertion.
2022-11-09 13:26:26 +01:00
export abstract class Person implements IPerson {
hp: HP = { current: 10, max: 10 };
skills: Skills = {
hacking: 1,
strength: 1,
defense: 1,
dexterity: 1,
agility: 1,
charisma: 1,
2022-08-15 15:38:10 +02:00
intelligence: 0,
};
exp: Skills = {
hacking: 0,
strength: 0,
defense: 0,
dexterity: 0,
agility: 0,
charisma: 0,
intelligence: 0,
};
2022-07-15 00:43:33 +02:00
mults = defaultMultipliers();
2022-09-27 19:27:17 +02:00
/** Augmentations */
augmentations: PlayerOwnedAugmentation[] = [];
queuedAugmentations: PlayerOwnedAugmentation[] = [];
2022-09-27 19:27:17 +02:00
/** City that the person is in */
2021-09-05 01:09:30 +02:00
city: CityName = CityName.Sector12;
gainHackingExp = personMethods.gainHackingExp;
gainStrengthExp = personMethods.gainStrengthExp;
gainDefenseExp = personMethods.gainDefenseExp;
gainDexterityExp = personMethods.gainDexterityExp;
gainAgilityExp = personMethods.gainAgilityExp;
gainCharismaExp = personMethods.gainCharismaExp;
gainIntelligenceExp = personMethods.gainIntelligenceExp;
gainStats = personMethods.gainStats;
regenerateHp = personMethods.regenerateHp;
updateSkillLevels = personMethods.updateSkillLevels;
2022-09-27 22:23:53 +02:00
hasAugmentation = personMethods.hasAugmentation;
calculateSkill = calculateSkill; //Class version is equal to imported version
2021-09-05 01:09:30 +02:00
2022-09-27 19:27:17 +02:00
/** Reset all multipliers to 1 */
resetMultipliers() {
2022-07-15 00:43:33 +02:00
this.mults = defaultMultipliers();
2021-09-05 01:09:30 +02:00
}
abstract takeDamage(amt: number): boolean;
abstract whoAmI(): string;
abstract toJSON(): IReviverValue;
}