@reldens/skills 0.33.0 → 0.35.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.
- package/lib/server/storage/models/mikro-orm/levels-set-model.js +1 -1
- package/lib/skill.js +22 -7
- package/lib/types/attack.js +13 -12
- package/lib/types/effect.js +3 -2
- package/lib/types/physical-attack.js +1 -1
- package/lib/types/physical-effect.js +1 -1
- package/lib/types/physical-properties-validator.js +10 -5
- package/lib/types/physical-skill-runner.js +1 -1
- package/package.json +4 -4
package/lib/skill.js
CHANGED
|
@@ -7,21 +7,25 @@
|
|
|
7
7
|
const SkillsConst = require('./constants');
|
|
8
8
|
const SkillsEvents = require('./skills-events');
|
|
9
9
|
const { PropertyManager, Condition, Calculator } = require('@reldens/modifiers');
|
|
10
|
-
const { InteractionArea, EventsManagerSingleton,
|
|
10
|
+
const { InteractionArea, EventsManagerSingleton, Logger, sc } = require('@reldens/utils');
|
|
11
11
|
|
|
12
12
|
class Skill
|
|
13
13
|
{
|
|
14
14
|
|
|
15
15
|
constructor(props)
|
|
16
16
|
{
|
|
17
|
+
this.isReady = true;
|
|
17
18
|
if(!sc.hasOwn(props, 'key')){
|
|
18
|
-
|
|
19
|
+
Logger.error('Missing skill key.');
|
|
20
|
+
this.isReady = false;
|
|
19
21
|
}
|
|
20
22
|
if(!sc.hasOwn(props, 'owner')){
|
|
21
|
-
|
|
23
|
+
Logger.error('Missing skill owner.');
|
|
24
|
+
this.isReady = false;
|
|
22
25
|
}
|
|
23
26
|
if(typeof props.owner.getPosition !== 'function'){
|
|
24
|
-
|
|
27
|
+
Logger.error('Undefined owner position method.');
|
|
28
|
+
this.isReady = false;
|
|
25
29
|
}
|
|
26
30
|
this.key = props.key;
|
|
27
31
|
this.owner = props.owner;
|
|
@@ -79,6 +83,10 @@ class Skill
|
|
|
79
83
|
|
|
80
84
|
validate()
|
|
81
85
|
{
|
|
86
|
+
if(!this.isReady){
|
|
87
|
+
Logger.error('Skill is not ready for validation.', this.key);
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
82
90
|
// @NOTE: the following is tricky, we use the isValid = true so developers can change it and return a different
|
|
83
91
|
// isValid value after the event "validateSuccess".
|
|
84
92
|
this.isValid = true;
|
|
@@ -119,7 +127,8 @@ class Skill
|
|
|
119
127
|
{
|
|
120
128
|
for(let condition of this.ownerConditions){
|
|
121
129
|
if(!(condition instanceof Condition)){
|
|
122
|
-
|
|
130
|
+
Logger.critical('Wrong Condition instance was specified.', (typeof condition));
|
|
131
|
+
return false;
|
|
123
132
|
}
|
|
124
133
|
if(!condition.isValidOn(this.owner)){
|
|
125
134
|
// @TODO - BETA - Replace catch.
|
|
@@ -135,7 +144,8 @@ class Skill
|
|
|
135
144
|
validateRange(target)
|
|
136
145
|
{
|
|
137
146
|
if(!this.rangePropertyX || !this.rangePropertyY){
|
|
138
|
-
|
|
147
|
+
Logger.error('Missing range properties for validation.');
|
|
148
|
+
return false;
|
|
139
149
|
}
|
|
140
150
|
let ownerPosition = {
|
|
141
151
|
x: this.propertyManager.getPropertyValue(this.owner, this.rangePropertyX),
|
|
@@ -171,12 +181,17 @@ class Skill
|
|
|
171
181
|
|
|
172
182
|
async execute(target)
|
|
173
183
|
{
|
|
184
|
+
if(!this.isReady){
|
|
185
|
+
Logger.error('Skill is not ready to be executed.', this.key);
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
174
188
|
await this.fireEvent(SkillsEvents.SKILL_BEFORE_EXECUTE, this, target);
|
|
175
189
|
if(target){
|
|
176
190
|
this.target = target;
|
|
177
191
|
}
|
|
178
192
|
if(!this.target){
|
|
179
|
-
|
|
193
|
+
Logger.error('Target undefined.');
|
|
194
|
+
return false;
|
|
180
195
|
}
|
|
181
196
|
if(
|
|
182
197
|
// custom conditions:
|
package/lib/types/attack.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
const Skill = require('../skill');
|
|
10
10
|
const SkillsEvents = require('../skills-events');
|
|
11
11
|
const SkillsConst = require('../constants');
|
|
12
|
-
const {
|
|
12
|
+
const { Logger, sc } = require('@reldens/utils');
|
|
13
13
|
|
|
14
14
|
class Attack extends Skill
|
|
15
15
|
{
|
|
@@ -19,26 +19,27 @@ class Attack extends Skill
|
|
|
19
19
|
super(props);
|
|
20
20
|
this.type = SkillsConst.SKILL.TYPE.ATTACK;
|
|
21
21
|
if(!sc.get(props, 'affectedProperty', false)){
|
|
22
|
-
|
|
22
|
+
Logger.error('Missing skill affectedProperty to which the result damage will be applied.');
|
|
23
|
+
this.isReady = false;
|
|
23
24
|
}
|
|
24
25
|
// the affected property is the one to which the damage calculation will have effect:
|
|
25
26
|
this.affectedProperty = props.affectedProperty;
|
|
26
27
|
this.allowEffectBelowZero = sc.get(props, 'allowEffectBelowZero', false);
|
|
27
28
|
// hit damage value at 100%:
|
|
28
|
-
this.hitDamage = sc.
|
|
29
|
-
this.applyDirectDamage = sc.
|
|
29
|
+
this.hitDamage = sc.get(props, 'hitDamage', 0);
|
|
30
|
+
this.applyDirectDamage = sc.get(props, 'applyDirectDamage', false);
|
|
30
31
|
// all properties are obtained from the skill owner and the target to calculate the damage:
|
|
31
|
-
this.attackProperties = sc.
|
|
32
|
-
this.defenseProperties = sc.
|
|
32
|
+
this.attackProperties = sc.get(props, 'attackProperties', []);
|
|
33
|
+
this.defenseProperties = sc.get(props, 'defenseProperties', []);
|
|
33
34
|
// aim and dodge properties are used to determine if the skill could fail:
|
|
34
|
-
this.aimProperties = sc.
|
|
35
|
-
this.dodgeProperties = sc.
|
|
35
|
+
this.aimProperties = sc.get(props, 'aimProperties', []);
|
|
36
|
+
this.dodgeProperties = sc.get(props, 'dodgeProperties', []);
|
|
36
37
|
// dodgeFullEnabled will make the attack fail if: dodge > ownerAim * dodgeOverAimSuccess
|
|
37
|
-
this.dodgeFullEnabled = sc.
|
|
38
|
-
this.dodgeOverAimSuccess = sc.
|
|
38
|
+
this.dodgeFullEnabled = sc.get(props, 'dodgeFullEnabled', true);
|
|
39
|
+
this.dodgeOverAimSuccess = sc.get(props, 'dodgeOverAimSuccess', 1);
|
|
39
40
|
// specify if the damage or the critical will be affected by the aim and dodge properties:
|
|
40
|
-
this.damageAffected = sc.
|
|
41
|
-
this.criticalAffected = sc.
|
|
41
|
+
this.damageAffected = sc.get(props, 'damageAffected', false);
|
|
42
|
+
this.criticalAffected = sc.get(props, 'criticalAffected', false);
|
|
42
43
|
// properties total calculator operators:
|
|
43
44
|
// example: {
|
|
44
45
|
// {key: 'propName1', op: ModifierConst.OPS.INC},
|
package/lib/types/effect.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
const Skill = require('../skill');
|
|
10
10
|
const SkillsEvents = require('../skills-events');
|
|
11
11
|
const SkillsConst = require('../constants');
|
|
12
|
-
const { ErrorManager, sc } = require('@reldens/utils');
|
|
12
|
+
const { ErrorManager, sc, Logger} = require('@reldens/utils');
|
|
13
13
|
|
|
14
14
|
class Effect extends Skill
|
|
15
15
|
{
|
|
@@ -19,7 +19,8 @@ class Effect extends Skill
|
|
|
19
19
|
super(props);
|
|
20
20
|
this.type = SkillsConst.SKILL.TYPE.EFFECT;
|
|
21
21
|
if(!sc.hasOwn(props, 'targetEffects')){
|
|
22
|
-
|
|
22
|
+
Logger.error('Missing targetEffects for skill.');
|
|
23
|
+
this.isReady = false;
|
|
23
24
|
}
|
|
24
25
|
this.targetEffects = props.targetEffects;
|
|
25
26
|
}
|
|
@@ -21,7 +21,7 @@ class PhysicalAttack extends Attack
|
|
|
21
21
|
super(props);
|
|
22
22
|
this.type = SkillsConst.SKILL.TYPE.PHYSICAL_ATTACK;
|
|
23
23
|
this.parentType = SkillsConst.SKILL.TYPE.ATTACK;
|
|
24
|
-
PhysicalPropertiesValidator.validate(props);
|
|
24
|
+
this.isReady = PhysicalPropertiesValidator.validate(props);
|
|
25
25
|
this.magnitude = props.magnitude;
|
|
26
26
|
this.objectWidth = props.objectWidth;
|
|
27
27
|
this.objectHeight = props.objectHeight;
|
|
@@ -21,7 +21,7 @@ class PhysicalEffect extends Effect
|
|
|
21
21
|
super(props);
|
|
22
22
|
this.type = SkillsConst.SKILL.TYPE.PHYSICAL_EFFECT;
|
|
23
23
|
this.parentType = SkillsConst.SKILL.TYPE.EFFECT;
|
|
24
|
-
PhysicalPropertiesValidator.validate(props);
|
|
24
|
+
this.isReady = PhysicalPropertiesValidator.validate(props);
|
|
25
25
|
this.magnitude = props.magnitude;
|
|
26
26
|
this.objectWidth = props.objectWidth;
|
|
27
27
|
this.objectHeight = props.objectHeight;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
const {
|
|
7
|
+
const { Logger, sc } = require('@reldens/utils');
|
|
8
8
|
|
|
9
9
|
class PhysicalPropertiesValidator
|
|
10
10
|
{
|
|
@@ -12,17 +12,22 @@ class PhysicalPropertiesValidator
|
|
|
12
12
|
static validate(props)
|
|
13
13
|
{
|
|
14
14
|
if(typeof props.owner.executePhysicalSkill !== 'function'){
|
|
15
|
-
|
|
15
|
+
Logger.error('Missing executePhysicalSkill required method.');
|
|
16
|
+
return false;
|
|
16
17
|
}
|
|
17
18
|
if(!sc.hasOwn(props, 'magnitude')){
|
|
18
|
-
|
|
19
|
+
Logger.error('Missing magnitude property.');
|
|
20
|
+
return false;
|
|
19
21
|
}
|
|
20
22
|
if(!sc.hasOwn(props, 'objectWidth')){
|
|
21
|
-
|
|
23
|
+
Logger.error('Missing objectWidth property.');
|
|
24
|
+
return false;
|
|
22
25
|
}
|
|
23
26
|
if(!sc.hasOwn(props, 'objectHeight')){
|
|
24
|
-
|
|
27
|
+
Logger.error('Missing objectHeight property.');
|
|
28
|
+
return false;
|
|
25
29
|
}
|
|
30
|
+
return true;
|
|
26
31
|
}
|
|
27
32
|
|
|
28
33
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reldens/skills",
|
|
3
3
|
"scope": "@reldens",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.35.0",
|
|
5
5
|
"description": "Reldens - Skills",
|
|
6
6
|
"author": "Damian A. Pastorini",
|
|
7
7
|
"license": "MIT",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"url": "https://github.com/damian-pastorini/reldens-skills/issues"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@reldens/modifiers": "^0.
|
|
44
|
-
"@reldens/storage": "^0.
|
|
45
|
-
"@reldens/utils": "^0.
|
|
43
|
+
"@reldens/modifiers": "^0.27.0",
|
|
44
|
+
"@reldens/storage": "^0.32.0",
|
|
45
|
+
"@reldens/utils": "^0.40.0"
|
|
46
46
|
}
|
|
47
47
|
}
|