mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-16 06:18:42 +02:00
CONTRACTS: createDummyContract returns filename (#1129)
This commit is contained in:
@@ -9,7 +9,7 @@ Generate a dummy contract.
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
createDummyContract(type: string): void;
|
||||
createDummyContract(type: string): string;
|
||||
```
|
||||
|
||||
## Parameters
|
||||
@@ -20,7 +20,9 @@ createDummyContract(type: string): void;
|
||||
|
||||
**Returns:**
|
||||
|
||||
void
|
||||
string
|
||||
|
||||
Filename of the contract.
|
||||
|
||||
## Remarks
|
||||
|
||||
|
||||
@@ -47,13 +47,15 @@ export function generateRandomContractOnHome(): void {
|
||||
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}'`);
|
||||
const serv = Player.getHomeComputer();
|
||||
|
||||
const contractFn = getRandomFilename(serv);
|
||||
const contract = new CodingContract(contractFn, problemType, null);
|
||||
serv.addContract(contract);
|
||||
|
||||
return contractFn;
|
||||
};
|
||||
|
||||
interface IGenerateContractParams {
|
||||
|
||||
@@ -81,7 +81,7 @@ export function NetscriptCodingContract(): InternalAPI<ICodingContract> {
|
||||
},
|
||||
createDummyContract: (ctx) => (_type) => {
|
||||
const type = helpers.string(ctx, "type", _type);
|
||||
generateDummyContract(type);
|
||||
return generateDummyContract(type);
|
||||
},
|
||||
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.
|
||||
*
|
||||
* @param type - Type of contract to generate
|
||||
* @returns Filename of the contract.
|
||||
*/
|
||||
createDummyContract(type: string): void;
|
||||
createDummyContract(type: string): string;
|
||||
|
||||
/**
|
||||
* List all contract types.
|
||||
|
||||
Reference in New Issue
Block a user