@rpgjs/server 4.0.0-rc.9 → 4.0.0
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/CHANGELOG.md +32 -0
- package/browser/manifest.json +7 -0
- package/browser/rpg.server.js +21930 -0
- package/browser/rpg.server.umd.cjs +21961 -0
- package/lib/Game/EventManager.d.ts +1 -0
- package/lib/Game/EventManager.js +16 -2
- package/lib/Game/EventManager.js.map +1 -1
- package/lib/Player/Player.d.ts +107 -32
- package/lib/Player/Player.js +48 -16
- package/lib/Player/Player.js.map +1 -1
- package/lib/Player/SkillManager.js +0 -5
- package/lib/Player/SkillManager.js.map +1 -1
- package/lib/express/server.js +9 -12
- package/lib/express/server.js.map +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/index.js.map +1 -1
- package/lib/server.d.ts +1 -1
- package/lib/server.js +3 -3
- package/lib/server.js.map +1 -1
- package/package.json +9 -7
- package/rpg.toml +14 -0
- package/src/Game/EventManager.ts +17 -2
- package/src/Player/ParameterManager.ts +1 -1
- package/src/Player/Player.ts +65 -19
- package/src/Player/SkillManager.ts +0 -7
- package/src/express/server.ts +9 -13
- package/src/index.ts +3 -3
- package/src/server.ts +4 -3
package/lib/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAC9F,OAAO,EAAE,KAAK,EAAc,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAiB,Y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AK,CAAC,WAAW,EAAE,GAAG,GAAG,GAAG,KAAK,CAAC,WAAW,EAAE,CAAA;YAC5F,MAAM,CAAC,OAAO,GAAG,QAAQ,CAAA;SAC5B;QAED,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAA;QAElE,IAAI,CAAC,KAAK,EAAE;YACR,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC,CAAA;SACnC;aACI;YACD,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,0BAA0B,EAAE,MAAM,CAAC,CAAA;SAChE;IACL,CAAC;IAEO,oBAAoB,CAAC,QAAgB;QACzC,MAAM,MAAM,GAAc,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAc,CAAA;QAC9D,MAAM,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAA;QACnC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAA;IACvC,CAAC;IAED,IAAI;QACA,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAA;IACzB,CAAC;CACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rpgjs/server",
|
|
3
|
-
"version": "4.0.0
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
|
-
"build": "tsc",
|
|
11
|
+
"build": "tsc && npm run build:browser",
|
|
12
|
+
"build:browser": "RPG_TYPE=rpg npx rpgjs build",
|
|
12
13
|
"watch": "tsc -w"
|
|
13
14
|
},
|
|
14
15
|
"typesVersions": {
|
|
@@ -26,10 +27,10 @@
|
|
|
26
27
|
"author": "Samuel Ronce",
|
|
27
28
|
"license": "MIT",
|
|
28
29
|
"dependencies": {
|
|
29
|
-
"@rpgjs/common": "^4.0.0
|
|
30
|
-
"@rpgjs/database": "^4.0.0
|
|
31
|
-
"@rpgjs/tiled": "^4.0.0
|
|
32
|
-
"@rpgjs/types": "^4.0.0
|
|
30
|
+
"@rpgjs/common": "^4.0.0",
|
|
31
|
+
"@rpgjs/database": "^4.0.0",
|
|
32
|
+
"@rpgjs/tiled": "^4.0.0",
|
|
33
|
+
"@rpgjs/types": "^4.0.0",
|
|
33
34
|
"axios": "^1.3.6",
|
|
34
35
|
"cors": "^2.8.5",
|
|
35
36
|
"express": "^4.18.2",
|
|
@@ -41,8 +42,9 @@
|
|
|
41
42
|
"simple-room": "^2.4.1",
|
|
42
43
|
"socket.io": "^4.6.1"
|
|
43
44
|
},
|
|
44
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "122f589ea1557e4b5405f1adf29ecca7d3fcf4d1",
|
|
45
46
|
"devDependencies": {
|
|
47
|
+
"@rpgjs/compiler": "^4.0.0",
|
|
46
48
|
"typescript": "^5.0.4"
|
|
47
49
|
},
|
|
48
50
|
"alias": {
|
package/rpg.toml
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
[compilerOptions.build]
|
|
2
|
+
pwaEnabled = false
|
|
3
|
+
outputDir = "./browser"
|
|
4
|
+
|
|
5
|
+
[vite.build.lib]
|
|
6
|
+
entry = "src/index.ts"
|
|
7
|
+
name = "RpgServer"
|
|
8
|
+
fileName = "rpg.server"
|
|
9
|
+
|
|
10
|
+
[vite.build.rollupOptions.output]
|
|
11
|
+
format = "umd"
|
|
12
|
+
|
|
13
|
+
[vite.build.rollupOptions]
|
|
14
|
+
external = ["@rpgjs/common", "@rpgjs/database"]
|
package/src/Game/EventManager.ts
CHANGED
|
@@ -61,14 +61,28 @@ export class EventManager {
|
|
|
61
61
|
removeEvent(eventId: string): boolean {
|
|
62
62
|
if (!this.events[eventId]) return false
|
|
63
63
|
const mode = this.events[eventId].mode
|
|
64
|
+
let currentState
|
|
65
|
+
// Restores previous state
|
|
66
|
+
if (mode == EventMode.Scenario) {
|
|
67
|
+
currentState = this.getCurrentMap()?.$currentState().users?.[this.id]?.events?.[eventId] ?? {}
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
currentState = this.$currentState().events?.[eventId] ?? {}
|
|
71
|
+
}
|
|
64
72
|
this.removeObject(this.events[eventId], mode)
|
|
65
73
|
delete this.events[eventId]
|
|
66
74
|
// Change the state of the packet that will be sent to the client, adding the deleted flag to indicate to the client that the event has been deleted.
|
|
67
75
|
if (mode == EventMode.Scenario) {
|
|
68
|
-
this.getCurrentMap()?.$setCurrentState(`users.${this.id}.events.${eventId}
|
|
76
|
+
this.getCurrentMap()?.$setCurrentState(`users.${this.id}.events.${eventId}`, {
|
|
77
|
+
...currentState,
|
|
78
|
+
deleted: true
|
|
79
|
+
})
|
|
69
80
|
}
|
|
70
81
|
else {
|
|
71
|
-
this.$setCurrentState(`events.${eventId}
|
|
82
|
+
this.$setCurrentState(`events.${eventId}`, {
|
|
83
|
+
...currentState,
|
|
84
|
+
deleted: true
|
|
85
|
+
})
|
|
72
86
|
}
|
|
73
87
|
return true
|
|
74
88
|
}
|
|
@@ -107,4 +121,5 @@ export interface EventManager {
|
|
|
107
121
|
getCurrentMap(): RpgMap | null
|
|
108
122
|
id: string
|
|
109
123
|
$setCurrentState: (path: string, value: any) => void;
|
|
124
|
+
$currentState(): any
|
|
110
125
|
}
|
package/src/Player/Player.ts
CHANGED
|
@@ -46,14 +46,26 @@ const {
|
|
|
46
46
|
|
|
47
47
|
export interface Position { x: number, y: number, z: number }
|
|
48
48
|
|
|
49
|
-
const
|
|
50
|
-
name:
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
const commonSchemaFeature = {
|
|
50
|
+
name: {
|
|
51
|
+
$permanent: false
|
|
52
|
+
},
|
|
53
|
+
description: {
|
|
54
|
+
$permanent: false
|
|
55
|
+
},
|
|
54
56
|
id: String
|
|
55
57
|
}
|
|
56
58
|
|
|
59
|
+
const itemSchemas = {
|
|
60
|
+
price: {
|
|
61
|
+
$permanent: false
|
|
62
|
+
},
|
|
63
|
+
consumable: {
|
|
64
|
+
$permanent: false
|
|
65
|
+
},
|
|
66
|
+
...commonSchemaFeature
|
|
67
|
+
}
|
|
68
|
+
|
|
57
69
|
export const componentSchema = { id: String, value: String }
|
|
58
70
|
export const layoutSchema = {
|
|
59
71
|
width: Number,
|
|
@@ -74,7 +86,7 @@ const playerSchemas = {
|
|
|
74
86
|
z: Number
|
|
75
87
|
},
|
|
76
88
|
direction: Number,
|
|
77
|
-
|
|
89
|
+
|
|
78
90
|
teleported: {
|
|
79
91
|
$permanent: false
|
|
80
92
|
},
|
|
@@ -90,14 +102,23 @@ const playerSchemas = {
|
|
|
90
102
|
level: {
|
|
91
103
|
$effects: ['$this.expForNextlevel']
|
|
92
104
|
},
|
|
93
|
-
expForNextlevel:
|
|
105
|
+
expForNextlevel: {
|
|
106
|
+
$permanent: false
|
|
107
|
+
},
|
|
94
108
|
exp: Number,
|
|
95
109
|
name: String,
|
|
96
110
|
items: [{ nb: Number, item: itemSchemas }],
|
|
97
|
-
_class:
|
|
111
|
+
_class: commonSchemaFeature,
|
|
98
112
|
equipments: [itemSchemas],
|
|
99
|
-
skills: [
|
|
100
|
-
|
|
113
|
+
skills: [
|
|
114
|
+
{
|
|
115
|
+
spCost: {
|
|
116
|
+
$permanent: false
|
|
117
|
+
},
|
|
118
|
+
...commonSchemaFeature
|
|
119
|
+
}
|
|
120
|
+
],
|
|
121
|
+
states: [commonSchemaFeature],
|
|
101
122
|
effects: [String],
|
|
102
123
|
|
|
103
124
|
layout: {
|
|
@@ -168,14 +189,26 @@ export class RpgPlayer extends RpgCommonPlayer {
|
|
|
168
189
|
public _rooms = []
|
|
169
190
|
public session: string | null = null
|
|
170
191
|
public prevMap: string = ''
|
|
171
|
-
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* ```ts
|
|
195
|
+
* retreive the server instance
|
|
196
|
+
* ```
|
|
197
|
+
* @title Server Instance
|
|
198
|
+
* @prop {RpgServerEngine} player.server
|
|
199
|
+
* @memberof Player
|
|
200
|
+
* */
|
|
172
201
|
public server: RpgServerEngine
|
|
173
202
|
private touchSide: boolean = false
|
|
203
|
+
|
|
174
204
|
/** @internal */
|
|
175
205
|
public tmpPositions: Position | string | null = null
|
|
176
206
|
public otherPossessedPlayer: RpgPlayer | RpgEvent | null = null
|
|
177
207
|
public following: RpgPlayer | RpgEvent | null = null
|
|
178
208
|
|
|
209
|
+
// Indicates whether to load data with load(). In this case, hooks are not triggered.
|
|
210
|
+
private _dataLoading: boolean = false
|
|
211
|
+
|
|
179
212
|
_lastFramePositions: {
|
|
180
213
|
frame: number
|
|
181
214
|
position: Position
|
|
@@ -470,7 +503,9 @@ export class RpgPlayer extends RpgCommonPlayer {
|
|
|
470
503
|
* @returns {Promise<boolean | RpgMap | null>}
|
|
471
504
|
* @memberof Player
|
|
472
505
|
*/
|
|
473
|
-
load(json: any): Promise<boolean | RpgMap | null> {
|
|
506
|
+
async load(json: any): Promise<boolean | RpgMap | null> {
|
|
507
|
+
this._dataLoading = true
|
|
508
|
+
|
|
474
509
|
if (isString(json)) json = JSON.parse(json)
|
|
475
510
|
|
|
476
511
|
const getData = (id) => new (this.databaseById(id))()
|
|
@@ -489,10 +524,12 @@ export class RpgPlayer extends RpgCommonPlayer {
|
|
|
489
524
|
items[it.item.id] = getData(it.item.id)
|
|
490
525
|
}
|
|
491
526
|
json.items = json.items.map(it => ({ nb: it.nb, item: items[it.item.id] }))
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
527
|
+
if (Array.isArray(json.equipments)) {
|
|
528
|
+
json.equipments = json.equipments.map(it => {
|
|
529
|
+
items[it.id].equipped = true
|
|
530
|
+
return items[it.id]
|
|
531
|
+
})
|
|
532
|
+
}
|
|
496
533
|
}
|
|
497
534
|
if (json.states) json.states = json.states.map(state => getData(state.id))
|
|
498
535
|
if (json.skills) json.skills = json.skills.map(skill => getData(skill.id))
|
|
@@ -501,12 +538,17 @@ export class RpgPlayer extends RpgCommonPlayer {
|
|
|
501
538
|
merge(this, json)
|
|
502
539
|
|
|
503
540
|
this.position = json.position
|
|
541
|
+
|
|
504
542
|
if (json.map) {
|
|
505
543
|
this.map = ''
|
|
506
|
-
|
|
544
|
+
const map = await this.changeMap(json.map, json.tmpPositions || json.position)
|
|
545
|
+
this._dataLoading = false
|
|
546
|
+
return map
|
|
507
547
|
}
|
|
508
548
|
|
|
509
|
-
|
|
549
|
+
this._dataLoading = false
|
|
550
|
+
|
|
551
|
+
return null
|
|
510
552
|
}
|
|
511
553
|
|
|
512
554
|
/**
|
|
@@ -804,6 +846,10 @@ export class RpgPlayer extends RpgCommonPlayer {
|
|
|
804
846
|
}
|
|
805
847
|
|
|
806
848
|
async execMethod(methodName: string, methodData = [], target?: any) {
|
|
849
|
+
const ignoreIfDataLoading = ['onLevelUp', 'onDead']
|
|
850
|
+
if (ignoreIfDataLoading.includes(methodName) && this._dataLoading) {
|
|
851
|
+
return
|
|
852
|
+
}
|
|
807
853
|
let ret
|
|
808
854
|
if (target && target[methodName]) {
|
|
809
855
|
ret = target[methodName](...methodData)
|
|
@@ -995,4 +1041,4 @@ export class RpgEvent extends RpgPlayer {
|
|
|
995
1041
|
}
|
|
996
1042
|
}
|
|
997
1043
|
}
|
|
998
|
-
}
|
|
1044
|
+
}
|
|
@@ -6,10 +6,6 @@ import { EffectManager } from './EffectManager'
|
|
|
6
6
|
import { ParameterManager } from './ParameterManager';
|
|
7
7
|
import { RpgPlayer } from './Player';
|
|
8
8
|
|
|
9
|
-
import {
|
|
10
|
-
INT
|
|
11
|
-
} from '../presets'
|
|
12
|
-
|
|
13
9
|
const {
|
|
14
10
|
isArray,
|
|
15
11
|
isString,
|
|
@@ -74,9 +70,6 @@ export class SkillManager {
|
|
|
74
70
|
learnSkill(skillClass: SkillClass | string) {
|
|
75
71
|
if (isString(skillClass)) skillClass = this.databaseById(skillClass)
|
|
76
72
|
const instance = new (skillClass as SkillClass)()
|
|
77
|
-
if (!instance.coefficient) instance.coefficient = {
|
|
78
|
-
[INT]: 1
|
|
79
|
-
}
|
|
80
73
|
this.skills.push(instance)
|
|
81
74
|
this['execMethod']('onLearn', [this], instance)
|
|
82
75
|
return instance
|
package/src/express/server.ts
CHANGED
|
@@ -23,8 +23,9 @@ export function expressServer(modules: ModuleType[], options: ExpressServerOptio
|
|
|
23
23
|
}> {
|
|
24
24
|
return new Promise((resolve, reject) => {
|
|
25
25
|
const envs = options.envs || {}
|
|
26
|
+
const { express: expressConfig = {} } = options.globalConfig || {}
|
|
26
27
|
const dirname = options.basePath
|
|
27
|
-
const PORT = process.env.PORT || 3000
|
|
28
|
+
const PORT = process.env.PORT || expressConfig.port || 3000
|
|
28
29
|
const pe = new PrettyError()
|
|
29
30
|
const app = express()
|
|
30
31
|
const server = http.createServer(app)
|
|
@@ -33,7 +34,8 @@ export function expressServer(modules: ModuleType[], options: ExpressServerOptio
|
|
|
33
34
|
cors: {
|
|
34
35
|
origin: "*",
|
|
35
36
|
methods: ["GET", "POST"]
|
|
36
|
-
}
|
|
37
|
+
},
|
|
38
|
+
...(expressConfig.socketIo || {})
|
|
37
39
|
})
|
|
38
40
|
|
|
39
41
|
// @ts-ignore
|
|
@@ -41,20 +43,14 @@ export function expressServer(modules: ModuleType[], options: ExpressServerOptio
|
|
|
41
43
|
|
|
42
44
|
// @ts-ignore
|
|
43
45
|
const hasStatic = process.env.STATIC_DIRECTORY_ENABLED
|
|
44
|
-
const staticDirectory = isBuilt ?
|
|
46
|
+
const staticDirectory = isBuilt ? expressConfig.static : 'dist'
|
|
45
47
|
// @ts-ignore
|
|
46
48
|
const staticEnabled = (isBuilt && hasStatic === undefined) || hasStatic === 'true'
|
|
47
49
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
// TODO
|
|
51
|
-
limit: '50mb'
|
|
52
|
-
}))
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
app.use(cors())
|
|
50
|
+
app.use(express.json(expressConfig.json))
|
|
51
|
+
app.use(cors(expressConfig.cors))
|
|
56
52
|
|
|
57
|
-
if (staticEnabled) {
|
|
53
|
+
if (staticEnabled || expressConfig.static) {
|
|
58
54
|
app.use('/', express.static(path.join(dirname, '..', staticDirectory, 'client')))
|
|
59
55
|
}
|
|
60
56
|
|
|
@@ -77,7 +73,7 @@ export function expressServer(modules: ModuleType[], options: ExpressServerOptio
|
|
|
77
73
|
}
|
|
78
74
|
|
|
79
75
|
// @ts-ignore
|
|
80
|
-
const serverPort = (envs.VITE_SERVER_URL || '').split(':')[1] || PORT
|
|
76
|
+
const serverPort = !isBuilt ? (envs.VITE_SERVER_URL || '').split(':')[1] || PORT : PORT
|
|
81
77
|
server.listen(serverPort, start)
|
|
82
78
|
|
|
83
79
|
process.on('uncaughtException', function (error) {
|
package/src/index.ts
CHANGED
|
@@ -11,7 +11,7 @@ export {
|
|
|
11
11
|
ShapePositioning,
|
|
12
12
|
AbstractObject
|
|
13
13
|
} from '@rpgjs/common'
|
|
14
|
-
export { RpgServer, RpgPlayerHooks, RpgServerEngineHooks } from './RpgServer'
|
|
14
|
+
export type { RpgServer, RpgPlayerHooks, RpgServerEngineHooks } from './RpgServer'
|
|
15
15
|
export { EventData } from './decorators/event'
|
|
16
16
|
export { MapData } from './decorators/map'
|
|
17
17
|
export { RpgPlayer, RpgEvent } from './Player/Player'
|
|
@@ -23,8 +23,8 @@ export { default as Monitor } from './Monitor'
|
|
|
23
23
|
export * as Presets from './presets'
|
|
24
24
|
export { Move, Frequency, Speed } from './Player/MoveManager'
|
|
25
25
|
export { RpgServerEngine } from './server'
|
|
26
|
-
export { SceneMap as RpgSceneMap, RpgClassMap } from './Scenes/Map'
|
|
26
|
+
export { SceneMap as RpgSceneMap, type RpgClassMap } from './Scenes/Map'
|
|
27
27
|
export { RpgMatchMaker } from './MatchMaker'
|
|
28
|
-
export { IStoreState } from './Interfaces/StateStore'
|
|
28
|
+
export type { IStoreState } from './Interfaces/StateStore'
|
|
29
29
|
export { Components } from './Player/ComponentManager'
|
|
30
30
|
export { Gui } from './Gui/Gui'
|
package/src/server.ts
CHANGED
|
@@ -35,8 +35,6 @@ export class RpgServerEngine {
|
|
|
35
35
|
* */
|
|
36
36
|
public globalConfig: any = {}
|
|
37
37
|
|
|
38
|
-
public assetsPath: string = 'assets'
|
|
39
|
-
|
|
40
38
|
/**
|
|
41
39
|
* Combat formulas
|
|
42
40
|
*
|
|
@@ -81,7 +79,6 @@ export class RpgServerEngine {
|
|
|
81
79
|
}
|
|
82
80
|
|
|
83
81
|
this.globalConfig = this.inputOptions.globalConfig
|
|
84
|
-
if (this.globalConfig.assetsPath !== undefined) this.assetsPath = this.globalConfig.assetsPath
|
|
85
82
|
|
|
86
83
|
if (!this.inputOptions.maps) this.inputOptions.maps = []
|
|
87
84
|
if (!this.inputOptions.events) this.inputOptions.events = []
|
|
@@ -340,6 +337,10 @@ export class RpgServerEngine {
|
|
|
340
337
|
return RpgPlugin
|
|
341
338
|
}
|
|
342
339
|
|
|
340
|
+
get assetsPath(): string {
|
|
341
|
+
return this.envs?.['VITE_ASSETS_PATH'] || 'assets'
|
|
342
|
+
}
|
|
343
|
+
|
|
343
344
|
sendToPlayer(currentPlayer, eventName, data) {
|
|
344
345
|
currentPlayer._socket.emit(eventName, data)
|
|
345
346
|
}
|