@reldens/skills 0.10.0-beta.32 → 0.11.0

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.
Files changed (28) hide show
  1. package/README.md +2 -2
  2. package/lib/server/data-server-validator.js +30 -30
  3. package/lib/server/storage/models/mikro-orm/class-path-level-labels-model.js +86 -0
  4. package/lib/server/storage/models/mikro-orm/class-path-level-skills-model.js +98 -0
  5. package/lib/server/storage/models/mikro-orm/class-path-model.js +105 -0
  6. package/lib/server/storage/models/mikro-orm/level-model.js +88 -0
  7. package/lib/server/storage/models/mikro-orm/level-modifiers-model.js +119 -0
  8. package/lib/server/storage/models/mikro-orm/levels-set-model.js +79 -0
  9. package/lib/server/storage/models/mikro-orm/owners-class-path-model.js +79 -0
  10. package/lib/server/storage/models/mikro-orm/registered-models-mikro-orm.js +39 -0
  11. package/lib/server/storage/models/mikro-orm/skill-attack-model.js +156 -0
  12. package/lib/server/storage/models/mikro-orm/skill-group-relation-model.js +82 -0
  13. package/lib/server/storage/models/mikro-orm/skill-model.js +236 -0
  14. package/lib/server/storage/models/mikro-orm/skill-owner-conditions-model.js +83 -0
  15. package/lib/server/storage/models/mikro-orm/skill-owner-effects-model.js +119 -0
  16. package/lib/server/storage/models/mikro-orm/skill-physical-data-model.js +83 -0
  17. package/lib/server/storage/models/mikro-orm/skill-target-effects-model.js +125 -0
  18. package/lib/server/storage/models/mikro-orm/skills-groups-model.js +77 -0
  19. package/lib/server/storage/models/objection-js/level-model.js +3 -3
  20. package/lib/server/storage/models/objection-js/level-modifiers-model.js +3 -3
  21. package/lib/server/storage/models/objection-js/registered-models-objection-js.js +4 -4
  22. package/lib/server/storage/models/objection-js/{skill-attack.js → skill-attack-model.js} +0 -0
  23. package/lib/server/storage/models/objection-js/{skill-group-relation.js → skill-group-relation-model.js} +0 -0
  24. package/lib/server/storage/models/objection-js/skill-model.js +2 -2
  25. package/lib/server/storage/models/objection-js/skills-groups-model.js +2 -2
  26. package/lib/server/storage/models-manager.js +13 -13
  27. package/migrations/production/reldens-skills-install.sql +125 -123
  28. package/package.json +4 -4
