@rpgjs/server 5.0.0-alpha.4 → 5.0.0-alpha.41
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.
- package/dist/Gui/DialogGui.d.ts +5 -0
- package/dist/Gui/GameoverGui.d.ts +23 -0
- package/dist/Gui/Gui.d.ts +6 -0
- package/dist/Gui/MenuGui.d.ts +22 -3
- package/dist/Gui/NotificationGui.d.ts +1 -2
- package/dist/Gui/SaveLoadGui.d.ts +13 -0
- package/dist/Gui/ShopGui.d.ts +28 -3
- package/dist/Gui/TitleGui.d.ts +23 -0
- package/dist/Gui/index.d.ts +10 -1
- package/dist/Player/BattleManager.d.ts +34 -12
- package/dist/Player/ClassManager.d.ts +46 -13
- package/dist/Player/ComponentManager.d.ts +123 -0
- package/dist/Player/Components.d.ts +345 -0
- package/dist/Player/EffectManager.d.ts +86 -0
- package/dist/Player/ElementManager.d.ts +104 -0
- package/dist/Player/GoldManager.d.ts +22 -0
- package/dist/Player/GuiManager.d.ts +259 -0
- package/dist/Player/ItemFixture.d.ts +6 -0
- package/dist/Player/ItemManager.d.ts +450 -9
- package/dist/Player/MoveManager.d.ts +324 -69
- package/dist/Player/ParameterManager.d.ts +344 -14
- package/dist/Player/Player.d.ts +460 -8
- package/dist/Player/SkillManager.d.ts +197 -15
- package/dist/Player/StateManager.d.ts +89 -25
- package/dist/Player/VariableManager.d.ts +74 -0
- package/dist/RpgServer.d.ts +502 -64
- package/dist/RpgServerEngine.d.ts +2 -1
- package/dist/decorators/event.d.ts +46 -0
- package/dist/decorators/map.d.ts +287 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +21653 -20900
- package/dist/index.js.map +1 -1
- package/dist/logs/log.d.ts +2 -3
- package/dist/module.d.ts +43 -1
- package/dist/presets/index.d.ts +0 -9
- package/dist/rooms/BaseRoom.d.ts +132 -0
- package/dist/rooms/lobby.d.ts +10 -2
- package/dist/rooms/map.d.ts +1236 -17
- package/dist/services/save.d.ts +43 -0
- package/dist/storage/index.d.ts +1 -0
- package/dist/storage/localStorage.d.ts +23 -0
- package/package.json +14 -10
- package/src/Gui/DialogGui.ts +19 -4
- package/src/Gui/GameoverGui.ts +39 -0
- package/src/Gui/Gui.ts +23 -1
- package/src/Gui/MenuGui.ts +155 -6
- package/src/Gui/NotificationGui.ts +1 -2
- package/src/Gui/SaveLoadGui.ts +60 -0
- package/src/Gui/ShopGui.ts +146 -16
- package/src/Gui/TitleGui.ts +39 -0
- package/src/Gui/index.ts +15 -2
- package/src/Player/BattleManager.ts +91 -49
- package/src/Player/ClassManager.ts +118 -50
- package/src/Player/ComponentManager.ts +425 -19
- package/src/Player/Components.ts +380 -0
- package/src/Player/EffectManager.ts +81 -44
- package/src/Player/ElementManager.ts +109 -86
- package/src/Player/GoldManager.ts +32 -35
- package/src/Player/GuiManager.ts +308 -150
- package/src/Player/ItemFixture.ts +4 -5
- package/src/Player/ItemManager.ts +774 -355
- package/src/Player/MoveManager.ts +1544 -774
- package/src/Player/ParameterManager.ts +546 -104
- package/src/Player/Player.ts +1163 -88
- package/src/Player/SkillManager.ts +520 -195
- package/src/Player/StateManager.ts +170 -182
- package/src/Player/VariableManager.ts +101 -63
- package/src/RpgServer.ts +525 -63
- package/src/core/context.ts +1 -0
- package/src/decorators/event.ts +61 -0
- package/src/decorators/map.ts +327 -0
- package/src/index.ts +11 -1
- package/src/logs/log.ts +10 -3
- package/src/module.ts +126 -3
- package/src/presets/index.ts +1 -10
- package/src/rooms/BaseRoom.ts +232 -0
- package/src/rooms/lobby.ts +25 -7
- package/src/rooms/map.ts +2502 -194
- package/src/services/save.ts +147 -0
- package/src/storage/index.ts +1 -0
- package/src/storage/localStorage.ts +76 -0
- package/tests/battle.spec.ts +375 -0
- package/tests/change-map.spec.ts +72 -0
- package/tests/class.spec.ts +274 -0
- package/tests/effect.spec.ts +219 -0
- package/tests/element.spec.ts +221 -0
- package/tests/event.spec.ts +80 -0
- package/tests/gold.spec.ts +99 -0
- package/tests/item.spec.ts +609 -0
- package/tests/module.spec.ts +38 -0
- package/tests/move.spec.ts +601 -0
- package/tests/player-param.spec.ts +28 -0
- package/tests/prediction-reconciliation.spec.ts +182 -0
- package/tests/random-move.spec.ts +65 -0
- package/tests/skill.spec.ts +658 -0
- package/tests/state.spec.ts +467 -0
- package/tests/variable.spec.ts +185 -0
- package/tests/world-maps.spec.ts +896 -0
- package/vite.config.ts +16 -0
- package/dist/Player/Event.d.ts +0 -0
- package/src/Player/Event.ts +0 -0
package/dist/logs/log.d.ts
CHANGED
package/dist/module.d.ts
CHANGED
|
@@ -1,2 +1,44 @@
|
|
|
1
1
|
import { FactoryProvider } from '@signe/di';
|
|
2
|
-
|
|
2
|
+
import { RpgServer } from './RpgServer';
|
|
3
|
+
/**
|
|
4
|
+
* Type for server modules that can be either:
|
|
5
|
+
* - An object implementing RpgServer interface
|
|
6
|
+
* - A class decorated with @RpgModule decorator
|
|
7
|
+
*/
|
|
8
|
+
export type RpgServerModule = RpgServer | (new () => any);
|
|
9
|
+
/**
|
|
10
|
+
* Provides server modules configuration to Angular Dependency Injection
|
|
11
|
+
*
|
|
12
|
+
* This function accepts an array of server modules that can be either:
|
|
13
|
+
* - Objects implementing the RpgServer interface
|
|
14
|
+
* - Classes decorated with the @RpgModule decorator (which will be instantiated)
|
|
15
|
+
*
|
|
16
|
+
* @param modules - Array of server modules (objects or classes)
|
|
17
|
+
* @returns FactoryProvider configuration for Angular DI
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* // Using an object
|
|
21
|
+
* provideServerModules([
|
|
22
|
+
* {
|
|
23
|
+
* player: {
|
|
24
|
+
* onConnected(player) {
|
|
25
|
+
* console.log('Player connected')
|
|
26
|
+
* }
|
|
27
|
+
* }
|
|
28
|
+
* }
|
|
29
|
+
* ])
|
|
30
|
+
*
|
|
31
|
+
* // Using a decorated class
|
|
32
|
+
* @RpgModule<RpgServer>({
|
|
33
|
+
* engine: {
|
|
34
|
+
* onStart(server) {
|
|
35
|
+
* console.log('Server started')
|
|
36
|
+
* }
|
|
37
|
+
* }
|
|
38
|
+
* })
|
|
39
|
+
* class MyServerModule {}
|
|
40
|
+
*
|
|
41
|
+
* provideServerModules([MyServerModule])
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare function provideServerModules(modules: RpgServerModule[]): FactoryProvider;
|
package/dist/presets/index.d.ts
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
export declare const MAXHP: string;
|
|
2
|
-
export declare const MAXSP: string;
|
|
3
|
-
export declare const ATK: string;
|
|
4
|
-
export declare const PDEF: string;
|
|
5
|
-
export declare const SDEF: string;
|
|
6
|
-
export declare const STR: string;
|
|
7
|
-
export declare const AGI: string;
|
|
8
|
-
export declare const INT: string;
|
|
9
|
-
export declare const DEX: string;
|
|
10
1
|
export declare const MAXHP_CURVE: {
|
|
11
2
|
start: number;
|
|
12
3
|
end: number;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { Hooks } from '../../../common/src';
|
|
2
|
+
import { RpgPlayer } from '../Player/Player';
|
|
3
|
+
/**
|
|
4
|
+
* Base class for rooms that need database functionality
|
|
5
|
+
*
|
|
6
|
+
* This class provides common database management functionality that is shared
|
|
7
|
+
* between RpgMap and LobbyRoom. It includes methods for adding and managing
|
|
8
|
+
* items, classes, and other game data in the room's database.
|
|
9
|
+
*
|
|
10
|
+
* ## Architecture
|
|
11
|
+
*
|
|
12
|
+
* Both RpgMap and LobbyRoom need to store game entities (items, classes, skills, etc.)
|
|
13
|
+
* in a database. This base class provides the common implementation to avoid code duplication.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* class MyCustomRoom extends BaseRoom {
|
|
18
|
+
* // Your custom room implementation
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare abstract class BaseRoom {
|
|
23
|
+
/**
|
|
24
|
+
* Signal containing the room's database of items, classes, and other game data
|
|
25
|
+
*
|
|
26
|
+
* This database can be dynamically populated using `addInDatabase()` and
|
|
27
|
+
* `removeInDatabase()` methods. It's used to store game entities like items,
|
|
28
|
+
* classes, skills, etc. that are available in this room.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* // Add data to database
|
|
33
|
+
* room.addInDatabase('Potion', PotionClass);
|
|
34
|
+
*
|
|
35
|
+
* // Access database
|
|
36
|
+
* const potion = room.database()['Potion'];
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
database: import('@signe/reactive').WritableObjectSignal<{}>;
|
|
40
|
+
onStart(): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Add data to the room's database
|
|
43
|
+
*
|
|
44
|
+
* Adds an item, class, or other game entity to the room's database.
|
|
45
|
+
* If the ID already exists and `force` is not enabled, the addition is ignored.
|
|
46
|
+
*
|
|
47
|
+
* ## Architecture
|
|
48
|
+
*
|
|
49
|
+
* This method is used by the item management system to store item definitions
|
|
50
|
+
* in the room's database. When a player adds an item, the system first checks
|
|
51
|
+
* if the item exists in the database, and if not, adds it using this method.
|
|
52
|
+
*
|
|
53
|
+
* @param id - Unique identifier for the data
|
|
54
|
+
* @param data - The data to add (can be a class, object, etc.)
|
|
55
|
+
* @param options - Optional configuration
|
|
56
|
+
* @param options.force - If true, overwrites existing data with the same ID
|
|
57
|
+
* @returns `true` if data was added, `false` if it was ignored (ID already exists)
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* // Add a class to the database
|
|
62
|
+
* room.addInDatabase('Potion', PotionClass);
|
|
63
|
+
*
|
|
64
|
+
* // Add an item object to the database
|
|
65
|
+
* room.addInDatabase('custom-item', {
|
|
66
|
+
* name: 'Custom Item',
|
|
67
|
+
* price: 100
|
|
68
|
+
* });
|
|
69
|
+
*
|
|
70
|
+
* // Force overwrite existing data
|
|
71
|
+
* room.addInDatabase('Potion', UpdatedPotionClass, { force: true });
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
addInDatabase(id: string, data: any, options?: {
|
|
75
|
+
force?: boolean;
|
|
76
|
+
}): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Remove data from the room's database
|
|
79
|
+
*
|
|
80
|
+
* This method allows you to remove items or data from the room's database.
|
|
81
|
+
*
|
|
82
|
+
* @param id - Unique identifier of the data to remove
|
|
83
|
+
* @returns `true` if data was removed, `false` if ID didn't exist
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* // Remove an item from the database
|
|
88
|
+
* room.removeInDatabase('Potion');
|
|
89
|
+
*
|
|
90
|
+
* // Check if removal was successful
|
|
91
|
+
* const removed = room.removeInDatabase('custom-item');
|
|
92
|
+
* if (removed) {
|
|
93
|
+
* console.log('Item removed successfully');
|
|
94
|
+
* }
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
removeInDatabase(id: string): boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Get the hooks system for this map
|
|
100
|
+
*
|
|
101
|
+
* Returns the dependency-injected Hooks instance that allows you to trigger
|
|
102
|
+
* and listen to various game events.
|
|
103
|
+
*
|
|
104
|
+
* @returns The Hooks instance for this map
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```ts
|
|
108
|
+
* // Trigger a custom hook
|
|
109
|
+
* map.hooks.callHooks('custom-event', data).subscribe();
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
get hooks(): Hooks;
|
|
113
|
+
/**
|
|
114
|
+
* Resolve complex snapshot entries (e.g. inventory items) before load.
|
|
115
|
+
*/
|
|
116
|
+
onSessionRestore({ userSnapshot, user }: {
|
|
117
|
+
userSnapshot: any;
|
|
118
|
+
user?: RpgPlayer;
|
|
119
|
+
}): Promise<any>;
|
|
120
|
+
listSaveSlots(player: RpgPlayer, value: {
|
|
121
|
+
requestId: string;
|
|
122
|
+
}): Promise<import('../../../common/src').SaveSlotList>;
|
|
123
|
+
saveSlot(player: RpgPlayer, value: {
|
|
124
|
+
requestId: string;
|
|
125
|
+
index: number;
|
|
126
|
+
meta?: any;
|
|
127
|
+
}): Promise<void>;
|
|
128
|
+
loadSlot(player: RpgPlayer, value: {
|
|
129
|
+
requestId: string;
|
|
130
|
+
index: number;
|
|
131
|
+
}): Promise<void>;
|
|
132
|
+
}
|
package/dist/rooms/lobby.d.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { MockConnection } from '@signe/room';
|
|
2
2
|
import { RpgPlayer } from '../Player/Player';
|
|
3
|
-
|
|
3
|
+
import { BaseRoom } from './BaseRoom';
|
|
4
|
+
export declare class LobbyRoom extends BaseRoom {
|
|
4
5
|
players: import('@signe/reactive').WritableObjectSignal<{}>;
|
|
5
|
-
|
|
6
|
+
autoSync: boolean;
|
|
7
|
+
constructor(room: any);
|
|
8
|
+
onJoin(player: RpgPlayer, conn: MockConnection): Promise<void>;
|
|
9
|
+
guiInteraction(player: RpgPlayer, value: {
|
|
10
|
+
guiId: string;
|
|
11
|
+
name: string;
|
|
12
|
+
data: any;
|
|
13
|
+
}): Promise<void>;
|
|
6
14
|
}
|