definition-generator-framework 1.12.4 → 1.12.6
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/framework/definition-component.d.ts +11 -9
- package/dist/framework/definition-component.js +18 -18
- package/dist/framework/definition-generator.d.ts +6 -5
- package/dist/framework/definition-generator.js +16 -18
- package/dist/framework/file-content-generator/file-content-generator.js +1 -1
- package/dist/framework/file-content-generator/file-content-generator.test.js +49 -49
- package/dist/framework/framework.d.ts +14 -13
- package/dist/framework/framework.data.d.ts +3 -3
- package/dist/framework/framework.data.js +13 -7
- package/dist/framework/framework.js +36 -33
- package/dist/framework/framework.model.d.ts +15 -15
- package/dist/framework/framework.model.js +3 -3
- package/dist/helpers/common-functions/common-functions.js +1 -1
- package/dist/helpers/common-functions/common-functions.spec.d.ts +1 -0
- package/dist/helpers/common-functions/common-functions.spec.js +50 -0
- package/dist/helpers/duplicate-helper/duplicate-helper.spec.d.ts +1 -0
- package/dist/helpers/duplicate-helper/duplicate-helper.spec.js +54 -0
- package/dist/helpers/output-helper/output-helper.d.ts +26 -26
- package/dist/helpers/output-helper/output-helper.js +127 -107
- package/dist/helpers/output-helper/output-helper.spec.d.ts +24 -0
- package/dist/helpers/output-helper/output-helper.spec.js +261 -0
- package/dist/helpers/output-helper/output-helper.test.d.ts +22 -22
- package/dist/helpers/output-helper/output-helper.test.js +224 -212
- package/dist/helpers/raw-definition-helper/raw-definition.helper.spec.d.ts +1 -0
- package/dist/helpers/raw-definition-helper/raw-definition.helper.spec.js +143 -0
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.spec.d.ts +1 -0
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.spec.js +191 -0
- package/dist/helpers/validator/custom-validators/image.custom-validator.d.ts +6 -6
- package/dist/helpers/validator/custom-validators/image.custom-validator.js +40 -39
- package/dist/helpers/validator/custom-validators/unique-name-group.custom-validator.d.ts +4 -4
- package/dist/helpers/validator/custom-validators/unique-name-group.custom-validator.js +29 -29
- package/dist/helpers/validator/joi-custom-validators.spec.d.ts +1 -0
- package/dist/helpers/validator/joi-custom-validators.spec.js +304 -0
- package/dist/helpers/validator/validator.spec.d.ts +1 -0
- package/dist/helpers/validator/validator.spec.js +332 -0
- package/dist/pipeline/1-select-definitions-helper.d.ts +13 -13
- package/dist/pipeline/1-select-definitions-helper.js +68 -72
- package/dist/pipeline/1-select-definitions.helper.test.js +40 -40
- package/dist/pipeline/1-select-definitions.spec.d.ts +1 -0
- package/dist/pipeline/1-select-definitions.spec.js +140 -0
- package/dist/pipeline/2-structure-parser.helper.spec.d.ts +1 -0
- package/dist/pipeline/2-structure-parser.helper.spec.js +280 -0
- package/dist/pipeline/parsers/array-parser.spec.d.ts +1 -0
- package/dist/pipeline/parsers/array-parser.spec.js +128 -0
- package/dist/pipeline/parsers/object-parser.spec.d.ts +1 -0
- package/dist/pipeline/parsers/object-parser.spec.js +179 -0
- package/dist/pipeline/parsers/primitive-parser.spec.d.ts +1 -0
- package/dist/pipeline/parsers/primitive-parser.spec.js +79 -0
- package/dist/pre-made-components/assets/3-font.js +4 -4
- package/dist/pre-made-components/events/1-event.d.ts +1 -1
- package/dist/pre-made-components/events/1-event.js +157 -125
- package/dist/pre-made-components/events/2-event-test.d.ts +8 -8
- package/dist/pre-made-components/events/2-event-test.js +156 -119
- package/dist/pre-made-components/events/2-script-test.js +0 -1
- package/dist/pre-made-components/events/event-setup.d.ts +10 -5
- package/dist/pre-made-components/events/event-setup.js +15 -15
- package/dist/pre-made-components/events/script-setup.d.ts +5 -3
- package/dist/pre-made-components/events/script-setup.js +11 -11
- package/package.json +11 -11
- package/.eslintrc.js +0 -212
- package/.vscode/launch.json +0 -15
- package/.vscode/settings.json +0 -25
- package/coverage/clover.xml +0 -503
- package/coverage/coverage-final.json +0 -16
- package/coverage/lcov-report/_mocks/index.html +0 -116
- package/coverage/lcov-report/_mocks/mocks.ts.html +0 -223
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/framework/framework.data.ts.html +0 -109
- package/coverage/lcov-report/framework/index.html +0 -116
- package/coverage/lcov-report/helpers/common-functions/common-functions.ts.html +0 -178
- package/coverage/lcov-report/helpers/common-functions/index.html +0 -116
- package/coverage/lcov-report/helpers/duplicate-helper/duplicate-helper.ts.html +0 -196
- package/coverage/lcov-report/helpers/duplicate-helper/index.html +0 -116
- package/coverage/lcov-report/helpers/output-helper/index.html +0 -116
- package/coverage/lcov-report/helpers/output-helper/output-helper.ts.html +0 -277
- package/coverage/lcov-report/helpers/raw-definition-helper/index.html +0 -116
- package/coverage/lcov-report/helpers/raw-definition-helper/raw-definition.helper.ts.html +0 -256
- package/coverage/lcov-report/helpers/validator/index.html +0 -131
- package/coverage/lcov-report/helpers/validator/joi-custom-validators.ts.html +0 -643
- package/coverage/lcov-report/helpers/validator/validator.ts.html +0 -310
- package/coverage/lcov-report/index.html +0 -251
- package/coverage/lcov-report/pipeline/1-select-definitions-helper.ts.html +0 -358
- package/coverage/lcov-report/pipeline/2-structure-parser.helper.ts.html +0 -301
- package/coverage/lcov-report/pipeline/3-config.ts.html +0 -178
- package/coverage/lcov-report/pipeline/_mocks/index.html +0 -116
- package/coverage/lcov-report/pipeline/_mocks/index.ts.html +0 -229
- package/coverage/lcov-report/pipeline/index.html +0 -146
- package/coverage/lcov-report/pipeline/parsers/array-parser.ts.html +0 -271
- package/coverage/lcov-report/pipeline/parsers/index.html +0 -146
- package/coverage/lcov-report/pipeline/parsers/object-parser.ts.html +0 -439
- package/coverage/lcov-report/pipeline/parsers/primitive-parser.ts.html +0 -370
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov.info +0 -911
- package/dist/_mocks/mocks.js.map +0 -1
- package/dist/decorators/definition-component.js.map +0 -1
- package/dist/decorators/definition-generator.js.map +0 -1
- package/dist/framework/context.js.map +0 -1
- package/dist/framework/definition-component.js.map +0 -1
- package/dist/framework/definition-generator.js.map +0 -1
- package/dist/framework/definition-store.js.map +0 -1
- package/dist/framework/file-content-generator/file-content-generator.js.map +0 -1
- package/dist/framework/file-content-generator/file-content-generator.test.js.map +0 -1
- package/dist/framework/framework.data.js.map +0 -1
- package/dist/framework/framework.js.map +0 -1
- package/dist/framework/framework.model.js.map +0 -1
- package/dist/framework/index-file-generator/index-file-generator.js.map +0 -1
- package/dist/framework/interfaces.js.map +0 -1
- package/dist/framework/kernel.js.map +0 -1
- package/dist/helpers/common-functions/common-functions.js.map +0 -1
- package/dist/helpers/common-functions/common-functions.spec.js.map +0 -1
- package/dist/helpers/common-functions/common-functions.test.js.map +0 -1
- package/dist/helpers/duplicate-helper/duplicate-helper.js.map +0 -1
- package/dist/helpers/duplicate-helper/duplicate-helper.spec.js.map +0 -1
- package/dist/helpers/duplicate-helper/duplicate-helper.test.js.map +0 -1
- package/dist/helpers/output-helper/output-helper.js.map +0 -1
- package/dist/helpers/output-helper/output-helper.spec.js.map +0 -1
- package/dist/helpers/output-helper/output-helper.test.js.map +0 -1
- package/dist/helpers/raw-definition-helper/raw-definition.helper.js.map +0 -1
- package/dist/helpers/raw-definition-helper/raw-definition.helper.spec.js.map +0 -1
- package/dist/helpers/raw-definition-helper/raw-definition.helper.test.js.map +0 -1
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.js.map +0 -1
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.spec.js.map +0 -1
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.test.js.map +0 -1
- package/dist/helpers/validator/custom-validators/helpers/sprite-validation.helper.js.map +0 -1
- package/dist/helpers/validator/custom-validators/helpers/sprite-validation.helper.test.js.map +0 -1
- package/dist/helpers/validator/custom-validators/image.custom-validator.js.map +0 -1
- package/dist/helpers/validator/custom-validators/path.custom-validator.js.map +0 -1
- package/dist/helpers/validator/custom-validators/position-on-sprite.js.map +0 -1
- package/dist/helpers/validator/custom-validators/reference.custom-validator.js.map +0 -1
- package/dist/helpers/validator/custom-validators/sprite.custom-validator.js.map +0 -1
- package/dist/helpers/validator/custom-validators/unique-name-group.custom-validator.js.map +0 -1
- package/dist/helpers/validator/custom-validators/unique.custom-validator.js.map +0 -1
- package/dist/helpers/validator/joi-custom-validators.js.map +0 -1
- package/dist/helpers/validator/joi-custom-validators.spec.js.map +0 -1
- package/dist/helpers/validator/validator.js.map +0 -1
- package/dist/helpers/validator/validator.spec.js.map +0 -1
- package/dist/helpers/validator/validator.test.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/pipeline/1-select-definitions-helper.js.map +0 -1
- package/dist/pipeline/1-select-definitions.helper.js.map +0 -1
- package/dist/pipeline/1-select-definitions.helper.test.js.map +0 -1
- package/dist/pipeline/1-select-definitions.spec.js.map +0 -1
- package/dist/pipeline/2-structure-parser.helper.js.map +0 -1
- package/dist/pipeline/2-structure-parser.helper.spec.js.map +0 -1
- package/dist/pipeline/2-structure-parser.helper.test.js.map +0 -1
- package/dist/pipeline/3-config.js.map +0 -1
- package/dist/pipeline/_mocks/index.js.map +0 -1
- package/dist/pipeline/parsers/array-parser.js.map +0 -1
- package/dist/pipeline/parsers/array-parser.spec.js.map +0 -1
- package/dist/pipeline/parsers/array-parser.test.js.map +0 -1
- package/dist/pipeline/parsers/object-parser.js.map +0 -1
- package/dist/pipeline/parsers/object-parser.spec.js.map +0 -1
- package/dist/pipeline/parsers/object-parser.test.js.map +0 -1
- package/dist/pipeline/parsers/primitive-parser.js.map +0 -1
- package/dist/pipeline/parsers/primitive-parser.spec.js.map +0 -1
- package/dist/pipeline/parsers/primitive-parser.test.js.map +0 -1
- package/dist/pipeline/raw-data-parser.js.map +0 -1
- package/dist/pre-made-components/_validators/shape-validators.js.map +0 -1
- package/dist/pre-made-components/_validators/sprite-validators.js.map +0 -1
- package/dist/pre-made-components/assets/1-sprite.js.map +0 -1
- package/dist/pre-made-components/assets/2-sprite-group.js.map +0 -1
- package/dist/pre-made-components/assets/3-font.js.map +0 -1
- package/dist/pre-made-components/events/1-event.js.map +0 -1
- package/dist/pre-made-components/events/1-script.js.map +0 -1
- package/dist/pre-made-components/events/2-event-test.js.map +0 -1
- package/dist/pre-made-components/events/2-script-test.js.map +0 -1
- package/dist/pre-made-components/events/3-event.js.map +0 -1
- package/dist/pre-made-components/events/4-event-test.js.map +0 -1
- package/dist/pre-made-components/events/event-setup.js.map +0 -1
- package/dist/pre-made-components/events/helpers/quotes-to-tags.helper.js.map +0 -1
- package/dist/pre-made-components/events/helpers/quotes-to-tags.helper.test.js.map +0 -1
- package/dist/pre-made-components/events/helpers/script-testing.helper.js.map +0 -1
- package/dist/pre-made-components/events/script-setup.js.map +0 -1
- package/dist/pre-made-components/events/scripting-setup.js.map +0 -1
- package/dist/pre-made-components/events/validators.js.map +0 -1
- package/dist/setup.js.map +0 -1
- package/package.json.bak +0 -60
- package/scripts/prepare-package-json.ts +0 -23
- package/tsconfig.json +0 -24
- package/vitest.config.ts +0 -1
|
@@ -2,5 +2,5 @@ import { ScriptDefinition } from 'script-engine-lib';
|
|
|
2
2
|
import { DefinitionComponent } from '../../decorators/definition-component';
|
|
3
3
|
import { Output } from '../../framework/interfaces';
|
|
4
4
|
export declare class EventComponent extends DefinitionComponent<ScriptDefinition> {
|
|
5
|
-
|
|
5
|
+
process(definitions: ScriptDefinition[], output: Output): Promise<void>;
|
|
6
6
|
}
|
|
@@ -1,174 +1,206 @@
|
|
|
1
|
-
|
|
2
|
-
var __decorate =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
var __decorate =
|
|
3
|
+
(this && this.__decorate) ||
|
|
4
|
+
function (decorators, target, key, desc) {
|
|
5
|
+
var c = arguments.length,
|
|
6
|
+
r = c < 3 ? target : desc === null ? (desc = Object.getOwnPropertyDescriptor(target, key)) : desc,
|
|
7
|
+
d;
|
|
8
|
+
if (typeof Reflect === 'object' && typeof Reflect.decorate === 'function')
|
|
9
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
10
|
+
else
|
|
11
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
12
|
+
if ((d = decorators[i])) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
13
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __importDefault =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
14
|
+
};
|
|
15
|
+
var __importDefault =
|
|
16
|
+
(this && this.__importDefault) ||
|
|
17
|
+
function (mod) {
|
|
18
|
+
return mod && mod.__esModule ? mod : { default: mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
12
21
|
exports.EventComponent = void 0;
|
|
13
|
-
const helpers_lib_1 = require(
|
|
14
|
-
const joi_1 = __importDefault(require(
|
|
15
|
-
const definition_component_1 = require(
|
|
16
|
-
const quotes_to_tags_helper_1 = require(
|
|
22
|
+
const helpers_lib_1 = require('helpers-lib');
|
|
23
|
+
const joi_1 = __importDefault(require('joi'));
|
|
24
|
+
const definition_component_1 = require('../../decorators/definition-component');
|
|
25
|
+
const quotes_to_tags_helper_1 = require('./helpers/quotes-to-tags.helper');
|
|
17
26
|
// ---- Conditions ----
|
|
18
|
-
const ActionCommandSchema = () =>
|
|
27
|
+
const ActionCommandSchema = () =>
|
|
28
|
+
joi_1.default.string().custom(value => ({
|
|
19
29
|
type: 'command',
|
|
20
30
|
value: value
|
|
21
|
-
}));
|
|
31
|
+
}));
|
|
22
32
|
// ---- Branches ----
|
|
23
|
-
const JumpToSchema = joi_1.default
|
|
24
|
-
|
|
33
|
+
const JumpToSchema = joi_1.default
|
|
34
|
+
.object()
|
|
35
|
+
.keys({
|
|
25
36
|
jumpTo: joi_1.default.string().lazyReference('EVENT').required()
|
|
26
|
-
})
|
|
27
|
-
|
|
37
|
+
})
|
|
38
|
+
.custom(value => ({
|
|
28
39
|
type: 'jumpTo',
|
|
29
40
|
value: value.jumpTo
|
|
30
|
-
}));
|
|
31
|
-
const BranchByConditionSchema = joi_1.default
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
41
|
+
}));
|
|
42
|
+
const BranchByConditionSchema = joi_1.default
|
|
43
|
+
.object()
|
|
44
|
+
.keys({
|
|
45
|
+
branchByCondition: joi_1.default
|
|
46
|
+
.array()
|
|
47
|
+
.items(
|
|
48
|
+
joi_1.default.object().keys({
|
|
49
|
+
condition: joi_1.default.string().optional(),
|
|
50
|
+
actions: joi_1.default.link('#EventActionsSchema').default([]).optional()
|
|
51
|
+
})
|
|
52
|
+
)
|
|
53
|
+
.custom((array, helpers) => {
|
|
39
54
|
let length = array.length;
|
|
40
55
|
if (length > 1) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
else if (length === 1) {
|
|
48
|
-
if (array[0].condition === undefined) {
|
|
49
|
-
throw new Error('Single element must have "condition"');
|
|
56
|
+
for (let i = 0; i < length - 1; i++) {
|
|
57
|
+
if (array[i].condition === undefined) {
|
|
58
|
+
throw new Error(`Element at index ${i} must have "condition"`);
|
|
50
59
|
}
|
|
60
|
+
}
|
|
61
|
+
} else if (length === 1) {
|
|
62
|
+
if (array[0].condition === undefined) {
|
|
63
|
+
throw new Error('Single element must have "condition"');
|
|
64
|
+
}
|
|
51
65
|
}
|
|
52
66
|
return array;
|
|
53
|
-
|
|
54
|
-
})
|
|
55
|
-
|
|
67
|
+
})
|
|
68
|
+
})
|
|
69
|
+
.custom(value => ({
|
|
56
70
|
type: 'branchByCondition',
|
|
57
71
|
value: value.branchByCondition
|
|
58
|
-
}));
|
|
59
|
-
const BranchByPlayerChoiceSchema = joi_1.default
|
|
60
|
-
|
|
61
|
-
|
|
72
|
+
}));
|
|
73
|
+
const BranchByPlayerChoiceSchema = joi_1.default
|
|
74
|
+
.object()
|
|
75
|
+
.keys({
|
|
76
|
+
branchByPlayerChoice: joi_1.default.array().items(
|
|
77
|
+
joi_1.default.object().keys({
|
|
62
78
|
text: joi_1.default.string().min(2).required(),
|
|
63
79
|
condition: joi_1.default.string().optional(),
|
|
64
80
|
actions: joi_1.default.link('#EventActionsSchema').default([]).optional()
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
81
|
+
})
|
|
82
|
+
)
|
|
83
|
+
})
|
|
84
|
+
.custom(value => ({
|
|
68
85
|
type: 'branchByPlayerChoice',
|
|
69
86
|
value: value.branchByPlayerChoice
|
|
70
|
-
}));
|
|
71
|
-
const BranchByChanceSchema = joi_1.default
|
|
72
|
-
|
|
73
|
-
|
|
87
|
+
}));
|
|
88
|
+
const BranchByChanceSchema = joi_1.default
|
|
89
|
+
.object()
|
|
90
|
+
.keys({
|
|
91
|
+
branchByChance: joi_1.default.array().items(
|
|
92
|
+
joi_1.default.object().keys({
|
|
74
93
|
label: joi_1.default.string().required(),
|
|
75
94
|
weight: joi_1.default.number().integer().min(1).max(100).required(),
|
|
76
95
|
condition: joi_1.default.string().optional(),
|
|
77
96
|
actions: joi_1.default.link('#EventActionsSchema').default([]).optional()
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
97
|
+
})
|
|
98
|
+
)
|
|
99
|
+
})
|
|
100
|
+
.custom(value => ({
|
|
81
101
|
type: 'branchByChance',
|
|
82
102
|
value: value.branchByChance
|
|
83
|
-
}));
|
|
103
|
+
}));
|
|
84
104
|
// ---- Dialog ----
|
|
85
|
-
const DialogSchema = joi_1.default
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
105
|
+
const DialogSchema = joi_1.default
|
|
106
|
+
.object()
|
|
107
|
+
.min(1)
|
|
108
|
+
.max(1)
|
|
109
|
+
.custom(value => {
|
|
89
110
|
let keys = Object.keys(value);
|
|
90
111
|
if (keys.length !== 1) {
|
|
91
|
-
|
|
112
|
+
throw new Error('object must have exactly one key/value pair');
|
|
92
113
|
}
|
|
93
114
|
let key = keys[0];
|
|
94
115
|
let text = value[key];
|
|
95
116
|
if (typeof text !== 'string') {
|
|
96
|
-
|
|
117
|
+
throw new Error('value must be a string');
|
|
97
118
|
}
|
|
98
119
|
text = quotes_to_tags_helper_1.QuotesToTagsHelper.convert(text);
|
|
99
120
|
return { type: 'dialog', value: { text, speaker: key } };
|
|
100
|
-
});
|
|
121
|
+
});
|
|
101
122
|
// ---- Main Schema ----
|
|
102
|
-
const ActionsSchema = () =>
|
|
103
|
-
|
|
104
|
-
.
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
123
|
+
const ActionsSchema = () =>
|
|
124
|
+
joi_1.default
|
|
125
|
+
.array()
|
|
126
|
+
.items(
|
|
127
|
+
joi_1.default
|
|
128
|
+
.alternatives()
|
|
129
|
+
.conditional(joi_1.default.string(), {
|
|
130
|
+
then: ActionCommandSchema()
|
|
131
|
+
})
|
|
132
|
+
.conditional(joi_1.default.object({ jumpTo: joi_1.default.exist() }).unknown(), {
|
|
133
|
+
then: JumpToSchema
|
|
134
|
+
})
|
|
135
|
+
.conditional(joi_1.default.object({ branchByChance: joi_1.default.exist() }).unknown(), {
|
|
136
|
+
then: BranchByChanceSchema
|
|
137
|
+
})
|
|
138
|
+
.conditional(joi_1.default.object({ branchByCondition: joi_1.default.exist() }).unknown(), {
|
|
139
|
+
then: BranchByConditionSchema
|
|
140
|
+
})
|
|
141
|
+
.conditional(joi_1.default.object({ branchByPlayerChoice: joi_1.default.exist() }).unknown(), {
|
|
142
|
+
then: BranchByPlayerChoiceSchema
|
|
143
|
+
})
|
|
144
|
+
.conditional(joi_1.default.object().min(1).max(1).unknown(), {
|
|
145
|
+
then: DialogSchema
|
|
146
|
+
})
|
|
147
|
+
.error(errors =>
|
|
148
|
+
errors.map(error => {
|
|
149
|
+
if (error.code === 'alternatives.any') {
|
|
150
|
+
let allowedTypes = 'command, jumpTo, branchByCondition, branchByPlayerChoice, branchByChance';
|
|
151
|
+
error.message = `${error.local.label} does not match any of the allowed types: ${allowedTypes}`;
|
|
152
|
+
}
|
|
153
|
+
return error;
|
|
154
|
+
})
|
|
155
|
+
)
|
|
156
|
+
)
|
|
157
|
+
.custom(array => {
|
|
158
|
+
let commandFoundAfterBranching = false;
|
|
159
|
+
let emptyStackRequiresBranchingFound = false;
|
|
160
|
+
array.forEach(action => {
|
|
133
161
|
if (emptyStackRequiresBranchingFound) {
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
162
|
+
commandFoundAfterBranching = true;
|
|
163
|
+
} else if (
|
|
164
|
+
action.type === 'branchByCondition' ||
|
|
165
|
+
action.type === 'branchByPlayerChoice' ||
|
|
166
|
+
action.type === 'branchByChance'
|
|
167
|
+
) {
|
|
168
|
+
emptyStackRequiresBranchingFound = true;
|
|
140
169
|
}
|
|
141
|
-
|
|
142
|
-
|
|
170
|
+
});
|
|
171
|
+
if (commandFoundAfterBranching) {
|
|
143
172
|
throw new Error('There should not be any command after branching.');
|
|
144
|
-
|
|
145
|
-
else {
|
|
173
|
+
} else {
|
|
146
174
|
return array;
|
|
147
|
-
|
|
148
|
-
})
|
|
175
|
+
}
|
|
176
|
+
})
|
|
149
177
|
.id('EventActionsSchema');
|
|
150
178
|
let EventComponent = class EventComponent extends definition_component_1.DefinitionComponent {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
179
|
+
async process(definitions, output) {
|
|
180
|
+
await output.addFile({
|
|
181
|
+
path: '/_premade/events/events.ts',
|
|
182
|
+
preText: `import { ScriptDefinition } from "script-engine-lib";`,
|
|
183
|
+
variableName: 'EventDefinitions',
|
|
184
|
+
variableType: 'Readonly<Record<string, ScriptDefinition>>',
|
|
185
|
+
variable: helpers_lib_1.JsonHelper.arrayToObject(definitions, 'id')
|
|
186
|
+
});
|
|
187
|
+
}
|
|
160
188
|
};
|
|
161
189
|
exports.EventComponent = EventComponent;
|
|
162
|
-
exports.EventComponent = EventComponent = __decorate(
|
|
190
|
+
exports.EventComponent = EventComponent = __decorate(
|
|
191
|
+
[
|
|
163
192
|
(0, definition_component_1.DefinitionComponentDecorator)({
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
193
|
+
componentName: 'EVENT',
|
|
194
|
+
keyName: 'id',
|
|
195
|
+
validationSchema: joi_1.default
|
|
196
|
+
.object()
|
|
197
|
+
.keys({
|
|
198
|
+
id: joi_1.default.string().required(),
|
|
199
|
+
actions: ActionsSchema().min(1).required()
|
|
170
200
|
})
|
|
171
|
-
|
|
201
|
+
.required()
|
|
172
202
|
})
|
|
173
|
-
],
|
|
174
|
-
|
|
203
|
+
],
|
|
204
|
+
EventComponent
|
|
205
|
+
);
|
|
206
|
+
//# sourceMappingURL=1-event.js.map
|
|
@@ -2,17 +2,17 @@ import { ScriptTestActionDefinition } from 'script-engine-lib';
|
|
|
2
2
|
import { DefinitionComponent } from '../../decorators/definition-component';
|
|
3
3
|
import { Output } from '../../framework/interfaces';
|
|
4
4
|
interface EventTestCasesDefinition {
|
|
5
|
-
|
|
5
|
+
readonly actionsBeforeTesting: readonly ScriptTestActionDefinition[];
|
|
6
6
|
}
|
|
7
7
|
interface EventTestDefinition {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
readonly event: string;
|
|
9
|
+
readonly cases: readonly EventTestCasesDefinition[];
|
|
10
10
|
}
|
|
11
11
|
export declare class EventTestComponent extends DefinitionComponent<EventTestDefinition> {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
process(definitions: EventTestDefinition[], output: Output): Promise<void>;
|
|
13
|
+
private createEventTestSimulator;
|
|
14
|
+
private runTests;
|
|
15
|
+
private prepareErrorLog;
|
|
16
|
+
private printErrors;
|
|
17
17
|
}
|
|
18
18
|
export {};
|