@@ -0,0 +1,119 @@
1
+ /**
2
+ *
3
+ * Reldens - Skills - SkillOwnerEffectsModel
4
+ *
5
+ */
6
+
7
+ const { MikroOrmCore } = require('@reldens/storage');
8
+ const { EntitySchema } = MikroOrmCore;
9
+
10
+ class SkillOwnerEffectsModel
11
+ {
12
+
13
+ beforeDestroyCalled = 0;
14
+ afterDestroyCalled = 0;
15
+
16
+ constructor(level_id, key, property_key, operation, value, minValue, maxValue, minProperty, maxProperty)
17
+ {
18
+ this.level_id = level_id;
19
+ this.key = key;
20
+ this.property_key = property_key;
21
+ this.operation = operation;
22
+ this.value = value;
23
+ this.minValue = minValue;
24
+ this.maxValue = maxValue;
25
+ this.minProperty = minProperty;
26
+ this.maxProperty = maxProperty;
27
+ this.type = type;
28
+ }
29
+
30
+ static createByProps(props)
31
+ {
32
+ const {
33
+ level_id,
34
+ key,
35
+ property_key,
36
+ operation,
37
+ value,
38
+ minValue,
39
+ maxValue,
40
+ minProperty,
41
+ maxProperty
42
+ } = props;
43
+ return new this(
44
+ level_id,
45
+ key,
46
+ property_key,
47
+ operation,
48
+ value,
49
+ minValue,
50
+ maxValue,
51
+ minProperty,
52
+ maxProperty
53
+ );
54
+ }
55
+
56
+ static relationMappings()
57
+ {
58
+ return {
59
+ level_id: {
60
+ reference: 'm:1',
61
+ type: 'SkillModel',
62
+ join: {
63
+ from: 'skill_id',
64
+ to: 'id'
65
+ }
66
+ }
67
+ };
68
+ }
69
+
70
+ }
71
+
72
+ const schema = new EntitySchema({
73
+ class: SkillOwnerEffectsModel,
74
+ properties: {
75
+ _id: {
76
+ primary: true,
77
+ type: 'ObjectID'
78
+ },
79
+ id: {
80
+ type: 'string',
81
+ serializedPrimaryKey: true
82
+ },
83
+ level_id: {
84
+ reference: 'm:1',
85
+ type: 'LevelModel',
86
+ nullable: true
87
+ },
88
+ key: {
89
+ type: 'string'
90
+ },
91
+ property_key: {
92
+ type: 'string'
93
+ },
94
+ operation: {
95
+ type: 'number'
96
+ },
97
+ value: {
98
+ type: 'string'
99
+ },
100
+ minValue: {
101
+ type: 'string'
102
+ },
103
+ maxValue: {
104
+ type: 'string'
105
+ },
106
+ minProperty: {
107
+ type: 'string'
108
+ },
109
+ maxProperty: {
110
+ type: 'string'
111
+ }
112
+ }
113
+ });
114
+
115
+ module.exports = {
116
+ SkillOwnerEffectsModel,
117
+ entity: SkillOwnerEffectsModel,
118
+ schema
119
+ };
@@ -0,0 +1,83 @@
1
+ /**
2
+ *
3
+ * Reldens - Skills - SkillPhysicalDataModel
4
+ *
5
+ */
6
+
7
+ const { MikroOrmCore } = require('@reldens/storage');
8
+ const { EntitySchema } = MikroOrmCore;
9
+
10
+ class SkillPhysicalDataModel
11
+ {
12
+
13
+ beforeDestroyCalled = 0;
14
+ afterDestroyCalled = 0;
15
+
16
+ constructor(skill_id, magnitude, objectWidth, objectHeight, validateTargetOnHit)
17
+ {
18
+ this.skill_id = skill_id;
19
+ this.magnitude = magnitude;
20
+ this.objectWidth = objectWidth;
21
+ this.objectHeight = objectHeight;
22
+ this.validateTargetOnHit = validateTargetOnHit;
23
+ }
24
+
25
+ static createByProps(props)
26
+ {
27
+ const {skill_id, magnitude, objectWidth, objectHeight, validateTargetOnHit} = props;
28
+ return new this(skill_id, magnitude, objectWidth, objectHeight, validateTargetOnHit);
29
+ }
30
+
31
+ static relationMappings()
32
+ {
33
+ return {
34
+ parent_skill: {
35
+ type: 'SkillModel',
36
+ entityName: 'skill',
37
+ reference: 'm:1',
38
+ join: {
39
+ from: 'skill_id',
40
+ to: 'id'
41
+ }
42
+ }
43
+ };
44
+ }
45
+
46
+ }
47
+
48
+ const schema = new EntitySchema({
49
+ class: SkillPhysicalDataModel,
50
+ properties: {
51
+ _id: {
52
+ primary: true,
53
+ type: 'ObjectID'
54
+ },
55
+ id: {
56
+ type: 'string',
57
+ serializedPrimaryKey: true
58
+ },
59
+ skill_id: {
60
+ type: 'SkillModel',
61
+ reference: 'm:1',
62
+ nullable: true
63
+ },
64
+ magnitude: {
65
+ type: 'number'
66
+ },
67
+ objectWidth: {
68
+ type: 'number'
69
+ },
70
+ objectHeight: {
71
+ type: 'number'
72
+ },
73
+ validateTargetOnHit: {
74
+ type: 'boolean'
75
+ }
76
+ }
77
+ });
78
+
79
+ module.exports = {
80
+ SkillPhysicalDataModel,
81
+ entity: SkillPhysicalDataModel,
82
+ schema
83
+ };
@@ -0,0 +1,125 @@
1
+ /**
2
+ *
3
+ * Reldens - Skills - SkillEffectModel
4
+ *
5
+ */
6
+
7
+ const { MikroOrmCore } = require('@reldens/storage');
8
+ const { EntitySchema } = MikroOrmCore;
9
+
10
+ class SkillTargetEffectsModel
11
+ {
12
+
13
+ beforeDestroyCalled = 0;
14
+ afterDestroyCalled = 0;
15
+
16
+ constructor(magnitude, skill_id, key, property_key, operation, value, minValue, maxValue, minProperty, maxProperty)
17
+ {
18
+ this.magnitude = magnitude;
19
+ this.skill_id = skill_id;
20
+ this.key = key;
21
+ this.property_key = property_key;
22
+ this.operation = operation;
23
+ this.value = value;
24
+ this.minValue = minValue;
25
+ this.maxValue = maxValue;
26
+ this.minProperty = minProperty;
27
+ this.maxProperty = maxProperty;
28
+ }
29
+
30
+ static createByProps(props)
31
+ {
32
+ const {
33
+ magnitude,
34
+ skill_id,
35
+ key,
36
+ property_key,
37
+ operation,
38
+ value,
39
+ minValue,
40
+ maxValue,
41
+ minProperty,
42
+ maxProperty
43
+ } = props;
44
+ return new this(
45
+ magnitude,
46
+ skill_id,
47
+ key,
48
+ property_key,
49
+ operation,
50
+ value,
51
+ minValue,
52
+ maxValue,
53
+ minProperty,
54
+ maxProperty
55
+ );
56
+ }
57
+
58
+ static relationMappings()
59
+ {
60
+ return {
61
+ skill_id: {
62
+ type: 'SkillModel',
63
+ entityName: 'skill',
64
+ reference: 'm:1',
65
+ join: {
66
+ from: 'skill_id',
67
+ to: 'id'
68
+ }
69
+ }
70
+ };
71
+ }
72
+
73
+ }
74
+
75
+ const schema = new EntitySchema({
76
+ class: SkillTargetEffectsModel,
77
+ properties: {
78
+ _id: {
79
+ primary: true,
80
+ type: 'ObjectID'
81
+ },
82
+ id: {
83
+ type: 'string',
84
+ serializedPrimaryKey: true
85
+ },
86
+ magnitude: {
87
+ type: 'number'
88
+ },
89
+ skill_id: {
90
+ type: 'SkillModel',
91
+ reference: 'm:1',
92
+ nullable: true
93
+ },
94
+ key: {
95
+ type: 'string'
96
+ },
97
+ property_key: {
98
+ type: 'string'
99
+ },
100
+ operation: {
101
+ type: 'string'
102
+ },
103
+ value: {
104
+ type: 'string'
105
+ },
106
+ minValue: {
107
+ type: 'string'
108
+ },
109
+ maxValue: {
110
+ type: 'string'
111
+ },
112
+ minProperty: {
113
+ type: 'string'
114
+ },
115
+ maxProperty: {
116
+ type: 'string'
117
+ }
118
+ }
119
+ });
120
+
121
+ module.exports = {
122
+ SkillTargetEffectsModel,
123
+ entity: SkillTargetEffectsModel,
124
+ schema
125
+ };
@@ -0,0 +1,77 @@
1
+ /**
2
+ *
3
+ * Reldens - Skills - SkillsGroupsModel
4
+ *
5
+ */
6
+
7
+ const { MikroOrmCore } = require('@reldens/storage');
8
+ const { EntitySchema } = MikroOrmCore;
9
+
10
+ class SkillsGroupsModel
11
+ {
12
+
13
+ beforeDestroyCalled = 0;
14
+ afterDestroyCalled = 0;
15
+
16
+ constructor(key, label, description, sort)
17
+ {
18
+ this.key = key;
19
+ this.label = label;
20
+ this.description = description;
21
+ this.sort = sort;
22
+ }
23
+
24
+ static createByProps(props)
25
+ {
26
+ const {key, label, description, sort} = props;
27
+ return new this(key, label, description, sort);
28
+ }
29
+
30
+ static relationMappings()
31
+ {
32
+ return {
33
+ group_id: {
34
+ type: 'SkillGroupRelationModel',
35
+ entityName: 'skillGroupRelation',
36
+ reference: 'm:1',
37
+ join: {
38
+ from: 'group_id',
39
+ to: 'id'
40
+ }
41
+ }
42
+ };
43
+ }
44
+
45
+ }
46
+
47
+ const schema = new EntitySchema({
48
+ class: SkillsGroupsModel,
49
+ properties: {
50
+ _id: {
51
+ primary: true,
52
+ type: 'ObjectID'
53
+ },
54
+ id: {
55
+ type: 'string',
56
+ serializedPrimaryKey: true
57
+ },
58
+ key: {
59
+ type: 'string'
60
+ },
61
+ label: {
62
+ type: 'string'
63
+ },
64
+ description: {
65
+ type: 'string'
66
+ },
67
+ sort: {
68
+ type: 'number'
69
+ }
70
+ }
71
+ });
72
+
73
+ module.exports = {
74
+ SkillsGroupsModel,
75
+ entity: SkillsGroupsModel,
76
+ schema
77
+ };
@@ -18,7 +18,7 @@ class LevelModel extends ObjectionJsRawModel
18
18
  static get relationMappings()
