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

@@ -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
}
```