Skip to content

Commit ca66d9d

Browse files
committed
feat: add ApplyAdvancedGameSettings
1 parent bae7550 commit ca66d9d

File tree

5 files changed

+69
-0
lines changed

5 files changed

+69
-0
lines changed

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,16 @@ client.v1
7373
.then((response) => {
7474
console.log("PasswordLogin Response:", response);
7575
});
76+
77+
client.v1
78+
.ApplyAdvancedGameSettings({
79+
data: {
80+
appliedAdvancedGameSettings: {
81+
"FG.GameRules.NoPower": "False",
82+
},
83+
},
84+
})
85+
.then((response) => {
86+
console.log("ApplyAdvancedGameSettings Response:", typeof response);
87+
});
7688
```

src/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ export { PrivilegeLevel } from "./v1/common.js";
44
export type {
55
ApiRequest,
66
ApiSuccessResponse,
7+
ApplyAdvancedGameSettingsRequest,
8+
ApplyAdvancedGameSettingsResponse,
79
BooleanString,
810
ErrorResponse,
911
GetAdvancedGameSettingsRequest,

src/v1/ApplyAdvancedGameSettings.ts

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import type { ApiRequest, BooleanString } from "./common.js";
2+
import { buildApiRequest } from "./common.js";
3+
4+
export type ApplyAdvancedGameSettingsRequest = ApiRequest<
5+
"ApplyAdvancedGameSettings",
6+
{
7+
/**
8+
* Key is the name of the Advanced Game Setting, and the Value is the new setting value as string.
9+
*/
10+
appliedAdvancedGameSettings: {
11+
"FG.GameRules.NoPower"?: BooleanString;
12+
"FG.GameRules.DisableArachnidCreatures"?: BooleanString;
13+
"FG.GameRules.NoUnlockCost"?: BooleanString;
14+
"FG.GameRules.SetGamePhase"?: string;
15+
"FG.GameRules.GiveAllTiers"?: BooleanString;
16+
"FG.GameRules.UnlockAllResearchSchematics"?: BooleanString;
17+
"FG.GameRules.UnlockInstantAltRecipes"?: BooleanString;
18+
"FG.GameRules.UnlockAllResourceSinkSchematics"?: BooleanString;
19+
"FG.GameRules.GiveItems"?: string;
20+
"FG.PlayerRules.NoBuildCost"?: BooleanString;
21+
"FG.PlayerRules.GodMode"?: BooleanString;
22+
"FG.PlayerRules.FlightMode"?: BooleanString;
23+
[key: string]: string | BooleanString | undefined;
24+
};
25+
}
26+
>;
27+
28+
export type ApplyAdvancedGameSettingsResponse = string;
29+
30+
export const buildApplyAdvancedGameSettings = buildApiRequest<
31+
ApplyAdvancedGameSettingsRequest,
32+
ApplyAdvancedGameSettingsResponse
33+
>("v1", {
34+
function: "ApplyAdvancedGameSettings",
35+
});

src/v1/index.ts

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { buildApplyAdvancedGameSettings } from "./ApplyAdvancedGameSettings.js";
12
import type { InternalClientOptions } from "./common.js";
23
import { buildGetAdvancedGameSettings } from "./GetAdvancedGameSettings.js";
34
import { buildGetServerOptions } from "./GetServerOptions.js";
@@ -47,9 +48,16 @@ export function buildV1(options: InternalClientOptions) {
4748
* Retrieves currently applied advanced game settings.
4849
*/
4950
GetAdvancedGameSettings: buildGetAdvancedGameSettings(options),
51+
/**
52+
* Applies new values to the provided Advanced Game Settings properties.
53+
*
54+
* Will automatically enable Advanced Game Settings for the currently loaded save if they are not enabled already.
55+
*/
56+
ApplyAdvancedGameSettings: buildApplyAdvancedGameSettings(options),
5057
};
5158
}
5259

60+
export type * from "./ApplyAdvancedGameSettings.js";
5361
export type * from "./common.js";
5462
export type * from "./error.js";
5563
export type * from "./GetAdvancedGameSettings.js";

test.js

+12
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,15 @@ client.v1
5454
.then((response) => {
5555
console.log("PasswordLogin Response:", response);
5656
});
57+
58+
client.v1
59+
.ApplyAdvancedGameSettings({
60+
data: {
61+
appliedAdvancedGameSettings: {
62+
"FG.GameRules.NoPower": "False",
63+
},
64+
},
65+
})
66+
.then((response) => {
67+
console.log("ApplyAdvancedGameSettings Response:", typeof response);
68+
});

0 commit comments

Comments
 (0)