19
19
  {
20
20
  const { LevelsSetModel } = require('./levels-set-model');
21
- const { LevelModifiersModels } = require('./level-modifiers-model');
21
+ const { LevelModifiersModel } = require('./level-modifiers-model');
22
22
  return {
23
23
  level_set_id: {
24
24
  relation: this.BelongsToOneRelation,
@@ -30,10 +30,10 @@ class LevelModel extends ObjectionJsRawModel
30
30
  },
31
31
  level_modifiers: {
32
32
  relation: this.HasManyRelation,
33
- modelClass: LevelModifiersModels,
33
+ modelClass: LevelModifiersModel,
34
34
  join: {
35
35
  from: this.tableName+'.id',
36
- to: LevelModifiersModels.tableName+'.level_id'
36
+ to: LevelModifiersModel.tableName+'.level_id'
37
37
  }
38
38
  },
39
39
  };
@@ -1,13 +1,13 @@
1
1
  /**
2
2
  *
3
- * Reldens - Skills - LevelModifiersModels
3
+ * Reldens - Skills - LevelModifiersModel
4
4
  *
5
5
  */
6
6
 
7
7
  const { ObjectionJsRawModel } = require('@reldens/storage');
8
8
  const SkillsConst = require('../../../../constants');
9
9
 
10
- class LevelModifiersModels extends ObjectionJsRawModel
10
+ class LevelModifiersModel extends ObjectionJsRawModel
11
11
  {
12
12
 
13
13
  static get tableName()
@@ -32,4 +32,4 @@ class LevelModifiersModels extends ObjectionJsRawModel
32
32
 
33
33
  }
34
34
 
35
- module.exports.LevelModifiersModels = LevelModifiersModels;
35
+ module.exports.LevelModifiersModel = LevelModifiersModel;
@@ -8,14 +8,14 @@ const { ClassPathModel } = require('./class-path-model');
8
8
  const { ClassPathLevelLabelsModel } = require('./class-path-level-labels-model');
9
9
  const { ClassPathLevelSkillsModel } = require('./class-path-level-skills-model');
10
10
  const { LevelModel } = require('./level-model');
11
- const { LevelModifiersModels } = require('./level-modifiers-model');
11
+ const { LevelModifiersModel } = require('./level-modifiers-model');
12
12
  const { LevelsSetModel } = require('./levels-set-model');
13
13
  const { OwnersClassPathModel } = require('./owners-class-path-model');
14
14
  const { SkillModel } = require('./skill-model');
15
- const { SkillAttackModel } = require('./skill-attack');
15
+ const { SkillAttackModel } = require('./skill-attack-model');
16
16
  const { SkillTargetEffectsModel } = require('./skill-target-effects-model');
17
17
  const { SkillPhysicalDataModel } = require('./skill-physical-data-model');
18
- const { SkillGroupRelationModel } = require('./skill-group-relation');
18
+ const { SkillGroupRelationModel } = require('./skill-group-relation-model');
19
19
  const { SkillOwnerConditionsModel } = require('./skill-owner-conditions-model');
20
20
  const { SkillOwnerEffectsModel } = require('./skill-owner-effects-model');
21
21
  const { SkillsGroupsModel } = require('./skills-groups-model');
@@ -25,7 +25,7 @@ module.exports.rawRegisteredEntities = {
25
25
  classPathLevelLabels: ClassPathLevelLabelsModel,
26
26
  classPathLevelSkills: ClassPathLevelSkillsModel,
27
27
  level: LevelModel,
28
- levelModifiers: LevelModifiersModels,
28
+ levelModifiers: LevelModifiersModel,
29
29
  levelsSet: LevelsSetModel,
30
30
  ownersClassPath: OwnersClassPathModel,
31
31
  skill: SkillModel,
@@ -20,9 +20,9 @@ class SkillModel extends ObjectionJsRawModel
20
20
  const { SkillOwnerConditionsModel } = require('./skill-owner-conditions-model');
21
21
  const { SkillOwnerEffectsModel } = require('./skill-owner-effects-model');
22
22
  const { SkillTargetEffectsModel } = require('./skill-target-effects-model');
23
- const { SkillGroupRelationModel } = require('./skill-group-relation');
23
+ const { SkillGroupRelationModel } = require('./skill-group-relation-model');
24
24
  const { ClassPathLevelSkillsModel } = require('./class-path-level-skills-model');
25
- const { SkillAttackModel } = require('./skill-attack');
25
+ const { SkillAttackModel } = require('./skill-attack-model');
26
26
  const { SkillPhysicalDataModel } = require('./skill-physical-data-model');
27
27
  return {
28
28
  skill_owner_conditions: {
@@ -17,9 +17,9 @@ class SkillsGroupsModel extends ObjectionJsRawModel
17
17
 
18
18
  static get relationMappings()
19
19
  {
20
- const { SkillGroupRelationModel } = require('./skill-group-relation');
20
+ const { SkillGroupRelationModel } = require('./skill-group-relation-model');
21
21
  return {
22
- level_id: {
22
+ group_id: {
23
23
  relation: this.BelongsToOneRelation,
24
24
  modelClass: SkillGroupRelationModel,
25
25
  join: {
@@ -44,7 +44,6 @@ class ModelsManager
44
44
  // @TODO - BETA - Create a skills instances generator class to replace this function.
45
45
  async prepareSkillsInstancesList(skillsClasses)
46
46
  {
47
- let result = {};
48
47
  // @TODO - BETA - Replace relations by constants on the registered-entities definition.
49
48
  // This way we will be able to use the get method, save the entity in a variable and call the relations
50
49
  // list from it.
@@ -53,26 +52,27 @@ class ModelsManager
53
52
  'skill_owner_effects',
54
53
  'skill_target_effects'
55
54
  ]);
56
- if(skillsModels.length){
57
- let skillsList = {};
58
- for(let skillModel of skillsModels){
59
- let skillClass = sc.hasOwn(skillsClasses, skillModel.type) ? skillsClasses[skillModel.type] : false;
60
- if(!skillClass){
61
- ErrorManager.error('Undefined skill type in skillsList:' + skillModel.type);
62
- }
63
- // force to use the same events manager instance used on the main package:
64
- skillModel.events = this.events;
65
- skillsList[skillModel.key] = {class: skillClass, data: skillModel};
55
+ if(0 === skillsModels.length){
56
+ return {};
57
+ }
58
+ let skillsList = {};
59
+ for(let skillModel of skillsModels){
60
+ let skillClass = sc.hasOwn(skillsClasses, skillModel.type) ? skillsClasses[skillModel.type] : false;
61
+ if(!skillClass){
62
+ ErrorManager.error('Undefined skill type in skillsList:' + skillModel.type);
66
63
  }
67
- result = {skillsModels, skillsList};
64
+ // force to use the same events manager instance used on the main package:
65
+ skillModel.events = this.events;
66
+ skillsList[skillModel.key] = {class: skillClass, data: skillModel};
68
67
  }
69
- return result;
68
+ return {skillsModels, skillsList};
70
69
  }
71
70
 
72
71
  // @TODO - BETA - Create a class path instances generator class to replace this function.
73
72
  async prepareClassPathInstancesList(classPathClasses)
74
73
  {
75
74
  let result = {};
75
+ // @TODO - BETA - Remove the executeCustomQuery.
76
76
  let classPathModels = await this.getEntity('classPath').executeCustomQuery('fullPathData');
77
77
  if(sc.isArray(classPathModels) && classPathModels.length){
78
78
  let classPathsById = {};