@wayward/types 2.14.4-beta.dev.20241228.1 → 2.14.4-beta.dev.20241230.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.
@@ -10,7 +10,7 @@
10
10
  */
11
11
  import { Uninit } from "@wayward/game/Uninit";
12
12
  import CommandManager from "@wayward/game/command/CommandManager";
13
- import type { IGameEvents, IMovementTime, IPlayOptions, ISynchronizeState } from "@wayward/game/game/IGame";
13
+ import type { IGameEvents, IGameUpgradeState, IMovementTime, IPlayOptions, ISynchronizeState } from "@wayward/game/game/IGame";
14
14
  import { PauseSource, SaveType, TurnMode } from "@wayward/game/game/IGame";
15
15
  import { TickHelper } from "@wayward/game/game/TickHelper";
16
16
  import type { BiomeTypes } from "@wayward/game/game/biome/IBiome";
@@ -51,7 +51,6 @@ import type { IVector2 } from "@wayward/game/utilities/math/IVector";
51
51
  import { WebWorkerManager } from "@wayward/game/webWorker/WebWorkerManager";
52
52
  import EventEmitter from "@wayward/utilities/event/EventEmitter";
53
53
  import type { Random } from "@wayward/utilities/random/Random";
54
- import type { IBuildId } from "@wayward/hosts/shared/globalTypes";
55
54
  export declare class Game extends EventEmitter.Host<IGameEvents> {
56
55
  get isChallenge(): boolean;
57
56
  private difficultyOptions;
@@ -71,9 +70,10 @@ export declare class Game extends EventEmitter.Host<IGameEvents> {
71
70
  * The version the save was originally created on
72
71
  */
73
72
  version: Version.String;
74
- lastSaveVersion?: Version.String;
75
- lastSaveBuildTime?: number;
76
- lastSaveBuildId?: IBuildId;
73
+ /**
74
+ * Set when a game save upgrade is running
75
+ */
76
+ upgradeState?: IGameUpgradeState;
77
77
  readonly interval = 16.6666;
78
78
  readonly autoSave: AutoSave;
79
79
  readonly commandManager: CommandManager;
@@ -31,6 +31,7 @@ import type { IReplayLogEntry } from "@wayward/game/replay/IReplayLogEntry";
31
31
  import type { IHighscoreOld, IOptions } from "@wayward/game/save/data/ISaveDataGlobal";
32
32
  import type Version from "@wayward/game/utilities/Version";
33
33
  import type { IVector2, IVector3 } from "@wayward/game/utilities/math/IVector";
34
+ import type { IBuildId } from "@wayward/hosts/shared/globalTypes";
34
35
  import type { IRange } from "@wayward/utilities/math/Range";
35
36
  export interface IGameEvents {
36
37
  /**
@@ -303,6 +304,20 @@ export interface IMovementTime {
303
304
  start: number;
304
305
  end: number;
305
306
  }
307
+ export interface IGameUpgradeState {
308
+ /**
309
+ * Current state of the upgrade. Set based on what is upgrading at the time.
310
+ */
311
+ state: GameUpgradeState;
312
+ readonly lastSaveVersion: Version.String;
313
+ readonly lastSaveBuildTime: number;
314
+ readonly lastSaveBuildId: IBuildId | undefined;
315
+ }
316
+ export declare enum GameUpgradeState {
317
+ None = 0,
318
+ Game = 1,
319
+ Island = 2
320
+ }
306
321
  export declare const LINE_OF_SIGHT_RADIUS = 15;
307
322
  export declare const LINE_OF_SIGHT_RADIUS_MAX = 20;
308
323
  export declare const LINE_OF_SIGHT_DETAIL = 4;
@@ -92,6 +92,15 @@ export default class Player extends Human<undefined, number, ReferenceType.Playe
92
92
  */
93
93
  private onLoadOrUnload;
94
94
  setup(spawnTile: Tile, respawn: boolean): void;
95
+ private setupEquipment;
96
+ private setupStats;
97
+ private setupSkills;
98
+ private setupRandomInventory;
99
+ private setupStatuses;
100
+ private setupItemsFromGroups;
101
+ private setupAdditionalItemsFromOptions;
102
+ private setupEquipmentFromOptions;
103
+ private setupSkillsFromOptions;
95
104
  protected onNoInput(): void;
96
105
  updateTables(source: string, options?: Partial<{
97
106
  allowCaching: boolean;
@@ -137,7 +137,7 @@ export default class Island extends EventEmitter.Host<IIslandEvents> implements
137
137
  get isFastForwarding(): boolean;
138
138
  constructor(game?: Game, position?: IVector2, seed?: number, mapSize?: number);
139
139
  toString(): string;
140
- createStaticRandom(seed?: number): Random<PCGSeededGenerator>;
140
+ createStaticRandom(seed?: number, advance?: number): Random<PCGSeededGenerator>;
141
141
  private registerMemoryLeakDetector;
142
142
  preSerializeObject(serializer: ISerializer): void;
143
143
  postSerializeObject(serializer: ISerializer): void;
@@ -12,7 +12,7 @@ import Deity from "@wayward/game/game/deity/Deity";
12
12
  import { DamageType } from "@wayward/game/game/entity/IEntity";
13
13
  import { SkillType } from "@wayward/game/game/entity/IHuman";
14
14
  import { Stat } from "@wayward/game/game/entity/IStats";
15
- import type { IItemDescription, IMagicalPropertyInfo } from "@wayward/game/game/item/IItem";
15
+ import type { IItemDescription, IMagicalPropertyInfo, ItemType } from "@wayward/game/game/item/IItem";
16
16
  import type Item from "@wayward/game/game/item/Item";
17
17
  import type { MagicalPropertyIdentity } from "@wayward/game/game/magic/MagicalPropertyManager";
18
18
  import type { TranslationArg } from "@wayward/game/language/ITranslation";
@@ -94,7 +94,7 @@ export interface IMagicalPropertyDescription {
94
94
  /**
95
95
  * Generates the magical property value when added.
96
96
  */
97
- getInfo(item: Item, description: IItemDescription): IMagicalPropertyInfo | undefined;
97
+ getInfo(item: Item | ItemType, description: IItemDescription): IMagicalPropertyInfo | undefined;
98
98
  /**
99
99
  * By default, all magical property types can be inscribed. This allows disabling that feature for this magical property type.
100
100
  */
@@ -111,4 +111,22 @@ export interface MagicalPropertyTypeSubTypeMap {
111
111
  [MagicalPropertyType.ElementalDamage]: DamageType;
112
112
  [MagicalPropertyType.StatPotency_EquipmentImproveConsumableStats]: Stat;
113
113
  }
114
+ export declare namespace MagicalPropertyInfoHelper {
115
+ /**
116
+ * Creates a partial `IMagicalPropertyDescription` that generates an integer value from min (inclusive) to max (exclusive),
117
+ * with an *actual* max for the magical property using `max`. (1 higher)
118
+ */
119
+ function intRange(item: Item | ItemType, min: number, max: number, generatedMax?: number): {
120
+ min: number;
121
+ max: number;
122
+ value: () => number;
123
+ };
124
+ function randomInt(item: Item | ItemType, maxExclusive: number): number;
125
+ function randomInt(item: Item | ItemType, min: number, maxExclusive: number): number;
126
+ function randomIntInRange(item: Item | ItemType, max: number): number;
127
+ function randomIntInRange(item: Item | ItemType, min: number, maxInclusive: number): number;
128
+ function randomFloat(item: Item | ItemType, maxExclusive: number): number;
129
+ function randomFloat(item: Item | ItemType, min: number, maxExclusive: number): number;
130
+ function functionRequiringItem<T>(item: Item | ItemType, fn: (item: Item) => T): () => T;
131
+ }
114
132
  export declare const magicalPropertyDescriptions: PartialRecord<MagicalPropertyType, IMagicalPropertyDescription>;
@@ -12,7 +12,7 @@ import type { SkillType } from "@wayward/game/game/entity/IHuman";
12
12
  import type { ItemType } from "@wayward/game/game/item/IItem";
13
13
  import type { IGameOptions, IGameOptionsSkill } from "@wayward/game/game/options/IGameOptions";
14
14
  import { GameMode } from "@wayward/game/game/options/IGameOptions";
15
- import Version from "@wayward/game/utilities/Version";
15
+ import type Version from "@wayward/game/utilities/Version";
16
16
  export declare const CREATURE_SPAWN_LIMIT = 15;
17
17
  declare namespace GameOptions {
18
18
  export function getDefault(difficulty?: GameMode, seed?: number): IGameOptions;
@@ -37,82 +37,84 @@ export declare enum MultiplayerSyncCheckLevel {
37
37
  All = "all"
38
38
  }
39
39
  export declare enum MultiplayerSyncCheck {
40
- Action = 0,
41
- ActionAttack = 1,
42
- ActionMove = 2,
43
- Alignment = 3,
44
- BaseEntityManager = 4,
45
- CanASeeB = 5,
46
- Container = 6,
47
- Creature = 7,
48
- CreatureAi = 8,
49
- CreatureAiAdd = 9,
50
- CreatureAiEmit = 10,
51
- CreatureAiMaskAdd = 11,
52
- CreatureAiMaskRemove = 12,
53
- CreatureAiRemove = 13,
54
- CreatureAiSet = 14,
55
- CreatureCheckMove = 15,
56
- CreatureMovement = 16,
57
- CreatureNearestPlayer = 17,
58
- CreatureOffer = 18,
59
- CreatureStatChange = 19,
60
- Damage = 20,
61
- Dismantle = 21,
62
- Doodad = 22,
63
- DoodadManager = 23,
64
- EncumberedStatus = 24,
65
- Entity = 25,
66
- EntityPosition = 26,
67
- ExhaustedPreMove = 27,
68
- FlowFieldHashCode = 28,
69
- FlowFieldPenalty = 29,
70
- FlowFieldUpdate = 30,
71
- FlowFieldUpdateTile = 31,
72
- FlowFieldValue = 32,
73
- HandToUse = 33,
74
- HealthChange = 34,
75
- History = 35,
76
- InventoryCount = 36,
77
- Island = 37,
78
- IslandCivilizationScore = 38,
79
- Islands = 39,
80
- IsTileEmpty = 40,
81
- Item = 41,
82
- ItemCraft = 42,
83
- ItemDamage = 43,
84
- ItemOrder = 44,
85
- LastCreationIds = 45,
86
- Merchant = 46,
87
- MilestoneSeed = 47,
88
- Modifier = 48,
89
- MoveToTile = 49,
90
- NPC = 50,
91
- Option = 51,
92
- PenaltyFieldHashCode = 52,
93
- PlaceOnTile = 53,
94
- PlayerManager = 54,
95
- Players = 55,
96
- PlayerSetup = 56,
97
- Random = 57,
98
- Seed = 58,
99
- SeededGenerator = 59,
100
- SetPosition = 60,
101
- SetZ = 61,
102
- SkillGain = 62,
103
- StaminaChanges = 63,
104
- StatChange = 64,
105
- Stats = 65,
106
- Status = 66,
107
- StatusChange = 67,
108
- TemperatureManager = 68,
109
- Temporary = 69,
110
- Tick = 70,
111
- TileEvent = 71,
112
- Time = 72,
113
- UpdateDirection = 73,
114
- Weight = 74,
115
- WorldUpdateTile = 75
40
+ "END REGION" = 0,
41
+ "START REGION" = 1,
42
+ Action = 2,
43
+ ActionAttack = 3,
44
+ ActionMove = 4,
45
+ Alignment = 5,
46
+ BaseEntityManager = 6,
47
+ CanASeeB = 7,
48
+ Container = 8,
49
+ Creature = 9,
50
+ CreatureAi = 10,
51
+ CreatureAiAdd = 11,
52
+ CreatureAiEmit = 12,
53
+ CreatureAiMaskAdd = 13,
54
+ CreatureAiMaskRemove = 14,
55
+ CreatureAiRemove = 15,
56
+ CreatureAiSet = 16,
57
+ CreatureCheckMove = 17,
58
+ CreatureMovement = 18,
59
+ CreatureNearestPlayer = 19,
60
+ CreatureOffer = 20,
61
+ CreatureStatChange = 21,
62
+ Damage = 22,
63
+ Dismantle = 23,
64
+ Doodad = 24,
65
+ DoodadManager = 25,
66
+ EncumberedStatus = 26,
67
+ Entity = 27,
68
+ EntityPosition = 28,
69
+ ExhaustedPreMove = 29,
70
+ FlowFieldHashCode = 30,
71
+ FlowFieldPenalty = 31,
72
+ FlowFieldUpdate = 32,
73
+ FlowFieldUpdateTile = 33,
74
+ FlowFieldValue = 34,
75
+ HandToUse = 35,
76
+ HealthChange = 36,
77
+ History = 37,
78
+ InventoryCount = 38,
79
+ Island = 39,
80
+ IslandCivilizationScore = 40,
81
+ Islands = 41,
82
+ IsTileEmpty = 42,
83
+ Item = 43,
84
+ ItemCraft = 44,
85
+ ItemDamage = 45,
86
+ ItemOrder = 46,
87
+ LastCreationIds = 47,
88
+ Merchant = 48,
89
+ MilestoneSeed = 49,
90
+ Modifier = 50,
91
+ MoveToTile = 51,
92
+ NPC = 52,
93
+ Option = 53,
94
+ PenaltyFieldHashCode = 54,
95
+ PlaceOnTile = 55,
96
+ PlayerManager = 56,
97
+ Players = 57,
98
+ PlayerSetup = 58,
99
+ Random = 59,
100
+ Seed = 60,
101
+ SeededGenerator = 61,
102
+ SetPosition = 62,
103
+ SetZ = 63,
104
+ SkillGain = 64,
105
+ StaminaChanges = 65,
106
+ StatChange = 66,
107
+ Stats = 67,
108
+ Status = 68,
109
+ StatusChange = 69,
110
+ TemperatureManager = 70,
111
+ Temporary = 71,
112
+ Tick = 72,
113
+ TileEvent = 73,
114
+ Time = 74,
115
+ UpdateDirection = 75,
116
+ Weight = 76,
117
+ WorldUpdateTile = 77
116
118
  }
117
119
  export declare const maxPlayers = 32;
118
120
  export declare const packetTickRate = 16.6666;
@@ -0,0 +1,22 @@
1
+ /*!
2
+ * Copyright 2011-2024 Unlok
3
+ * https://www.unlok.ca
4
+ *
5
+ * Credits & Thanks:
6
+ * https://www.unlok.ca/credits-thanks/
7
+ *
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
+ * https://github.com/WaywardGame/types/wiki
10
+ */
11
+ type Decorator = (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
12
+ /**
13
+ * **Note:** Do not intentionally throw errors through this decorated function. It does not close the region if an error is thrown.
14
+ */
15
+ export default function SyncRegion(target: any, propertyKey: string, descriptor: PropertyDescriptor): PropertyDescriptor;
16
+ /**
17
+ * **Note:** Do not intentionally throw errors through this decorated function. It does not close the region if an error is thrown.
18
+ *
19
+ * **Warning:** Do not combine this with other decorators.
20
+ */
21
+ export default function SyncRegion<T>(detailProvider: (target: T) => string): Decorator;
22
+ export {};
@@ -29,8 +29,10 @@ export interface ISyncCheck {
29
29
  }
30
30
  export type SyncChecks = ISyncCheck[];
31
31
  export interface IHashedSyncCheck {
32
- hash: number;
32
+ hashServer: number;
33
+ hashClient: number;
33
34
  syncCheck: SyncChecks;
35
+ type: "enabled" | "universal";
34
36
  }
35
37
  export interface IPacket<T = any> {
36
38
  getAllowedStates(): ConnectionState;
@@ -11,7 +11,7 @@
11
11
  import type { Game } from "@wayward/game/game/Game";
12
12
  import type Player from "@wayward/game/game/entity/player/Player";
13
13
  import UpgradesArray from "@wayward/game/save/upgrade/UpgradesArray";
14
- import Version from "@wayward/game/utilities/Version";
14
+ import type Version from "@wayward/game/utilities/Version";
15
15
  export default function upgradePlayer(game: Game, player: Player, saveVersion: Version.Info, isLocalPlayer: boolean): UpgradesArray;
16
16
  /**
17
17
  * Called after loading item & tile references
@@ -77,7 +77,6 @@ declare namespace Version {
77
77
  pt: string;
78
78
  build: string;
79
79
  };
80
- export function isTimeBefore(date: Date, dateStr: DateString, timezone: keyof typeof timezones): boolean;
81
80
  export interface Info extends IVersionInfo {
82
81
  }
83
82
  export class Info {
@@ -8,4 +8,27 @@
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
+ /**
12
+ * Formats a JSON string with custom pretty-printing rules.
13
+ * This function first stringifies the data with tabs as indentation, then applies several formatting improvements:
14
+ *
15
+ * 1. Removes unnecessary tabbing before values in arrays
16
+ * 2. Reduces multiple spaces between comma-separated values to a single space
17
+ * 3. Removes unnecessary whitespace after opening brackets
18
+ * 4. Ensures consistent spacing after commas in arrays and objects
19
+ *
20
+ * @param data - The data to be stringified. Can be any JSON-serializable value
21
+ * @returns A formatted JSON string with customized pretty-printing
22
+ *
23
+ * @example
24
+ * const data = { arr: [1, 2, 3], obj: { a: 1 } };
25
+ * console.log(prettyJsonStringify(data));
26
+ * // Output:
27
+ * // {
28
+ * // "arr": [1, 2, 3],
29
+ * // "obj": {
30
+ * // "a": 1
31
+ * // }
32
+ * // }
33
+ */
11
34
  export default function prettyJsonStringify(data: any): string;
@@ -24,6 +24,10 @@ declare namespace Errors {
24
24
  * Returns the Error callsite string for the caller of the current function.
25
25
  */
26
26
  function caller(skip?: number): string;
27
+ /**
28
+ * Returns the filename of the caller of the current function.
29
+ */
30
+ function callerFileBasename(skip?: number): string;
27
31
  }
28
32
  export default Errors;
29
33
  export declare function ensureExhaustive(value: never): never;
@@ -23,7 +23,7 @@ export interface IRandomGenerator<T = any> {
23
23
  pushSeed(seed?: T): void;
24
24
  popSeed(): T;
25
25
  get(): number;
26
- advance?(): this;
26
+ advance?(times?: number): this;
27
27
  asPCG?: PCGSeededGenerator;
28
28
  }
29
29
  export declare enum RandomInstance {
@@ -97,5 +97,5 @@ export declare class Random<G extends IRandomGenerator = IRandomGenerator> {
97
97
  * @returns number between provided min/max, rounded.
98
98
  */
99
99
  intInRangeExponential(min: number, max: number, steepness?: number): number;
100
- advance(): this;
100
+ advance(times?: number): this;
101
101
  }
@@ -21,7 +21,7 @@ export declare function convertStringToSeed(seed: string | number): number;
21
21
  /**
22
22
  * Creates a seeded random generator with the latest one available
23
23
  */
24
- export declare function createLatestSeededRandom(requiresSynchronization: RandomSychronizationCheck, seed?: Uint16Array | number): Random<PCGSeededGenerator> | Random<LegacySeededGenerator>;
24
+ export declare function createLatestSeededRandom(requiresSynchronization: RandomSychronizationCheck, seed?: Uint16Array | number, advance?: number): Random<PCGSeededGenerator> | Random<LegacySeededGenerator>;
25
25
  interface SeededGeneratorMap {
26
26
  [SeedType.PCG]: PCGSeededGenerator;
27
27
  [SeedType.Legacy]: LegacySeededGenerator;
@@ -29,7 +29,7 @@ interface SeededGeneratorMap {
29
29
  /**
30
30
  * Creates seeded random generator for the given type
31
31
  */
32
- export declare function createSeededRandom<TYPE extends SeedType = SeedType>(seedType: TYPE, requiresSynchronization: RandomSychronizationCheck, seed?: Uint16Array | number): Random<SeededGeneratorMap[TYPE]>;
32
+ export declare function createSeededRandom<TYPE extends SeedType = SeedType>(seedType: TYPE, requiresSynchronization: RandomSychronizationCheck, seed?: Uint16Array | number, advance?: number): Random<SeededGeneratorMap[TYPE]>;
33
33
  /**
34
34
  * Random without seeds
35
35
  */
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.14.4-beta.dev.20241228.1",
4
+ "version": "2.14.4-beta.dev.20241230.1",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",