API: Add a way to get the list of all factions (#1457)

This commit is contained in:
catloversg
2025-01-29 01:40:11 +07:00
committed by GitHub
parent ffae0045a4
commit 2965f51879
16 changed files with 295 additions and 14 deletions

View File

@@ -9,14 +9,14 @@ Attempts a coding contract, returning a reward string on success or empty string
**Signature:**
```typescript
attempt(answer: string | number | any[], filename: string, host?: string): string;
attempt(answer: any, filename: string, host?: string): string;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| answer | string \| number \| any\[\] | Attempted solution for the contract. |
| answer | any | Attempted solution for the contract. This can be a string formatted like submitting manually, or the answer in the format of the specific contract type. |
| filename | string | Filename of the contract. |
| host | string | _(Optional)_ Hostname of the server containing the contract. Optional. Defaults to current server if not provided. |
@@ -36,7 +36,9 @@ Attempts to solve the Coding Contract with the provided solution.
```js
const reward = ns.codingcontract.attempt(yourSolution, filename, hostname);
const reward = ns.codingcontract.attempt("[solution, as, a, string]", filename, hostname);
// or
const reward = ns.codingcontract.attempt(["answer", "as", "an", "array"], filename, hostname);
if (reward) {
ns.tprint(`Contract solved successfully! Reward: ${reward}`);
} else {

View File

@@ -0,0 +1,44 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [CodingContract](./bitburner.codingcontract.md) &gt; [getContract](./bitburner.codingcontract.getcontract.md)
## CodingContract.getContract() method
Get various data about a specific contract.
**Signature:**
```typescript
getContract(filename: string, host?: string): CodingContractObject;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| filename | string | Filename of the contract. |
| host | string | _(Optional)_ Host of the server containing the contract. Optional. Default to the current server if not provided. |
**Returns:**
[CodingContractObject](./bitburner.codingcontractobject.md)
An object containing various data about the contract specified.
## Remarks
RAM cost: 15 GB
The returned object includes the type, data, description as well as methods for getting the number of tries remaining and submitting your answer. Depending on the type of the contract, the data is typed differently. Using type-narrowing, you can get the correct type of the data:
## Example
```js
const contract = ns.codingcontract.getContract(fileName, hostName);
if (contract.type === ns.enums.CodingContractName.FindLargestPrimeFactor) {
const data = contract.data;
// ^? data: number
}
```

View File

@@ -9,7 +9,7 @@ Get the type of a coding contract.
**Signature:**
```typescript
getContractType(filename: string, host?: string): string;
getContractType(filename: string, host?: string): `${CodingContractName}`;
```
## Parameters
@@ -21,7 +21,7 @@ getContractType(filename: string, host?: string): string;
**Returns:**
string
\`${[CodingContractName](./bitburner.codingcontractname.md)<!-- -->}\`
Name describing the type of problem posed by the Coding Contract.

View File

@@ -9,11 +9,11 @@ List all contract types.
**Signature:**
```typescript
getContractTypes(): string[];
getContractTypes(): `${CodingContractName}`[];
```
**Returns:**
string\[\]
\`${[CodingContractName](./bitburner.codingcontractname.md)<!-- -->}\`\[\]
## Remarks

View File

@@ -9,7 +9,7 @@ Get the input data.
**Signature:**
```typescript
getData(filename: string, host?: string): CodingContractData;
getData(filename: string, host?: string): any;
```
## Parameters
@@ -21,7 +21,7 @@ getData(filename: string, host?: string): CodingContractData;
**Returns:**
[CodingContractData](./bitburner.codingcontractdata.md)
any
The specified contracts data, data type depends on contract type.

View File

@@ -18,6 +18,7 @@ export interface CodingContract
| --- | --- |
| [attempt(answer, filename, host)](./bitburner.codingcontract.attempt.md) | Attempts a coding contract, returning a reward string on success or empty string on failure. |
| [createDummyContract(type)](./bitburner.codingcontract.createdummycontract.md) | Generate a dummy contract. |
| [getContract(filename, host)](./bitburner.codingcontract.getcontract.md) | Get various data about a specific contract. |
| [getContractType(filename, host)](./bitburner.codingcontract.getcontracttype.md) | Get the type of a coding contract. |
| [getContractTypes()](./bitburner.codingcontract.getcontracttypes.md) | List all contract types. |
| [getData(filename, host)](./bitburner.codingcontract.getdata.md) | Get the input data. |

View File

@@ -0,0 +1,15 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [CodingContractAnswer](./bitburner.codingcontractanswer.md)
## CodingContractAnswer type
**Signature:**
```typescript
export type CodingContractAnswer<T extends string> = T extends `${keyof CodingContractSignatures}`
? CodingContractSignatures[T][1]
: any;
```
**References:** [CodingContractSignatures](./bitburner.codingcontractsignatures.md)

View File

@@ -4,10 +4,12 @@
## CodingContractData type
Coding contract data will differ depending on coding contract.
**Signature:**
```typescript
type CodingContractData = any;
export type CodingContractData<T extends string> = T extends `${keyof CodingContractSignatures}`
? CodingContractSignatures[T][0]
: any;
```
**References:** [CodingContractSignatures](./bitburner.codingcontractsignatures.md)

View File

@@ -0,0 +1,45 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [CodingContractName](./bitburner.codingcontractname.md)
## CodingContractName enum
**Signature:**
```typescript
declare enum CodingContractName
```
## Enumeration Members
| Member | Value | Description |
| --- | --- | --- |
| AlgorithmicStockTraderI | <code>&quot;Algorithmic Stock Trader I&quot;</code> | |
| AlgorithmicStockTraderII | <code>&quot;Algorithmic Stock Trader II&quot;</code> | |
| AlgorithmicStockTraderIII | <code>&quot;Algorithmic Stock Trader III&quot;</code> | |
| AlgorithmicStockTraderIV | <code>&quot;Algorithmic Stock Trader IV&quot;</code> | |
| ArrayJumpingGame | <code>&quot;Array Jumping Game&quot;</code> | |
| ArrayJumpingGameII | <code>&quot;Array Jumping Game II&quot;</code> | |
| CompressionIIILZCompression | <code>&quot;Compression III: LZ Compression&quot;</code> | |
| CompressionIILZDecompression | <code>&quot;Compression II: LZ Decompression&quot;</code> | |
| CompressionIRLECompression | <code>&quot;Compression I: RLE Compression&quot;</code> | |
| EncryptionICaesarCipher | <code>&quot;Encryption I: Caesar Cipher&quot;</code> | |
| EncryptionIIVigenereCipher | <code>&quot;Encryption II: Vigenère Cipher&quot;</code> | |
| FindAllValidMathExpressions | <code>&quot;Find All Valid Math Expressions&quot;</code> | |
| FindLargestPrimeFactor | <code>&quot;Find Largest Prime Factor&quot;</code> | |
| GenerateIPAddresses | <code>&quot;Generate IP Addresses&quot;</code> | |
| HammingCodesEncodedBinaryToInteger | <code>&quot;HammingCodes: Encoded Binary to Integer&quot;</code> | |
| HammingCodesIntegerToEncodedBinary | <code>&quot;HammingCodes: Integer to Encoded Binary&quot;</code> | |
| MergeOverlappingIntervals | <code>&quot;Merge Overlapping Intervals&quot;</code> | |
| MinimumPathSumInATriangle | <code>&quot;Minimum Path Sum in a Triangle&quot;</code> | |
| Proper2ColoringOfAGraph | <code>&quot;Proper 2-Coloring of a Graph&quot;</code> | |
| SanitizeParenthesesInExpression | <code>&quot;Sanitize Parentheses in Expression&quot;</code> | |
| ShortestPathInAGrid | <code>&quot;Shortest Path in a Grid&quot;</code> | |
| SpiralizeMatrix | <code>&quot;Spiralize Matrix&quot;</code> | |
| SquareRoot | <code>&quot;Square Root&quot;</code> | |
| SubarrayWithMaximumSum | <code>&quot;Subarray with Maximum Sum&quot;</code> | |
| TotalWaysToSum | <code>&quot;Total Ways to Sum&quot;</code> | |
| TotalWaysToSumII | <code>&quot;Total Ways to Sum II&quot;</code> | |
| UniquePathsInAGridI | <code>&quot;Unique Paths in a Grid I&quot;</code> | |
| UniquePathsInAGridII | <code>&quot;Unique Paths in a Grid II&quot;</code> | |

View File

@@ -0,0 +1,21 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [CodingContractObject](./bitburner.codingcontractobject.md)
## CodingContractObject type
**Signature:**
```typescript
export type CodingContractObject = {
[T in keyof CodingContractSignatures]: {
type: T;
data: CodingContractSignatures[T][0];
submit: (answer: CodingContractSignatures[T][1] | string) => string;
description: string;
numTriesRemaining: () => number;
};
}[keyof CodingContractSignatures];
```
**References:** [CodingContractSignatures](./bitburner.codingcontractsignatures.md)

View File

@@ -0,0 +1,42 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [CodingContractSignatures](./bitburner.codingcontractsignatures.md)
## CodingContractSignatures type
**Signature:**
```typescript
export type CodingContractSignatures = {
[CodingContractName.FindLargestPrimeFactor]: [number, number];
[CodingContractName.SubarrayWithMaximumSum]: [number[], number];
[CodingContractName.TotalWaysToSum]: [number, number];
[CodingContractName.TotalWaysToSumII]: [[number, number[]], number];
[CodingContractName.SpiralizeMatrix]: [number[][], number[]];
[CodingContractName.ArrayJumpingGame]: [number[], 1 | 0];
[CodingContractName.ArrayJumpingGameII]: [number[], number];
[CodingContractName.MergeOverlappingIntervals]: [[number, number][], [number, number][]];
[CodingContractName.GenerateIPAddresses]: [string, string[]];
[CodingContractName.AlgorithmicStockTraderI]: [number[], number];
[CodingContractName.AlgorithmicStockTraderII]: [number[], number];
[CodingContractName.AlgorithmicStockTraderIII]: [number[], number];
[CodingContractName.AlgorithmicStockTraderIV]: [[number, number[]], number];
[CodingContractName.MinimumPathSumInATriangle]: [number[][], number];
[CodingContractName.UniquePathsInAGridI]: [[number, number], number];
[CodingContractName.UniquePathsInAGridII]: [(1 | 0)[][], number];
[CodingContractName.ShortestPathInAGrid]: [(1 | 0)[][], string];
[CodingContractName.SanitizeParenthesesInExpression]: [string, string[]];
[CodingContractName.FindAllValidMathExpressions]: [[string, number], string[]];
[CodingContractName.HammingCodesIntegerToEncodedBinary]: [number, string];
[CodingContractName.HammingCodesEncodedBinaryToInteger]: [string, number];
[CodingContractName.Proper2ColoringOfAGraph]: [[number, [number, number][]], (1 | 0)[]];
[CodingContractName.CompressionIRLECompression]: [string, string];
[CodingContractName.CompressionIILZDecompression]: [string, string];
[CodingContractName.CompressionIIILZCompression]: [string, string];
[CodingContractName.EncryptionICaesarCipher]: [[string, number], string];
[CodingContractName.EncryptionIIVigenereCipher]: [[string, string], string];
[CodingContractName.SquareRoot]: [bigint, bigint, [string, string]];
};
```
**References:** [CodingContractName.FindLargestPrimeFactor](./bitburner.codingcontractname.md)<!-- -->, [CodingContractName.SubarrayWithMaximumSum](./bitburner.codingcontractname.md)<!-- -->, [CodingContractName.TotalWaysToSum](./bitburner.codingcontractname.md)<!-- -->, [CodingContractName.TotalWaysToSumII](./bitburner.codingcontractname.md)<!-- -->, [CodingContractName.SpiralizeMatrix](./bitburner.codingcontractname.md)<!-- -->, [CodingContractName.ArrayJumpingGame](./bitburner.codingcontractname.md)<!-- -->, [CodingContractName.ArrayJumpingGameII](./bitburner.codingcontractname.md)<!-- -->, [CodingContractName.MergeOverlappingIntervals](./bitburner.codingcontractname.md)<!-- -->, [CodingContractName.GenerateIPAddresses](./bitburner.codingcontractname.md)<!-- -->, [CodingContractName.AlgorithmicStockTraderI](./bitburner.codingcontractname.md)<!-- -->, [CodingContractName.AlgorithmicStockTraderII](./bitburner.codingcontractname.md)<!-- -->, [CodingContractName.AlgorithmicStockTraderIII](./bitburner.codingcontractname.md)<!-- -->, [CodingContractName.AlgorithmicStockTraderIV](./bitburner.codingcontractname.md)<!-- -->, [CodingContractName.MinimumPathSumInATriangle](./bitburner.codingcontractname.md)<!-- -->, [CodingContractName.UniquePathsInAGridI](./bitburner.codingcontractname.md)<!-- -->, [CodingContractName.UniquePathsInAGridII](./bitburner.codingcontractname.md)<!-- -->, [CodingContractName.ShortestPathInAGrid](./bitburner.codingcontractname.md)<!-- -->, [CodingContractName.SanitizeParenthesesInExpression](./bitburner.codingcontractname.md)<!-- -->, [CodingContractName.FindAllValidMathExpressions](./bitburner.codingcontractname.md)<!-- -->, [CodingContractName.HammingCodesIntegerToEncodedBinary](./bitburner.codingcontractname.md)<!-- -->, [CodingContractName.HammingCodesEncodedBinaryToInteger](./bitburner.codingcontractname.md)<!-- -->, [CodingContractName.Proper2ColoringOfAGraph](./bitburner.codingcontractname.md)<!-- -->, [CodingContractName.CompressionIRLECompression](./bitburner.codingcontractname.md)<!-- -->, [CodingContractName.CompressionIILZDecompression](./bitburner.codingcontractname.md)<!-- -->, [CodingContractName.CompressionIIILZCompression](./bitburner.codingcontractname.md)<!-- -->, [CodingContractName.EncryptionICaesarCipher](./bitburner.codingcontractname.md)<!-- -->, [CodingContractName.EncryptionIIVigenereCipher](./bitburner.codingcontractname.md)<!-- -->, [CodingContractName.SquareRoot](./bitburner.codingcontractname.md)

View File

@@ -0,0 +1,55 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [FactionName](./bitburner.factionname.md)
## FactionName enum
Names of all factions.
Warning: Spoiler ahead. This enum contains names of \*\*all\*\* factions. If you do not want to know what all the factions are, you should not check this enum. Some factions are only accessible in the endgame.
**Signature:**
```typescript
declare enum FactionName
```
## Enumeration Members
| Member | Value | Description |
| --- | --- | --- |
| Aevum | <code>&quot;Aevum&quot;</code> | |
| BachmanAssociates | <code>&quot;Bachman &amp; Associates&quot;</code> | |
| BitRunners | <code>&quot;BitRunners&quot;</code> | |
| Bladeburners | <code>&quot;Bladeburners&quot;</code> | |
| BladeIndustries | <code>&quot;Blade Industries&quot;</code> | |
| Chongqing | <code>&quot;Chongqing&quot;</code> | |
| ChurchOfTheMachineGod | <code>&quot;Church of the Machine God&quot;</code> | |
| ClarkeIncorporated | <code>&quot;Clarke Incorporated&quot;</code> | |
| CyberSec | <code>&quot;CyberSec&quot;</code> | |
| Daedalus | <code>&quot;Daedalus&quot;</code> | |
| ECorp | <code>&quot;ECorp&quot;</code> | |
| FourSigma | <code>&quot;Four Sigma&quot;</code> | |
| FulcrumSecretTechnologies | <code>&quot;Fulcrum Secret Technologies&quot;</code> | |
| Illuminati | <code>&quot;Illuminati&quot;</code> | |
| Ishima | <code>&quot;Ishima&quot;</code> | |
| KuaiGongInternational | <code>&quot;KuaiGong International&quot;</code> | |
| MegaCorp | <code>&quot;MegaCorp&quot;</code> | |
| Netburners | <code>&quot;Netburners&quot;</code> | |
| NewTokyo | <code>&quot;New Tokyo&quot;</code> | |
| NiteSec | <code>&quot;NiteSec&quot;</code> | |
| NWO | <code>&quot;NWO&quot;</code> | |
| OmniTekIncorporated | <code>&quot;OmniTek Incorporated&quot;</code> | |
| Sector12 | <code>&quot;Sector-12&quot;</code> | |
| ShadowsOfAnarchy | <code>&quot;Shadows of Anarchy&quot;</code> | |
| Silhouette | <code>&quot;Silhouette&quot;</code> | |
| SlumSnakes | <code>&quot;Slum Snakes&quot;</code> | |
| SpeakersForTheDead | <code>&quot;Speakers for the Dead&quot;</code> | |
| Tetrads | <code>&quot;Tetrads&quot;</code> | |
| TheBlackHand | <code>&quot;The Black Hand&quot;</code> | |
| TheCovenant | <code>&quot;The Covenant&quot;</code> | |
| TheDarkArmy | <code>&quot;The Dark Army&quot;</code> | |
| TheSyndicate | <code>&quot;The Syndicate&quot;</code> | |
| TianDiHui | <code>&quot;Tian Di Hui&quot;</code> | |
| Volhaven | <code>&quot;Volhaven&quot;</code> | |

View File

@@ -15,9 +15,11 @@
| [BladeburnerOperationName](./bitburner.bladeburneroperationname.md) | Operation names of Bladeburner |
| [BladeburnerSkillName](./bitburner.bladeburnerskillname.md) | Skill names type of Bladeburner |
| [CityName](./bitburner.cityname.md) | Names of all cities |
| [CodingContractName](./bitburner.codingcontractname.md) | |
| [CompanyName](./bitburner.companyname.md) | Names of all companies |
| [CreatingCorporationCheckResult](./bitburner.creatingcorporationcheckresult.md) | |
| [CrimeType](./bitburner.crimetype.md) | |
| [FactionName](./bitburner.factionname.md) | <p>Names of all factions.</p><p>Warning: Spoiler ahead. This enum contains names of \*\*all\*\* factions. If you do not want to know what all the factions are, you should not check this enum. Some factions are only accessible in the endgame.</p> |
| [FactionWorkType](./bitburner.factionworktype.md) | |
| [GymLocationName](./bitburner.gymlocationname.md) | Locations of gym |
| [GymType](./bitburner.gymtype.md) | |
@@ -164,7 +166,10 @@
| --- | --- |
| [BladeburnerActionName](./bitburner.bladeburneractionname.md) | |
| [BladeburnerActionTypeForSleeve](./bitburner.bladeburneractiontypeforsleeve.md) | |
| [CodingContractData](./bitburner.codingcontractdata.md) | Coding contract data will differ depending on coding contract. |
| [CodingContractAnswer](./bitburner.codingcontractanswer.md) | |
| [CodingContractData](./bitburner.codingcontractdata.md) | |
| [CodingContractObject](./bitburner.codingcontractobject.md) | |
| [CodingContractSignatures](./bitburner.codingcontractsignatures.md) | |
| [CorpEmployeePosition](./bitburner.corpemployeeposition.md) | |
| [CorpIndustryName](./bitburner.corpindustryname.md) | |
| [CorpMaterialName](./bitburner.corpmaterialname.md) | |

View File

@@ -19,7 +19,9 @@ export type NSEnums = {
ToastVariant: typeof ToastVariant;
UniversityClassType: typeof UniversityClassType;
CompanyName: typeof CompanyName;
FactionName: typeof FactionName;
CodingContractName: typeof CodingContractName;
};
```
**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)
**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)<!-- -->, [FactionName](./bitburner.factionname.md)<!-- -->, [CodingContractName](./bitburner.codingcontractname.md)

