@vnejs/compatibility.rpg.skills-with-scales 0.1.9
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 +15 -0
- package/dist/index.js +14 -0
- package/dist/types.d.ts +7 -0
- package/dist/types.js +1 -0
- package/package.json +41 -0
- package/src/index.ts +38 -0
- package/src/types.ts +13 -0
- package/tsconfig.json +9 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import "@vnejs/contracts.scales";
|
|
2
|
+
import { ModuleCore } from "@vnejs/module.core";
|
|
3
|
+
import type { PluginConstants, PluginEvents, PluginParams, PluginSettings } from "./types.js";
|
|
4
|
+
type SkillsScalesPayload = {
|
|
5
|
+
entityType?: string;
|
|
6
|
+
entityId?: string;
|
|
7
|
+
scales?: Record<string, number>;
|
|
8
|
+
};
|
|
9
|
+
export declare class CompatibilitySkillsScales extends ModuleCore<PluginEvents, PluginConstants, PluginSettings, PluginParams> {
|
|
10
|
+
name: string;
|
|
11
|
+
subscribe: () => void;
|
|
12
|
+
onSkillEmitStart: ({ entityType, entityId, scales }?: SkillsScalesPayload) => Promise<(unknown[] | undefined)[]>;
|
|
13
|
+
onSkillCheck: ({ entityType, entityId, scales }?: SkillsScalesPayload) => Promise<(unknown[] | undefined)[]>;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import "@vnejs/contracts.scales";
|
|
2
|
+
import { ModuleCore } from "@vnejs/module.core";
|
|
3
|
+
import { getScaleKey } from "@vnejs/contracts.scales";
|
|
4
|
+
import { regModule } from "@vnejs/shared";
|
|
5
|
+
export class CompatibilitySkillsScales extends ModuleCore {
|
|
6
|
+
name = "compatibility.rpg.skills-with-scales";
|
|
7
|
+
subscribe = () => {
|
|
8
|
+
this.on(this.EVENTS.SKILLS.EMIT_START, this.onSkillEmitStart);
|
|
9
|
+
this.on(this.EVENTS.SKILLS.CHECK, this.onSkillCheck);
|
|
10
|
+
};
|
|
11
|
+
onSkillEmitStart = ({ entityType = "", entityId = "", scales = {} } = {}) => Promise.all(Object.entries(scales).map(([type, value]) => this.emit(this.EVENTS.SCALES.CHANGE, { key: getScaleKey(entityType, entityId, type), shift: -value })));
|
|
12
|
+
onSkillCheck = ({ entityType = "", entityId = "", scales = {} } = {}) => Promise.all(Object.entries(scales).map(([type, value]) => this.emit(this.EVENTS.SCALES.CHECK, { key: getScaleKey(entityType, entityId, type), value })));
|
|
13
|
+
}
|
|
14
|
+
regModule(CompatibilitySkillsScales);
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ModuleCoreConstants, ModuleCoreEvents, ModuleCoreParams, ModuleCoreSettings } from "@vnejs/module.core";
|
|
2
|
+
import type { Params as ScalesParams, PluginName as ScalesPluginName, SubscribeEvents as ScalesSubscribeEvents } from "@vnejs/contracts.scales";
|
|
3
|
+
import type { PluginName as SkillsPluginName, SubscribeEvents as SkillsSubscribeEvents } from "@vnejs/contracts.rpg.skills";
|
|
4
|
+
export type PluginEvents = ModuleCoreEvents & Record<SkillsPluginName, SkillsSubscribeEvents> & Record<ScalesPluginName, ScalesSubscribeEvents>;
|
|
5
|
+
export type PluginConstants = ModuleCoreConstants;
|
|
6
|
+
export type PluginSettings = ModuleCoreSettings;
|
|
7
|
+
export type PluginParams = ModuleCoreParams & Record<ScalesPluginName, ScalesParams>;
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vnejs/compatibility.rpg.skills-with-scales",
|
|
3
|
+
"version": "0.1.9",
|
|
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
|
+
"peerDependencies": {
|
|
33
|
+
"@vnejs/module.core": "~0.1.0",
|
|
34
|
+
"@vnejs/contracts.rpg.skills": "~0.1.0",
|
|
35
|
+
"@vnejs/contracts.scales": "~0.1.0",
|
|
36
|
+
"@vnejs/shared": "~0.1.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@vnejs/configs.ts-common": "~0.1.0"
|
|
40
|
+
}
|
|
41
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import "@vnejs/contracts.scales";
|
|
2
|
+
|
|
3
|
+
import { ModuleCore } from "@vnejs/module.core";
|
|
4
|
+
import { getScaleKey, type ScaleType } from "@vnejs/contracts.scales";
|
|
5
|
+
import { regModule } from "@vnejs/shared";
|
|
6
|
+
|
|
7
|
+
import type { PluginConstants, PluginEvents, PluginParams, PluginSettings } from "./types.js";
|
|
8
|
+
|
|
9
|
+
type SkillsScalesPayload = {
|
|
10
|
+
entityType?: string;
|
|
11
|
+
entityId?: string;
|
|
12
|
+
scales?: Record<string, number>;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export class CompatibilitySkillsScales extends ModuleCore<PluginEvents, PluginConstants, PluginSettings, PluginParams> {
|
|
16
|
+
name = "compatibility.rpg.skills-with-scales";
|
|
17
|
+
|
|
18
|
+
subscribe = () => {
|
|
19
|
+
this.on(this.EVENTS.SKILLS.EMIT_START, this.onSkillEmitStart);
|
|
20
|
+
this.on(this.EVENTS.SKILLS.CHECK, this.onSkillCheck);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
onSkillEmitStart = ({ entityType = "", entityId = "", scales = {} }: SkillsScalesPayload = {}) =>
|
|
24
|
+
Promise.all(
|
|
25
|
+
Object.entries(scales).map(([type, value]) =>
|
|
26
|
+
this.emit(this.EVENTS.SCALES.CHANGE, { key: getScaleKey(entityType, entityId, type as ScaleType), shift: -value }),
|
|
27
|
+
),
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
onSkillCheck = ({ entityType = "", entityId = "", scales = {} }: SkillsScalesPayload = {}) =>
|
|
31
|
+
Promise.all(
|
|
32
|
+
Object.entries(scales).map(([type, value]) =>
|
|
33
|
+
this.emit(this.EVENTS.SCALES.CHECK, { key: getScaleKey(entityType, entityId, type as ScaleType), value }),
|
|
34
|
+
),
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
regModule(CompatibilitySkillsScales);
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ModuleCoreConstants, ModuleCoreEvents, ModuleCoreParams, ModuleCoreSettings } from "@vnejs/module.core";
|
|
2
|
+
import type { Params as ScalesParams, PluginName as ScalesPluginName, SubscribeEvents as ScalesSubscribeEvents } from "@vnejs/contracts.scales";
|
|
3
|
+
import type { PluginName as SkillsPluginName, SubscribeEvents as SkillsSubscribeEvents } from "@vnejs/contracts.rpg.skills";
|
|
4
|
+
|
|
5
|
+
export type PluginEvents = ModuleCoreEvents &
|
|
6
|
+
Record<SkillsPluginName, SkillsSubscribeEvents> &
|
|
7
|
+
Record<ScalesPluginName, ScalesSubscribeEvents>;
|
|
8
|
+
|
|
9
|
+
export type PluginConstants = ModuleCoreConstants;
|
|
10
|
+
|
|
11
|
+
export type PluginSettings = ModuleCoreSettings;
|
|
12
|
+
|
|
13
|
+
export type PluginParams = ModuleCoreParams & Record<ScalesPluginName, ScalesParams>;
|