bard-legends-framework 0.2.2 → 0.2.4
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/game-entities/attachable/attachable.test.d.ts +1 -0
- package/dist/game-entities/attachable/attachable.test.js +136 -0
- package/dist/game-entities/attachable/attachable.test.js.map +1 -0
- package/dist/game-entities/attachable/helpers/decorate-actions-lib.js +42 -15
- package/dist/game-entities/attachable/helpers/decorate-actions-lib.js.map +1 -1
- package/dist/game-entities/controller/controller.test.d.ts +1 -0
- package/dist/game-entities/controller/controller.test.js +128 -0
- package/dist/game-entities/controller/controller.test.js.map +1 -0
- package/dist/game-entities/entity/entity.test.d.ts +1 -0
- package/dist/game-entities/entity/entity.test.js +301 -0
- package/dist/game-entities/entity/entity.test.js.map +1 -0
- package/dist/game-entities/scene/scene.test.d.ts +1 -0
- package/dist/game-entities/scene/scene.test.js +231 -0
- package/dist/game-entities/scene/scene.test.js.map +1 -0
- package/dist/game-entities/service/service.test.d.ts +1 -0
- package/dist/game-entities/service/service.test.js +245 -0
- package/dist/game-entities/service/service.test.js.map +1 -0
- package/dist/game-entities/view/view.test.d.ts +1 -0
- package/dist/game-entities/view/view.test.js +514 -0
- package/dist/game-entities/view/view.test.js.map +1 -0
- package/dist/utilities/libraries/animator/animator.test.d.ts +1 -0
- package/dist/utilities/libraries/animator/animator.test.js +670 -0
- package/dist/utilities/libraries/animator/animator.test.js.map +1 -0
- package/dist/utilities/libraries/data-structures/grid/grid.test.d.ts +1 -0
- package/dist/utilities/libraries/data-structures/grid/grid.test.js +140 -0
- package/dist/utilities/libraries/data-structures/grid/grid.test.js.map +1 -0
- package/dist/utilities/libraries/grid-algorithms/closest-available-space/closest-available-space.helper.test.d.ts +1 -0
- package/dist/utilities/libraries/grid-algorithms/closest-available-space/closest-available-space.helper.test.js +70 -0
- package/dist/utilities/libraries/grid-algorithms/closest-available-space/closest-available-space.helper.test.js.map +1 -0
- package/dist/utilities/libraries/grid-algorithms/path-finder/path-finder.test.d.ts +1 -0
- package/dist/utilities/libraries/grid-algorithms/path-finder/path-finder.test.js +164 -0
- package/dist/utilities/libraries/grid-algorithms/path-finder/path-finder.test.js.map +1 -0
- package/dist/utilities/libraries/grid-algorithms/vector-field-path-finder/vector-field-path-finder.test.d.ts +1 -0
- package/dist/utilities/libraries/grid-algorithms/vector-field-path-finder/vector-field-path-finder.test.js +232 -0
- package/dist/utilities/libraries/grid-algorithms/vector-field-path-finder/vector-field-path-finder.test.js.map +1 -0
- package/dist/utilities/services/keyboard/keyboard.js +5 -2
- package/dist/utilities/services/keyboard/keyboard.js.map +1 -1
- package/dist/utilities/services/mouse/helpers/mouse-position.helper.d.ts +4 -0
- package/dist/utilities/services/mouse/helpers/mouse-position.helper.js +17 -0
- package/dist/utilities/services/mouse/helpers/mouse-position.helper.js.map +1 -0
- package/dist/utilities/services/mouse/helpers/mouse-position.helper.test.d.ts +1 -0
- package/dist/utilities/services/mouse/helpers/mouse-position.helper.test.js +43 -0
- package/dist/utilities/services/mouse/helpers/mouse-position.helper.test.js.map +1 -0
- package/dist/utilities/services/mouse/mouse.service.js +10 -4
- package/dist/utilities/services/mouse/mouse.service.js.map +1 -1
- package/package.json +4 -4
- package/vitest.config.ts +12 -7
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
+
if (mod && mod.__esModule) return mod;
|
|
26
|
+
var result = {};
|
|
27
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
+
__setModuleDefault(result, mod);
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
31
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
32
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
const vitest_1 = require("vitest");
|
|
36
|
+
const actions_lib_1 = require("actions-lib");
|
|
37
|
+
const ActionsLib = __importStar(require("actions-lib"));
|
|
38
|
+
const entity_1 = require("../entity/entity");
|
|
39
|
+
const update_loop_1 = require("../update-loop");
|
|
40
|
+
const scene_1 = require("../scene/scene");
|
|
41
|
+
const decorate_actions_lib_1 = require("./helpers/decorate-actions-lib");
|
|
42
|
+
decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
|
|
43
|
+
(0, vitest_1.describe)('ATTACHABLE', () => {
|
|
44
|
+
(0, vitest_1.beforeEach)(() => {
|
|
45
|
+
update_loop_1.UpdateCycle.hardResetAction.trigger();
|
|
46
|
+
let SampleScene = class SampleScene extends scene_1.Scene {
|
|
47
|
+
};
|
|
48
|
+
SampleScene = __decorate([
|
|
49
|
+
(0, scene_1.SceneDecorator)()
|
|
50
|
+
], SampleScene);
|
|
51
|
+
SampleScene.open(undefined);
|
|
52
|
+
});
|
|
53
|
+
(0, vitest_1.test)('destroyable', () => {
|
|
54
|
+
let Sample = class Sample extends entity_1.Entity {
|
|
55
|
+
};
|
|
56
|
+
Sample = __decorate([
|
|
57
|
+
(0, entity_1.EntityDecorator)()
|
|
58
|
+
], Sample);
|
|
59
|
+
class Foo {
|
|
60
|
+
constructor() {
|
|
61
|
+
this.destroyed = false;
|
|
62
|
+
}
|
|
63
|
+
destroy() {
|
|
64
|
+
this.destroyed = true;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
let sample = new Sample().attach(scene_1.Scene.activeScene);
|
|
68
|
+
let foo = new Foo();
|
|
69
|
+
sample['setAttachment'](foo);
|
|
70
|
+
sample.destroy();
|
|
71
|
+
update_loop_1.UpdateCycle.triggerUpdateTick(0); // Update cycle should take place to destroy functions to be called
|
|
72
|
+
(0, vitest_1.expect)(foo.destroyed).toBeTruthy();
|
|
73
|
+
});
|
|
74
|
+
(0, vitest_1.test)('destroyable, delayed', () => {
|
|
75
|
+
let Sample = class Sample extends entity_1.Entity {
|
|
76
|
+
};
|
|
77
|
+
Sample = __decorate([
|
|
78
|
+
(0, entity_1.EntityDecorator)()
|
|
79
|
+
], Sample);
|
|
80
|
+
class Foo {
|
|
81
|
+
constructor() {
|
|
82
|
+
this.destroyed = false;
|
|
83
|
+
}
|
|
84
|
+
destroy() {
|
|
85
|
+
this.destroyed = true;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
let sample = new Sample().attach(scene_1.Scene.activeScene);
|
|
89
|
+
let foo = new Foo();
|
|
90
|
+
sample['setAttachment'](foo);
|
|
91
|
+
sample.destroy();
|
|
92
|
+
update_loop_1.UpdateCycle.triggerUpdateTick(0); // Update cycle should take place to destroy functions to be called
|
|
93
|
+
(0, vitest_1.expect)(foo.destroyed).toBeTruthy();
|
|
94
|
+
});
|
|
95
|
+
(0, vitest_1.test)('subscription', () => {
|
|
96
|
+
let Sample = class Sample extends entity_1.Entity {
|
|
97
|
+
};
|
|
98
|
+
Sample = __decorate([
|
|
99
|
+
(0, entity_1.EntityDecorator)()
|
|
100
|
+
], Sample);
|
|
101
|
+
let foo = new actions_lib_1.Variable();
|
|
102
|
+
let sample = new Sample().attach(scene_1.Scene.activeScene);
|
|
103
|
+
(0, vitest_1.expect)(foo.listenerCount).toEqual(0);
|
|
104
|
+
foo.subscribe(() => { }).attach(sample);
|
|
105
|
+
(0, vitest_1.expect)(foo.listenerCount).toEqual(1);
|
|
106
|
+
sample.destroy();
|
|
107
|
+
update_loop_1.UpdateCycle.triggerUpdateTick(0); // Update cycle should take place to destroy functions to be called
|
|
108
|
+
(0, vitest_1.expect)(foo.listenerCount).toEqual(0);
|
|
109
|
+
});
|
|
110
|
+
(0, vitest_1.test)('entity attachment in constructor', () => {
|
|
111
|
+
let childDestoyIsCalled = false;
|
|
112
|
+
let Parent = class Parent extends entity_1.Entity {
|
|
113
|
+
constructor() {
|
|
114
|
+
super();
|
|
115
|
+
new Child().attach(this);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
Parent = __decorate([
|
|
119
|
+
(0, entity_1.EntityDecorator)(),
|
|
120
|
+
__metadata("design:paramtypes", [])
|
|
121
|
+
], Parent);
|
|
122
|
+
let Child = class Child extends entity_1.Entity {
|
|
123
|
+
destroy() {
|
|
124
|
+
childDestoyIsCalled = true;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
Child = __decorate([
|
|
128
|
+
(0, entity_1.EntityDecorator)()
|
|
129
|
+
], Child);
|
|
130
|
+
let parent = new Parent().attach(scene_1.Scene.activeScene);
|
|
131
|
+
parent.destroy();
|
|
132
|
+
update_loop_1.UpdateCycle.triggerUpdateTick(0); // Update cycle should take place to destroy functions to be called
|
|
133
|
+
(0, vitest_1.expect)(childDestoyIsCalled).toBeTruthy();
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
//# sourceMappingURL=attachable.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachable.test.js","sourceRoot":"","sources":["../../../src/game-entities/attachable/attachable.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAA4D;AAC5D,6CAAuC;AACvC,wDAA0C;AAE1C,6CAA2D;AAC3D,gDAA6C;AAC7C,0CAAuD;AAGvD,yEAAqE;AACrE,0CAAmB,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;AAEzC,IAAA,iBAAQ,EAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,IAAA,mBAAU,EAAC,GAAG,EAAE;QACd,yBAAW,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC;QAGtC,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,aAAW;SAAG,CAAA;QAAlC,WAAW;YADhB,IAAA,sBAAc,GAAE;WACX,WAAW,CAAuB;QAExC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;IAEH,IAAA,aAAI,EAAC,aAAa,EAAE,GAAG,EAAE;QAEvB,IAAM,MAAM,GAAZ,MAAM,MAAO,SAAQ,eAAM;SAAG,CAAA;QAAxB,MAAM;YADX,IAAA,wBAAe,GAAE;WACZ,MAAM,CAAkB;QAE9B,MAAM,GAAG;YAAT;gBACE,cAAS,GAAG,KAAK,CAAC;YAIpB,CAAC;YAHC,OAAO;gBACL,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;YACxB,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AAM,CAAC,OAAO,EAAE,CAAC;QACjB,yBAAW,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,mEAAmE;QAErG,IAAA,eAAM,EAAC,mBAAmB,CAAC,CAAC,UAAU,EAAE,CAAC;IAC3C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
26
|
exports.ActionsLibDecorator = void 0;
|
|
27
|
+
const ActionsLib = __importStar(require("actions-lib"));
|
|
4
28
|
const attachable_1 = require("../attachable");
|
|
5
29
|
class ActionsLibDecorator {
|
|
6
30
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
@@ -8,32 +32,35 @@ class ActionsLibDecorator {
|
|
|
8
32
|
this.decorateAttachFunctions(actionsLib);
|
|
9
33
|
this.decorateSubscriptions(actionsLib);
|
|
10
34
|
this.decorateEffectChannels(actionsLib);
|
|
35
|
+
if (actionsLib !== ActionsLib) {
|
|
36
|
+
this.decorate(ActionsLib);
|
|
37
|
+
}
|
|
11
38
|
}
|
|
12
|
-
static decorateAttachFunctions(
|
|
13
|
-
|
|
39
|
+
static decorateAttachFunctions(actionsLib) {
|
|
40
|
+
actionsLib.ActionSubscription.prototype.attach = function (parent) {
|
|
14
41
|
let parentEntity = attachable_1.Attachable.findAttachableParent(parent);
|
|
15
42
|
parentEntity['setAttachment'](this);
|
|
16
43
|
this.$meta = { attachIsCalled: true };
|
|
17
44
|
return this;
|
|
18
45
|
};
|
|
19
|
-
|
|
46
|
+
actionsLib.ActionSubscription.prototype.skipAttachCheck = function () {
|
|
20
47
|
this.$meta = { attachIsCalled: true };
|
|
21
48
|
return this;
|
|
22
49
|
};
|
|
23
|
-
|
|
50
|
+
actionsLib.ReducerEffectChannel.prototype.attach = function (parent) {
|
|
24
51
|
let parentEntity = attachable_1.Attachable.findAttachableParent(parent);
|
|
25
52
|
parentEntity['setAttachment'](this);
|
|
26
53
|
this.$meta = { attachIsCalled: true };
|
|
27
54
|
return this;
|
|
28
55
|
};
|
|
29
|
-
|
|
56
|
+
actionsLib.ReducerEffectChannel.prototype.skipAttachCheck = function () {
|
|
30
57
|
this.$meta = { attachIsCalled: true };
|
|
31
58
|
return this;
|
|
32
59
|
};
|
|
33
60
|
}
|
|
34
|
-
static decorateSubscriptions(
|
|
35
|
-
let originalActionSubscribe =
|
|
36
|
-
|
|
61
|
+
static decorateSubscriptions(actionsLib) {
|
|
62
|
+
let originalActionSubscribe = actionsLib.Action.prototype.subscribe;
|
|
63
|
+
actionsLib.Action.prototype.subscribe = function (callback) {
|
|
37
64
|
let subscription = originalActionSubscribe.call(this, callback);
|
|
38
65
|
setTimeout(() => {
|
|
39
66
|
if (!subscription.$meta?.attachIsCalled) {
|
|
@@ -42,8 +69,8 @@ class ActionsLibDecorator {
|
|
|
42
69
|
});
|
|
43
70
|
return subscription;
|
|
44
71
|
};
|
|
45
|
-
let originalVariableSubscribe =
|
|
46
|
-
|
|
72
|
+
let originalVariableSubscribe = actionsLib.Variable.prototype.subscribe;
|
|
73
|
+
actionsLib.Variable.prototype.subscribe = function (callback) {
|
|
47
74
|
let subscription = originalVariableSubscribe.call(this, callback);
|
|
48
75
|
setTimeout(() => {
|
|
49
76
|
if (!subscription.$meta?.attachIsCalled) {
|
|
@@ -52,8 +79,8 @@ class ActionsLibDecorator {
|
|
|
52
79
|
});
|
|
53
80
|
return subscription;
|
|
54
81
|
};
|
|
55
|
-
let originalReducerSubscribe =
|
|
56
|
-
|
|
82
|
+
let originalReducerSubscribe = actionsLib.Reducer.prototype.subscribe;
|
|
83
|
+
actionsLib.Reducer.prototype.subscribe = function (callback) {
|
|
57
84
|
let subscription = originalReducerSubscribe.call(this, callback);
|
|
58
85
|
setTimeout(() => {
|
|
59
86
|
if (!subscription.$meta?.attachIsCalled) {
|
|
@@ -63,9 +90,9 @@ class ActionsLibDecorator {
|
|
|
63
90
|
return subscription;
|
|
64
91
|
};
|
|
65
92
|
}
|
|
66
|
-
static decorateEffectChannels(
|
|
67
|
-
let originalEffect =
|
|
68
|
-
|
|
93
|
+
static decorateEffectChannels(actionsLib) {
|
|
94
|
+
let originalEffect = actionsLib.Reducer.prototype.effect;
|
|
95
|
+
actionsLib.Reducer.prototype.effect = function (value) {
|
|
69
96
|
let effectChannel = originalEffect.call(this, value);
|
|
70
97
|
setTimeout(() => {
|
|
71
98
|
if (!effectChannel.$meta?.attachIsCalled) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorate-actions-lib.js","sourceRoot":"","sources":["../../../../src/game-entities/attachable/helpers/decorate-actions-lib.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"decorate-actions-lib.js","sourceRoot":"","sources":["../../../../src/game-entities/attachable/helpers/decorate-actions-lib.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,wDAA0C;AAE1C,8CAA2C;AAc3C,MAAa,mBAAmB;IAC9B,6EAA6E;IAC7E,MAAM,CAAC,QAAQ,CAAC,UAAe;QAC7B,IAAI,CAAC,uBAAuB,CAAC,UAAU,CAAC,CAAC;QACzC,IAAI,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;QACvC,IAAI,CAAC,sBAAsB,CAAC,UAAU,CAAC,CAAC;QAExC,IAAI,UAAU,KAAK,UAAU,EAAE,CAAC;YAC9B,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;IAEO,MAAM,CAAC,uBAAuB,CAAC,UAAe;QACpD,UAAU,CAAC,kBAAkB,CAAC,SAAS,CAAC,MAAM,GAAG,UAAU,MAA2B;YACpF,IAAI,YAAY,GAAG,uBAAU,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;YAC3D,YAAY,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,CAAC;YAC9B,IAAK,CAAC,KAAK,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC;YAC7C,OAAO,IAAI,CAAC;QACd,CAAC,CAAC;QAEF,UAAU,CAAC,kBAAkB,CAAC,SAAS,CAAC,eAAe,GAAG;YAClD,IAAK,CAAC,KAAK,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC;YAC7C,OAAO,IAAI,CAAC;QACd,CAAC,CAAC;QAEF,UAAU,CAAC,oBAAoB,CAAC,SAAS,CAAC,MAAM,GAAG,UACjD,MAA2B;YAE3B,IAAI,YAAY,GAAG,uBAAU,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;YAC3D,YAAY,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,CAAC;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AAwB,GAAG,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC;QACtE,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,SAAS,GAAG,UAAU,QAA0C;YAC3F,IAAI,YAAY,GAAG,wBAAwB,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;YACjE,UAAU,CAAC,GAAG,EAAE;gBACd,IAAI,CAAO,YAAa,CAAC,KAAK,EAAE,cAAc,EAAE,CAAC;oBAC/C,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;gBAClE,CAAC;YACH,CAAC,CAAC,CAAC;YACH,OAAO,YAAY,CAAC;QACtB,CAAC,CAAC;IACJ,CAAC;IAEO,MAAM,CAAC,sBAAsB,CAAC,UAAe;QACnD,IAAI,cAAc,GAAG,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC;QACzD,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,GAAG,UAAU,KAAU;YACxD,IAAI,aAAa,GAAG,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;YACrD,UAAU,CAAC,GAAG,EAAE;gBACd,IAAI,CAAO,aAAc,CAAC,KAAK,EAAE,cAAc,EAAE,CAAC;oBAChD,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;gBAC/D,CAAC;YACH,CAAC,CAAC,CAAC;YACH,OAAO,aAAa,CAAC;QACvB,CAAC,CAAC;IACJ,CAAC;CACF;AA1FD,kDA0FC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
const vitest_1 = require("vitest");
|
|
10
|
+
const update_loop_1 = require("../update-loop");
|
|
11
|
+
const controller_1 = require("./controller");
|
|
12
|
+
const service_1 = require("../service/service");
|
|
13
|
+
(0, vitest_1.describe)('CONTROLLER', () => {
|
|
14
|
+
(0, vitest_1.beforeEach)(() => {
|
|
15
|
+
update_loop_1.UpdateCycle.hardResetAction.trigger();
|
|
16
|
+
});
|
|
17
|
+
(0, vitest_1.test)('when gateway triggers service link, it should trigger the controller function', () => {
|
|
18
|
+
let SampleLink = new controller_1.ControllerLink();
|
|
19
|
+
let Gateway = class Gateway {
|
|
20
|
+
test(data) {
|
|
21
|
+
SampleLink.trigger('testFunction', data);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
Gateway = __decorate([
|
|
25
|
+
(0, service_1.ServiceDecorator)()
|
|
26
|
+
], Gateway);
|
|
27
|
+
let triggeredData;
|
|
28
|
+
let Controller = class Controller {
|
|
29
|
+
testFunction(data) {
|
|
30
|
+
triggeredData = data;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
Controller = __decorate([
|
|
34
|
+
(0, controller_1.ControllerDecorator)({ controllerLink: SampleLink })
|
|
35
|
+
], Controller);
|
|
36
|
+
let gateway = new Gateway();
|
|
37
|
+
let sampleData = 'sampleData';
|
|
38
|
+
gateway.test(sampleData);
|
|
39
|
+
(0, vitest_1.expect)(triggeredData).toEqual(sampleData);
|
|
40
|
+
});
|
|
41
|
+
(0, vitest_1.test)('there can be multiple controllers linked to one gateway', () => {
|
|
42
|
+
var Controller1_1, Controller2_1;
|
|
43
|
+
let SampleLink = new controller_1.ControllerLink();
|
|
44
|
+
let Gateway = class Gateway {
|
|
45
|
+
test1(data) {
|
|
46
|
+
SampleLink.trigger('testFunction1', data);
|
|
47
|
+
}
|
|
48
|
+
test2(data) {
|
|
49
|
+
SampleLink.trigger('testFunction2', data);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
Gateway = __decorate([
|
|
53
|
+
(0, service_1.ServiceDecorator)()
|
|
54
|
+
], Gateway);
|
|
55
|
+
let Controller1 = class Controller1 {
|
|
56
|
+
static { Controller1_1 = this; }
|
|
57
|
+
testFunction1(data) {
|
|
58
|
+
Controller1_1.data = data;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
Controller1 = Controller1_1 = __decorate([
|
|
62
|
+
(0, controller_1.ControllerDecorator)({ controllerLink: SampleLink })
|
|
63
|
+
], Controller1);
|
|
64
|
+
let Controller2 = class Controller2 {
|
|
65
|
+
static { Controller2_1 = this; }
|
|
66
|
+
testFunction2(data) {
|
|
67
|
+
Controller2_1.data = data;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
Controller2 = Controller2_1 = __decorate([
|
|
71
|
+
(0, controller_1.ControllerDecorator)({ controllerLink: SampleLink })
|
|
72
|
+
], Controller2);
|
|
73
|
+
let gateway = new Gateway();
|
|
74
|
+
let sampleData1 = 'sampleData1';
|
|
75
|
+
let sampleData2 = 'sampleData2';
|
|
76
|
+
gateway.test1(sampleData1);
|
|
77
|
+
gateway.test2(sampleData2);
|
|
78
|
+
(0, vitest_1.expect)(Controller1.data).toEqual(sampleData1);
|
|
79
|
+
(0, vitest_1.expect)(Controller2.data).toEqual(sampleData2);
|
|
80
|
+
});
|
|
81
|
+
(0, vitest_1.test)('it should complain when there are two functions with the same name', () => {
|
|
82
|
+
let SampleLink = new controller_1.ControllerLink();
|
|
83
|
+
let Gateway = class Gateway {
|
|
84
|
+
test() {
|
|
85
|
+
SampleLink.trigger('testFunction');
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
Gateway = __decorate([
|
|
89
|
+
(0, service_1.ServiceDecorator)()
|
|
90
|
+
], Gateway);
|
|
91
|
+
let Controller1 = class Controller1 {
|
|
92
|
+
testFunction() { }
|
|
93
|
+
};
|
|
94
|
+
Controller1 = __decorate([
|
|
95
|
+
(0, controller_1.ControllerDecorator)({ controllerLink: SampleLink })
|
|
96
|
+
], Controller1);
|
|
97
|
+
(0, vitest_1.expect)(() => {
|
|
98
|
+
let Controller2 = class Controller2 {
|
|
99
|
+
testFunction() { }
|
|
100
|
+
};
|
|
101
|
+
Controller2 = __decorate([
|
|
102
|
+
(0, controller_1.ControllerDecorator)({ controllerLink: SampleLink })
|
|
103
|
+
], Controller2);
|
|
104
|
+
}).toThrow();
|
|
105
|
+
});
|
|
106
|
+
(0, vitest_1.test)('it should complain when there is no corresponding function', () => {
|
|
107
|
+
let SampleLink = new controller_1.ControllerLink();
|
|
108
|
+
let Gateway = class Gateway {
|
|
109
|
+
test() {
|
|
110
|
+
SampleLink.trigger('falseFunction');
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
Gateway = __decorate([
|
|
114
|
+
(0, service_1.ServiceDecorator)()
|
|
115
|
+
], Gateway);
|
|
116
|
+
let Controller = class Controller {
|
|
117
|
+
testFunction() { }
|
|
118
|
+
};
|
|
119
|
+
Controller = __decorate([
|
|
120
|
+
(0, controller_1.ControllerDecorator)({ controllerLink: SampleLink })
|
|
121
|
+
], Controller);
|
|
122
|
+
let gateway = new Gateway();
|
|
123
|
+
(0, vitest_1.expect)(() => {
|
|
124
|
+
gateway.test();
|
|
125
|
+
}).toThrow('ServiceLink: no defined function with the name: "falseFunction", found in the linked controllers!');
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
//# sourceMappingURL=controller.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller.test.js","sourceRoot":"","sources":["../../../src/game-entities/controller/controller.test.ts"],"names":[],"mappings":";;;;;;;;AAAA,mCAA4D;AAE5D,gD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