@wayward/types 2.11.1-beta.dev.20211230.1 → 2.11.1-beta.dev.20220102.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,7 +17,7 @@ import { Delay, SkillType } from "game/entity/IHuman";
17
17
  import type { TurnType } from "game/entity/player/IPlayer";
18
18
  import type Player from "game/entity/player/Player";
19
19
  import type { IGameEvents, IPlayOptions, ISynchronizeState } from "game/IGame";
20
- import { SaveType, TickFlag, TurnMode } from "game/IGame";
20
+ import { SaveType, TickFlag, TurnMode, PauseSource } from "game/IGame";
21
21
  import type Island from "game/island/Island";
22
22
  import IslandManager from "game/island/IslandManager";
23
23
  import type { MultiplayerLoadingDescription } from "game/meta/Loading";
@@ -59,7 +59,7 @@ export declare class Game extends EventEmitter.Host<IGameEvents> {
59
59
  readonly interval = 16.6666;
60
60
  slot: number | undefined;
61
61
  absoluteTime: number;
62
- paused: boolean;
62
+ paused: Set<PauseSource>;
63
63
  playing: boolean;
64
64
  nextTickTime: number | undefined;
65
65
  lastTickTime: number | undefined;
@@ -82,6 +82,7 @@ export declare class Game extends EventEmitter.Host<IGameEvents> {
82
82
  private gameOptionsCached?;
83
83
  private synchronizeStateId;
84
84
  protected stringTokenizer: StringTokenizer | undefined;
85
+ get isPaused(): boolean;
85
86
  initializeRenderer(): void;
86
87
  globalSlotReady(): void;
87
88
  /**
@@ -96,7 +97,7 @@ export declare class Game extends EventEmitter.Host<IGameEvents> {
96
97
  resetWebGL(): void;
97
98
  setGlContextSize(width: number, height: number): void;
98
99
  resizeRenderer(): void;
99
- setPaused(paused: boolean, showChatMessage?: boolean): void;
100
+ setPaused(pause: boolean, source: PauseSource): void;
100
101
  gameLogicLoop: () => void;
101
102
  isSimulatedOrRealTimeMode(): boolean;
102
103
  getTurnMode(): TurnMode;
@@ -165,7 +166,8 @@ export declare class Game extends EventEmitter.Host<IGameEvents> {
165
166
  * This method should be able to be called multiple times in a row and nothing unexpected should occur.
166
167
  * @param saveType Saves the game with the specified save type. Set to false to not save. Defaults to BackToMainMenu.
167
168
  * @param shouldDisconnect Marks if the game should disconnect from multiplayer. Defaults to true.
169
+ * @param hasDisconnected Marks if the game just disconnected from multiplayer. Defaults to false.
168
170
  */
169
- reset(saveType?: SaveType | false, shouldDisconnect?: boolean): Promise<void>;
171
+ reset(saveType?: SaveType | false, shouldDisconnect?: boolean, hasDisconnected?: boolean): Promise<void>;
170
172
  fastForwardIsland(island: Island, ticks: number, multiplayerLoadingDescription?: MultiplayerLoadingDescription): Promise<void>;
171
173
  }
@@ -205,6 +205,18 @@ export declare enum CreationId {
205
205
  Item = 4,
206
206
  TileEvent = 5
207
207
  }
208
+ export declare enum PauseSource {
209
+ /**
210
+ * Used for pauses that the player will be able to turn on / off / override
211
+ */
212
+ Generic = 0,
213
+ IslandLoad = 1,
214
+ Mod = 2,
215
+ PlayerMoveToIsland = 3,
216
+ SyncGameState = 4,
217
+ WebGlContextLost = 5,
218
+ MultiplayerConnect = 6
219
+ }
208
220
  /**
209
221
  * For items and terrain that can decay, the temperature range that controls the rate of decay.
210
222
  * If not provided for items, they will always decays no matter the temperature.
@@ -86,6 +86,11 @@ export default class Island extends EventEmitter.Host<IIslandEvents> implements
86
86
  loadCount: number;
87
87
  seeds: ISeeds;
88
88
  readonly seededRandom: Random<SeededGenerator>;
89
+ /**
90
+ * Random for milestone modifiers. You should only use the one in the default island
91
+ * todo: remove since this is no longer used
92
+ */
93
+ readonly seededMilestoneModifiersRandom: Random<SeededGenerator>;
89
94
  /**
90
95
  * Set of players on this island
91
96
  */
@@ -196,7 +201,7 @@ export default class Island extends EventEmitter.Host<IIslandEvents> implements
196
201
  * @param z The z coord to get the closest player.
197
202
  * @param canSee If set to true, check if the player can see the x/y/z coords. Defaults to false.
198
203
  */
199
- getNearestPlayer(x: number, y: number, z?: number, canSee?: boolean, includeConnecting?: boolean): {
204
+ getNearestPlayer(x: number, y: number, z?: number, canSee?: boolean, includeGhosts?: boolean, includeConnecting?: boolean): {
200
205
  player?: Player;
201
206
  distance?: number;
202
207
  };
@@ -74,31 +74,32 @@ export declare enum MultiplayerSyncCheck {
74
74
  Merchant = 36,
75
75
  MilestoneSeed = 37,
76
76
  Misc = 38,
77
- MoveToTile = 39,
78
- PenaltyFieldHashCode = 40,
79
- PlaceOnTile = 41,
80
- PlayerManager = 42,
81
- PlayerPositions = 43,
82
- Players = 44,
83
- PlayerSetup = 45,
84
- Random = 46,
85
- Reputation = 47,
86
- Seed = 48,
87
- SeededGenerator = 49,
88
- SkillGain = 50,
89
- StaminaChanges = 51,
90
- StatChange = 52,
91
- Stats = 53,
92
- StatusChange = 54,
93
- StatusEffect = 55,
94
- SyncChecks = 56,
95
- TemperatureManager = 57,
96
- Temporary = 58,
97
- Tick = 59,
98
- TileEvent = 60,
99
- Time = 61,
100
- UpdateDirection = 62,
101
- Weight = 63
77
+ Modifier = 39,
78
+ MoveToTile = 40,
79
+ PenaltyFieldHashCode = 41,
80
+ PlaceOnTile = 42,
81
+ PlayerManager = 43,
82
+ PlayerPositions = 44,
83
+ Players = 45,
84
+ PlayerSetup = 46,
85
+ Random = 47,
86
+ Reputation = 48,
87
+ Seed = 49,
88
+ SeededGenerator = 50,
89
+ SkillGain = 51,
90
+ StaminaChanges = 52,
91
+ StatChange = 53,
92
+ Stats = 54,
93
+ StatusChange = 55,
94
+ StatusEffect = 56,
95
+ SyncChecks = 57,
96
+ TemperatureManager = 58,
97
+ Temporary = 59,
98
+ Tick = 60,
99
+ TileEvent = 61,
100
+ Time = 62,
101
+ UpdateDirection = 63,
102
+ Weight = 64
102
103
  }
103
104
  export declare const maxPlayers = 32;
104
105
  export declare const packetTickRate = 16;
@@ -47,7 +47,6 @@ export declare abstract class Connection implements IConnection {
47
47
  sendKeepAlive(): void;
48
48
  getState(): ConnectionState;
49
49
  setState(state: ConnectionState): void;
50
- serializePacket(packet: IPacket): ArrayBuffer;
51
50
  /**
52
51
  * Queues a packet to be sent soon
53
52
  * Note: packets are serialized when queued
@@ -56,7 +55,7 @@ export declare abstract class Connection implements IConnection {
56
55
  /**
57
56
  * Queues data to be sent soon
58
57
  */
59
- protected queuePacketData(data: ArrayBuffer): void;
58
+ protected queuePacketData(data: ArrayBuffer, packetNumber?: number): void;
60
59
  /**
61
60
  * Clears queued packets
62
61
  */
@@ -73,6 +72,7 @@ export declare abstract class Connection implements IConnection {
73
72
  * Sends queued data to the connection w/ flow control
74
73
  */
75
74
  private _processQueuedData;
75
+ private _serializePacket;
76
76
  abstract readonly maxMessageSize: number;
77
77
  abstract isConnected(): boolean;
78
78
  protected abstract onClosing(): void;
@@ -69,5 +69,6 @@ export interface IConnection {
69
69
  export interface IQueuedData {
70
70
  data: ArrayBuffer;
71
71
  byteOffset: number;
72
+ packetNumber?: number;
72
73
  retries?: number;
73
74
  }
@@ -31,8 +31,8 @@ export interface IPacket<T = any> {
31
31
  isSyncCheckEnabled(): boolean;
32
32
  isAllowedWhenPaused(): boolean;
33
33
  process(): T;
34
- processData(dataView: DataView): void;
35
- preSerialize(): void;
34
+ processSerializedData(dataView: DataView): void;
35
+ serializeData(): void;
36
36
  }
37
37
  export declare enum NetworkPropertyType {
38
38
  Bool = 0,
@@ -22,8 +22,8 @@ export declare abstract class Packet<T = void> extends IndexedPacket implements
22
22
  isAllowedWhenPaused(): boolean;
23
23
  getSynchronizationCheckData(): ISynchronizationCheckData;
24
24
  getArrayBuffer(id?: number): ArrayBuffer;
25
- preSerialize(): number;
26
- processData(dataView: DataView): void;
25
+ serializeData(): number;
26
+ processSerializedData(dataView: DataView): void;
27
27
  abstract process(): T;
28
28
  send(exclude?: PacketTarget): void;
29
29
  sendTo(to: PacketTarget, force?: boolean): void;
@@ -8,10 +8,11 @@
8
8
  * Wayward is a copyrighted and licensed work. Modification and/or distribution of any source files is prohibited. If you wish to modify the game in any way, please refer to the modding guide:
9
9
  * https://github.com/WaywardGame/types/wiki
10
10
  */
11
+ import { PauseSource } from "game/IGame";
11
12
  import ClientPacket from "multiplayer/packets/ClientPacket";
12
13
  export default class PausePacket extends ClientPacket {
13
14
  paused: boolean;
14
- showChatMessage: boolean;
15
+ pauseSource: PauseSource;
15
16
  getDebugInfo(): string;
16
17
  process(): void;
17
18
  }
@@ -132,7 +132,6 @@ export declare module RandomReference {
132
132
  export declare function getRandom(randomInstance: RandomInstance, islandId?: IslandId): Random<SeededGenerator>;
133
133
  export declare function createSeededRandom(seed?: number, addMultiplayerSyncChecks?: boolean): Random<SeededGenerator>;
134
134
  export declare const mapGenRandom: Random<SeededGenerator>;
135
- export declare const randomMilestoneModifiers: Random<SeededGenerator>;
136
135
  export declare const generalRandom: Random<{
137
136
  get: () => number;
138
137
  }>;
@@ -23,7 +23,7 @@ export default class ApplicationDom {
23
23
  clickIfVisibleElement(selector: string): Promise<WebdriverIO.Element | undefined>;
24
24
  getVisibleElements(selector: string): Promise<WebdriverIO.Element[] | undefined>;
25
25
  getVisibleAndClickableElement(selector: string): Promise<WebdriverIO.Element | undefined>;
26
- waitForVisibleThenClick(selector: string, timeout?: number, indent?: boolean): Promise<void>;
26
+ waitForVisibleThenClick(selector: string, timeout?: number, indent?: boolean, clickOnce?: boolean): Promise<void>;
27
27
  waitForVisibleElements(selector: string, timeout?: number): Promise<WebdriverIO.Element[]>;
28
28
  waitForNotVisible(selector: string, timeout?: number): Promise<void>;
29
29
  waitUntil(executor: () => Promise<boolean>, options: webdriverio.WaitUntilOptions): Promise<true | void>;
@@ -12,8 +12,7 @@
12
12
  import type { Stat } from "../../game/game/entity/IStats";
13
13
  import { Direction } from "../../game/utilities/math/Direction";
14
14
  import type { Random, SeededGenerator } from "../../game/utilities/random/Random";
15
- import type { INewGameOptions } from "../interfaces";
16
- import { GameMode } from "../interfaces";
15
+ import type { IDedicatedServerGameOptions, IJoinServerOptions, INewGameOptions } from "../interfaces";
17
16
  import type { IslandId } from "../../game/game/island/IIsland";
18
17
  import ApplicationDom from "./applicationDom";
19
18
  import ApplicationLogger from "./applicationLogger";
@@ -27,11 +26,14 @@ export default class ApplicationInteractions {
27
26
  constructor(additionalArgs: string[], random: Random<SeededGenerator>);
28
27
  waitForInitialStartup(expectedInitialScreen: "title" | "mp_gameplay_modifiers"): Promise<void>;
29
28
  waitUntilLoadingIsFinished(expectedMultiplayerMenu?: boolean): Promise<void>;
30
- playDedicatedServer(gameMode?: GameMode): Promise<void>;
29
+ playDedicatedServer(options: IDedicatedServerGameOptions): Promise<void>;
31
30
  playNewGame(options: INewGameOptions): Promise<void>;
31
+ private setupCommonOptions;
32
+ unlockMilestoneModifiers(): Promise<void>;
32
33
  playImportedGame(savePath: string): Promise<void>;
33
34
  playContinueGame(): Promise<void>;
34
35
  quitGame(): Promise<void>;
36
+ clickOptions(): Promise<void>;
35
37
  clickNewGame(): Promise<void>;
36
38
  clickLoadGame(): Promise<void>;
37
39
  clickConfirm(): Promise<void>;
@@ -41,7 +43,11 @@ export default class ApplicationInteractions {
41
43
  clickJoinServer(): Promise<void>;
42
44
  clickDailyChallenge(): Promise<void>;
43
45
  clickBack(timeout?: number): Promise<void>;
44
- clickButton(name: string, timeout?: number): Promise<void>;
46
+ clickButton(name: string, options?: Partial<{
47
+ force: boolean;
48
+ clickOnce: boolean;
49
+ timeout: number;
50
+ }>): Promise<void>;
45
51
  clickYesIfVisible(): Promise<boolean>;
46
52
  clickButtonIfVisible(name: string): Promise<boolean>;
47
53
  clickUnpauseIconIfVisible(): Promise<void>;
@@ -61,8 +67,7 @@ export default class ApplicationInteractions {
61
67
  waitForGameEndScreen(isWinner: boolean): Promise<void>;
62
68
  returnToTitleScreen(): Promise<void>;
63
69
  getServerGameCode(): Promise<string>;
64
- joinMultiplayerServer(gameCode: string): Promise<void>;
65
- joinMultiplayerDedicatedServer(gameCode: string): Promise<void>;
70
+ joinMultiplayerServer(gameCode: string, options: IJoinServerOptions, isDedicatedServer: boolean): Promise<void>;
66
71
  pauseGame(): Promise<void>;
67
72
  unpauseGame(): Promise<void>;
68
73
  moveToIslandId(islandId: IslandId): Promise<void>;
@@ -80,7 +85,10 @@ export default class ApplicationInteractions {
80
85
  isOverlayVisible(): Promise<WebdriverIO.Element[] | undefined>;
81
86
  waitUntilTitleScreenIsVisible(): Promise<void>;
82
87
  waitUntilGameEndMenuIsVisible(): Promise<void>;
83
- waitForVisibleButtonThenClick(name: string, timeout?: number): Promise<void>;
88
+ waitForVisibleButtonThenClick(name: string, options?: Partial<{
89
+ clickOnce: boolean;
90
+ timeout: number;
91
+ }>): Promise<void>;
84
92
  increaseStat(stat: Stat, value: number): Promise<void>;
85
93
  randomInput(count: number): Promise<void>;
86
94
  pressKey(key: string, modifier?: string): Promise<void>;
@@ -10,7 +10,7 @@
10
10
  */
11
11
  import type Player from "../../game/game/entity/player/Player";
12
12
  import { Direction } from "../../game/utilities/math/Direction";
13
- import type { GameMode } from "../interfaces";
13
+ import type { IJoinServerOptions, INewGameOptions } from "../interfaces";
14
14
  import type { IDifferences } from "../../game/utilities/object/JsonHelper";
15
15
  import type Application from "./application";
16
16
  import type { ITestState } from "./application";
@@ -62,10 +62,10 @@ export declare class Apps {
62
62
  getLog(): string[];
63
63
  compileDifferences(client: string | number, differences: IDifferences): string;
64
64
  verifyGameStates(): Promise<void>;
65
- createMultiplayerGame(gameMode: GameMode): Promise<void>;
65
+ createMultiplayerGame(options: Omit<INewGameOptions, "playMode">): Promise<void>;
66
66
  setClientJoinIsland(x: number, y: number): Promise<void>;
67
67
  getServerGameCode(): Promise<string>;
68
- joinServer(...apps: Application[]): Promise<void>;
68
+ joinServer(options: IJoinServerOptions, ...apps: Application[]): Promise<void>;
69
69
  leaveServer(...apps: Application[]): Promise<void>;
70
70
  returnToTitleScreen(): Promise<void>;
71
71
  waitUntilLoadingIsFinished(): Promise<void>;
@@ -8,11 +8,19 @@
8
8
  * Wayward is a copyrighted and licensed work. Modification and/or distribution of any source files is prohibited. If you wish to modify the game in any way, please refer to the modding guide:
9
9
  * https://github.com/WaywardGame/types/wiki
10
10
  */
11
- export interface INewGameOptions {
11
+ export interface ICommonGameOptions {
12
12
  gameMode: GameMode;
13
+ seed?: string | number;
14
+ enableAllMilestoneModifiers?: boolean;
15
+ }
16
+ export interface INewGameOptions extends ICommonGameOptions {
13
17
  playMode: GamePlayMode;
14
18
  reuseCharacter?: boolean;
15
- seed?: string | number;
19
+ }
20
+ export declare type IDedicatedServerGameOptions = ICommonGameOptions;
21
+ export interface IJoinServerOptions {
22
+ joinProgrammatically: boolean;
23
+ enableAllMilestoneModifiers?: boolean;
16
24
  }
17
25
  export declare enum GameMode {
18
26
  Hardcore = "Hardcore Mode",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wayward/types",
3
3
  "description": "TypeScript declarations for Wayward, used for modding.",
4
- "version": "2.11.1-beta.dev.20211230.1",
4
+ "version": "2.11.1-beta.dev.20220102.1",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -14,11 +14,11 @@
14
14
  "watch": "tsc --build"
15
15
  },
16
16
  "dependencies": {
17
+ "@types/fs-extra": "^9.0.13",
18
+ "@types/node": "^17.0.5",
17
19
  "@wayward/goodstream": "0.7.1"
18
20
  },
19
21
  "devDependencies": {
20
- "@wayward/game": "^1.0.0",
21
- "@types/node": "^17.0.5",
22
- "@types/fs-extra": "^9.0.13"
22
+ "@wayward/game": "^1.0.0"
23
23
  }
24
24
  }
@@ -12,7 +12,8 @@
12
12
  "removeComments": true,
13
13
  "strict": true,
14
14
  "strictPropertyInitialization": false,
15
- "moduleResolution": "node",
15
+ // classic is required for auto imports to use the shortest path in vscode
16
+ "moduleResolution": "classic",
16
17
  "paths": {
17
18
  "*": [
18
19
  "node_modules/@wayward/types/definitions/game/*"
@@ -22,6 +23,15 @@
22
23
  ],
23
24
  "@hosts/*": [
24
25
  "node_modules/@wayward/types/definitions/hosts/*"
26
+ ],
27
+ // required when using classic module resolution
28
+ "@wayward/goodstream": [
29
+ "node_modules/@wayward/goodstream/Stream",
30
+ "node_modules/@wayward/types/node_modules/@wayward/goodstream/Stream"
31
+ ],
32
+ "@wayward/goodstream/*": [
33
+ "node_modules/@wayward/goodstream/*",
34
+ "node_modules/@wayward/types/node_modules/@wayward/goodstream/*"
25
35
  ]
26
36
  },
27
37
  "types": [],