@reldens/skills 0.10.0-beta.34 → 0.12.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.
@@ -4,11 +4,10 @@
4
4
  *
5
5
  */
6
6
 
7
- const ClassPath = require('../../class-path');
8
- const Level = require('../../level');
7
+ const { ClassPathGenerator } = require('./class-path-generator');
9
8
  const { DataServerValidator } = require('../data-server-validator');
10
- const { Modifier, Condition } = require('@reldens/modifiers');
11
- const { ErrorManager, Logger, EventsManagerSingleton, sc } = require('@reldens/utils');
9
+ const { SkillsGenerator } = require('./skills-generator');
10
+ const { Logger, EventsManagerSingleton, sc } = require('@reldens/utils');
12
11
 
13
12
  class ModelsManager
14
13
  {
@@ -26,101 +25,51 @@ class ModelsManager
26
25
 
27
26
  async loadOwnerClassPath(ownerId)
28
27
  {
29
- return await this.getEntity('ownersClassPath').loadOneByWithRelations('owner_id', ownerId, '[owner_full_class_path]');
28
+ return await this.getEntity('ownersClassPath').loadOneByWithRelations(
29
+ 'owner_id',
30
+ ownerId,
31
+ '[owner_full_class_path]'
32
+ );
30
33
  }
31
34
 
32
35
  async updateLevel(levelsSet)
33
36
  {
34
- return await this.getEntity('ownersClassPath')
35
- .updateBy('owner_id', levelsSet.getOwnerId(), {currentLevel: levelsSet.currentLevel})
37
+ return await this.getEntity('ownersClassPath').updateBy(
38
+ 'owner_id',
39
+ levelsSet.getOwnerId(),
40
+ {currentLevel: levelsSet.currentLevel}
41
+ );
36
42
  }
37
43
 
38
44
  async updateExperience(levelsSet)
39
45
  {
40
- return await this.getEntity('ownersClassPath')
41
- .updateBy('owner_id', levelsSet.getOwnerId(), {currentExp: levelsSet.currentExp});
46
+ return await this.getEntity('ownersClassPath').updateBy(
47
+ 'owner_id',
48
+ levelsSet.getOwnerId(),
49
+ {currentExp: levelsSet.currentExp}
50
+ );
42
51
  }
43
52
 
44
- // @TODO - BETA - Create a skills instances generator class to replace this function.
45
- async prepareSkillsInstancesList(skillsClasses)
53
+ async generateSkillsDataFromModels(skillsClasses)
46
54
  {
47
55
  // @TODO - BETA - Replace relations by constants on the registered-entities definition.
48
- // This way we will be able to use the get method, save the entity in a variable and call the relations
49
- // list from it.
56
+ // This way we will be able to use the get method, save the entity in a variable and call the relations list
57
+ // from it.
50
58
  let skillsModels = await this.getEntity('skill').loadAllWithRelations([
51
59
  'skill_owner_conditions',
52
60
  'skill_owner_effects',
53
61
  'skill_target_effects'
54
62
  ]);
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);
63
- }
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};
67
- }
68
- return {skillsModels, skillsList};
63
+ return SkillsGenerator.dataFromSkillsModelsWithClasses(skillsModels, skillsClasses, this.events);
69
64
  }
70
65
 
