@rpgjs/server 3.3.2 → 4.0.0-beta.3
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/LICENSE +19 -0
- package/lib/Game/Map.d.ts +58 -5
- package/lib/Game/Map.js +185 -80
- package/lib/Game/Map.js.map +1 -1
- package/lib/Game/WorldMaps.d.ts +3 -2
- package/lib/Game/WorldMaps.js +6 -11
- package/lib/Game/WorldMaps.js.map +1 -1
- package/lib/Gui/DialogGui.d.ts +1 -1
- package/lib/Gui/DialogGui.js +12 -13
- package/lib/Gui/DialogGui.js.map +1 -1
- package/lib/Gui/Gui.js +2 -6
- package/lib/Gui/Gui.js.map +1 -1
- package/lib/Gui/MenuGui.js +4 -8
- package/lib/Gui/MenuGui.js.map +1 -1
- package/lib/Gui/NotificationGui.js +4 -8
- package/lib/Gui/NotificationGui.js.map +1 -1
- package/lib/Gui/ShopGui.js +4 -8
- package/lib/Gui/ShopGui.js.map +1 -1
- package/lib/Gui/index.js +6 -13
- package/lib/Gui/index.js.map +1 -1
- package/lib/Interfaces/Gui.js +1 -2
- package/lib/Interfaces/StateStore.js +1 -2
- package/lib/MatchMaker.js +28 -46
- package/lib/MatchMaker.js.map +1 -1
- package/lib/Monitor/index.js +3 -5
- package/lib/Monitor/index.js.map +1 -1
- package/lib/Player/BattleManager.js +17 -16
- package/lib/Player/BattleManager.js.map +1 -1
- package/lib/Player/ClassManager.js +6 -10
- package/lib/Player/ClassManager.js.map +1 -1
- package/lib/Player/ComponentManager.d.ts +4 -4
- package/lib/Player/ComponentManager.js +37 -24
- package/lib/Player/ComponentManager.js.map +1 -1
- package/lib/Player/EffectManager.js +8 -12
- package/lib/Player/EffectManager.js.map +1 -1
- package/lib/Player/ElementManager.js +5 -9
- package/lib/Player/ElementManager.js.map +1 -1
- package/lib/Player/GoldManager.js +1 -5
- package/lib/Player/GoldManager.js.map +1 -1
- package/lib/Player/GuiManager.js +17 -15
- package/lib/Player/GuiManager.js.map +1 -1
- package/lib/Player/ItemFixture.js +1 -5
- package/lib/Player/ItemFixture.js.map +1 -1
- package/lib/Player/ItemManager.d.ts +3 -3
- package/lib/Player/ItemManager.js +29 -31
- package/lib/Player/ItemManager.js.map +1 -1
- package/lib/Player/MoveManager.d.ts +7 -6
- package/lib/Player/MoveManager.js +67 -74
- package/lib/Player/MoveManager.js.map +1 -1
- package/lib/Player/ParameterManager.js +10 -14
- package/lib/Player/ParameterManager.js.map +1 -1
- package/lib/Player/Player.d.ts +7 -1
- package/lib/Player/Player.js +193 -191
- package/lib/Player/Player.js.map +1 -1
- package/lib/Player/SkillManager.js +18 -22
- package/lib/Player/SkillManager.js.map +1 -1
- package/lib/Player/StateManager.js +9 -13
- package/lib/Player/StateManager.js.map +1 -1
- package/lib/Player/VariableManager.js +1 -5
- package/lib/Player/VariableManager.js.map +1 -1
- package/lib/Query.d.ts +2 -1
- package/lib/Query.js +19 -15
- package/lib/Query.js.map +1 -1
- package/lib/RpgServer.d.ts +11 -3
- package/lib/RpgServer.js +1 -2
- package/lib/Scenes/Map.d.ts +27 -4
- package/lib/Scenes/Map.js +117 -122
- package/lib/Scenes/Map.js.map +1 -1
- package/lib/decorators/event.js +4 -7
- package/lib/decorators/event.js.map +1 -1
- package/lib/decorators/map.d.ts +1 -1
- package/lib/decorators/map.js +5 -9
- package/lib/decorators/map.js.map +1 -1
- package/lib/entry-point.js +59 -65
- package/lib/entry-point.js.map +1 -1
- package/lib/express/api.d.ts +3 -0
- package/lib/express/api.js +105 -0
- package/lib/express/api.js.map +1 -0
- package/lib/express/errors/NotAuthorized.d.ts +4 -0
- package/lib/express/errors/NotAuthorized.js +7 -0
- package/lib/express/errors/NotAuthorized.js.map +1 -0
- package/lib/express/errors/NotFound.d.ts +4 -0
- package/lib/express/errors/NotFound.js +7 -0
- package/lib/express/errors/NotFound.js.map +1 -0
- package/lib/express/server.js +20 -5
- package/lib/express/server.js.map +1 -1
- package/lib/index.js +15 -68
- package/lib/index.js.map +1 -1
- package/lib/logs/index.js +5 -11
- package/lib/logs/index.js.map +1 -1
- package/lib/logs/item.js +11 -15
- package/lib/logs/item.js.map +1 -1
- package/lib/logs/log.js +1 -5
- package/lib/logs/log.js.map +1 -1
- package/lib/logs/skill.js +6 -10
- package/lib/logs/skill.js.map +1 -1
- package/lib/logs/state.js +5 -9
- package/lib/logs/state.js.map +1 -1
- package/lib/models/Item.js +1 -2
- package/lib/presets/index.js +28 -36
- package/lib/presets/index.js.map +1 -1
- package/lib/server.d.ts +23 -2
- package/lib/server.js +227 -134
- package/lib/server.js.map +1 -1
- package/package.json +24 -16
- package/src/Game/Map.ts +513 -0
- package/src/Game/WorldMaps.ts +45 -0
- package/src/Gui/DialogGui.ts +67 -0
- package/src/Gui/Gui.ts +45 -0
- package/src/Gui/MenuGui.ts +26 -0
- package/src/Gui/NotificationGui.ts +10 -0
- package/src/Gui/ShopGui.ts +43 -0
- package/src/Gui/index.ts +13 -0
- package/src/Interfaces/Gui.ts +4 -0
- package/src/Interfaces/StateStore.ts +5 -0
- package/src/MatchMaker.ts +63 -0
- package/src/Monitor/index.ts +78 -0
- package/src/Player/BattleManager.ts +123 -0
- package/src/Player/ClassManager.ts +72 -0
- package/src/Player/ComponentManager.ts +538 -0
- package/src/Player/EffectManager.ts +94 -0
- package/src/Player/ElementManager.ts +142 -0
- package/src/Player/GoldManager.ts +26 -0
- package/src/Player/GuiManager.ts +308 -0
- package/src/Player/ItemFixture.ts +24 -0
- package/src/Player/ItemManager.ts +474 -0
- package/src/Player/MoveManager.ts +635 -0
- package/src/Player/ParameterManager.ts +468 -0
- package/src/Player/Player.ts +931 -0
- package/src/Player/SkillManager.ts +229 -0
- package/src/Player/StateManager.ts +230 -0
- package/src/Player/VariableManager.ts +55 -0
- package/src/Query.ts +172 -0
- package/src/RpgServer.ts +429 -0
- package/src/Scenes/Map.ts +302 -0
- package/src/decorators/event.ts +57 -0
- package/src/decorators/map.ts +223 -0
- package/src/entry-point.ts +102 -0
- package/src/express/api.ts +118 -0
- package/src/express/errors/NotAuthorized.ts +6 -0
- package/src/express/errors/NotFound.ts +6 -0
- package/src/express/server.ts +93 -0
- package/src/index.ts +28 -0
- package/src/logs/index.ts +11 -0
- package/src/logs/item.ts +31 -0
- package/src/logs/log.ts +3 -0
- package/src/logs/skill.ts +16 -0
- package/src/logs/state.ts +13 -0
- package/src/models/Item.ts +11 -0
- package/src/presets/index.ts +71 -0
- package/src/server.ts +394 -0
- package/tsconfig.json +27 -0
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
const presets_1 = require("../presets");
|
|
11
|
-
const { isArray, isString, isInstanceOf, applyMixins } = common_1.Utils;
|
|
12
|
-
class SkillManager {
|
|
1
|
+
import { Utils } from '@rpgjs/common';
|
|
2
|
+
import { Effect } from '@rpgjs/database';
|
|
3
|
+
import { SkillLog } from '../logs';
|
|
4
|
+
import { StateManager } from './StateManager';
|
|
5
|
+
import { EffectManager } from './EffectManager';
|
|
6
|
+
import { ParameterManager } from './ParameterManager';
|
|
7
|
+
import { INT } from '../presets';
|
|
8
|
+
const { isArray, isString, isInstanceOf, applyMixins } = Utils;
|
|
9
|
+
export class SkillManager {
|
|
13
10
|
_getSkillIndex(skillClass) {
|
|
14
11
|
return this.skills.findIndex(skill => {
|
|
15
12
|
if (isString(skill)) {
|
|
@@ -57,7 +54,7 @@ class SkillManager {
|
|
|
57
54
|
const instance = new skillClass();
|
|
58
55
|
if (!instance.coefficient)
|
|
59
56
|
instance.coefficient = {
|
|
60
|
-
[
|
|
57
|
+
[INT]: 1
|
|
61
58
|
};
|
|
62
59
|
this.skills.push(instance);
|
|
63
60
|
this['execMethod']('onLearn', [this], instance);
|
|
@@ -96,7 +93,7 @@ class SkillManager {
|
|
|
96
93
|
forgetSkill(skillClass) {
|
|
97
94
|
const index = this._getSkillIndex(skillClass);
|
|
98
95
|
if (index == -1) {
|
|
99
|
-
throw
|
|
96
|
+
throw SkillLog.notLearned(skillClass);
|
|
100
97
|
}
|
|
101
98
|
this.skills.splice(index, 1);
|
|
102
99
|
const instance = this.skills[index];
|
|
@@ -180,20 +177,20 @@ class SkillManager {
|
|
|
180
177
|
*/
|
|
181
178
|
useSkill(skillClass, otherPlayer) {
|
|
182
179
|
const skill = this.getSkill(skillClass);
|
|
183
|
-
if (this.hasEffect(
|
|
184
|
-
throw
|
|
180
|
+
if (this.hasEffect(Effect.CAN_NOT_SKILL)) {
|
|
181
|
+
throw SkillLog.restriction(skillClass);
|
|
185
182
|
}
|
|
186
183
|
if (!skill) {
|
|
187
|
-
throw
|
|
184
|
+
throw SkillLog.notLearned(skillClass);
|
|
188
185
|
}
|
|
189
186
|
if (skill.spCost > this.sp) {
|
|
190
|
-
throw
|
|
187
|
+
throw SkillLog.notEnoughSp(skillClass, skill.spCost, this.sp);
|
|
191
188
|
}
|
|
192
|
-
this.sp -= (skill.spCost / (this.hasEffect(
|
|
189
|
+
this.sp -= (skill.spCost / (this.hasEffect(Effect.HALF_SP_COST) ? 2 : 1));
|
|
193
190
|
const hitRate = skill.hitRate || 1;
|
|
194
191
|
if (Math.random() > hitRate) {
|
|
195
192
|
this['execMethod']('onUseFailed', [this, otherPlayer], skill);
|
|
196
|
-
throw
|
|
193
|
+
throw SkillLog.chanceToUseFailed(skillClass);
|
|
197
194
|
}
|
|
198
195
|
if (otherPlayer) {
|
|
199
196
|
let players = otherPlayer;
|
|
@@ -209,6 +206,5 @@ class SkillManager {
|
|
|
209
206
|
return skill;
|
|
210
207
|
}
|
|
211
208
|
}
|
|
212
|
-
|
|
213
|
-
applyMixins(SkillManager, [ParameterManager_1.ParameterManager, StateManager_1.StateManager, EffectManager_1.EffectManager]);
|
|
209
|
+
applyMixins(SkillManager, [ParameterManager, StateManager, EffectManager]);
|
|
214
210
|
//# sourceMappingURL=SkillManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SkillManager.js","sourceRoot":"","sources":["../../src/Player/SkillManager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SkillManager.js","sourceRoot":"","sources":["../../src/Player/SkillManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAO,eAAe,CAAA;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD,OAAO,EACH,GAAG,EACN,MAAM,YAAY,CAAA;AAEnB,MAAM,EACF,OAAO,EACP,QAAQ,EACR,YAAY,EACZ,WAAW,EACd,GAAG,KAAK,CAAA;AAET,MAAM,OAAO,YAAY;IAIb,cAAc,CAAC,UAAU;QAC7B,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE;YACjC,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE;gBACjB,OAAO,KAAK,CAAC,EAAE,IAAI,UAAU,CAAA;aAChC;YACD,OAAO,YAAY,CAAC,KAAK,EAAE,UAAU,CAAC,CAAA;QAC1C,CAAC,CAAC,CAAA;IACN,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,QAAQ,CAAC,UAAU;QACf,MAAM,KAAK,GAAG,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAA;QAC7C,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IAC7B,CAAC;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,UAAU,CAAC,UAAU;QACjB,MAAM,QAAQ,GAAG,IAAI,UAAU,EAAE,CAAA;QACjC,IAAI,CAAC,QAAQ,CAAC,WAAW;YAAE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-
const
|
|
5
|
-
|
|
6
|
-
const state_1 = require("../logs/state");
|
|
7
|
-
const { isInstanceOf, applyMixins } = common_1.Utils;
|
|
8
|
-
class StateManager {
|
|
1
|
+
import { Utils } from '@rpgjs/common';
|
|
2
|
+
import { ItemFixture } from './ItemFixture';
|
|
3
|
+
import { StateLog } from '../logs/state';
|
|
4
|
+
const { isInstanceOf, applyMixins } = Utils;
|
|
5
|
+
export class StateManager {
|
|
9
6
|
constructor() {
|
|
10
7
|
this.states = [];
|
|
11
8
|
}
|
|
@@ -150,7 +147,7 @@ class StateManager {
|
|
|
150
147
|
const state = this.getState(stateClass);
|
|
151
148
|
if (!state) {
|
|
152
149
|
if (Math.random() > chance) {
|
|
153
|
-
throw
|
|
150
|
+
throw StateLog.addFailed(stateClass);
|
|
154
151
|
}
|
|
155
152
|
//const efficiency = this.findStateEfficiency(stateClass)
|
|
156
153
|
const instance = new stateClass();
|
|
@@ -200,18 +197,17 @@ class StateManager {
|
|
|
200
197
|
const index = this.states.findIndex(state => state instanceof stateClass);
|
|
201
198
|
if (index != -1) {
|
|
202
199
|
if (Math.random() > chance) {
|
|
203
|
-
throw
|
|
200
|
+
throw StateLog.removeFailed(stateClass);
|
|
204
201
|
}
|
|
205
202
|
this.states.splice(index, 1);
|
|
206
203
|
}
|
|
207
204
|
else {
|
|
208
|
-
throw
|
|
205
|
+
throw StateLog.notApplied(stateClass);
|
|
209
206
|
}
|
|
210
207
|
}
|
|
211
208
|
findStateEfficiency(stateClass) {
|
|
212
209
|
return this.statesEfficiency.find(state => isInstanceOf(state.state, stateClass));
|
|
213
210
|
}
|
|
214
211
|
}
|
|
215
|
-
|
|
216
|
-
applyMixins(StateManager, [ItemFixture_1.ItemFixture]);
|
|
212
|
+
applyMixins(StateManager, [ItemFixture]);
|
|
217
213
|
//# sourceMappingURL=StateManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StateManager.js","sourceRoot":"","sources":["../../src/Player/StateManager.ts"],"names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CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAA;IACrF,CAAC;CACJ;AAED,WAAW,CAAC,YAAY,EAAE,CAAC,WAAW,CAAC,CAAC,CAAA"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.VariableManager = void 0;
|
|
4
|
-
class VariableManager {
|
|
1
|
+
export class VariableManager {
|
|
5
2
|
/**
|
|
6
3
|
* Assign a variable to the player
|
|
7
4
|
*
|
|
@@ -52,5 +49,4 @@ class VariableManager {
|
|
|
52
49
|
return this.variables.delete(key);
|
|
53
50
|
}
|
|
54
51
|
}
|
|
55
|
-
exports.VariableManager = VariableManager;
|
|
56
52
|
//# sourceMappingURL=VariableManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VariableManager.js","sourceRoot":"","sources":["../../src/Player/VariableManager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"VariableManager.js","sourceRoot":"","sources":["../../src/Player/VariableManager.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,eAAe;IAGxB;;;;;;;;;;;;;SAaK;IACL,WAAW,CAAC,GAAW,EAAE,GAAG;QACxB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;IAChC,CAAC;IAED;;;;;;;;;;;;SAYK;IACL,WAAW,CAAC,GAAW;QACnB,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IAClC,CAAC;IAED;;;;;;;;;;;;SAYK;IACL,cAAc,CAAC,GAAW;QACtB,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;IACrC,CAAC;CACJ"}
|
package/lib/Query.d.ts
CHANGED
|
@@ -104,7 +104,8 @@ declare class QueryClass {
|
|
|
104
104
|
_getShapesOfMap(map: string): {
|
|
105
105
|
[id: string]: RpgShape;
|
|
106
106
|
};
|
|
107
|
-
getRooms(): Map<string,
|
|
107
|
+
getRooms<T>(): Map<string, T>;
|
|
108
|
+
getRoom<T>(name: string): T;
|
|
108
109
|
/**
|
|
109
110
|
* Recover all the players of a map
|
|
110
111
|
*
|
package/lib/Query.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const simple_room_1 = require("simple-room");
|
|
5
|
-
const common_1 = require("@rpgjs/common");
|
|
6
|
-
const { isString } = common_1.Utils;
|
|
1
|
+
import { World } from 'simple-room';
|
|
2
|
+
import { Utils } from '@rpgjs/common';
|
|
3
|
+
const { isString } = Utils;
|
|
7
4
|
class QueryClass {
|
|
8
5
|
/**
|
|
9
6
|
* Listen to the changes on all the rooms
|
|
@@ -27,7 +24,7 @@ class QueryClass {
|
|
|
27
24
|
* @memberof RpgWorld
|
|
28
25
|
* */
|
|
29
26
|
get changes() {
|
|
30
|
-
return
|
|
27
|
+
return World.changes.asObservable();
|
|
31
28
|
}
|
|
32
29
|
/**
|
|
33
30
|
* Retrieve a player according to his ID
|
|
@@ -46,7 +43,7 @@ class QueryClass {
|
|
|
46
43
|
*/
|
|
47
44
|
getPlayer(player) {
|
|
48
45
|
const id = isString(player) ? player : '' + player.id;
|
|
49
|
-
const _player =
|
|
46
|
+
const _player = World.getUser(id);
|
|
50
47
|
return _player;
|
|
51
48
|
}
|
|
52
49
|
/**
|
|
@@ -64,7 +61,7 @@ class QueryClass {
|
|
|
64
61
|
* @memberof RpgWorld
|
|
65
62
|
*/
|
|
66
63
|
getPlayers() {
|
|
67
|
-
const users =
|
|
64
|
+
const users = World.getUsers();
|
|
68
65
|
const array = Object.values(users);
|
|
69
66
|
return array.map((user) => this.getPlayer(user));
|
|
70
67
|
}
|
|
@@ -97,12 +94,16 @@ class QueryClass {
|
|
|
97
94
|
return Object.values(this._getObjectsOfMap(map, playerId));
|
|
98
95
|
}
|
|
99
96
|
_getObjectsOfMap(map, playerId) {
|
|
100
|
-
const room =
|
|
97
|
+
const room = World.getRoom(map);
|
|
101
98
|
let player = null;
|
|
102
99
|
if (playerId) {
|
|
103
100
|
player = this.getPlayer(playerId);
|
|
104
101
|
}
|
|
105
|
-
return
|
|
102
|
+
return {
|
|
103
|
+
...room.users,
|
|
104
|
+
...room.events,
|
|
105
|
+
...(player ? player.events : {})
|
|
106
|
+
};
|
|
106
107
|
}
|
|
107
108
|
/**
|
|
108
109
|
* Find all the shapes of the map
|
|
@@ -124,12 +125,15 @@ class QueryClass {
|
|
|
124
125
|
return Object.values(this._getShapesOfMap(map));
|
|
125
126
|
}
|
|
126
127
|
_getShapesOfMap(map) {
|
|
127
|
-
const room =
|
|
128
|
+
const room = World.getRoom(map);
|
|
128
129
|
return room.shapes;
|
|
129
130
|
}
|
|
130
131
|
// TODO
|
|
131
132
|
getRooms() {
|
|
132
|
-
return
|
|
133
|
+
return World.getRooms();
|
|
134
|
+
}
|
|
135
|
+
getRoom(name) {
|
|
136
|
+
return World.getRoom(name);
|
|
133
137
|
}
|
|
134
138
|
/**
|
|
135
139
|
* Recover all the players of a map
|
|
@@ -147,9 +151,9 @@ class QueryClass {
|
|
|
147
151
|
* @memberof RpgWorld
|
|
148
152
|
*/
|
|
149
153
|
getPlayersOfMap(map) {
|
|
150
|
-
const room =
|
|
154
|
+
const room = World.getRoom(map);
|
|
151
155
|
return Object.values(room.users);
|
|
152
156
|
}
|
|
153
157
|
}
|
|
154
|
-
|
|
158
|
+
export const Query = new QueryClass();
|
|
155
159
|
//# sourceMappingURL=Query.js.map
|
package/lib/Query.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Query.js","sourceRoot":"","sources":["../src/Query.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Query.js","sourceRoot":"","sources":["../src/Query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE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Q,CAAC,CAAA;SACpC;QACD,OAAO;YACH,GAAG,IAAI,CAAC,KAAK;YACb,GAAG,IAAI,CAAC,MAAM;YACd,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;SACnC,CAAA;IACL,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACH,cAAc,CAAC,GAAW;QACtB,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAA;IACnD,CAAC;IAED,eAAe,CAAC,GAAW;QACvB,MAAM,IAAI,GAAQ,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;QACpC,OAAO,IAAI,CAAC,MAAM,CAAA;IACtB,CAAC;IAED,OAAO;IACP,QAAQ;QACJ,OAAO,KAAK,CAAC,QAAQ,EAAoB,CAAA;IAC7C,CAAC;IAED,OAAO,CAAI,IAAY;QACnB,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAM,CAAA;IACnC,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,eAAe,CAAC,GAAW;QACvB,MAAM,IAAI,GAAQ,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;QACpC,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAgB,CAAA;IACnD,CAAC;CACJ;AAED,MAAM,CAAC,MAAM,KAAK,GAAG,IAAI,UAAU,EAAE,CAAA"}
|
package/lib/RpgServer.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ModuleType, RpgShape, Direction, Control } from '@rpgjs/common';
|
|
2
|
-
import { RpgPlayer } from './Player/Player';
|
|
2
|
+
import { RpgClassEvent, RpgEvent, RpgPlayer } from './Player/Player';
|
|
3
3
|
import { RpgMap } from './Game/Map';
|
|
4
4
|
import { RpgServerEngine } from './server';
|
|
5
5
|
import { MapOptions } from './decorators/map';
|
|
@@ -253,7 +253,7 @@ export interface RpgServer {
|
|
|
253
253
|
* @prop { { [dataName]: data } } [database]
|
|
254
254
|
* @memberof RpgServer
|
|
255
255
|
* */
|
|
256
|
-
database?: object;
|
|
256
|
+
database?: object | any[];
|
|
257
257
|
/**
|
|
258
258
|
* Array of all maps. Each element is an `RpgMap` class
|
|
259
259
|
*
|
|
@@ -305,6 +305,15 @@ export interface RpgServer {
|
|
|
305
305
|
* @memberof RpgServer
|
|
306
306
|
* */
|
|
307
307
|
maps?: RpgClassMap<RpgMap>[] | MapOptions[] | string[] | TiledMap[];
|
|
308
|
+
/**
|
|
309
|
+
* Array of all events. Each element is an `RpgEvent` class
|
|
310
|
+
* Events can be used by placing a shape with the name of the event on Tiled Map Editor
|
|
311
|
+
*
|
|
312
|
+
* @prop {RpgClassEvent<RpgEvent>[]} [events]
|
|
313
|
+
* @since 4.0.0
|
|
314
|
+
* @memberof RpgServer
|
|
315
|
+
*/
|
|
316
|
+
events?: RpgClassEvent<RpgEvent>[];
|
|
308
317
|
/**
|
|
309
318
|
* Loads the content of a `.world` file from Tiled Map Editor into the map scene
|
|
310
319
|
*
|
|
@@ -328,7 +337,6 @@ export interface RpgServer {
|
|
|
328
337
|
type: 'world' // only for Tiled Map Editor
|
|
329
338
|
* }
|
|
330
339
|
* ```
|
|
331
|
-
* @param {RpgSceneMap} sceneMap
|
|
332
340
|
* @since 3.0.0-beta.8
|
|
333
341
|
* @example
|
|
334
342
|
* ```ts
|
package/lib/RpgServer.js
CHANGED
package/lib/Scenes/Map.d.ts
CHANGED
|
@@ -2,22 +2,44 @@ import { TiledMap } from '@rpgjs/tiled';
|
|
|
2
2
|
import { MapOptions } from '../decorators/map';
|
|
3
3
|
import { RpgMap } from '../Game/Map';
|
|
4
4
|
import { RpgWorldMaps, WorldMap } from '../Game/WorldMaps';
|
|
5
|
-
import { RpgPlayer } from '../Player/Player';
|
|
5
|
+
import { RpgEvent, RpgPlayer } from '../Player/Player';
|
|
6
6
|
import { RpgServerEngine } from '../server';
|
|
7
7
|
export interface RpgClassMap<T> {
|
|
8
8
|
id?: string;
|
|
9
|
+
file?: string;
|
|
9
10
|
new (server: any): T;
|
|
10
11
|
}
|
|
12
|
+
type SceneMapObject = {
|
|
13
|
+
maps: any[];
|
|
14
|
+
worldMaps: WorldMap[];
|
|
15
|
+
events: RpgEvent[];
|
|
16
|
+
};
|
|
11
17
|
export declare class SceneMap {
|
|
12
|
-
private maps;
|
|
13
18
|
private server;
|
|
14
19
|
static readonly id: string;
|
|
20
|
+
private maps;
|
|
15
21
|
private mapsById;
|
|
16
22
|
private worldMaps;
|
|
17
|
-
constructor(
|
|
23
|
+
constructor(sceneMapObject: SceneMapObject, server: RpgServerEngine);
|
|
24
|
+
/**
|
|
25
|
+
* Returns an array of RpgClassMap objects that represent maps with static properties.
|
|
26
|
+
* @returns {RpgClassMap<RpgMap>[]} Array of RpgClassMap objects.
|
|
27
|
+
* @since 4.0.0
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* const maps = scene.getMaps();
|
|
31
|
+
* console.log(maps);
|
|
32
|
+
* // Output: [
|
|
33
|
+
* // { file: 'maps/level1.tmx', id: 'level1', type: 'map' },
|
|
34
|
+
* // { file: 'maps/level2.tmx', id: 'level1', type: 'map' },
|
|
35
|
+
* // { file: 'maps/level3.tmx', id: 'level1', type: 'map' }
|
|
36
|
+
* // ]
|
|
37
|
+
* ```
|
|
38
|
+
* @memberof SceneMap
|
|
39
|
+
*/
|
|
40
|
+
getMaps(): RpgClassMap<RpgMap>[];
|
|
18
41
|
getMapBydId(id: string): RpgClassMap<RpgMap> | null;
|
|
19
42
|
loadMap(id: string): Promise<RpgMap | undefined>;
|
|
20
|
-
removeMap(id: string): void;
|
|
21
43
|
/**
|
|
22
44
|
* Loads the content of a `.world` file from Tiled Map Editor into the map scene
|
|
23
45
|
*
|
|
@@ -109,3 +131,4 @@ export declare class SceneMap {
|
|
|
109
131
|
z?: number;
|
|
110
132
|
} | string): Promise<RpgMap | null | boolean>;
|
|
111
133
|
}
|
|
134
|
+
export {};
|