@rpgjs/server 5.0.0-alpha.32 → 5.0.0-alpha.35

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.
@@ -4,8 +4,12 @@ export type ShopSellList = Record<string, number> | Array<{
4
4
  id: string;
5
5
  multiplier: number;
6
6
  }>;
7
+ export type ShopItemInput = string | {
8
+ id?: string;
9
+ [key: string]: any;
10
+ };
7
11
  export interface ShopGuiOptions {
8
- items: any[];
12
+ items: ShopItemInput[];
9
13
  sell?: ShopSellList;
10
14
  sellMultiplier?: number;
11
15
  message?: string;
@@ -386,12 +386,13 @@ export interface IItemManager {
386
386
  /**
387
387
  * Equips a weapon or armor on a player
388
388
  *
389
- * Think first to add the item in the inventory with the `addItem()` method before equipping the item.
389
+ * Think first to add the item in the inventory with the `addItem()` method before equipping the item,
390
+ * or pass `"auto"` to add the item if it is missing and equip it.
390
391
  *
391
392
  * The `onEquip()` method is called on the ItemClass when the item is equipped or unequipped.
392
393
  *
393
- * @param itemClass - Item class or string identifier. If string, it's the item ID
394
- * @param equip - Equip the item if `true`, unequip if `false` (default: `true`)
394
+ * @param itemId - Item identifier to resolve from the database
395
+ * @param equip - Equip the item if `true`, unequip if `false`, or `"auto"` to add then equip (default: `true`)
395
396
  * @throws {Object} ItemLog.notInInventory - If the item is not in the inventory
396
397
  * - `id`: `ITEM_NOT_INVENTORY`
397
398
  * - `msg`: Error message
@@ -404,19 +405,17 @@ export interface IItemManager {
404
405
  *
405
406
  * @example
406
407
  * ```ts
407
- * import Sword from 'your-database/sword'
408
- *
409
408
  * try {
410
- * player.addItem(Sword)
411
- * player.equip(Sword)
409
+ * player.addItem('sword')
410
+ * player.equip('sword')
412
411
  * // Later, unequip it
413
- * player.equip(Sword, false)
412
+ * player.equip('sword', false)
414
413
  * } catch (err) {
415
414
  * console.log(err)
416
415
  * }
417
416
  * ```
418
417
  */
419
- equip(itemClass: ItemClass | string, equip?: boolean): void;
418
+ equip(itemId: string, equip?: boolean | 'auto'): void;
420
419
  /**
421
420
  * Get the player's attack (sum of items equipped)
422
421
  *
@@ -1,3 +1,4 @@
1
+ import { WeatherState } from '../../../common/src';
1
2
  export interface MapOptions {
2
3
  /**
3
4
  * Map identifier. Allows to go to the map (for example with player.changeMap())
@@ -96,6 +97,27 @@ export interface MapOptions {
96
97
  * @memberof MapData
97
98
  * */
98
99
  sounds?: string[];
100
+ /**
101
+ * Initial weather state for this map.
102
+ *
103
+ * This value is applied when the map is loaded and can later be updated
104
+ * at runtime with `map.setWeather()` from server logic.
105
+ *
106
+ * ```ts
107
+ * @MapData({
108
+ * id: 'forest',
109
+ * file: require('./tmx/forest.tmx'),
110
+ * weather: {
111
+ * effect: 'fog',
112
+ * preset: 'rpgForestFog',
113
+ * params: { density: 1.2, height: 0.75 },
114
+ * transitionMs: 1200
115
+ * }
116
+ * })
117
+ * class ForestMap extends RpgMap {}
118
+ * ```
119
+ */
120
+ weather?: WeatherState | null;
99
121
  /**
100
122
  * Whether to stop all sounds before playing the map sounds when a player joins.
101
123
  *