71
- // @TODO - BETA - Create a class path instances generator class to replace this function.
72
- async prepareClassPathInstancesList(classPathClasses)
66
+ async generateClassPathInstances(classPathClasses)
73
67
  {
74
- let result = {};
75
68
  // @TODO - BETA - Remove the executeCustomQuery.
76
- let classPathModels = await this.getEntity('classPath').executeCustomQuery('fullPathData');
77
- if(sc.isArray(classPathModels) && classPathModels.length){
78
- let classPathsById = {};
79
- let classPathsByKey = {};
80
- for(let classPathModel of classPathModels){
81
- let classPathClass = ClassPath;
82
- if(sc.hasOwn(classPathClasses, classPathModel.key)){
83
- classPathClass = classPathClasses[classPathModel.key];
84
- }
85
- let classPathData = {class: classPathClass, data: classPathModel};
86
- classPathModel.classPathLevels = this.getClassPathLevels(
87
- classPathModel.skills_levels_set.skills_levels_set_levels
88
- );
89
- classPathModel.labelsByLevel = this.parseLabelsByLevels(classPathModel.skills_class_path_level_labels);
90
- classPathsById[classPathModel.id] = classPathData;
91
- classPathsByKey[classPathModel.key] = classPathData;
92
- }
93
- result = {classPathModels: classPathModels, classPathsById, classPathsByKey};
94
- }
95
- return result;
96
- }
97
-
98
- parseLabelsByLevels(levelLabelsModel)
99
- {
100
- let labelsByLevel = {};
101
- for(let labelData of levelLabelsModel){
102
- labelsByLevel[labelData['label_level'].key] = labelData.label;
103
- }
104
- return labelsByLevel;
105
- }
106
-
107
- getClassPathLevels(levelsModels)
108
- {
109
- let levels = {};
110
- for(let levelData of levelsModels){
111
- let levelModifiers = [];
112
- if(levelData['level_modifiers'].length){
113
- for(let modifierData of levelData['level_modifiers']){
114
- let modifier = new Modifier(modifierData);
115
- levelModifiers.push(modifier);
116
- }
117
- }
118
- levelData.modifiers = levelModifiers;
119
- let levelKey = parseInt(levelData['key']);
120
- levelData.key = levelKey;
121
- levels[levelKey] = new Level(levelData);
122
- }
123
- return levels;
69
+ return ClassPathGenerator.fromClassPathModels(
70
+ await this.getEntity('classPath').executeCustomQuery('fullPathData'),
71
+ classPathClasses
72
+ );
124
73
  }
125
74
 
126
75
  async prepareClassPathData(owner, ownerIdProperty, classPathsListById, skillsClassesList)
@@ -132,11 +81,12 @@ class ModelsManager
132
81
  return false;
133
82
  }
134
83
  let currentClassPath = classPathsListById[currentPlayerClassPath.class_path_id];
135
- let skillsByLevel = this.parseSkillsByLevels(
84
+ let skillsByLevel = SkillsGenerator.skillsByLevelsFromSkillsModels(
136
85
  currentClassPath.data.skills_class_path_level_skills,
137
86
  owner,
138
87
  ownerIdProperty,
139
- skillsClassesList
88
+ skillsClassesList,
89
+ this.events
140
90
  );
141
91
  return {
142
92
  key: currentClassPath.data.key,
@@ -153,82 +103,6 @@ class ModelsManager
153
103
  };
154
104
  }
155
105
 
