mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-08 08:43:53 +01:00
API: Change singularity.applyToCompany() to use an enum for job field (#859)
This commit is contained in:
parent
686d2e2b9b
commit
1a052a7daf
11
markdown/bitburner.companypositioninfo.field.md
Normal file
11
markdown/bitburner.companypositioninfo.field.md
Normal file
@ -0,0 +1,11 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [bitburner](./bitburner.md) > [CompanyPositionInfo](./bitburner.companypositioninfo.md) > [field](./bitburner.companypositioninfo.field.md)
|
||||
|
||||
## CompanyPositionInfo.field property
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
field: JobField;
|
||||
```
|
@ -16,6 +16,7 @@ export interface CompanyPositionInfo
|
||||
|
||||
| Property | Modifiers | Type | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| [field](./bitburner.companypositioninfo.field.md) | | [JobField](./bitburner.jobfield.md) | |
|
||||
| [name](./bitburner.companypositioninfo.name.md) | | [JobName](./bitburner.jobname.md) | |
|
||||
| [nextPosition](./bitburner.companypositioninfo.nextposition.md) | | [JobName](./bitburner.jobname.md) \| null | |
|
||||
| [requiredReputation](./bitburner.companypositioninfo.requiredreputation.md) | | number | |
|
||||
|
31
markdown/bitburner.jobfield.md
Normal file
31
markdown/bitburner.jobfield.md
Normal file
@ -0,0 +1,31 @@
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [bitburner](./bitburner.md) > [JobField](./bitburner.jobfield.md)
|
||||
|
||||
## JobField enum
|
||||
|
||||
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
declare enum JobField
|
||||
```
|
||||
|
||||
## Enumeration Members
|
||||
|
||||
| Member | Value | Description |
|
||||
| --- | --- | --- |
|
||||
| agent | <code>"Agent"</code> | |
|
||||
| business | <code>"Business"</code> | |
|
||||
| businessConsultant | <code>"Business Consultant"</code> | |
|
||||
| employee | <code>"Employee"</code> | |
|
||||
| it | <code>"IT"</code> | |
|
||||
| networkEngineer | <code>"Network Engineer"</code> | |
|
||||
| partTimeEmployee | <code>"part-time Employee"</code> | |
|
||||
| partTimeWaiter | <code>"part-time Waiter"</code> | |
|
||||
| security | <code>"Security"</code> | |
|
||||
| securityEngineer | <code>"Security Engineer"</code> | |
|
||||
| software | <code>"Software"</code> | |
|
||||
| softwareConsultant | <code>"Software Consultant"</code> | |
|
||||
| waiter | <code>"Waiter"</code> | |
|
||||
|
@ -13,6 +13,7 @@
|
||||
| [CrimeType](./bitburner.crimetype.md) | |
|
||||
| [FactionWorkType](./bitburner.factionworktype.md) | |
|
||||
| [GymType](./bitburner.gymtype.md) | |
|
||||
| [JobField](./bitburner.jobfield.md) | |
|
||||
| [JobName](./bitburner.jobname.md) | |
|
||||
| [LocationName](./bitburner.locationname.md) | Names of all locations |
|
||||
| [OrderType](./bitburner.ordertype.md) | |
|
||||
|
@ -14,11 +14,12 @@ export type NSEnums = {
|
||||
FactionWorkType: typeof FactionWorkType;
|
||||
GymType: typeof GymType;
|
||||
JobName: typeof JobName;
|
||||
JobField: typeof JobField;
|
||||
LocationName: typeof LocationName;
|
||||
ToastVariant: typeof ToastVariant;
|
||||
UniversityClassType: typeof UniversityClassType;
|
||||
CompanyName: typeof CompanyName;
|
||||
};
|
||||
```
|
||||
**References:** [CityName](./bitburner.cityname.md)<!-- -->, [CrimeType](./bitburner.crimetype.md)<!-- -->, [FactionWorkType](./bitburner.factionworktype.md)<!-- -->, [GymType](./bitburner.gymtype.md)<!-- -->, [JobName](./bitburner.jobname.md)<!-- -->, [LocationName](./bitburner.locationname.md)<!-- -->, [ToastVariant](./bitburner.toastvariant.md)<!-- -->, [UniversityClassType](./bitburner.universityclasstype.md)<!-- -->, [CompanyName](./bitburner.companyname.md)
|
||||
**References:** [CityName](./bitburner.cityname.md)<!-- -->, [CrimeType](./bitburner.crimetype.md)<!-- -->, [FactionWorkType](./bitburner.factionworktype.md)<!-- -->, [GymType](./bitburner.gymtype.md)<!-- -->, [JobName](./bitburner.jobname.md)<!-- -->, [JobField](./bitburner.jobfield.md)<!-- -->, [LocationName](./bitburner.locationname.md)<!-- -->, [ToastVariant](./bitburner.toastvariant.md)<!-- -->, [UniversityClassType](./bitburner.universityclasstype.md)<!-- -->, [CompanyName](./bitburner.companyname.md)
|
||||
|
||||
|
@ -9,7 +9,7 @@ Apply for a job at a company.
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
applyToCompany(companyName: CompanyName | `${CompanyName}`, field: string): boolean;
|
||||
applyToCompany(companyName: CompanyName | `${CompanyName}`, field: JobField | `${JobField}`): boolean;
|
||||
```
|
||||
|
||||
## Parameters
|
||||
@ -17,7 +17,7 @@ applyToCompany(companyName: CompanyName | `${CompanyName}`, field: string): bool
|
||||
| Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| companyName | [CompanyName](./bitburner.companyname.md) \| \`${[CompanyName](./bitburner.companyname.md)<!-- -->}\` | Name of company to apply to. |
|
||||
| field | string | Field to which you want to apply. |
|
||||
| field | [JobField](./bitburner.jobfield.md) \| \`${[JobField](./bitburner.jobfield.md)<!-- -->}\` | Field to which you want to apply. |
|
||||
|
||||
**Returns:**
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Person as IPerson } from "@nsdefs";
|
||||
import { CONSTANTS } from "../Constants";
|
||||
import { JobName } from "@enums";
|
||||
import { JobName, JobField } from "@enums";
|
||||
import {
|
||||
agentJobs,
|
||||
businessConsultJobs,
|
||||
@ -14,6 +14,7 @@ import {
|
||||
|
||||
export interface CompanyPositionCtorParams {
|
||||
nextPosition: JobName | null;
|
||||
field: JobField;
|
||||
baseSalary: number;
|
||||
repMultiplier: number;
|
||||
|
||||
@ -44,6 +45,9 @@ export class CompanyPosition {
|
||||
/** Position title */
|
||||
name: JobName;
|
||||
|
||||
/** Field type of the position (software, it, business, etc) */
|
||||
field: JobField;
|
||||
|
||||
/** Title of next position to be promoted to */
|
||||
nextPosition: JobName | null;
|
||||
|
||||
@ -85,6 +89,7 @@ export class CompanyPosition {
|
||||
|
||||
constructor(name: JobName, p: CompanyPositionCtorParams) {
|
||||
this.name = name;
|
||||
this.field = p.field;
|
||||
this.nextPosition = p.nextPosition;
|
||||
this.baseSalary = p.baseSalary;
|
||||
this.repMultiplier = p.repMultiplier;
|
||||
|
@ -1,11 +1,12 @@
|
||||
// Metadata used for constructing Company Positions
|
||||
import { JobName } from "@enums";
|
||||
import { JobName, JobField } from "@enums";
|
||||
import { CompanyPositionCtorParams } from "../CompanyPosition";
|
||||
|
||||
export function getCompanyPositionMetadata(): Record<JobName, CompanyPositionCtorParams> {
|
||||
return {
|
||||
[JobName.software0]: {
|
||||
nextPosition: JobName.software1, // Junior Software Engineer
|
||||
field: JobField.software,
|
||||
baseSalary: 33,
|
||||
charismaEffectiveness: 15,
|
||||
charismaExpGain: 0.02,
|
||||
@ -16,6 +17,7 @@ export function getCompanyPositionMetadata(): Record<JobName, CompanyPositionCto
|
||||
},
|
||||
[JobName.software1]: {
|
||||
nextPosition: JobName.software2, // Senior Software Engineer
|
||||
field: JobField.software,
|
||||
baseSalary: 80,
|
||||
charismaEffectiveness: 15,
|
||||
charismaExpGain: 0.05,
|
||||
@ -27,6 +29,7 @@ export function getCompanyPositionMetadata(): Record<JobName, CompanyPositionCto
|
||||
},
|
||||
[JobName.software2]: {
|
||||
nextPosition: JobName.software3, // Lead Software Developer
|
||||
field: JobField.software,
|
||||
baseSalary: 165,
|
||||
charismaEffectiveness: 20,
|
||||
charismaExpGain: 0.08,
|
||||
@ -39,6 +42,7 @@ export function getCompanyPositionMetadata(): Record<JobName, CompanyPositionCto
|
||||
},
|
||||
[JobName.software3]: {
|
||||
nextPosition: JobName.software4, // Head of Software
|
||||
field: JobField.software,
|
||||
baseSalary: 500,
|
||||
charismaEffectiveness: 25,
|
||||
charismaExpGain: 0.1,
|
||||
@ -51,6 +55,7 @@ export function getCompanyPositionMetadata(): Record<JobName, CompanyPositionCto
|
||||
},
|
||||
[JobName.software4]: {
|
||||
nextPosition: JobName.software5, // Head of Engineering
|
||||
field: JobField.software,
|
||||
baseSalary: 800,
|
||||
charismaEffectiveness: 25,
|
||||
charismaExpGain: 0.5,
|
||||
@ -63,6 +68,7 @@ export function getCompanyPositionMetadata(): Record<JobName, CompanyPositionCto
|
||||
},
|
||||
[JobName.software5]: {
|
||||
nextPosition: JobName.software6, // Vice President of Technology
|
||||
field: JobField.software,
|
||||
baseSalary: 1650,
|
||||
charismaEffectiveness: 25,
|
||||
charismaExpGain: 0.5,
|
||||
@ -75,6 +81,7 @@ export function getCompanyPositionMetadata(): Record<JobName, CompanyPositionCto
|
||||
},
|
||||
[JobName.software6]: {
|
||||
nextPosition: JobName.software7, // Chief Technology Officer
|
||||
field: JobField.software,
|
||||
baseSalary: 2310,
|
||||
charismaEffectiveness: 30,
|
||||
charismaExpGain: 0.6,
|
||||
@ -87,6 +94,7 @@ export function getCompanyPositionMetadata(): Record<JobName, CompanyPositionCto
|
||||
},
|
||||
[JobName.software7]: {
|
||||
nextPosition: null,
|
||||
field: JobField.software,
|
||||
baseSalary: 2640,
|
||||
charismaEffectiveness: 35,
|
||||
charismaExpGain: 1,
|
||||
@ -99,6 +107,7 @@ export function getCompanyPositionMetadata(): Record<JobName, CompanyPositionCto
|
||||
},
|
||||
[JobName.IT0]: {
|
||||
nextPosition: JobName.IT1, // IT Analyst
|
||||
field: JobField.it,
|
||||
baseSalary: 26,
|
||||
charismaEffectiveness: 10,
|
||||
charismaExpGain: 0.01,
|
||||
@ -109,6 +118,7 @@ export function getCompanyPositionMetadata(): Record<JobName, CompanyPositionCto
|
||||
},
|
||||
[JobName.IT1]: {
|
||||
nextPosition: JobName.IT2, // IT Manager
|
||||
field: JobField.it,
|
||||
baseSalary: 66,
|
||||
charismaEffectiveness: 15,
|
||||
charismaExpGain: 0.02,
|
||||
@ -120,6 +130,7 @@ export function getCompanyPositionMetadata(): Record<JobName, CompanyPositionCto
|
||||
},
|
||||
[JobName.IT2]: {
|
||||
nextPosition: JobName.IT3, // Systems Administrator
|
||||
field: JobField.it,
|
||||
baseSalary: 132,
|
||||
charismaEffectiveness: 20,
|
||||
charismaExpGain: 0.1,
|
||||
@ -132,6 +143,7 @@ export function getCompanyPositionMetadata(): Record<JobName, CompanyPositionCto
|
||||
},
|
||||
[JobName.IT3]: {
|
||||
nextPosition: JobName.software5, // Head of Engineering
|
||||
field: JobField.it,
|
||||
baseSalary: 410,
|
||||
charismaEffectiveness: 20,
|
||||
charismaExpGain: 0.2,
|
||||
@ -144,6 +156,7 @@ export function getCompanyPositionMetadata(): Record<JobName, CompanyPositionCto
|
||||
},
|
||||
[JobName.securityEng]: {
|
||||
nextPosition: JobName.software5, // Head of Engineering
|
||||
field: JobField.securityEngineer,
|
||||
baseSalary: 121,
|
||||
charismaEffectiveness: 15,
|
||||
charismaExpGain: 0.05,
|
||||
@ -156,6 +169,7 @@ export function getCompanyPositionMetadata(): Record<JobName, CompanyPositionCto
|
||||
},
|
||||
[JobName.networkEng0]: {
|
||||
nextPosition: JobName.networkEng1, // Network Administrator
|
||||
field: JobField.networkEngineer,
|
||||
baseSalary: 121,
|
||||
charismaEffectiveness: 15,
|
||||
charismaExpGain: 0.05,
|
||||
@ -168,6 +182,7 @@ export function getCompanyPositionMetadata(): Record<JobName, CompanyPositionCto
|
||||
},
|
||||
[JobName.networkEng1]: {
|
||||
nextPosition: JobName.software5, // Head of Engineering
|
||||
field: JobField.networkEngineer,
|
||||
baseSalary: 410,
|
||||
charismaEffectiveness: 20,
|
||||
charismaExpGain: 0.1,
|
||||
@ -180,6 +195,7 @@ export function getCompanyPositionMetadata(): Record<JobName, CompanyPositionCto
|
||||
},
|
||||
[JobName.business0]: {
|
||||
nextPosition: JobName.business1, // Business Analyst
|
||||
field: JobField.business,
|
||||
baseSalary: 46,
|
||||
charismaEffectiveness: 90,
|
||||
charismaExpGain: 0.08,
|
||||
@ -191,6 +207,7 @@ export function getCompanyPositionMetadata(): Record<JobName, CompanyPositionCto
|
||||
},
|
||||
[JobName.business1]: {
|
||||
nextPosition: JobName.business2, // Business Manager
|
||||
field: JobField.business,
|
||||
baseSalary: 100,
|
||||
charismaEffectiveness: 85,
|
||||
charismaExpGain: 0.15,
|
||||
@ -203,6 +220,7 @@ export function getCompanyPositionMetadata(): Record<JobName, CompanyPositionCto
|
||||
},
|
||||
[JobName.business2]: {
|
||||
nextPosition: JobName.business3, // Operations Manager
|
||||
field: JobField.business,
|
||||
baseSalary: 200,
|
||||
charismaEffectiveness: 85,
|
||||
charismaExpGain: 0.3,
|
||||
@ -215,6 +233,7 @@ export function getCompanyPositionMetadata(): Record<JobName, CompanyPositionCto
|
||||
},
|
||||
[JobName.business3]: {
|
||||
nextPosition: JobName.business4, // Chief Financial Officer
|
||||
field: JobField.business,
|
||||
baseSalary: 660,
|
||||
charismaEffectiveness: 85,
|
||||
charismaExpGain: 0.4,
|
||||
@ -227,6 +246,7 @@ export function getCompanyPositionMetadata(): Record<JobName, CompanyPositionCto
|
||||
},
|
||||
[JobName.business4]: {
|
||||
nextPosition: JobName.business5, // Chief Executive Officer
|
||||
field: JobField.business,
|
||||
baseSalary: 1950,
|
||||
charismaEffectiveness: 90,
|
||||
charismaExpGain: 1,
|
||||
@ -239,6 +259,7 @@ export function getCompanyPositionMetadata(): Record<JobName, CompanyPositionCto
|
||||
},
|
||||
[JobName.business5]: {
|
||||
nextPosition: null,
|
||||
field: JobField.business,
|
||||
baseSalary: 3900,
|
||||
charismaEffectiveness: 90,
|
||||
charismaExpGain: 1.5,
|
||||
@ -251,6 +272,7 @@ export function getCompanyPositionMetadata(): Record<JobName, CompanyPositionCto
|
||||
},
|
||||
[JobName.security0]: {
|
||||
nextPosition: JobName.security1, // Security Officer
|
||||
field: JobField.security,
|
||||
baseSalary: 50,
|
||||
hackingEffectiveness: 5,
|
||||
strengthEffectiveness: 20,
|
||||
@ -273,6 +295,7 @@ export function getCompanyPositionMetadata(): Record<JobName, CompanyPositionCto
|
||||
},
|
||||
[JobName.security1]: {
|
||||
nextPosition: JobName.security2, // Security Supervisor
|
||||
field: JobField.security,
|
||||
baseSalary: 195,
|
||||
hackingEffectiveness: 10,
|
||||
strengthEffectiveness: 20,
|
||||
@ -297,6 +320,7 @@ export function getCompanyPositionMetadata(): Record<JobName, CompanyPositionCto
|
||||
},
|
||||
[JobName.security2]: {
|
||||
nextPosition: JobName.security3, // Head of Security
|
||||
field: JobField.security,
|
||||
baseSalary: 660,
|
||||
hackingEffectiveness: 10,
|
||||
strengthEffectiveness: 15,
|
||||
@ -321,6 +345,7 @@ export function getCompanyPositionMetadata(): Record<JobName, CompanyPositionCto
|
||||
},
|
||||
[JobName.security3]: {
|
||||
nextPosition: null,
|
||||
field: JobField.security,
|
||||
baseSalary: 1320,
|
||||
hackingEffectiveness: 10,
|
||||
strengthEffectiveness: 15,
|
||||
@ -345,6 +370,7 @@ export function getCompanyPositionMetadata(): Record<JobName, CompanyPositionCto
|
||||
},
|
||||
[JobName.agent0]: {
|
||||
nextPosition: JobName.agent1, // Secret Agent
|
||||
field: JobField.agent,
|
||||
baseSalary: 330,
|
||||
hackingEffectiveness: 10,
|
||||
strengthEffectiveness: 15,
|
||||
@ -369,6 +395,7 @@ export function getCompanyPositionMetadata(): Record<JobName, CompanyPositionCto
|
||||
},
|
||||
[JobName.agent1]: {
|
||||
nextPosition: JobName.agent2, // Special Operative
|
||||
field: JobField.agent,
|
||||
baseSalary: 990,
|
||||
hackingEffectiveness: 15,
|
||||
strengthEffectiveness: 15,
|
||||
@ -393,6 +420,7 @@ export function getCompanyPositionMetadata(): Record<JobName, CompanyPositionCto
|
||||
},
|
||||
[JobName.agent2]: {
|
||||
nextPosition: null,
|
||||
field: JobField.agent,
|
||||
baseSalary: 2000,
|
||||
hackingEffectiveness: 15,
|
||||
strengthEffectiveness: 15,
|
||||
@ -417,6 +445,7 @@ export function getCompanyPositionMetadata(): Record<JobName, CompanyPositionCto
|
||||
},
|
||||
[JobName.waiter]: {
|
||||
nextPosition: null,
|
||||
field: JobField.waiter,
|
||||
baseSalary: 22,
|
||||
strengthEffectiveness: 10,
|
||||
dexterityEffectiveness: 10,
|
||||
@ -431,6 +460,7 @@ export function getCompanyPositionMetadata(): Record<JobName, CompanyPositionCto
|
||||
},
|
||||
[JobName.employee]: {
|
||||
nextPosition: null,
|
||||
field: JobField.employee,
|
||||
baseSalary: 22,
|
||||
strengthEffectiveness: 10,
|
||||
dexterityEffectiveness: 10,
|
||||
@ -445,6 +475,7 @@ export function getCompanyPositionMetadata(): Record<JobName, CompanyPositionCto
|
||||
},
|
||||
[JobName.softwareConsult0]: {
|
||||
nextPosition: JobName.softwareConsult1, // Senior Software Consultant
|
||||
field: JobField.softwareConsultant,
|
||||
baseSalary: 66,
|
||||
hackingEffectiveness: 80,
|
||||
charismaEffectiveness: 20,
|
||||
@ -455,6 +486,7 @@ export function getCompanyPositionMetadata(): Record<JobName, CompanyPositionCto
|
||||
},
|
||||
[JobName.softwareConsult1]: {
|
||||
nextPosition: null,
|
||||
field: JobField.softwareConsultant,
|
||||
baseSalary: 132,
|
||||
hackingEffectiveness: 75,
|
||||
charismaEffectiveness: 25,
|
||||
@ -466,6 +498,7 @@ export function getCompanyPositionMetadata(): Record<JobName, CompanyPositionCto
|
||||
},
|
||||
[JobName.businessConsult0]: {
|
||||
nextPosition: JobName.businessConsult1, // Senior Business Consultant
|
||||
field: JobField.businessConsultant,
|
||||
baseSalary: 66,
|
||||
hackingEffectiveness: 20,
|
||||
charismaEffectiveness: 80,
|
||||
@ -477,6 +510,7 @@ export function getCompanyPositionMetadata(): Record<JobName, CompanyPositionCto
|
||||
},
|
||||
[JobName.businessConsult1]: {
|
||||
nextPosition: null,
|
||||
field: JobField.businessConsultant,
|
||||
baseSalary: 525,
|
||||
hackingEffectiveness: 15,
|
||||
charismaEffectiveness: 85,
|
||||
@ -488,6 +522,7 @@ export function getCompanyPositionMetadata(): Record<JobName, CompanyPositionCto
|
||||
},
|
||||
[JobName.waiterPT]: {
|
||||
nextPosition: null,
|
||||
field: JobField.partTimeWaiter,
|
||||
baseSalary: 20,
|
||||
strengthEffectiveness: 10,
|
||||
dexterityEffectiveness: 10,
|
||||
@ -502,6 +537,7 @@ export function getCompanyPositionMetadata(): Record<JobName, CompanyPositionCto
|
||||
},
|
||||
[JobName.employeePT]: {
|
||||
nextPosition: null,
|
||||
field: JobField.partTimeEmployee,
|
||||
baseSalary: 20,
|
||||
strengthEffectiveness: 10,
|
||||
dexterityEffectiveness: 10,
|
||||
|
@ -12,7 +12,7 @@ import Box from "@mui/material/Box";
|
||||
import { ApplyToJobButton } from "./ApplyToJobButton";
|
||||
|
||||
import { Locations } from "../Locations";
|
||||
import { CompanyName, JobName } from "@enums";
|
||||
import { CompanyName, JobName, JobField } from "@enums";
|
||||
|
||||
import { Companies } from "../../Company/Companies";
|
||||
import { CompanyPositions } from "../../Company/CompanyPositions";
|
||||
@ -238,7 +238,7 @@ export function CompanyLocation(props: IProps): React.ReactElement {
|
||||
company={company}
|
||||
entryPosType={CompanyPositions[JobName.agent0]}
|
||||
onClick={applyForAgentJob}
|
||||
text={"Apply for Agent Job"}
|
||||
text={"Apply for " + JobField.agent + " Job"}
|
||||
/>
|
||||
)}
|
||||
{company.hasBusinessConsultantPositions() && (
|
||||
@ -246,7 +246,7 @@ export function CompanyLocation(props: IProps): React.ReactElement {
|
||||
company={company}
|
||||
entryPosType={CompanyPositions[JobName.businessConsult0]}
|
||||
onClick={applyForBusinessConsultantJob}
|
||||
text={"Apply for Business Consultant Job"}
|
||||
text={"Apply for " + JobField.businessConsultant + " Job"}
|
||||
/>
|
||||
)}
|
||||
{company.hasBusinessPositions() && (
|
||||
@ -254,7 +254,7 @@ export function CompanyLocation(props: IProps): React.ReactElement {
|
||||
company={company}
|
||||
entryPosType={CompanyPositions[JobName.business0]}
|
||||
onClick={applyForBusinessJob}
|
||||
text={"Apply for Business Job"}
|
||||
text={"Apply for " + JobField.business + " Job"}
|
||||
/>
|
||||
)}
|
||||
{company.hasEmployeePositions() && (
|
||||
@ -262,7 +262,7 @@ export function CompanyLocation(props: IProps): React.ReactElement {
|
||||
company={company}
|
||||
entryPosType={CompanyPositions[JobName.employee]}
|
||||
onClick={applyForEmployeeJob}
|
||||
text={"Apply to be an Employee"}
|
||||
text={"Apply to be an " + JobField.employee}
|
||||
/>
|
||||
)}
|
||||
{company.hasEmployeePositions() && (
|
||||
@ -270,7 +270,7 @@ export function CompanyLocation(props: IProps): React.ReactElement {
|
||||
company={company}
|
||||
entryPosType={CompanyPositions[JobName.employeePT]}
|
||||
onClick={applyForPartTimeEmployeeJob}
|
||||
text={"Apply to be a part-time Employee"}
|
||||
text={"Apply to be a " + JobField.partTimeEmployee}
|
||||
/>
|
||||
)}
|
||||
{company.hasITPositions() && (
|
||||
@ -278,7 +278,7 @@ export function CompanyLocation(props: IProps): React.ReactElement {
|
||||
company={company}
|
||||
entryPosType={CompanyPositions[JobName.IT0]}
|
||||
onClick={applyForItJob}
|
||||
text={"Apply for IT Job"}
|
||||
text={"Apply for " + JobField.it + " Job"}
|
||||
/>
|
||||
)}
|
||||
{company.hasSecurityPositions() && (
|
||||
@ -286,7 +286,7 @@ export function CompanyLocation(props: IProps): React.ReactElement {
|
||||
company={company}
|
||||
entryPosType={CompanyPositions[JobName.security0]}
|
||||
onClick={applyForSecurityJob}
|
||||
text={"Apply for Security Job"}
|
||||
text={"Apply for " + JobField.security + " Job"}
|
||||
/>
|
||||
)}
|
||||
{company.hasSoftwareConsultantPositions() && (
|
||||
@ -294,7 +294,7 @@ export function CompanyLocation(props: IProps): React.ReactElement {
|
||||
company={company}
|
||||
entryPosType={CompanyPositions[JobName.softwareConsult0]}
|
||||
onClick={applyForSoftwareConsultantJob}
|
||||
text={"Apply for Software Consultant Job"}
|
||||
text={"Apply for " + JobField.softwareConsultant + " Job"}
|
||||
/>
|
||||
)}
|
||||
{company.hasSoftwarePositions() && (
|
||||
@ -302,7 +302,7 @@ export function CompanyLocation(props: IProps): React.ReactElement {
|
||||
company={company}
|
||||
entryPosType={CompanyPositions[JobName.software0]}
|
||||
onClick={applyForSoftwareJob}
|
||||
text={"Apply for Software Job"}
|
||||
text={"Apply for " + JobField.software + " Job"}
|
||||
/>
|
||||
)}
|
||||
{company.hasWaiterPositions() && (
|
||||
@ -310,7 +310,7 @@ export function CompanyLocation(props: IProps): React.ReactElement {
|
||||
company={company}
|
||||
entryPosType={CompanyPositions[JobName.waiter]}
|
||||
onClick={applyForWaiterJob}
|
||||
text={"Apply to be a Waiter"}
|
||||
text={"Apply to be a " + JobField.waiter}
|
||||
/>
|
||||
)}
|
||||
{company.hasWaiterPositions() && (
|
||||
@ -318,7 +318,7 @@ export function CompanyLocation(props: IProps): React.ReactElement {
|
||||
company={company}
|
||||
entryPosType={CompanyPositions[JobName.waiterPT]}
|
||||
onClick={applyForPartTimeWaiterJob}
|
||||
text={"Apply to be a part-time Waiter"}
|
||||
text={"Apply to be a " + JobField.partTimeWaiter}
|
||||
/>
|
||||
)}
|
||||
{location.infiltrationData != null && <Button onClick={startInfiltration}>Infiltrate Company</Button>}
|
||||
|
@ -20,6 +20,7 @@ import {
|
||||
FactionWorkType,
|
||||
GymType,
|
||||
JobName,
|
||||
JobField,
|
||||
LiteratureName,
|
||||
LocationName,
|
||||
ToastVariant,
|
||||
@ -109,6 +110,7 @@ export const enums: NSEnums = {
|
||||
FactionWorkType,
|
||||
GymType,
|
||||
JobName,
|
||||
JobField,
|
||||
LocationName,
|
||||
ToastVariant,
|
||||
UniversityClassType,
|
||||
|
@ -8,6 +8,7 @@ import {
|
||||
FactionName,
|
||||
FactionWorkType,
|
||||
GymType,
|
||||
JobField,
|
||||
LocationName,
|
||||
UniversityClassType,
|
||||
} from "@enums";
|
||||
@ -31,7 +32,7 @@ import { formatMoney, formatRam, formatReputation } from "../ui/formatNumber";
|
||||
import { currentNodeMults } from "../BitNode/BitNodeMultipliers";
|
||||
import { Companies } from "../Company/Companies";
|
||||
import { Factions } from "../Faction/Factions";
|
||||
import { helpers } from "../Netscript/NetscriptHelpers";
|
||||
import { helpers, assertString } from "../Netscript/NetscriptHelpers";
|
||||
import { convertTimeMsToTimeElapsedString } from "../utils/StringHelperFunctions";
|
||||
import { getServerOnNetwork } from "../Server/ServerHelpers";
|
||||
import { Terminal } from "../Terminal";
|
||||
@ -687,6 +688,7 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
|
||||
const job = CompanyPositions[positionName];
|
||||
const res = {
|
||||
name: CompanyPositions[positionName].name,
|
||||
field: CompanyPositions[positionName].field,
|
||||
nextPosition: CompanyPositions[positionName].nextPosition,
|
||||
salary: CompanyPositions[positionName].baseSalary * company.salaryMultiplier,
|
||||
requiredReputation: CompanyPositions[positionName].requiredReputation,
|
||||
@ -736,48 +738,63 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
|
||||
applyToCompany: (ctx) => (_companyName, _field) => {
|
||||
helpers.checkSingularityAccess(ctx);
|
||||
const companyName = getEnumHelper("CompanyName").nsGetMember(ctx, _companyName);
|
||||
const field = helpers.string(ctx, "field", _field);
|
||||
assertString(ctx, "field", _field);
|
||||
|
||||
// capitalize each word, except for "part-time"
|
||||
function capitalizeJobField(field: string) {
|
||||
return field
|
||||
.toLowerCase()
|
||||
.split(" ")
|
||||
.map((s) => {
|
||||
if (s.length == 0 || s == "part-time") return s;
|
||||
if (s.length == 2) return s.toUpperCase(); // Probably an acronym
|
||||
return s[0].toUpperCase() + s.slice(1);
|
||||
})
|
||||
.join(" ");
|
||||
}
|
||||
|
||||
const field = getEnumHelper("JobField").nsGetMember(ctx, capitalizeJobField(_field as string), "field");
|
||||
|
||||
Player.location = companyNameAsLocationName(companyName);
|
||||
let res;
|
||||
switch (field.toLowerCase()) {
|
||||
case "software":
|
||||
switch (field) {
|
||||
case JobField.software:
|
||||
res = Player.applyForSoftwareJob(true);
|
||||
break;
|
||||
case "software consultant":
|
||||
case JobField.softwareConsultant:
|
||||
res = Player.applyForSoftwareConsultantJob(true);
|
||||
break;
|
||||
case "it":
|
||||
case JobField.it:
|
||||
res = Player.applyForItJob(true);
|
||||
break;
|
||||
case "security engineer":
|
||||
case JobField.securityEngineer:
|
||||
res = Player.applyForSecurityEngineerJob(true);
|
||||
break;
|
||||
case "network engineer":
|
||||
case JobField.networkEngineer:
|
||||
res = Player.applyForNetworkEngineerJob(true);
|
||||
break;
|
||||
case "business":
|
||||
case JobField.business:
|
||||
res = Player.applyForBusinessJob(true);
|
||||
break;
|
||||
case "business consultant":
|
||||
case JobField.businessConsultant:
|
||||
res = Player.applyForBusinessConsultantJob(true);
|
||||
break;
|
||||
case "security":
|
||||
case JobField.security:
|
||||
res = Player.applyForSecurityJob(true);
|
||||
break;
|
||||
case "agent":
|
||||
case JobField.agent:
|
||||
res = Player.applyForAgentJob(true);
|
||||
break;
|
||||
case "employee":
|
||||
case JobField.employee:
|
||||
res = Player.applyForEmployeeJob(true);
|
||||
break;
|
||||
case "part-time employee":
|
||||
case JobField.partTimeEmployee:
|
||||
res = Player.applyForPartTimeEmployeeJob(true);
|
||||
break;
|
||||
case "waiter":
|
||||
case JobField.waiter:
|
||||
res = Player.applyForWaiterJob(true);
|
||||
break;
|
||||
case "part-time waiter":
|
||||
case JobField.partTimeWaiter:
|
||||
res = Player.applyForPartTimeWaiterJob(true);
|
||||
break;
|
||||
default:
|
||||
|
21
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
21
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
@ -1856,7 +1856,7 @@ export interface Singularity {
|
||||
* @param field - Field to which you want to apply.
|
||||
* @returns True if the player successfully get a job/promotion, and false otherwise.
|
||||
*/
|
||||
applyToCompany(companyName: CompanyName | `${CompanyName}`, field: string): boolean;
|
||||
applyToCompany(companyName: CompanyName | `${CompanyName}`, field: JobField | `${JobField}`): boolean;
|
||||
|
||||
/**
|
||||
* Get company reputation.
|
||||
@ -2423,6 +2423,7 @@ export interface Singularity {
|
||||
*/
|
||||
export interface CompanyPositionInfo {
|
||||
name: JobName;
|
||||
field: JobField;
|
||||
nextPosition: JobName | null;
|
||||
salary: number;
|
||||
requiredReputation: number;
|
||||
@ -6860,6 +6861,23 @@ declare enum JobName {
|
||||
employeePT = "Part-time Employee",
|
||||
}
|
||||
|
||||
/** @public */
|
||||
declare enum JobField {
|
||||
software = "Software",
|
||||
softwareConsultant = "Software Consultant",
|
||||
it = "IT",
|
||||
securityEngineer = "Security Engineer",
|
||||
networkEngineer = "Network Engineer",
|
||||
business = "Business",
|
||||
businessConsultant = "Business Consultant",
|
||||
security = "Security",
|
||||
agent = "Agent",
|
||||
employee = "Employee",
|
||||
partTimeEmployee = "part-time Employee",
|
||||
waiter = "Waiter",
|
||||
partTimeWaiter = "part-time Waiter",
|
||||
}
|
||||
|
||||
// CORP ENUMS - Changed to types
|
||||
/** @public */
|
||||
type CorpEmployeePosition =
|
||||
@ -7021,6 +7039,7 @@ export type NSEnums = {
|
||||
FactionWorkType: typeof FactionWorkType;
|
||||
GymType: typeof GymType;
|
||||
JobName: typeof JobName;
|
||||
JobField: typeof JobField;
|
||||
LocationName: typeof LocationName;
|
||||
ToastVariant: typeof ToastVariant;
|
||||
UniversityClassType: typeof UniversityClassType;
|
||||
|
@ -63,3 +63,19 @@ export enum JobName {
|
||||
businessConsult0 = "Business Consultant",
|
||||
businessConsult1 = "Senior Business Consultant",
|
||||
}
|
||||
|
||||
export enum JobField {
|
||||
software = "Software",
|
||||
softwareConsultant = "Software Consultant",
|
||||
it = "IT",
|
||||
securityEngineer = "Security Engineer",
|
||||
networkEngineer = "Network Engineer",
|
||||
business = "Business",
|
||||
businessConsultant = "Business Consultant",
|
||||
security = "Security",
|
||||
agent = "Agent",
|
||||
employee = "Employee",
|
||||
partTimeEmployee = "part-time Employee",
|
||||
waiter = "Waiter",
|
||||
partTimeWaiter = "part-time Waiter",
|
||||
}
|
||||
|
101
test/jest/NetscriptFunctions/Singularity.test.ts
Normal file
101
test/jest/NetscriptFunctions/Singularity.test.ts
Normal file
@ -0,0 +1,101 @@
|
||||
import { Player, setPlayer } from "../../../src/Player";
|
||||
import { getCompaniesMetadata } from "../../../src/Company/data/CompaniesMetadata";
|
||||
import { getCompanyPositionMetadata } from "../../../src/Company/data/CompanyPositionsMetadata";
|
||||
import { PlayerObject } from "../../../src/PersonObjects/Player/PlayerObject";
|
||||
import { NetscriptSingularity } from "../../../src/NetscriptFunctions/Singularity";
|
||||
import { CompanyName, JobField, JobName } from "@enums";
|
||||
|
||||
import { WorkerScript } from "../../../src/Netscript/WorkerScript";
|
||||
import { Script } from "../../../src/Script/Script";
|
||||
import { RunningScript } from "../../../src/Script/RunningScript";
|
||||
import { ScriptFilePath } from "../../../src/Paths/ScriptFilePath";
|
||||
import { GetServer } from "../../../src/Server/AllServers";
|
||||
|
||||
describe("Singularity", () => {
|
||||
let ctx;
|
||||
let singularity;
|
||||
let positionMetadata;
|
||||
let companyMetadata;
|
||||
|
||||
beforeAll(() => {
|
||||
singularity = NetscriptSingularity();
|
||||
positionMetadata = getCompanyPositionMetadata();
|
||||
companyMetadata = getCompaniesMetadata();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
setPlayer(new PlayerObject());
|
||||
Player.init();
|
||||
Player.sourceFiles.set(4, 3);
|
||||
|
||||
GetServer("home").writeToScriptFile("function.js", "");
|
||||
let script = new Script("function.js", "", "home");
|
||||
let runningScript = new RunningScript(script, 1, []);
|
||||
let workerScript = new WorkerScript(runningScript, 1);
|
||||
ctx = { workerScript: workerScript, function: "singularityTest", functionPath: "test.singularityTest" };
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
Object.values(CompanyName).forEach((k) => {
|
||||
companyMetadata[k].playerReputation = 0;
|
||||
});
|
||||
});
|
||||
|
||||
describe("getCompanyPositionInfo", () => {
|
||||
it("returns an enum for field", () => {
|
||||
let companyWithPositions = Object.values(CompanyName).find(
|
||||
(cn) => companyMetadata[cn].companyPositions.length > 0,
|
||||
);
|
||||
let company = companyMetadata[companyWithPositions];
|
||||
let positionName = company.companyPositions[0];
|
||||
let position = positionMetadata[positionName];
|
||||
|
||||
let companyPosition = singularity.getCompanyPositionInfo(ctx)(company.name, positionName);
|
||||
expect(companyPosition.field).toEqual(position.field);
|
||||
});
|
||||
});
|
||||
|
||||
describe("applyToCompany", () => {
|
||||
it("throws an error if input doesn't match an enum", () => {
|
||||
let anyValidCompany = Object.values(CompanyName)[0];
|
||||
expect(() => singularity.applyToCompany(ctx)(anyValidCompany, "sockware")).toThrow("should be a JobField");
|
||||
expect(() => singularity.applyToCompany(ctx)(anyValidCompany, "invalid-job-field")).toThrow(
|
||||
"should be a JobField",
|
||||
);
|
||||
});
|
||||
|
||||
it("accepts the JobField specified by getCompanyPositionInfo", () => {
|
||||
Object.values(CompanyName).forEach((cn) => {
|
||||
companyMetadata[cn].companyPositions.forEach((pn) => {
|
||||
let pos = positionMetadata[pn];
|
||||
expect(() => singularity.applyToCompany(ctx)(cn, pos.field)).not.toThrow();
|
||||
Player.quitJob(cn);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("is case-insensitive to string inputs to the field parameter", () => {
|
||||
Object.values(CompanyName).forEach((cn) => {
|
||||
companyMetadata[cn].companyPositions.forEach((pn) => {
|
||||
let pos = positionMetadata[pn];
|
||||
let field = pos.field;
|
||||
|
||||
let upperCase = field.toUpperCase();
|
||||
expect(() => singularity.applyToCompany(ctx)(cn, upperCase)).not.toThrow();
|
||||
Player.quitJob(cn);
|
||||
|
||||
let lowerCase = field.toLowerCase();
|
||||
expect(() => singularity.applyToCompany(ctx)(cn, lowerCase)).not.toThrow();
|
||||
Player.quitJob(cn);
|
||||
|
||||
let brokenCasing = field
|
||||
.split("")
|
||||
.map((c, i) => (i % 2 == 0 ? c.toUpperCase() : c.toLowerCase()))
|
||||
.join("");
|
||||
expect(() => singularity.applyToCompany(ctx)(cn, brokenCasing)).not.toThrow();
|
||||
Player.quitJob(cn);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user