bitburner-src/src/PersonObjects/Person.ts
Snarling 8e0e0eaa88
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 07:26:26 -05:00

65 lines
2.0 KiB
TypeScript

import * as personMethods from "./PersonMethods";
import { PlayerOwnedAugmentation } from "../Augmentation/PlayerOwnedAugmentation";
import { CityName } from "../Locations/data/CityNames";
import { calculateSkill } from "./formulas/skill";
import { defaultMultipliers } from "./Multipliers";
import { Skills } from "./Skills";
import { HP } from "./HP";
import { Person as IPerson } from "../ScriptEditor/NetscriptDefinitions";
import { IReviverValue } from "../utils/JSONReviver";
// Base class representing a person-like object
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,
intelligence: 0,
};
exp: Skills = {
hacking: 0,
strength: 0,
defense: 0,
dexterity: 0,
agility: 0,
charisma: 0,
intelligence: 0,
};
mults = defaultMultipliers();
/** Augmentations */
augmentations: PlayerOwnedAugmentation[] = [];
queuedAugmentations: PlayerOwnedAugmentation[] = [];
/** City that the person is in */
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;
queryStatFromString = personMethods.queryStatFromString;
updateSkillLevels = personMethods.updateSkillLevels;
hasAugmentation = personMethods.hasAugmentation;
calculateSkill = calculateSkill; //Class version is equal to imported version
/** Reset all multipliers to 1 */
resetMultipliers() {
this.mults = defaultMultipliers();
}
abstract takeDamage(amt: number): boolean;
abstract whoAmI(): string;
abstract toJSON(): IReviverValue;
}