156
- // @TODO - BETA - Create a skills generator class to replace this function.
157
- parseSkillsByLevels(levelSkillsModel, owner, ownerIdProperty, skillsClassesList)
158
- {
159
- let skillsByLevel = {};
160
- for(let skillData of levelSkillsModel){
161
- let levelKey = parseInt(skillData['class_path_level'].key);
162
- if(!sc.hasOwn(skillsByLevel, levelKey)){
163
- skillsByLevel[levelKey] = {};
164
- }
165
- let skillModel = skillData.class_path_level_skill;
166
- skillModel.owner = owner;
167
- skillModel.ownerIdProperty = ownerIdProperty;
168
- skillModel.events = this.events;
169
- // @TODO - BETA - Make attack properties configurable.
170
- if(sc.isTrue(skillModel, 'skill_attack')){
171
- skillModel['attackProperties'] = skillModel['skill_attack'].attackProperties.split(',');
172
- skillModel['defenseProperties'] = skillModel['skill_attack'].defenseProperties.split(',');
173
- skillModel['aimProperties'] = skillModel['skill_attack'].aimProperties.split(',');
174
- skillModel['dodgeProperties'] = skillModel['skill_attack'].dodgeProperties.split(',');
175
- let attackProps = [
176
- 'affectedProperty',
177
- 'allowEffectBelowZero',
178
- 'hitDamage',
179
- 'applyDirectDamage',
180
- 'dodgeFullEnabled',
181
- 'dodgeOverAimSuccess',
182
- 'damageAffected',
183
- 'criticalAffected'
184
- ];
185
- for(let i of attackProps){
186
- skillModel[i] = skillModel['skill_attack'][i];
187
- }
188
- }
189
- // @TODO - BETA - Make physical properties configurable.
190
- if(sc.isTrue(skillModel, 'skill_physical_data')){
191
- let physicalProps = [
192
- 'magnitude',
193
- 'objectWidth',
194
- 'objectHeight',
195
- 'validateTargetOnHit'
196
- ];
197
- for(let i of physicalProps){
198
- skillModel[i] = skillModel['skill_physical_data'][i];
199
- }
200
- }
201
- if(sc.isTrue(skillModel, 'skill_owner_conditions')){
202
- skillModel.ownerConditions = [];
203
- for(let conditionData of skillModel['skill_owner_conditions']){
204
- conditionData['propertyKey'] = conditionData['property_key'];
205
- let skillCondition = new Condition(conditionData);
206
- skillModel.ownerConditions.push(skillCondition);
207
- }
208
- }
209
- if(sc.isTrue(skillModel, 'skill_owner_effects')){
210
- // @NOTE: skill effects are just modifiers that will affect the skill owner.
211
- let skillEffects = [];
212
- for(let effectData of skillModel['skill_owner_effects']){
213
- let effectModifier = new Modifier(effectData);
214
- skillEffects.push(effectModifier);
215
- }
216
- skillModel.ownerEffects = skillEffects;
217
- }
218
- if(sc.isTrue(skillModel, 'skill_target_effects')){
219
- // @NOTE: skill effects are just modifiers that will affect the skill owner.
220
- let skillEffects = [];
221
- for(let effectData of skillModel['skill_target_effects']){
222
- let effectModifier = new Modifier(effectData);
223
- skillEffects.push(effectModifier);
224
- }
225
- skillModel.targetEffects = skillEffects;
226
- }
227
- skillsByLevel[levelKey][skillModel.key] = new skillsClassesList[skillModel.key]['class'](skillModel);
228
- }
229
- return skillsByLevel;
230
- }
231
-
232
106
  }
233
107
 
234
108
  module.exports.ModelsManager = ModelsManager;
