@vnejs/plugins.rpg.skills 0.1.1
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/index.d.ts +1 -0
- package/dist/index.js +4 -0
- package/dist/modules/skills.d.ts +10 -0
- package/dist/modules/skills.js +27 -0
- package/dist/types.d.ts +8 -0
- package/dist/types.js +1 -0
- package/package.json +45 -0
- package/src/index.ts +6 -0
- package/src/modules/skills.ts +37 -0
- package/src/types.ts +15 -0
- package/tsconfig.json +9 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { regPlugin } from "@vnejs/shared";
|
|
2
|
+
import { CONSTANTS, PARAMS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/plugins.rpg.skills.contract";
|
|
3
|
+
import { Skills } from "./modules/skills.js";
|
|
4
|
+
regPlugin(PLUGIN_NAME, { constants: CONSTANTS, events: SUBSCRIBE_EVENTS, params: PARAMS }, [Skills]);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Module } from "@vnejs/module";
|
|
2
|
+
import type { SkillsEmitLifecyclePayload, SkillsEmitPayload } from "@vnejs/plugins.rpg.skills.contract";
|
|
3
|
+
import type { SkillsPluginConstants, SkillsPluginEvents, SkillsPluginParams, SkillsPluginSettings } from "../types.js";
|
|
4
|
+
export declare class Skills extends Module<SkillsPluginEvents, SkillsPluginConstants, SkillsPluginSettings, SkillsPluginParams> {
|
|
5
|
+
name: string;
|
|
6
|
+
subscribe: () => void;
|
|
7
|
+
onSkillEmit: ({ id, unit, target }?: SkillsEmitPayload) => Promise<void>;
|
|
8
|
+
onSkillEmitStart: ({ skillId, unit, target }?: SkillsEmitLifecyclePayload) => void;
|
|
9
|
+
onSkillEmitFinish: ({ skillId, unit, target }?: SkillsEmitLifecyclePayload) => void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Module } from "@vnejs/module";
|
|
2
|
+
export class Skills extends Module {
|
|
3
|
+
name = "skills";
|
|
4
|
+
subscribe = () => {
|
|
5
|
+
this.on(this.EVENTS.SKILLS.EMIT, this.onSkillEmit);
|
|
6
|
+
this.on(this.EVENTS.SKILLS.EMIT_START, this.onSkillEmitStart);
|
|
7
|
+
this.on(this.EVENTS.SKILLS.EMIT_FINISH, this.onSkillEmitFinish);
|
|
8
|
+
};
|
|
9
|
+
onSkillEmit = async ({ id = "", unit = "", target = "" } = {}) => {
|
|
10
|
+
const skillInfo = this.PARAMS.SKILLS.ITEMS[id];
|
|
11
|
+
if (skillInfo) {
|
|
12
|
+
if (skillInfo.type === this.CONST.SKILLS.TYPE.DAMAGE) {
|
|
13
|
+
const { type: _type, ...rest } = skillInfo;
|
|
14
|
+
const arg = { skillId: id, unit, target, ...rest };
|
|
15
|
+
await this.emit(this.EVENTS.SKILLS.EMIT_START, arg);
|
|
16
|
+
await this.emit(this.EVENTS.DAMAGE.EMIT, arg);
|
|
17
|
+
await this.emit(this.EVENTS.SKILLS.EMIT_FINISH, arg);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
onSkillEmitStart = ({ skillId = "", unit = "", target = "" } = {}) => {
|
|
22
|
+
this.emit(this.EVENTS.LOGS.EMIT, { module: this.name, value: { action: "start", skillId, unit, target } });
|
|
23
|
+
};
|
|
24
|
+
onSkillEmitFinish = ({ skillId = "", unit = "", target = "" } = {}) => {
|
|
25
|
+
this.emit(this.EVENTS.LOGS.EMIT, { module: this.name, value: { action: "finish", skillId, unit, target } });
|
|
26
|
+
};
|
|
27
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { VnePluginConstantsMapRegistry, VnePluginEventsMapRegistry, VnePluginParamsMapRegistry, VnePluginSettingsMapRegistry } from "@vnejs/shared";
|
|
2
|
+
import type { PluginName as LogsPluginName, SubscribeEvents as LogsSubscribeEvents } from "@vnejs/plugins.core.logs.contract";
|
|
3
|
+
import type { PluginName as DamagePluginName, SubscribeEvents as DamageSubscribeEvents } from "@vnejs/plugins.rpg.damage.contract";
|
|
4
|
+
import type { Constants, Params, PluginName, SubscribeEvents } from "@vnejs/plugins.rpg.skills.contract";
|
|
5
|
+
export type SkillsPluginEvents = VnePluginEventsMapRegistry & Record<PluginName, SubscribeEvents> & Record<LogsPluginName, LogsSubscribeEvents> & Record<DamagePluginName, DamageSubscribeEvents>;
|
|
6
|
+
export type SkillsPluginConstants = VnePluginConstantsMapRegistry & Record<PluginName, Constants>;
|
|
7
|
+
export type SkillsPluginSettings = VnePluginSettingsMapRegistry;
|
|
8
|
+
export type SkillsPluginParams = VnePluginParamsMapRegistry & Record<PluginName, Params>;
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vnejs/plugins.rpg.skills",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"require": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"src",
|
|
18
|
+
"tsconfig.json"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
22
|
+
"build": "npx @vnejs/monorepo package",
|
|
23
|
+
"publish:major:plugin": "npm run publish:major",
|
|
24
|
+
"publish:minor:plugin": "npm run publish:minor",
|
|
25
|
+
"publish:patch:plugin": "npm run publish:patch",
|
|
26
|
+
"publish:major": "npx @vnejs/monorepo publish major --access public",
|
|
27
|
+
"publish:minor": "npx @vnejs/monorepo publish minor --access public",
|
|
28
|
+
"publish:patch": "npx @vnejs/monorepo publish patch --access public"
|
|
29
|
+
},
|
|
30
|
+
"author": "",
|
|
31
|
+
"license": "ISC",
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@vnejs/plugins.rpg.skills.contract": "~0.0.1"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"@vnejs/module": "~0.0.1",
|
|
37
|
+
"@vnejs/plugins.core.logs.contract": "~0.0.1",
|
|
38
|
+
"@vnejs/shared": "~0.0.9"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@vnejs/configs.ts-common": "~0.0.1",
|
|
42
|
+
"@vnejs/plugins.core.logs.contract": "~0.0.1",
|
|
43
|
+
"@vnejs/plugins.rpg.damage.contract": "~0.0.1"
|
|
44
|
+
}
|
|
45
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { regPlugin } from "@vnejs/shared";
|
|
2
|
+
import { CONSTANTS, PARAMS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/plugins.rpg.skills.contract";
|
|
3
|
+
|
|
4
|
+
import { Skills } from "./modules/skills.js";
|
|
5
|
+
|
|
6
|
+
regPlugin(PLUGIN_NAME, { constants: CONSTANTS, events: SUBSCRIBE_EVENTS, params: PARAMS }, [Skills]);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Module } from "@vnejs/module";
|
|
2
|
+
import type { SkillsEmitLifecyclePayload, SkillsEmitPayload } from "@vnejs/plugins.rpg.skills.contract";
|
|
3
|
+
|
|
4
|
+
import type { SkillsPluginConstants, SkillsPluginEvents, SkillsPluginParams, SkillsPluginSettings } from "../types.js";
|
|
5
|
+
|
|
6
|
+
export class Skills extends Module<SkillsPluginEvents, SkillsPluginConstants, SkillsPluginSettings, SkillsPluginParams> {
|
|
7
|
+
name = "skills";
|
|
8
|
+
|
|
9
|
+
subscribe = () => {
|
|
10
|
+
this.on(this.EVENTS.SKILLS.EMIT, this.onSkillEmit);
|
|
11
|
+
this.on(this.EVENTS.SKILLS.EMIT_START, this.onSkillEmitStart);
|
|
12
|
+
this.on(this.EVENTS.SKILLS.EMIT_FINISH, this.onSkillEmitFinish);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
onSkillEmit = async ({ id = "", unit = "", target = "" }: SkillsEmitPayload = {}) => {
|
|
16
|
+
const skillInfo = this.PARAMS.SKILLS.ITEMS[id];
|
|
17
|
+
|
|
18
|
+
if (skillInfo) {
|
|
19
|
+
if (skillInfo.type === this.CONST.SKILLS.TYPE.DAMAGE) {
|
|
20
|
+
const { type: _type, ...rest } = skillInfo;
|
|
21
|
+
const arg: SkillsEmitLifecyclePayload = { skillId: id, unit, target, ...rest };
|
|
22
|
+
|
|
23
|
+
await this.emit(this.EVENTS.SKILLS.EMIT_START, arg);
|
|
24
|
+
await this.emit(this.EVENTS.DAMAGE.EMIT, arg);
|
|
25
|
+
await this.emit(this.EVENTS.SKILLS.EMIT_FINISH, arg);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
onSkillEmitStart = ({ skillId = "", unit = "", target = "" }: SkillsEmitLifecyclePayload = {}) => {
|
|
31
|
+
this.emit(this.EVENTS.LOGS.EMIT, { module: this.name, value: { action: "start", skillId, unit, target } });
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
onSkillEmitFinish = ({ skillId = "", unit = "", target = "" }: SkillsEmitLifecyclePayload = {}) => {
|
|
35
|
+
this.emit(this.EVENTS.LOGS.EMIT, { module: this.name, value: { action: "finish", skillId, unit, target } });
|
|
36
|
+
};
|
|
37
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { VnePluginConstantsMapRegistry, VnePluginEventsMapRegistry, VnePluginParamsMapRegistry, VnePluginSettingsMapRegistry } from "@vnejs/shared";
|
|
2
|
+
import type { PluginName as LogsPluginName, SubscribeEvents as LogsSubscribeEvents } from "@vnejs/plugins.core.logs.contract";
|
|
3
|
+
import type { PluginName as DamagePluginName, SubscribeEvents as DamageSubscribeEvents } from "@vnejs/plugins.rpg.damage.contract";
|
|
4
|
+
import type { Constants, Params, PluginName, SubscribeEvents } from "@vnejs/plugins.rpg.skills.contract";
|
|
5
|
+
|
|
6
|
+
export type SkillsPluginEvents = VnePluginEventsMapRegistry &
|
|
7
|
+
Record<PluginName, SubscribeEvents> &
|
|
8
|
+
Record<LogsPluginName, LogsSubscribeEvents> &
|
|
9
|
+
Record<DamagePluginName, DamageSubscribeEvents>;
|
|
10
|
+
|
|
11
|
+
export type SkillsPluginConstants = VnePluginConstantsMapRegistry & Record<PluginName, Constants>;
|
|
12
|
+
|
|
13
|
+
export type SkillsPluginSettings = VnePluginSettingsMapRegistry;
|
|
14
|
+
|
|
15
|
+
export type SkillsPluginParams = VnePluginParamsMapRegistry & Record<PluginName, Params>;
|