mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-28 03:47:03 +02:00
Finished location code refactor. Has not yet been tested
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
// Interface for an object that represents the player (PlayerObject)
|
||||
// Used because at the time of implementation, the PlayerObject
|
||||
// cant be converted to TypeScript.
|
||||
//
|
||||
// Only contains the needed properties for Sleeve implementation
|
||||
/**
|
||||
* Interface for an object that represents the player (PlayerObject)
|
||||
* Used because at the time of implementation, the PlayerObject
|
||||
* cant be converted to TypeScript.
|
||||
*/
|
||||
import { Resleeve } from "./Resleeving/Resleeve";
|
||||
import { Sleeve } from "./Sleeve/Sleeve";
|
||||
|
||||
@@ -12,9 +12,10 @@ import { IPlayerOwnedAugmentation } from "../Augmentation/PlayerOwnedAugment
|
||||
import { Company } from "../Company/Company";
|
||||
import { CompanyPosition } from "../Company/CompanyPosition";
|
||||
import { CityName } from "../Locations/data/CityNames";
|
||||
import { HashManager } from "../Hacknet/HashManager";
|
||||
import { HacknetNode } from "../Hacknet/HacknetNode";
|
||||
import { HacknetServer } from "../Hacknet/HacknetServer";
|
||||
import { LocationName } from "../Locations/data/LocationNames";
|
||||
import { Server } from "../Server/Server";
|
||||
import { IPlayerOwnedSourceFile } from "../SourceFile/PlayerOwnedSourceFile";
|
||||
import { MoneySourceTracker } from "../utils/MoneySourceTracker";
|
||||
|
||||
@@ -28,11 +29,15 @@ export interface IPlayer {
|
||||
corporation: any;
|
||||
currentServer: string;
|
||||
factions: string[];
|
||||
firstTimeTraveled: boolean;
|
||||
hacknetNodes: (HacknetNode | string)[]; // HacknetNode object or IP of Hacknet Server
|
||||
hashManager: HashManager;
|
||||
hasWseAccount: boolean;
|
||||
hp: number;
|
||||
jobs: IMap<string>;
|
||||
karma: number;
|
||||
location: LocationName;
|
||||
max_hp: number;
|
||||
money: any;
|
||||
moneySourceA: MoneySourceTracker;
|
||||
moneySourceB: MoneySourceTracker;
|
||||
@@ -114,15 +119,22 @@ export interface IPlayer {
|
||||
gainAgilityExp(exp: number): void;
|
||||
gainCharismaExp(exp: number): void;
|
||||
gainMoney(money: number): void;
|
||||
getHomeComputer(): Server;
|
||||
getNextCompanyPosition(company: Company, entryPosType: CompanyPosition): CompanyPosition;
|
||||
getUpgradeHomeRamCost(): number;
|
||||
hasCorporation(): boolean;
|
||||
hasTorRouter(): boolean;
|
||||
inBladeburner(): boolean;
|
||||
inGang(): boolean;
|
||||
isQualified(company: Company, position: CompanyPosition): boolean;
|
||||
loseMoney(money: number): void;
|
||||
reapplyAllAugmentations(resetMultipliers: boolean): void;
|
||||
reapplyAllSourceFiles(): void;
|
||||
regenerateHp(amt: number): void;
|
||||
recordMoneySource(amt: number, source: string): void;
|
||||
startBladeburner(p: object): void;
|
||||
startClass(costMult: number, expMult: number, className: string): void;
|
||||
startCorporation(corpName: string, additionalShares?: number): void;
|
||||
startCrime(crimeType: string,
|
||||
hackExp: number,
|
||||
strExp: number,
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
import { PlayerObject } from "../../Player";
|
||||
import { Cities } from "../../Locations/Cities";
|
||||
|
||||
PlayerObject.prototype.travel = function(to) {
|
||||
if (Cities[to] == null) {
|
||||
console.warn(`Player.travel() called with invalid city: ${to}`);
|
||||
return false;
|
||||
}
|
||||
this.city = to;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -22,8 +22,6 @@ import { BitNodeMultipliers } from "../../BitNode/BitNodeMultipliers";
|
||||
import { Crime } from "../../Crime/Crime";
|
||||
import { Crimes } from "../../Crime/Crimes";
|
||||
|
||||
import { CityName } from "../../Locations/data/CityNames";
|
||||
|
||||
import { Companies } from "../../Company/Companies";
|
||||
import { Company } from "../../Company/Company";
|
||||
import { CompanyPosition } from "../../Company/CompanyPosition";
|
||||
@@ -35,7 +33,8 @@ import { Faction } from "../../Faction/Faction";
|
||||
import { Factions } from "../../Faction/Factions";
|
||||
import { FactionWorkType } from "../../Faction/FactionWorkTypeEnum";
|
||||
|
||||
import { Locations } from "../../Locations";
|
||||
import { CityName } from "../../Locations/data/CityNames";
|
||||
import { LocationName } from "../../Locations/data/LocationNames";
|
||||
|
||||
import { Generic_fromJSON, Generic_toJSON, Reviver } from "../../../utils/JSONReviver";
|
||||
|
||||
@@ -586,21 +585,21 @@ export class Sleeve extends Person {
|
||||
let costMult: number = 1;
|
||||
let expMult: number = 1;
|
||||
switch (universityName.toLowerCase()) {
|
||||
case Locations.AevumSummitUniversity.toLowerCase():
|
||||
case LocationName.AevumSummitUniversity.toLowerCase():
|
||||
if (this.city !== CityName.Aevum) { return false; }
|
||||
this.currentTaskLocation = Locations.AevumSummitUniversity;
|
||||
this.currentTaskLocation = LocationName.AevumSummitUniversity;
|
||||
costMult = 4;
|
||||
expMult = 3;
|
||||
break;
|
||||
case Locations.Sector12RothmanUniversity.toLowerCase():
|
||||
case LocationName.Sector12RothmanUniversity.toLowerCase():
|
||||
if (this.city !== CityName.Sector12) { return false; }
|
||||
this.currentTaskLocation = Locations.Sector12RothmanUniversity;
|
||||
this.currentTaskLocation = LocationName.Sector12RothmanUniversity;
|
||||
costMult = 3;
|
||||
expMult = 2;
|
||||
break;
|
||||
case Locations.VolhavenZBInstituteOfTechnology.toLowerCase():
|
||||
case LocationName.VolhavenZBInstituteOfTechnology.toLowerCase():
|
||||
if (this.city !== CityName.Volhaven) { return false; }
|
||||
this.currentTaskLocation = Locations.VolhavenZBInstituteOfTechnology;
|
||||
this.currentTaskLocation = LocationName.VolhavenZBInstituteOfTechnology;
|
||||
costMult = 5;
|
||||
expMult = 4;
|
||||
break;
|
||||
@@ -781,33 +780,33 @@ export class Sleeve extends Person {
|
||||
let costMult: number = 1;
|
||||
let expMult: number = 1;
|
||||
switch (gymName.toLowerCase()) {
|
||||
case Locations.AevumCrushFitnessGym.toLowerCase():
|
||||
case LocationName.AevumCrushFitnessGym.toLowerCase():
|
||||
if (this.city != CityName.Aevum) { return false; }
|
||||
this.currentTaskLocation = Locations.AevumCrushFitnessGym;
|
||||
this.currentTaskLocation = LocationName.AevumCrushFitnessGym;
|
||||
costMult = 3;
|
||||
expMult = 2;
|
||||
break;
|
||||
case Locations.AevumSnapFitnessGym.toLowerCase():
|
||||
case LocationName.AevumSnapFitnessGym.toLowerCase():
|
||||
if (this.city != CityName.Aevum) { return false; }
|
||||
this.currentTaskLocation = Locations.AevumSnapFitnessGym;
|
||||
this.currentTaskLocation = LocationName.AevumSnapFitnessGym;
|
||||
costMult = 10;
|
||||
expMult = 5;
|
||||
break;
|
||||
case Locations.Sector12IronGym.toLowerCase():
|
||||
case LocationName.Sector12IronGym.toLowerCase():
|
||||
if (this.city != CityName.Sector12) { return false; }
|
||||
this.currentTaskLocation = Locations.Sector12IronGym;
|
||||
this.currentTaskLocation = LocationName.Sector12IronGym;
|
||||
costMult = 1;
|
||||
expMult = 1;
|
||||
break;
|
||||
case Locations.Sector12PowerhouseGym.toLowerCase():
|
||||
case LocationName.Sector12PowerhouseGym.toLowerCase():
|
||||
if (this.city != CityName.Sector12) { return false; }
|
||||
this.currentTaskLocation = Locations.Sector12PowerhouseGym;
|
||||
this.currentTaskLocation = LocationName.Sector12PowerhouseGym;
|
||||
costMult = 20;
|
||||
expMult = 10;
|
||||
break;
|
||||
case Locations.VolhavenMilleniumFitnessGym:
|
||||
case LocationName.VolhavenMilleniumFitnessGym:
|
||||
if (this.city != CityName.Volhaven) { return false; }
|
||||
this.currentTaskLocation = Locations.VolhavenMilleniumFitnessGym;
|
||||
this.currentTaskLocation = LocationName.VolhavenMilleniumFitnessGym;
|
||||
costMult = 7;
|
||||
expMult = 4;
|
||||
break;
|
||||
|
||||
@@ -9,15 +9,16 @@ import { SleeveFaq } from "./data/SleeveFaq";
|
||||
import { IPlayer } from "../IPlayer";
|
||||
|
||||
import { CONSTANTS } from "../../Constants";
|
||||
import { Locations } from "../../Locations";
|
||||
|
||||
import { Faction } from "../../Faction/Faction";
|
||||
import { Factions } from "../../Faction/Factions";
|
||||
import { FactionWorkType } from "../../Faction/FactionWorkTypeEnum";
|
||||
|
||||
import { Cities } from "../../Locations/Cities";
|
||||
import { Crime } from "../../Crime/Crime";
|
||||
import { Crimes } from "../../Crime/Crimes";
|
||||
import { Cities } from "../../Locations/Cities";
|
||||
import { CityName } from "../../Locations/data/CityNames";
|
||||
import { LocationName } from "../../Locations/data/LocationNames";
|
||||
|
||||
import { numeralWrapper } from "../../ui/numeralFormat";
|
||||
import { Page,
|
||||
@@ -243,20 +244,20 @@ function createSleeveUi(sleeve: Sleeve, allSleeves: Sleeve[]): ISleeveUIElems {
|
||||
`Traveling to a different city costs ${numeralWrapper.formatMoney(CONSTANTS.TravelCost)}. ` +
|
||||
"It will also CANCEL the sleeve's current task (setting it to idle)",
|
||||
}));
|
||||
for (const label in Cities) {
|
||||
if (sleeve.city === Cities[label]) { continue; }
|
||||
(function(sleeve, label) {
|
||||
for (const cityName in Cities) {
|
||||
if (sleeve.city === cityName) { continue; }
|
||||
(function(sleeve, cityName) {
|
||||
popupArguments.push(createElement("div", {
|
||||
// Reusing this css class. It adds a border and makes it so that
|
||||
// the background color changes when you hover
|
||||
class: "cmpy-mgmt-find-employee-option",
|
||||
innerText: Cities[label],
|
||||
innerText: cityName,
|
||||
clickListener: () => {
|
||||
if (!playerRef!.canAfford(CONSTANTS.TravelCost)) {
|
||||
dialogBoxCreate("You cannot afford to have this sleeve travel to another city", false);
|
||||
return false;
|
||||
}
|
||||
sleeve.city = Cities[label];
|
||||
sleeve.city = <CityName>cityName;
|
||||
playerRef!.loseMoney(CONSTANTS.TravelCost);
|
||||
sleeve.resetTaskStatus();
|
||||
removeElementById(popupId);
|
||||
@@ -265,7 +266,7 @@ function createSleeveUi(sleeve: Sleeve, allSleeves: Sleeve[]): ISleeveUIElems {
|
||||
return false;
|
||||
}
|
||||
}));
|
||||
})(sleeve, label);
|
||||
})(sleeve, cityName);
|
||||
}
|
||||
|
||||
createPopup(popupId, popupArguments);
|
||||
@@ -569,14 +570,14 @@ function updateSleeveTaskSelector(sleeve: Sleeve, elems: ISleeveUIElems, allSlee
|
||||
|
||||
// Second selector has which university
|
||||
switch (sleeve.city) {
|
||||
case Cities.Aevum:
|
||||
elems.taskDetailsSelector2!.add(createOptionElement(Locations.AevumSummitUniversity));
|
||||
case CityName.Aevum:
|
||||
elems.taskDetailsSelector2!.add(createOptionElement(LocationName.AevumSummitUniversity));
|
||||
break;
|
||||
case Cities.Sector12:
|
||||
elems.taskDetailsSelector2!.add(createOptionElement(Locations.Sector12RothmanUniversity));
|
||||
case CityName.Sector12:
|
||||
elems.taskDetailsSelector2!.add(createOptionElement(LocationName.Sector12RothmanUniversity));
|
||||
break;
|
||||
case Cities.Volhaven:
|
||||
elems.taskDetailsSelector2!.add(createOptionElement(Locations.VolhavenZBInstituteOfTechnology));
|
||||
case CityName.Volhaven:
|
||||
elems.taskDetailsSelector2!.add(createOptionElement(LocationName.VolhavenZBInstituteOfTechnology));
|
||||
break;
|
||||
default:
|
||||
elems.taskDetailsSelector2!.add(createOptionElement("No university available in city!"));
|
||||
@@ -597,30 +598,30 @@ function updateSleeveTaskSelector(sleeve: Sleeve, elems: ISleeveUIElems, allSlee
|
||||
// Second selector has gym
|
||||
// In this switch statement we also set the initial value of the second selector
|
||||
switch (sleeve.city) {
|
||||
case Cities.Aevum:
|
||||
elems.taskDetailsSelector2!.add(createOptionElement(Locations.AevumCrushFitnessGym));
|
||||
elems.taskDetailsSelector2!.add(createOptionElement(Locations.AevumSnapFitnessGym));
|
||||
case CityName.Aevum:
|
||||
elems.taskDetailsSelector2!.add(createOptionElement(LocationName.AevumCrushFitnessGym));
|
||||
elems.taskDetailsSelector2!.add(createOptionElement(LocationName.AevumSnapFitnessGym));
|
||||
|
||||
// Set initial value
|
||||
if (sleeve.currentTaskLocation === Locations.AevumCrushFitnessGym) {
|
||||
if (sleeve.currentTaskLocation === LocationName.AevumCrushFitnessGym) {
|
||||
elems.taskDetailsSelector2!.selectedIndex = 0;
|
||||
} else if (sleeve.currentTaskLocation === Locations.AevumSnapFitnessGym) {
|
||||
} else if (sleeve.currentTaskLocation === LocationName.AevumSnapFitnessGym) {
|
||||
elems.taskDetailsSelector2!.selectedIndex = 1;
|
||||
}
|
||||
break;
|
||||
case Cities.Sector12:
|
||||
elems.taskDetailsSelector2!.add(createOptionElement(Locations.Sector12IronGym));
|
||||
elems.taskDetailsSelector2!.add(createOptionElement(Locations.Sector12PowerhouseGym));
|
||||
case CityName.Sector12:
|
||||
elems.taskDetailsSelector2!.add(createOptionElement(LocationName.Sector12IronGym));
|
||||
elems.taskDetailsSelector2!.add(createOptionElement(LocationName.Sector12PowerhouseGym));
|
||||
|
||||
// Set initial value
|
||||
if (sleeve.currentTaskLocation === Locations.Sector12IronGym) {
|
||||
if (sleeve.currentTaskLocation === LocationName.Sector12IronGym) {
|
||||
elems.taskDetailsSelector2!.selectedIndex = 0;
|
||||
} else if (sleeve.currentTaskLocation === Locations.Sector12PowerhouseGym) {
|
||||
} else if (sleeve.currentTaskLocation === LocationName.Sector12PowerhouseGym) {
|
||||
elems.taskDetailsSelector2!.selectedIndex = 1;
|
||||
}
|
||||
break;
|
||||
case Cities.Volhaven:
|
||||
elems.taskDetailsSelector2!.add(createOptionElement(Locations.VolhavenMilleniumFitnessGym));
|
||||
case CityName.Volhaven:
|
||||
elems.taskDetailsSelector2!.add(createOptionElement(LocationName.VolhavenMilleniumFitnessGym));
|
||||
break;
|
||||
default:
|
||||
elems.taskDetailsSelector2!.add(createOptionElement("No gym available in city!"));
|
||||
|
||||
Reference in New Issue
Block a user