@@ -0,0 +1,28 @@
1
+ /**
2
+ *
3
+ * Reldens - Skills - ModifiersGenerator
4
+ *
5
+ */
6
+
7
+ const { Modifier } = require('@reldens/modifiers');
8
+ const { sc } = require('@reldens/utils');
9
+
10
+ class ModifiersGenerator
11
+ {
12
+
13
+ static fromModifiersModels(modifiersModels)
14
+ {
15
+ if(!sc.isArray(modifiersModels) || 0 === modifiersModels.length){
16
+ return [];
17
+ }
18
+ let modifiers = [];
19
+ for (let modifierModel of modifiersModels) {
20
+ let modifier = new Modifier(modifierModel);
21
+ modifiers.push(modifier);
22
+ }
23
+ return modifiers;
24
+ }
25
+
26
+ }
27
+
28
+ module.exports.ModifiersGenerator = ModifiersGenerator;
@@ -0,0 +1,101 @@
1
+ /**
2
+ *
3
+ * Reldens - Skills - SkillsGenerator
4
+ *
5
+ */
6
+
7
+ const { ModifiersGenerator } = require('./modifiers-generator');
8
+ const { ConditionsGenerator } = require('./conditions-generator');
9
+ const { sc, ErrorManager} = require('@reldens/utils');
10
+
11
+ class SkillsGenerator
12
+ {
13
+
14
+ static dataFromSkillsModelsWithClasses(skillsModels, skillsClasses, events)
15
+ {
16
+ if(0 === skillsModels.length){
17
+ return {};
18
+ }
19
+ let skillsList = {};
20
+ for(let skillModel of skillsModels){
21
+ let skillClass = sc.hasOwn(skillsClasses, skillModel.type) ? skillsClasses[skillModel.type] : false;
22
+ if(!skillClass){
23
+ ErrorManager.error('Undefined skill type in skillsList:' + skillModel.type);
24
+ }
25
+ // force to use the same events manager instance used on the main package:
26
+ skillModel.events = events;
27
+ skillsList[skillModel.key] = {class: skillClass, data: skillModel};
28
+ }
29
+ return {skillsModels, skillsList};
30
+ }
31
+
32
+ static skillsByLevelsFromSkillsModels(levelSkillsModels, owner, ownerIdProperty, skillsClassesList, events)
33
+ {
34
+ if(!sc.isArray(levelSkillsModels) || 0 === levelSkillsModels.length){
35
+ return {};
36
+ }
37
+ let skillsByLevel = {};
38
+ for(let skillData of levelSkillsModels){
39
+ let levelKey = parseInt(skillData['class_path_level'].key);
40
+ if(!sc.hasOwn(skillsByLevel, levelKey)){
41
+ skillsByLevel[levelKey] = {};
42
+ }
43
+ let skillModel = skillData.class_path_level_skill;
44
+ skillModel.owner = owner;
45
+ skillModel.ownerIdProperty = ownerIdProperty;
46
+ skillModel.events = events;
47
+ this.enrichWithAttackData(skillModel);
48
+ this.enrichWithPhysicalData(skillModel);
49
+ skillModel.ownerConditions = ConditionsGenerator.fromConditionsModels(skillModel['skill_owner_conditions']);
50
+ // @NOTE: skill effects are modifiers that will affect the skill owner or target.
51
+ skillModel.ownerEffects = ModifiersGenerator.fromModifiersModels(skillModel['skill_owner_effects']);
52
+ skillModel.targetEffects = ModifiersGenerator.fromModifiersModels(skillModel['skill_target_effects']);
53
+ skillsByLevel[levelKey][skillModel.key] = new skillsClassesList[skillModel.key]['class'](skillModel);
54
+ }
55
+ return skillsByLevel;
56
+ }
57
+
58
+ static enrichWithPhysicalData(skillModel)
59
+ {
60
+ if(!sc.isTrue(skillModel, 'skill_physical_data')){
61
+ return;
62
+ }
63
+ // @TODO - BETA - Make physical properties configurable.
64
+ let physicalProps = [
65
+ 'magnitude',
66
+ 'objectWidth',
67
+ 'objectHeight',
68
+ 'validateTargetOnHit'
69
+ ];
70
+ for(let i of physicalProps){
71
+ skillModel[i] = skillModel['skill_physical_data'][i];
72
+ }
73
+ }
74
+
75
+ static enrichWithAttackData(skillModel)
76
+ {
77
+ if(!sc.isTrue(skillModel, 'skill_attack')){
78
+ return;
79
+ }
80
+ // @TODO - BETA - Make attack properties configurable.
81
+ skillModel['attackProperties'] = skillModel['skill_attack'].attackProperties.split(',');
82
+ skillModel['defenseProperties'] = skillModel['skill_attack'].defenseProperties.split(',');
83
+ skillModel['aimProperties'] = skillModel['skill_attack'].aimProperties.split(',');
84
+ skillModel['dodgeProperties'] = skillModel['skill_attack'].dodgeProperties.split(',');
85
+ let attackProps = [
86
+ 'affectedProperty',
87
+ 'allowEffectBelowZero',
88
+ 'hitDamage',
89
+ 'applyDirectDamage',
90
+ 'dodgeFullEnabled',
91
+ 'dodgeOverAimSuccess',
92
+ 'damageAffected',
93
+ 'criticalAffected'
94
+ ];
95
+ for(let i of attackProps){
96
+ skillModel[i] = skillModel['skill_attack'][i];
97
+ }
98
+ }
99
+ }
100
+
101
+ module.exports.SkillsGenerator = SkillsGenerator;
package/lib/skill.js CHANGED
@@ -178,12 +178,7 @@ class Skill
178
178
  // custom conditions:
