mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-21 13:45:44 +01:00
CONTRACTS: createDummyContract returns filename (#1129)
This commit is contained in:
parent
4c7f192645
commit
6a3d22d7bd
@ -9,7 +9,7 @@ Generate a dummy contract.
|
|||||||
**Signature:**
|
**Signature:**
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
createDummyContract(type: string): void;
|
createDummyContract(type: string): string;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Parameters
|
## Parameters
|
||||||
@ -20,7 +20,9 @@ createDummyContract(type: string): void;
|
|||||||
|
|
||||||
**Returns:**
|
**Returns:**
|
||||||
|
|
||||||
void
|
string
|
||||||
|
|
||||||
|
Filename of the contract.
|
||||||
|
|
||||||
## Remarks
|
## Remarks
|
||||||
|
|
||||||
|
@ -47,13 +47,15 @@ export function generateRandomContractOnHome(): void {
|
|||||||
serv.addContract(contract);
|
serv.addContract(contract);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const generateDummyContract = (problemType: string): void => {
|
export const generateDummyContract = (problemType: string): string => {
|
||||||
if (!CodingContractTypes[problemType]) throw new Error(`Invalid problem type: '${problemType}'`);
|
if (!CodingContractTypes[problemType]) throw new Error(`Invalid problem type: '${problemType}'`);
|
||||||
const serv = Player.getHomeComputer();
|
const serv = Player.getHomeComputer();
|
||||||
|
|
||||||
const contractFn = getRandomFilename(serv);
|
const contractFn = getRandomFilename(serv);
|
||||||
const contract = new CodingContract(contractFn, problemType, null);
|
const contract = new CodingContract(contractFn, problemType, null);
|
||||||
serv.addContract(contract);
|
serv.addContract(contract);
|
||||||
|
|
||||||
|
return contractFn;
|
||||||
};
|
};
|
||||||
|
|
||||||
interface IGenerateContractParams {
|
interface IGenerateContractParams {
|
||||||
|
@ -81,7 +81,7 @@ export function NetscriptCodingContract(): InternalAPI<ICodingContract> {
|
|||||||
},
|
},
|
||||||
createDummyContract: (ctx) => (_type) => {
|
createDummyContract: (ctx) => (_type) => {
|
||||||
const type = helpers.string(ctx, "type", _type);
|
const type = helpers.string(ctx, "type", _type);
|
||||||
generateDummyContract(type);
|
return generateDummyContract(type);
|
||||||
},
|
},
|
||||||
getContractTypes: () => () => codingContractTypesMetadata.map((c) => c.name),
|
getContractTypes: () => () => codingContractTypesMetadata.map((c) => c.name),
|
||||||
};
|
};
|
||||||
|
3
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
3
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
@ -3577,8 +3577,9 @@ export interface CodingContract {
|
|||||||
* Generate a dummy contract on the home computer with no reward. Used to test various algorithms.
|
* Generate a dummy contract on the home computer with no reward. Used to test various algorithms.
|
||||||
*
|
*
|
||||||
* @param type - Type of contract to generate
|
* @param type - Type of contract to generate
|
||||||
|
* @returns Filename of the contract.
|
||||||
*/
|
*/
|
||||||
createDummyContract(type: string): void;
|
createDummyContract(type: string): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List all contract types.
|
* List all contract types.
|
||||||
|
Loading…
Reference in New Issue
Block a user