View File

@@ -26,6 +26,7 @@ import {
ToastVariant,
UniversityClassType,
CompanyName,
FactionName,
type MessageFilename,
} from "@enums";
import { PromptEvent } from "./ui/React/PromptManager";
@@ -124,6 +125,7 @@ export const enums: NSEnums = {
ToastVariant,
UniversityClassType,
CompanyName,
FactionName,
CodingContractName,
};
for (const val of Object.values(enums)) Object.freeze(val);

View File

@@ -8350,6 +8350,50 @@ declare enum CompanyName {
NoodleBar = "Noodle Bar",
}
/**
* Names of all factions.
*
* Warning: Spoiler ahead. This enum contains names of **all** factions. If you do not want to know what all the
* factions are, you should not check this enum. Some factions are only accessible in the endgame.
*
* @public */
declare enum FactionName {
Illuminati = "Illuminati",
Daedalus = "Daedalus",
TheCovenant = "The Covenant",
ECorp = "ECorp",
MegaCorp = "MegaCorp",
BachmanAssociates = "Bachman & Associates",
BladeIndustries = "Blade Industries",
NWO = "NWO",
ClarkeIncorporated = "Clarke Incorporated",
OmniTekIncorporated = "OmniTek Incorporated",
FourSigma = "Four Sigma",
KuaiGongInternational = "KuaiGong International",
FulcrumSecretTechnologies = "Fulcrum Secret Technologies",
BitRunners = "BitRunners",
TheBlackHand = "The Black Hand",
NiteSec = "NiteSec",
Aevum = "Aevum",
Chongqing = "Chongqing",
Ishima = "Ishima",
NewTokyo = "New Tokyo",
Sector12 = "Sector-12",
Volhaven = "Volhaven",
SpeakersForTheDead = "Speakers for the Dead",
TheDarkArmy = "The Dark Army",
TheSyndicate = "The Syndicate",
Silhouette = "Silhouette",
Tetrads = "Tetrads",
SlumSnakes = "Slum Snakes",
Netburners = "Netburners",
TianDiHui = "Tian Di Hui",
CyberSec = "CyberSec",
Bladeburners = "Bladeburners",
ChurchOfTheMachineGod = "Church of the Machine God",
ShadowsOfAnarchy = "Shadows of Anarchy",
}
declare enum CodingContractName {
FindLargestPrimeFactor = "Find Largest Prime Factor",
SubarrayWithMaximumSum = "Subarray with Maximum Sum",
@@ -8441,6 +8485,7 @@ export type NSEnums = {
ToastVariant: typeof ToastVariant;
UniversityClassType: typeof UniversityClassType;
CompanyName: typeof CompanyName;
FactionName: typeof FactionName;
CodingContractName: typeof CodingContractName;
};