Skip to content

Commit 675cce9

Browse files
committed
feat: add CreateNewGame
1 parent 55dc226 commit 675cce9

File tree

3 files changed

+80
-0
lines changed

3 files changed

+80
-0
lines changed

src/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ export type {
1313
ClaimServerRequest,
1414
ClaimServerResponse,
1515
ClaimServerResponseData,
16+
CreateNewGameRequest,
17+
CreateNewGameResponse,
1618
ErrorResponse,
1719
GetAdvancedGameSettingsRequest,
1820
GetAdvancedGameSettingsResponse,

src/v1/CreateNewGame.ts

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import type { ApiRequest, BooleanString } from "./common.js";
2+
import { buildApiRequest } from "./common.js";
3+
4+
export type CreateNewGameRequest = ApiRequest<
5+
"CreateNewGame",
6+
{
7+
/**
8+
* Parameters needed to create new game session.
9+
*/
10+
newGameData: {
11+
/**
12+
* Name of the session to create.
13+
*/
14+
sessionName: string;
15+
/**
16+
* Path Name to the Map Package to use as a map.
17+
*
18+
* If not specified, default level.
19+
*/
20+
mapName?: string;
21+
/**
22+
* Name of the starting location to use.
23+
*
24+
* Leaving it empty will use random starting location.
25+
*/
26+
startingLocation: string;
27+
/**
28+
* Whenever the Onboarding should be skipped.
29+
*
30+
* Currently Onboarding is always skipped on the Dedicated Servers.
31+
*/
32+
skipOnboarding: boolean;
33+
/**
34+
* Advanced Game Settings to apply to the newly created session.
35+
*/
36+
advancedGameSettings: {
37+
"FG.GameRules.NoPower"?: BooleanString;
38+
"FG.GameRules.DisableArachnidCreatures"?: BooleanString;
39+
"FG.GameRules.NoUnlockCost"?: BooleanString;
40+
"FG.GameRules.SetGamePhase"?: string;
41+
"FG.GameRules.GiveAllTiers"?: BooleanString;
42+
"FG.GameRules.UnlockAllResearchSchematics"?: BooleanString;
43+
"FG.GameRules.UnlockInstantAltRecipes"?: BooleanString;
44+
"FG.GameRules.UnlockAllResourceSinkSchematics"?: BooleanString;
45+
"FG.GameRules.GiveItems"?: string;
46+
"FG.PlayerRules.NoBuildCost"?: BooleanString;
47+
"FG.PlayerRules.GodMode"?: BooleanString;
48+
"FG.PlayerRules.FlightMode"?: BooleanString;
49+
[key: string]: string | BooleanString | undefined;
50+
};
51+
/**
52+
* Custom Options to pass to the newly created session URL.
53+
*
54+
* Not used by vanilla Dedicated Servers.
55+
*/
56+
customOptionsOnlyForModding: Record<string, string>;
57+
};
58+
}
59+
>;
60+
61+
export type CreateNewGameResponse = string;
62+
63+
export const buildCreateNewGame = buildApiRequest<
64+
CreateNewGameRequest,
65+
CreateNewGameResponse
66+
>("v1", {
67+
function: "CreateNewGame",
68+
});

src/v1/index.ts

+10
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { buildApplyAdvancedGameSettings } from "./ApplyAdvancedGameSettings.js";
22
import { buildApplyServerOptions } from "./ApplyServerOptions.js";
33
import { buildClaimServer } from "./ClaimServer.js";
44
import type { InternalClientOptions } from "./common.js";
5+
import { buildCreateNewGame } from "./CreateNewGame.js";
56
import { buildGetAdvancedGameSettings } from "./GetAdvancedGameSettings.js";
67
import { buildGetServerOptions } from "./GetServerOptions.js";
78
import { buildHealthCheck } from "./HealthCheck.js";
@@ -138,13 +139,22 @@ export function buildV1(options: InternalClientOptions) {
138139
* Function does not return any data on success.
139140
*/
140141
ApplyServerOptions: buildApplyServerOptions(options),
142+
/**
143+
* Creates a new session on the Dedicated Server, and immediately loads it.
144+
*
145+
* HTTPS API becomes temporarily unavailable when map loading is in progress.
146+
*
147+
* Function does not return any data on success.
148+
*/
149+
CreateNewGame: buildCreateNewGame(options),
141150
};
142151
}
143152

144153
export type * from "./ApplyAdvancedGameSettings.js";
145154
export type * from "./ApplyServerOptions.js";
146155
export type * from "./ClaimServer.js";
147156
export type * from "./common.js";
157+
export type * from "./CreateNewGame.js";
148158
export type * from "./error.js";
149159
export type * from "./GetAdvancedGameSettings.js";
150160
export type * from "./GetServerOptions.js";

0 commit comments

Comments
 (0)