@reldens/skills 0.29.0 → 0.31.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/constants.js +2 -1
- package/lib/types/attack.js +29 -8
- package/package.json +4 -4
package/lib/constants.js
CHANGED
|
@@ -61,6 +61,7 @@ module.exports = {
|
|
|
61
61
|
APPLIED_CRITICAL_DAMAGE: 'appliedCriticalDamage',
|
|
62
62
|
APPLYING_EFFECTS: 'applyingEffects',
|
|
63
63
|
APPLIED_EFFECTS: 'appliedEffects',
|
|
64
|
-
EXECUTE_PHYSICAL_ATTACK: 'executePhysicalAttack'
|
|
64
|
+
EXECUTE_PHYSICAL_ATTACK: 'executePhysicalAttack',
|
|
65
|
+
TARGET_NOT_AVAILABLE: 'targetNotAvailable'
|
|
65
66
|
}
|
|
66
67
|
};
|
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 { ErrorManager, sc } = require('@reldens/utils');
|
|
12
|
+
const { ErrorManager, sc, Logger} = require('@reldens/utils');
|
|
13
13
|
|
|
14
14
|
class Attack extends Skill
|
|
15
15
|
{
|
|
@@ -61,11 +61,23 @@ class Attack extends Skill
|
|
|
61
61
|
|
|
62
62
|
async applyDamageTo(target)
|
|
63
63
|
{
|
|
64
|
+
if(!target){
|
|
65
|
+
this.lastState = SkillsConst.SKILL_STATES.TARGET_NOT_AVAILABLE;
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
64
68
|
// @NOTE: both owner and target properties values has to be calculated at the time the skill is executed, that
|
|
65
69
|
// is why we are getting the target always as parameter.
|
|
66
70
|
// check if the skill can be dodged:
|
|
67
71
|
let ownerAim = this.getPropertiesTotal(this.owner, this.aimProperties);
|
|
72
|
+
if(false === ownerAim){
|
|
73
|
+
Logger.debug('Missing owner aim properties.', this.owner);
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
68
76
|
let targetDodge = this.getPropertiesTotal(target, this.dodgeProperties);
|
|
77
|
+
if(false === targetDodge){
|
|
78
|
+
Logger.debug('Missing target dodge properties.', target);
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
69
81
|
if(this.dodgeFullEnabled && targetDodge > (ownerAim * this.dodgeOverAimSuccess)){
|
|
70
82
|
this.lastState = SkillsConst.SKILL_STATES.DODGED;
|
|
71
83
|
return false;
|
|
@@ -129,17 +141,26 @@ class Attack extends Skill
|
|
|
129
141
|
|
|
130
142
|
getPropertiesTotal(object, propertiesArray)
|
|
131
143
|
{
|
|
144
|
+
if(!object){
|
|
145
|
+
Logger.warning('Missing object to get properties total.');
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
132
148
|
if(0 === propertiesArray.length){
|
|
133
149
|
return 0;
|
|
134
150
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
let
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
151
|
+
try {
|
|
152
|
+
let totalValue = 0;
|
|
153
|
+
for(let prop of propertiesArray){
|
|
154
|
+
let propValue = this.propertyManager.getPropertyValue(object, prop);
|
|
155
|
+
totalValue = sc.hasOwn(this.propertiesTotalOperators, prop)
|
|
156
|
+
? this.calculator.calculateNewValue(totalValue, this.propertiesTotalOperators[prop], propValue)
|
|
157
|
+
: totalValue + propValue;
|
|
158
|
+
}
|
|
159
|
+
return totalValue;
|
|
160
|
+
} catch (error) {
|
|
161
|
+
Logger.debug(error.message);
|
|
162
|
+
return false;
|
|
141
163
|
}
|
|
142
|
-
return totalValue;
|
|
143
164
|
}
|
|
144
165
|
|
|
145
166
|
getDiffProportion(totalValue, upProportionValue)
|
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.31.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.25.0",
|
|
44
|
+
"@reldens/storage": "^0.29.0",
|
|
45
|
+
"@reldens/utils": "^0.38.0"
|
|
46
46
|
}
|
|
47
47
|
}
|