diff --git a/src/Company/Company.ts b/src/Company/Company.ts index 98e8e3c8c..52dc44cd1 100644 --- a/src/Company/Company.ts +++ b/src/Company/Company.ts @@ -1,8 +1,11 @@ -import { Generic_fromJSON, Generic_toJSON, Reviver } from "../../utils/JSONReviver"; import { CompanyPosition } from "./CompanyPosition"; +import * as posNames from "./data/companypositionnames"; + import { CONSTANTS } from "../Constants"; import { IMap } from "../types"; +import { Generic_fromJSON, Generic_toJSON, Reviver } from "../../utils/JSONReviver"; + export interface IConstructorParams { name: string; info: string; @@ -93,6 +96,43 @@ export class Company { } } + hasAgentPositions(): boolean { + return (this.companyPositions[posNames.AgentCompanyPositions[0]] != null); + } + + hasBusinessConsultantPositions(): boolean { + return (this.companyPositions[posNames.BusinessConsultantCompanyPositions[0]] != null); + } + + hasBusinessPositions(): boolean { + return (this.companyPositions[posNames.BusinessCompanyPositions[0]] != null); + } + + hasEmployeePositions(): boolean { + return (this.companyPositions[posNames.MiscCompanyPositions[1]] != null); + } + + hasITPositions(): boolean { + return (this.companyPositions[posNames.ITCompanyPositions[0]] != null); + } + + hasSecurityPositions(): boolean { + return (this.companyPositions[posNames.SecurityCompanyPositions[2]] != null); + } + + hasSoftwareConsultantPositions(): boolean { + return (this.companyPositions[posNames.SoftwareConsultantCompanyPositions[0]] != null); + } + + hasSoftwarePositions(): boolean { + return (this.companyPositions[posNames.SoftwareCompanyPositions[0]] != null); + } + + hasWaiterPositions(): boolean { + return (this.companyPositions[posNames.MiscCompanyPositions[0]] != null); + } + + gainFavor(): void { if (this.favor == null) { this.favor = 0; } if (this.rolloverRep == null) { this.rolloverRep = 0; } diff --git a/src/Location.js b/src/LocationHelpers.js similarity index 100% rename from src/Location.js rename to src/LocationHelpers.js diff --git a/src/Locations/Cities.ts b/src/Locations/Cities.ts index fc138ad25..1ec9d970a 100644 --- a/src/Locations/Cities.ts +++ b/src/Locations/Cities.ts @@ -2,6 +2,7 @@ * Map of all Cities in the game * Key = City Name, Value = City object */ -export interface IMetadata = { - name: string; -} +import { City } from "./City"; +import { IMap } from "../types"; + +export const Cities: IMap = {}; diff --git a/src/Locations/City.ts b/src/Locations/City.ts index 14aae4a7c..637d2734f 100644 --- a/src/Locations/City.ts +++ b/src/Locations/City.ts @@ -1,22 +1,26 @@ /** * Class representing a City in the game */ -import { Location } from "./Location"; import { CityName } from "./data/CityNames"; +import { LocationName } from "./data/LocationNames"; export class City { /** * List of all locations in this city */ - locations: Location[]; + locations: LocationName[]; /** * Name of this city */ name: CityName; - constructor(name: CityName, locations: Location[]) { + constructor(name: CityName, locations: LocationName[]=[]) { this.name = name; this.locations = locations; } + + addLocation(loc: LocationName): void { + this.locations.push(loc); + } } diff --git a/src/Locations/Location.ts b/src/Locations/Location.ts index 3cc97609c..8667e4d86 100644 --- a/src/Locations/Location.ts +++ b/src/Locations/Location.ts @@ -10,29 +10,44 @@ export interface IConstructorParams { name?: LocationName; types?: LocationType[]; techVendorMaxRam?: number; + techVendorMinRam?: number; } export class Location { - // Name of city this location is in - // If this property is null, it means this is a generic Location that - // is available in all cities + /** + * Name of city this location is in. If this property is null, it means this i + * is a generic location that is available in all cities + */ city: CityName | null = null; - // Identifier for location + /** + * Identifier for location + */ name: LocationName = LocationName.Void; - // List of what type(s) this location is - // A location can be multiple types (e.g. company and tech vendor) + /** + * List of what type(s) this location is. A location can be multiple types + * (e.g. company and tech vendor) + */ types: LocationType[] = []; - // Tech vendors allow you to purchase servers. - // This property defines the max RAM server you can purchase from this vendor + /** + * Tech vendors allow you to purchase servers. + * This property defines the max RAM server you can purchase from this vendor + */ techVendorMaxRam: number = 0; + /** + * Tech vendors allow you to purchase servers. + * This property defines the max RAM server you can purchase from this vendor + */ + techVendorMinRam: number = 0; + constructor(p: IConstructorParams) { if (p.city) { this.city = p.city; } if (p.name) { this.name = p.name; } if (p.types) { this.types = p.types; } if (p.techVendorMaxRam) { this.techVendorMaxRam = p.techVendorMaxRam; } + if (p.techVendorMinRam) { this.techVendorMinRam = p.techVendorMinRam; } } } diff --git a/src/Locations/LocationTypeEnum.ts b/src/Locations/LocationTypeEnum.ts index ddfeafbce..246e6122d 100644 --- a/src/Locations/LocationTypeEnum.ts +++ b/src/Locations/LocationTypeEnum.ts @@ -2,11 +2,11 @@ * Enum defining the different types of possible locations */ export enum LocationType { - CityHall, Company, Gym, Hospital, Slums, + Special, // This location has special options/activities (e.g. Bladeburner, Re-sleeving) StockMarket, TechVendor, TravelAgency, diff --git a/src/Locations/Locations.ts b/src/Locations/Locations.ts index d91095247..752085d9b 100644 --- a/src/Locations/Locations.ts +++ b/src/Locations/Locations.ts @@ -2,15 +2,23 @@ * Map of all Locations in the game * Key = Location name, value = Location object */ +import { City } from "./City"; +import { Cities } from "./Cities"; import { Location, - IConstructorParams } from "./Location"; -import { LocationsMetadata } from "./data/LocationsMetadata"; + IConstructorParams } from "./Location"; +import { CityName } from "./data/CityNames"; +import { LocationsMetadata } from "./data/LocationsMetadata"; + import { IMap } from "../types"; export const Locations: IMap = {}; -function constructLocation(p: IConstructorParams) { +/** + * Here, we'll initialize both Locations and Cities data. These can both + * be initialized from the `LocationsMetadata` + */ +function constructLocation(p: IConstructorParams): Location { if (!p.name) { throw new Error(`Invalid constructor parameters for Location. No 'name' property`); } @@ -20,8 +28,29 @@ function constructLocation(p: IConstructorParams) { } Locations[p.name] = new Location(p); + + return Locations[p.name]; } -for (const metadata of LocationsMetadata { - constructLocation(metadata); +// First construct all cities +Cities[CityName.Aevum] = new City(CityName.Aevum); +Cities[CityName.Chongqing] = new City(CityName.Chongqing); +Cities[CityName.Ishima] = new City(CityName.Ishima); +Cities[CityName.NewTokyo] = new City(CityName.NewTokyo); +Cities[CityName.Sector12] = new City(CityName.Sector12); +Cities[CityName.Volhaven] = new City(CityName.Volhaven); + +// Then construct all locations, and add them to the cities as we go. +for (const metadata of LocationsMetadata) { + const loc = constructLocation(metadata); + + const cityName = loc.city; + if (cityName === null) { + // Generic location, add to all cities + for (const city in Cities) { + Cities[city].addLocation(loc.name); + } + } else { + Cities[cityName].addLocation(loc.name); + } } diff --git a/src/Locations/LocationsHelpers.js b/src/Locations/LocationsHelpers.js new file mode 100644 index 000000000..590e9ea56 --- /dev/null +++ b/src/Locations/LocationsHelpers.js @@ -0,0 +1 @@ +import { Player } from "../Player"; diff --git a/src/Locations/data/LocationsMetadata.ts b/src/Locations/data/LocationsMetadata.ts index fb8ae03e3..0b80019d1 100644 --- a/src/Locations/data/LocationsMetadata.ts +++ b/src/Locations/data/LocationsMetadata.ts @@ -5,312 +5,278 @@ import { CityName } from "./CityNames"; import { LocationName } from "./LocationNames"; import { IConstructorParams } from "../Location"; +import { LocationType } from "../LocationTypeEnum"; export const LocationsMetadata: IConstructorParams[] = [ { city: CityName.Aevum, name: LocationName.AevumAeroCorp, - types: - techVendorMaxRam: + types: [LocationType.Company], }, { city: CityName.Aevum, name: LocationName.AevumBachmanAndAssociates, - types: - techVendorMaxRam: + types: [LocationType.Company], }, { city: CityName.Aevum, name: LocationName.AevumClarkeIncorporated, - types: - techVendorMaxRam: + types: [LocationType.Company], }, { city: CityName.Aevum, name: LocationName.AevumCrushFitnessGym, - types: - techVendorMaxRam: + types: [LocationType.Gym], }, { city: CityName.Aevum, name: LocationName.AevumECorp, - types: - techVendorMaxRam: + types: [LocationType.Company, LocationType.TechVendor], + techVendorMaxRam: 512, + techVendorMinRam: 128, }, { city: CityName.Aevum, name: LocationName.AevumFulcrumTechnologies, - types: - techVendorMaxRam: + types: [LocationType.Company, LocationType.TechVendor], + techVendorMaxRam: 1024, + techVendorMinRam: 256, }, { city: CityName.Aevum, name: LocationName.AevumGalacticCybersystems, - types: - techVendorMaxRam: + types: [LocationType.Company], }, { city: CityName.Aevum, - name: LocationName.AevumNetLinkTechnologies - types: - techVendorMaxRam: + name: LocationName.AevumNetLinkTechnologies, + types: [LocationType.Company, LocationType.TechVendor], + techVendorMaxRam: 64, + techVendorMinRam: 8, }, { city: CityName.Aevum, name: LocationName.AevumPolice, - types: - techVendorMaxRam: + types: [LocationType.Company], }, { city: CityName.Aevum, name: LocationName.AevumRhoConstruction, - types: - techVendorMaxRam: + types: [LocationType.Company], }, { city: CityName.Aevum, name: LocationName.AevumSnapFitnessGym, - types: - techVendorMaxRam: + types: [LocationType.Gym], }, { city: CityName.Aevum, name: LocationName.AevumSummitUniversity, - types: - techVendorMaxRam: + types: [LocationType.University], }, { city: CityName.Aevum, name: LocationName.AevumWatchdogSecurity, - types: - techVendorMaxRam: + types: [LocationType.Company], }, { city: CityName.Chongqing, name: LocationName.ChongqingKuaiGongInternational, - types: - techVendorMaxRam: + types: [LocationType.Company], }, { city: CityName.Chongqing, name: LocationName.ChongqingSolarisSpaceSystems, - types: - techVendorMaxRam: + types: [LocationType.Company], }, { city: CityName.Ishima, name: LocationName.IshimaNovaMedical, - types: - techVendorMaxRam: + types: [LocationType.Company], }, { city: CityName.Ishima, name: LocationName.IshimaOmegaSoftware, - types: - techVendorMaxRam: + types: [LocationType.Company, LocationType.TechVendor], + techVendorMaxRam: 128, + techVendorMinRam: 4, }, { city: CityName.Ishima, name: LocationName.IshimaStormTechnologies, - types: - techVendorMaxRam: + types: [LocationType.Company, LocationType.TechVendor], + techVendorMaxRam: 512, + techVendorMinRam: 32, }, { city: CityName.NewTokyo, name: LocationName.NewTokyoDefComm, - types: - techVendorMaxRam: + types: [LocationType.Company], }, { city: CityName.NewTokyo, name: LocationName.NewTokyoGlobalPharmaceuticals, - types: - techVendorMaxRam: + types: [LocationType.Company], }, { city: CityName.NewTokyo, name: LocationName.NewTokyoNoodleBar, - types: - techVendorMaxRam: + types: [LocationType.Company], }, { city: CityName.NewTokyo, name: LocationName.NewTokyoVitaLife, - types: - techVendorMaxRam: + types: [LocationType.Company, LocationType.Special], }, { city: CityName.Sector12, name: LocationName.Sector12AlphaEnterprises, - types: - techVendorMaxRam: + types: [LocationType.Company, LocationType.TechVendor], + techVendorMaxRam: 8, + techVendorMinRam: 2, }, { city: CityName.Sector12, name: LocationName.Sector12BladeIndustries, - types: - techVendorMaxRam: + types: [LocationType.Company], }, { city: CityName.Sector12, name: LocationName.Sector12CIA, - types: - techVendorMaxRam: + types: [LocationType.Company], }, { city: CityName.Sector12, name: LocationName.Sector12CarmichaelSecurity, - types: - techVendorMaxRam: + types: [LocationType.Company], }, { city: CityName.Sector12, name: LocationName.Sector12CityHall, - types: - techVendorMaxRam: + types: [LocationType.Special], }, { city: CityName.Sector12, name: LocationName.Sector12DeltaOne, - types: - techVendorMaxRam: + types: [LocationType.Company], }, { city: CityName.Sector12, name: LocationName.Sector12FoodNStuff, - types: - techVendorMaxRam: + types: [LocationType.Company], }, { city: CityName.Sector12, name: LocationName.Sector12FourSigma, - types: - techVendorMaxRam: + types: [LocationType.Company], }, { city: CityName.Sector12, name: LocationName.Sector12IcarusMicrosystems, - types: - techVendorMaxRam: + types: [LocationType.Company], }, { city: CityName.Sector12, name: LocationName.Sector12IronGym, - types: - techVendorMaxRam: + types: [LocationType.Gym], }, { city: CityName.Sector12, name: LocationName.Sector12JoesGuns, - types: - techVendorMaxRam: + types: [LocationType.Company], }, { city: CityName.Sector12, name: LocationName.Sector12MegaCorp, - types: - techVendorMaxRam: + types: [LocationType.Company], }, { city: CityName.Sector12, name: LocationName.Sector12NSA, - types: - techVendorMaxRam: + types: [LocationType.Company, LocationType.Special], }, { city: CityName.Sector12, name: LocationName.Sector12PowerhouseGym, - types: - techVendorMaxRam: + types: [LocationType.Gym], }, { city: CityName.Sector12, name: LocationName.Sector12RothmanUniversity, - types: - techVendorMaxRam: + types: [LocationType.University], }, { city: CityName.Sector12, name: LocationName.Sector12UniversalEnergy, - types: - techVendorMaxRam: + types: [LocationType.Company], }, { city: CityName.Volhaven, name: LocationName.VolhavenCompuTek, - types: - techVendorMaxRam: + types: [LocationType.Company, LocationType.TechVendor], + techVendorMaxRam: 256, + techVendorMinRam: 8, }, { city: CityName.Volhaven, name: LocationName.VolhavenHeliosLabs, - types: - techVendorMaxRam: + types: [LocationType.Company], }, { city: CityName.Volhaven, name: LocationName.VolhavenLexoCorp, - types: - techVendorMaxRam: + types: [LocationType.Company], }, { city: CityName.Volhaven, name: LocationName.VolhavenMilleniumFitnessGym, - types: - techVendorMaxRam: + types: [LocationType.Gym], }, { city: CityName.Volhaven, name: LocationName.VolhavenNWO, - types: - techVendorMaxRam: + types: [LocationType.Company], }, { city: CityName.Volhaven, name: LocationName.VolhavenOmniTekIncorporated, - types: - techVendorMaxRam: + types: [LocationType.Company, LocationType.TechVendor], + techVendorMaxRam: 1024, + techVendorMinRam: 128, }, { city: CityName.Volhaven, name: LocationName.VolhavenOmniaCybersystems, - types: - techVendorMaxRam: + types: [LocationType.Company], }, { city: CityName.Volhaven, name: LocationName.VolhavenSysCoreSecurities, - types: - techVendorMaxRam: + types: [LocationType.Company], }, { city: CityName.Volhaven, name: LocationName.VolhavenZBInstituteOfTechnology, - types: - techVendorMaxRam: + types: [LocationType.University], }, { city: null, name: LocationName.Hospital, - types: - techVendorMaxRam: + types: [LocationType.Hospital], }, { city: null, name: LocationName.Slums, - types: - techVendorMaxRam: + types: [LocationType.Slums], }, { city: null, name: LocationName.TravelAgency, - types: - techVendorMaxRam: + types: [LocationType.TravelAgency], }, { city: null, name: LocationName.WorldStockExchange, - types: - techVendorMaxRam: + types: [LocationType.StockMarket], }, ]; diff --git a/src/Locations/ui/City.tsx b/src/Locations/ui/City.tsx new file mode 100644 index 000000000..91ad06f1a --- /dev/null +++ b/src/Locations/ui/City.tsx @@ -0,0 +1,34 @@ +/** + * React Component for displaying a City's UI. + * This UI shows all of the available locations in the city, and lets the player + * visit those locations + */ +import * as React from "react"; + +import { City } from "../City"; +import { LocationName } from "../data/LocationNames"; + +import { StdButton } from "../../ui/React/StdButton"; + +type IProps = { + city: City; + enterLocation: (to: LocationName) => void; +} + +export class LocationCity extends React.Component { + render() { + const locationButtons = this.props.city.locations.map((locName) => { + return ( +
  • + +
  • + ) + }); + + return ( +
      + {locationButtons} +
    + ) + } +} diff --git a/src/Locations/ui/CompanyLocation.tsx b/src/Locations/ui/CompanyLocation.tsx new file mode 100644 index 000000000..392e309ad --- /dev/null +++ b/src/Locations/ui/CompanyLocation.tsx @@ -0,0 +1,112 @@ +/** + * React Component for displaying a location's UI, when that location is a company + */ +import * as React from "react"; + +import { LocationName } from "../data/LocationNames"; + +import { Companies } from "../../Company/Companies"; +import { Company } from "../../Company/Company"; +import { IPlayer } from "../../PersonObjects/IPlayer"; + +import { StdButton } from "../../ui/React/StdButton"; + +type IProps = { + locName: LocationName; + p: IPlayer; +} + +export class CompanyLocation extends React.Component { + /** + * We'll keep a reference to the Company that this component is being rendered for, + * so we don't have to look it up every time + */ + company: Company; + + constructor(props: IProps) { + super(props); + + this.applyForAgentJob = this.applyForAgentJob.bind(this); + this.applyForBusinessConsultantJob = this.applyForBusinessConsultantJob.bind(this); + this.applyForBusinessJob = this.applyForBusinessJob.bind(this); + this.applyForEmployeeJob = this.applyForEmployeeJob.bind(this); + this.applyForItJob = this.applyForItJob.bind(this); + this.applyForPartTimeEmployeeJob = this.applyForPartTimeEmployeeJob.bind(this); + this.applyForPartTimeWaiterJob = this.applyForPartTimeWaiterJob.bind(this); + this.applyForSecurityJob = this.applyForSecurityJob.bind(this); + this.applyForSoftwareConsultantJob = this.applyForSoftwareConsultantJob.bind(this); + this.applyForSoftwareJob = this.applyForSoftwareJob.bind(this); + this.applyForWaiterJob = this.applyForWaiterJob.bind(this); + + this.company = Companies[props.locName]; + if (this.company == null) { + throw new Error(`CompanyLocation component constructed with invalid company: ${props.locName}`); + } + } + + applyForAgentJob(e: React.MouseEvent) { + if (!e.isTrusted) { return false; } + this.props.p.applyForAgentJob(); + } + + applyForBusinessConsultantJob(e: React.MouseEvent) { + if (!e.isTrusted) { return false; } + this.props.p.applyForBusinessConsultantJob(); + } + + applyForBusinessJob(e: React.MouseEvent) { + if (!e.isTrusted) { return false; } + this.props.p.applyForBusinessJob(); + } + + applyForEmployeeJob(e: React.MouseEvent) { + if (!e.isTrusted) { return false; } + this.props.p.applyForEmployeeJob(); + } + + applyForItJob(e: React.MouseEvent) { + if (!e.isTrusted) { return false; } + this.props.p.applyForItJob(); + } + + applyForPartTimeEmployeeJob(e: React.MouseEvent) { + if (!e.isTrusted) { return false; } + this.props.p.applyForPartTimeEmployeeJob(); + } + + applyForPartTimeWaiterJob(e: React.MouseEvent) { + if (!e.isTrusted) { return false; } + this.props.p.applyForPartTimeWaiterJob(); + } + + applyForSecurityJob(e: React.MouseEvent) { + if (!e.isTrusted) { return false; } + this.props.p.applyForSecurityJob(); + } + + applyForSoftwareConsultantJob(e: React.MouseEvent) { + if (!e.isTrusted) { return false; } + this.props.p.applyForSoftwareConsultantJob(); + } + + applyForSoftwareJob(e: React.MouseEvent) { + if (!e.isTrusted) { return false; } + this.props.p.applyForSoftwareJob(); + } + + applyForWaiterJob(e: React.MouseEvent) { + if (!e.isTrusted) { return false; } + this.props.p.applyForWaiterJob(); + } + + render() { + return ( +
    + { + this.company.hasAgentPositions() && + + ) + } +} diff --git a/src/Locations/ui/GenericLocation.tsx b/src/Locations/ui/GenericLocation.tsx new file mode 100644 index 000000000..e5c37d32a --- /dev/null +++ b/src/Locations/ui/GenericLocation.tsx @@ -0,0 +1,95 @@ +/** + * React Component for displaying a location's UI + * + * This is a "router" component of sorts, meaning it deduces the type of + * location that is being rendered and then creates the proper component(s) for that. + */ +import * as React from "react"; + +import { Location } from "../Location"; +import { Locations } from "../Locations"; +import { LocationType } from "../LocationTypeEnum"; +import { LocationName } from "../data/LocationNames"; + +import { IPlayer } from "../../PersonObjects/IPlayer"; + +import { StdButton } from "../../ui/React/StdButton"; + +type IProps = { + locName: LocationName; + p: IPlayer; + returnToCity: () => void; +} + +export class GenericLocation extends React.Component { + /** + * Reference to the Location object that is being rendered + */ + loc: Location; + + constructor(props: IProps) { + super(props); + + this.loc = Locations[props.locName]; + if (this.loc == null) { + throw new Error(`Invalid Location being rendered: ${props.locName}`); + } + } + + /** + * Determine what needs to be rendered for this location based on the locations + * type. Returns an array of React components that should be rendered + */ + getLocationSpecificContent(): React.ReactNode[] { + const content: React.ReactNode[] = []; + + if (this.loc.types.includes(LocationType.Company)) { + + } + + if (this.loc.types.includes(LocationType.Gym)) { + + } + + if (this.loc.types.includes(LocationType.Hospital)) { + + } + + if (this.loc.types.includes(LocationType.Slums)) { + + } + + if (this.loc.types.includes(LocationType.Special)) { + + } + + if (this.loc.types.includes(LocationType.StockMarket)) { + + } + + if (this.loc.types.includes(LocationType.TechVendor)) { + + } + + if (this.loc.types.includes(LocationType.TravelAgency)) { + + } + + if (this.loc.types.includes(LocationType.University)) { + + } + } + + render() { + const locContent: React.ReactNode[] = this.getLocationSpecificContent(); + + return ( +
    + +
    +

    this.loc.name

    + {locContent} +
    + ) + } +} diff --git a/src/Locations/ui/Root.tsx b/src/Locations/ui/Root.tsx new file mode 100644 index 000000000..01f61e349 --- /dev/null +++ b/src/Locations/ui/Root.tsx @@ -0,0 +1,91 @@ +/** + * Root React Component for displaying overall Location UI + */ +import * as React from "react"; + +import { LocationCity } from "./City"; + +import { CityName } from "../data/CityNames"; +import { LocationName } from "../data/LocationNames"; + +import { IPlayer } from "../../PersonObjects/IPlayer"; + +type IProps = { + p: IPlayer; +} + +type IState = { + city: CityName; + inCity: boolean; + location: LocationName; +} + +export class LocationRoot extends React.Component { + constructor(props: IProps) { + super(props); + + this.state = { + city: props.p.city, + inCity: true, + location: props.p.location, + } + + this.changeCity = this.changeCity.bind(this); + this.returnToCity = this.returnToCity.bind(this); + } + + changeCity(to: CityName): void { + if (this.props.p.travel(to)) { + this.setState({ + city: to + }); + } + } + + enterLocation(to: LocationName): void { + this.props.p.location = to; + this.setState({ + inCity: false, + location: to, + }); + } + + /** + * Click listener for a button that lets the player go from a specific location + * back to the city + */ + returnToCity(): void { + this.setState({ + inCity: true, + }); + } + + /** + * Render UI for a city + */ + renderCity(): React.ReactNode { + return ( +
    +

    {this.state.city}

    + +
    + ) + } + + /** + * Render UI for a specific location + */ + renderLocation(): React.ReactNode { + return ( + + ) + } + + render() { + if (this.state.inCity) { + return this.renderCity(); + } else { + return this.renderLocation(); + } + } +} diff --git a/src/PersonObjects/IPlayer.ts b/src/PersonObjects/IPlayer.ts index c41247a2e..40cd39cdb 100644 --- a/src/PersonObjects/IPlayer.ts +++ b/src/PersonObjects/IPlayer.ts @@ -8,16 +8,20 @@ import { Sleeve } from "./Sleeve/Sleeve"; import { IMap } from "../types"; -import { IPlayerOwnedAugmentation } from "../Augmentation/PlayerOwnedAugmentation"; -import { IPlayerOwnedSourceFile } from "../SourceFile/PlayerOwnedSourceFile"; -import { MoneySourceTracker } from "../utils/MoneySourceTracker"; +import { IPlayerOwnedAugmentation } from "../Augmentation/PlayerOwnedAugmentation"; +import { Company } from "../Company/Company"; +import { CompanyPosition } from "../Company/CompanyPosition"; +import { CityName } from "../Locations/data/CityNames"; +import { LocationName } from "../Locations/data/LocationNames"; +import { IPlayerOwnedSourceFile } from "../SourceFile/PlayerOwnedSourceFile"; +import { MoneySourceTracker } from "../utils/MoneySourceTracker"; export interface IPlayer { // Class members augmentations: IPlayerOwnedAugmentation[]; bladeburner: any; bitNodeN: number; - city: string; + city: CityName; companyName: string; corporation: any; currentServer: string; @@ -26,6 +30,7 @@ export interface IPlayer { hasWseAccount: boolean; jobs: IMap; karma: number; + location: LocationName; money: any; moneySourceA: MoneySourceTracker; moneySourceB: MoneySourceTracker; @@ -85,6 +90,20 @@ export interface IPlayer { crime_money_mult: number; // Methods + applyForAgentJob(sing?: boolean): boolean | void; + applyForBusinessConsultantJob(sing?: boolean): boolean | void; + applyForBusinessJob(sing?: boolean): boolean | void; + applyForEmployeeJob(sing?: boolean): boolean | void; + applyForItJob(sing?: boolean): boolean | void; + applyForJob(entryPosType: CompanyPosition, sing?: boolean): boolean | void; + applyForNetworkEngineerJob(sing?: boolean): boolean | void; + applyForPartTimeEmployeeJob(sing?: boolean): boolean | void; + applyForPartTimeWaiterJob(sing?: boolean): boolean | void; + applyForSecurityEngineerJob(sing?: boolean): boolean | void; + applyForSecurityJob(sing?: boolean): boolean | void; + applyForSoftwareConsultantJob(sing?: boolean): boolean | void; + applyForSoftwareJob(sing?: boolean): boolean | void; + applyForWaiterJob(sing?: boolean): boolean | void; canAfford(cost: number): boolean; gainHackingExp(exp: number): void; gainStrengthExp(exp: number): void; @@ -93,9 +112,11 @@ export interface IPlayer { gainAgilityExp(exp: number): void; gainCharismaExp(exp: number): void; gainMoney(money: number): void; + getNextCompanyPosition(company: Company, entryPosType: CompanyPosition): CompanyPosition; hasCorporation(): boolean; inBladeburner(): boolean; inGang(): boolean; + isQualified(company: Company, position: CompanyPosition): boolean; loseMoney(money: number): void; reapplyAllAugmentations(resetMultipliers: boolean): void; reapplyAllSourceFiles(): void; @@ -110,4 +131,5 @@ export interface IPlayer { money: number, time: number, singParams: any): void; + travel(to: CityName): boolean; } diff --git a/src/PersonObjects/Player/PlayerGeneralMethods.js b/src/PersonObjects/Player/PlayerGeneralMethods.js new file mode 100644 index 000000000..df585e69a --- /dev/null +++ b/src/PersonObjects/Player/PlayerGeneralMethods.js @@ -0,0 +1,12 @@ +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; +} diff --git a/src/index.html b/src/index.html index 5dd72486b..568785a22 100644 --- a/src/index.html +++ b/src/index.html @@ -236,222 +236,7 @@ if (htmlWebpackPlugin.options.googleAnalytics.trackingId) { %>