Skip to content

Commit

Permalink
Merge pull request #16 from damian-pastorini/develop
Browse files Browse the repository at this point in the history
- Reldens - Modifiers
  • Loading branch information
damian-pastorini authored Feb 21, 2022
2 parents 9bc8d02 + d52573c commit 230d07b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## About

This package is for the Modifiers class orinally created for the Reldens project, but now it can be used anywhere.
This package is for the Modifiers class originally created for the Reldens project, but now it can be used anywhere.
By implementing this package you will get:
- The Modifier class which is a helper to apply and revert values into an specific target properties.
- The Conditions class which is a helper to avoid an action only if the condition is satisfied.
Expand Down
2 changes: 1 addition & 1 deletion lib/condition.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Condition
this.key = props.key;
this.propertyKey = props.propertyKey;
this.conditional = props.conditional;
this.type = sc.hasOwn(props, 'type') ? props.type : ModifierConst.TYPES.INT;
this.type = sc.get(props, 'type', ModifierConst.TYPES.INT);
this.value = this.parseValue(props.value);
this.propertyManager = new PropertyManager();
}
Expand Down
19 changes: 9 additions & 10 deletions lib/modifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,20 @@ class Modifier
]);
}
this.key = props.key;
this.propertyKey = props.propertyKey ? props.propertyKey : props.property_key;
this.basePropertyKey = props.basePropertyKey ? props.basePropertyKey : this.propertyKey;
this.propertyKey = sc.get(props, 'propertyKey', props.property_key);
this.basePropertyKey = sc.get(props, 'basePropertyKey', this.propertyKey);
this.operation = props.operation;
this.type = sc.hasOwn(props, 'type') ? props.type : ModifierConst.TYPES.INT;
this.type = sc.get(props, 'type', ModifierConst.TYPES.INT);
this.value = this.parseValue(props.value);
this.originalValue = props.value;
this.target = sc.hasOwn(props, 'target') ? props.target : false;
this.target = sc.get(props, 'target', false);
this.minValue = sc.hasOwn(props, 'minValue') ? this.parseValue(props.minValue) : false;
this.maxValue = sc.hasOwn(props, 'maxValue') ? this.parseValue(props.maxValue) : false;
this.minProperty = sc.getDef(props, 'minProperty', false);
this.maxProperty = sc.getDef(props, 'maxProperty', false);
this.minProperty = sc.get(props, 'minProperty', false);
this.maxProperty = sc.get(props, 'maxProperty', false);
// array of conditions objects:
this.conditions = sc.hasOwn(props, 'conditions') ? props.conditions : [];
this.conditionsOnRevert = sc.hasOwn(props, 'conditionsOnRevert')
? props.conditionsOnRevert : false;
this.conditions = sc.get(props, 'conditions', []);
this.conditionsOnRevert = sc.get(props, 'conditionsOnRevert', false);
this.state = false;
this.calculator = new Calculator();
this.propertyManager = new PropertyManager();
Expand Down Expand Up @@ -73,7 +72,7 @@ class Modifier
* Here you have two specific attributes for special features, useBasePropertyToGetValue and applyOnBaseProperty.
* When useBasePropertyToGetValue is true then the modifier will use the basePropertyKey to calculate the modified
* value.
* Beside that, no matter from which value your start the calculations then you can use the applyOnBaseProperty
* Besides, no matter from which value your start the calculations then you can use the applyOnBaseProperty
* property to specify if you want to apply the new calculated value to the propertyKey or to the basePropertyKey.
*
*/
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@reldens/modifiers",
"scope": "@reldens",
"version": "0.4.7",
"version": "0.11.0",
"description": "Reldens - Modifiers",
"author": "Damian A. Pastorini",
"license": "MIT",
Expand Down Expand Up @@ -33,6 +33,6 @@
"url": "https://github.com/damian-pastorini/reldens-modifiers/issues"
},
"dependencies": {
"@reldens/utils": "^0.4.3"
"@reldens/utils": "^0.11.0"
}
}

0 comments on commit 230d07b

Please sign in to comment.