@rpgjs/server 5.0.0-alpha.14 → 5.0.0-alpha.15
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/Player/MoveManager.d.ts +2 -2
- package/dist/Player/Player.d.ts +20 -2
- package/dist/index.js +6051 -13463
- package/dist/index.js.map +1 -1
- package/dist/rooms/map.d.ts +50 -1
- package/package.json +3 -2
- package/src/Player/MoveManager.ts +289 -283
- package/src/Player/Player.ts +37 -3
- package/src/rooms/map.ts +249 -35
package/dist/rooms/map.d.ts
CHANGED
|
@@ -2,6 +2,21 @@ import { MockConnection, RoomOnJoin } from '@signe/room';
|
|
|
2
2
|
import { Hooks, RpgCommonMap, ZoneData, WorldMapsManager, WorldMapConfig } from '@rpgjs/common';
|
|
3
3
|
import { RpgPlayer, RpgEvent } from '../Player/Player';
|
|
4
4
|
import { BehaviorSubject } from 'rxjs';
|
|
5
|
+
/**
|
|
6
|
+
* Interface for input controls configuration
|
|
7
|
+
*
|
|
8
|
+
* Defines the structure for input validation and anti-cheat controls
|
|
9
|
+
*/
|
|
10
|
+
export interface Controls {
|
|
11
|
+
/** Maximum allowed time delta between inputs in milliseconds */
|
|
12
|
+
maxTimeDelta?: number;
|
|
13
|
+
/** Maximum allowed frame delta between inputs */
|
|
14
|
+
maxFrameDelta?: number;
|
|
15
|
+
/** Minimum time between inputs in milliseconds */
|
|
16
|
+
minTimeBetweenInputs?: number;
|
|
17
|
+
/** Whether to enable anti-cheat validation */
|
|
18
|
+
enableAntiCheat?: boolean;
|
|
19
|
+
}
|
|
5
20
|
/**
|
|
6
21
|
* Interface representing hook methods available for map events
|
|
7
22
|
*
|
|
@@ -49,7 +64,7 @@ export declare class RpgMap extends RpgCommonMap<RpgPlayer> implements RoomOnJoi
|
|
|
49
64
|
globalConfig: any;
|
|
50
65
|
damageFormulas: any;
|
|
51
66
|
constructor();
|
|
52
|
-
|
|
67
|
+
interceptorPacket(player: RpgPlayer, packet: any, conn: MockConnection): any;
|
|
53
68
|
onJoin(player: RpgPlayer, conn: MockConnection): void;
|
|
54
69
|
onLeave(player: RpgPlayer, conn: MockConnection): void;
|
|
55
70
|
get hooks(): Hooks;
|
|
@@ -77,6 +92,39 @@ export declare class RpgMap extends RpgCommonMap<RpgPlayer> implements RoomOnJoi
|
|
|
77
92
|
* - WorldMapConfig[]
|
|
78
93
|
*/
|
|
79
94
|
updateWorld(request: Request): Promise<any>;
|
|
95
|
+
/**
|
|
96
|
+
* Process pending inputs for a player with anti-cheat validation
|
|
97
|
+
*
|
|
98
|
+
* This method processes all pending inputs for a player while performing
|
|
99
|
+
* anti-cheat validation to prevent time manipulation and frame skipping.
|
|
100
|
+
* It validates the time deltas between inputs and ensures they are within
|
|
101
|
+
* acceptable ranges. After processing, it saves the last frame position
|
|
102
|
+
* for use in packet interception.
|
|
103
|
+
*
|
|
104
|
+
* @param playerId - The ID of the player to process inputs for
|
|
105
|
+
* @param controls - Optional anti-cheat configuration
|
|
106
|
+
* @returns Promise containing the player and processed input strings
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```ts
|
|
110
|
+
* // Process inputs with default anti-cheat settings
|
|
111
|
+
* const result = await map.processInput('player1');
|
|
112
|
+
* console.log('Processed inputs:', result.inputs);
|
|
113
|
+
*
|
|
114
|
+
* // Process inputs with custom anti-cheat configuration
|
|
115
|
+
* const result = await map.processInput('player1', {
|
|
116
|
+
* maxTimeDelta: 100,
|
|
117
|
+
* maxFrameDelta: 5,
|
|
118
|
+
* minTimeBetweenInputs: 16,
|
|
119
|
+
* enableAntiCheat: true
|
|
120
|
+
* });
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
processInput(playerId: string, controls?: Controls): Promise<{
|
|
124
|
+
player: RpgPlayer;
|
|
125
|
+
inputs: string[];
|
|
126
|
+
}>;
|
|
127
|
+
private loop;
|
|
80
128
|
/**
|
|
81
129
|
* Get a world manager by id (if multiple supported in future)
|
|
82
130
|
*/
|
|
@@ -138,6 +186,7 @@ export declare class RpgMap extends RpgCommonMap<RpgPlayer> implements RoomOnJoi
|
|
|
138
186
|
createDynamicEvent(eventObj: EventPosOption): Promise<void>;
|
|
139
187
|
getEvent<T extends RpgPlayer>(eventId: string): T | undefined;
|
|
140
188
|
getPlayer(playerId: string): RpgPlayer | undefined;
|
|
189
|
+
getPlayers(): RpgPlayer[];
|
|
141
190
|
getEvents(): RpgEvent[];
|
|
142
191
|
getEventBy(cb: (event: RpgEvent) => boolean): RpgEvent | undefined;
|
|
143
192
|
getEventsBy(cb: (event: RpgEvent) => boolean): RpgEvent[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rpgjs/server",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.15",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"publishConfig": {
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"description": "",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@rpgjs/common": "5.0.0-alpha.
|
|
14
|
+
"@rpgjs/common": "5.0.0-alpha.15",
|
|
15
|
+
"@rpgjs/physic": "5.0.0-alpha.15",
|
|
15
16
|
"@rpgjs/database": "^4.3.0",
|
|
16
17
|
"@signe/di": "^2.4.6",
|
|
17
18
|
"@signe/reactive": "^2.4.6",
|