179
179
  !this.onExecuteConditions()
180
180
  // range:
181
- || (
182
- this.rangeAutomaticValidation
183
- && this.rangePropertyX
184
- && this.rangePropertyY
185
- && !(await this.validateRange(target))
186
- )
181
+ || await this.isValidRange(target)
187
182
  // cast validation:
188
183
  || (this.autoValidation && !this.validate())
189
184
  // @TODO - BETA - Auto validation doesn't work, check ActionsMessageActions.parseMessageAndRunActions.
@@ -211,6 +206,14 @@ class Skill
211
206
  return skillLogicResult;
212
207
  }
213
208
 
209
+ async isValidRange(target)
210
+ {
211
+ return this.rangeAutomaticValidation
212
+ && this.rangePropertyX
213
+ && this.rangePropertyY
214
+ && !(await this.validateRange(target));
215
+ }
216
+
214
217
  async finishExecution(target)
215
218
  {
216
219
  await this.fireEvent(SkillsEvents.SKILL_BEFORE_RUN_LOGIC, this, target);
@@ -238,21 +241,21 @@ class Skill
238
241
 
239
242
  applyCriticalValue(normalValue)
240
243
  {
241
- if(this.isCritical()){
242
- if(this.criticalMultiplier){
243
- normalValue = normalValue * this.criticalMultiplier;
244
- }
245
- if(this.criticalFixedValue){
246
- normalValue = normalValue + this.criticalFixedValue;
247
- }
244
+ if(!this.isCritical()){
245
+ return normalValue;
246
+ }
247
+ if(this.criticalMultiplier){
248
+ normalValue = normalValue * this.criticalMultiplier;
249
+ }
250
+ if(this.criticalFixedValue){
251
+ normalValue = normalValue + this.criticalFixedValue;
248
252
  }
249
253
  return normalValue;
250
254
  }
251
255
 
252
256
  getCriticalDiff(normalValue)
253
257
  {
254
- let criticalValue = this.applyCriticalValue(normalValue);
255
- return criticalValue - normalValue;
258
+ return this.applyCriticalValue(normalValue) - normalValue;
256
259
  }
257
260
 
258
261
  isCritical()
@@ -260,8 +263,7 @@ class Skill
260
263
  if(this.criticalChance <= 0){
261
264
  return false;
262
265
  }
263
- let rand = this.randomInteger(1, 100);
264
- return rand > this.criticalChance;
266
+ return this.criticalChance < this.randomInteger(1, 100);
265
267
  }
266
268
 
267
269
  randomInteger(min, max)
@@ -18,7 +18,7 @@ class Attack extends Skill
18
18
  {
19
19
  super(props);
20
20
  this.type = SkillsConst.SKILL_TYPE_ATTACK;
21
- if(!sc.hasOwn(props, 'affectedProperty')){
21
+ if(!sc.get(props, 'affectedProperty', false)){
22
22
  ErrorManager.error('Missing skill affectedProperty to which the result damage will be applied.');
23
23
  }
24
24
  // the affected property is the one to which the damage calculation will have effect:
@@ -39,7 +39,7 @@ class Attack extends Skill
39
39
  // specify if the damage or the critical will be affected by the aim and dodge properties:
40
40
  this.damageAffected = sc.hasOwn(props, 'damageAffected') ? props.damageAffected : false;
41
41
  this.criticalAffected = sc.hasOwn(props, 'criticalAffected') ? props.criticalAffected : false;
42
- // properties totals calculator operators:
42
+ // properties total calculator operators:
43
43
  // example: {
44
44
  // {key: 'propName1', op: ModifierConst.OPS.INC},
45
45
  // {key: 'propName2', op: ModifierConst.OPS.DEC}
@@ -67,68 +67,71 @@ class Attack extends Skill
67
67
  return false;
68
68
  }
69
69
  let affectedPropertyValue = this.getAffectedPropertyValue(target);
70
- if(this.allowEffectBelowZero || affectedPropertyValue > 0){
71
- let damage = this.hitDamage; // 100%
72
- // dodge proportion:
73
- let dodgeAimDiff = this.getDiffProportion(ownerAim, targetDodge);
74
- if(!this.applyDirectDamage){
75
- let ownerAtk = this.getPropertiesTotal(this.owner, this.attackProperties);
76
- let targetDef = this.getPropertiesTotal(target, this.defenseProperties);
77
- // atk and def calculation to affect the hit damage:
78
- let diff = ownerAtk - targetDef;
79
- if(diff > 0){
80
- let p = diff < targetDef ? (diff * 100 / targetDef) : 99;
81
- p = p > 99 ? 99 : p; // maximum modifier percentage to add.
82
- let additionalDamage = Math.ceil((p * damage / 100));
83
- damage = damage + additionalDamage;
84
- }
85
- if(diff < 0){
86
- let p = -diff < ownerAtk ? (-diff * 100 / ownerAtk) : 99;
87
- p = p > 99 ? 99 : p; // maximum modifier percentage to remove.
88
- let reduceDamage = Math.floor((p * damage / 100));
89
- damage = damage - reduceDamage;
90
- }
91
- if(this.damageAffected && targetDodge > ownerAim){
92
- // calculate dodge proportion over damage and remove it from the total:
93
- let damageProportion = Math.floor((damage * dodgeAimDiff / 100));
94
- damage = damage - damageProportion;
95
- }
96
- }
97
- // critical calculation:
98
- let criticalValue = this.getCriticalDiff(damage);
99
- if(this.criticalAffected && targetDodge > ownerAim){
100
- // calculate dodge proportion over critical damage and remove it from the critical total:
101
- let criticalProportion = Math.floor((criticalValue * dodgeAimDiff / 100));
102
- criticalValue = criticalValue - criticalProportion;
103
- }
104
- damage = damage + criticalValue;
105
- // avoid getting below 0:
106
- let modifiedValue = affectedPropertyValue - damage;
107
- if(!this.allowEffectBelowZero && affectedPropertyValue < damage){
108
- modifiedValue = 0;
109
- }
110
- await this.fireEvent(SkillsEvents.SKILL_ATTACK_APPLY_DAMAGE, this, target, damage, modifiedValue);
111
- this.setAffectedPropertyValue(target, modifiedValue);
70
+ if(!this.allowEffectBelowZero && 0 < affectedPropertyValue){
71
+ return false;
72
+ }
73
+ // dodge proportion:
74
+ let dodgeAimDiff = this.getDiffProportion(ownerAim, targetDodge);
75
+ let damage = this.applyDirectDamage
76
+ ? this.hitDamage // 100%
77
+ : this.calculateProportionDamage(target, this.hitDamage, targetDodge, ownerAim, dodgeAimDiff);
78
+ // critical calculation:
79
+ damage = damage + this.calculateCriticalDamage(damage, targetDodge, ownerAim, dodgeAimDiff);
80
+ // avoid getting below 0:
81
+ let modifiedValue = (!this.allowEffectBelowZero && affectedPropertyValue < damage)
82
+ ? 0
83
+ : affectedPropertyValue - damage;
84
+ await this.fireEvent(SkillsEvents.SKILL_ATTACK_APPLY_DAMAGE, this, target, damage, modifiedValue);
85
+ this.setAffectedPropertyValue(target, modifiedValue);
86
+ }
87
+
88
+ calculateCriticalDamage(damage, targetDodge, ownerAim, dodgeAimDiff)
89
+ {
90
+ let criticalValue = this.getCriticalDiff(damage);
91
+ if(!this.criticalAffected || targetDodge > ownerAim){
92
+ return criticalValue;
93
+ }
94
+ // calculate dodge proportion over critical damage and remove it from the critical total:
95
+ return criticalValue - (Math.floor((criticalValue * dodgeAimDiff / 100)));
96
+ }
97
+
98
+ calculateProportionDamage(target, damage, targetDodge, ownerAim, dodgeAimDiff)
99
+ {
100
+ let ownerAtk = this.getPropertiesTotal(this.owner, this.attackProperties);
101
+ let targetDef = this.getPropertiesTotal(target, this.defenseProperties);
102
+ // atk and def calculation to affect the hit damage:
103
+ let diff = ownerAtk - targetDef;
104
+ if(diff > 0){
105
+ let p = diff < targetDef ? (diff * 100 / targetDef) : 99;
106
+ p = p > 99 ? 99 : p; // maximum modifier percentage to add.
107
+ let additionalDamage = Math.ceil((p * damage / 100));
108
+ damage = damage + additionalDamage;
112
109
  }
110
+ if(diff < 0){
111
+ let p = -diff < ownerAtk ? (-diff * 100 / ownerAtk) : 99;
112
+ p = p > 99 ? 99 : p; // maximum modifier percentage to remove.
113
+ let reduceDamage = Math.floor((p * damage / 100));
114
+ damage = damage - reduceDamage;
115
+ }
116
+ if(this.damageAffected && targetDodge > ownerAim){
117
+ // calculate dodge proportion over damage and remove it from the total:
118
+ let damageProportion = Math.floor((damage * dodgeAimDiff / 100));
119
+ damage = damage - damageProportion;
120
+ }
121
+ return damage;
113
122
  }
114
123
 
115
124
  getPropertiesTotal(object, propertiesArray)
116
125
  {
126
+ if(0 === propertiesArray.length){
127
+ return 0;
128
+ }
117
129
  let totalValue = 0;
118
- if(propertiesArray.length){
119
- for(let prop of propertiesArray){
120
- let propValue = this.propertyManager.getPropertyValue(object, prop);
121
- if(sc.hasOwn(this.propertiesTotalOperators, prop)){
122
- totalValue = this.calculator.calculateNewValue(
123
- totalValue,
124
- this.propertiesTotalOperators[prop],
125
- propValue
126
- );
127
- } else {
128
- // default operation:
129
- totalValue = totalValue + propValue;
130
- }
131
- }
130
+ for(let prop of propertiesArray){
131
+ let propValue = this.propertyManager.getPropertyValue(object, prop);
132
+ totalValue = sc.hasOwn(this.propertiesTotalOperators, prop)
133
+ ? this.calculator.calculateNewValue(totalValue, this.propertiesTotalOperators[prop], propValue)
134
+ : totalValue + propValue;
132
135
  }
133
136
  return totalValue;
134
137
  }
@@ -20,13 +20,13 @@ class PhysicalSkillRunner
20
20
  static async executeOnHit(target, skill, skillType, runSkillLogicCallback)
21
21
  {
22
22
  await skill.fireEvent(skillType, skill, target);
23
- if(!skill.validateTargetOnHit || target === skill.target){
24
- if('function' !== typeof runSkillLogicCallback){
25
- return false;
26
- }
27
- return await runSkillLogicCallback(target);
23
+ if(skill.validateTargetOnHit && target !== skill.target){
24
+ return false;
28
25
  }
29
- return false;
26
+ if('function' !== typeof runSkillLogicCallback){
27
+ return false;
28
+ }
29
+ return await runSkillLogicCallback(target);
30
30
  }
31
31
 
32
32
  }