-
Notifications
You must be signed in to change notification settings - Fork 0
INQTest.js.addModifier.js
kyleady edited this page Jan 28, 2018
·
1 revision
At certain points it can be difficult for players to do the math of several modifiers in their head. On top of that, it can be difficult to check if they forgot anything. This method makes it possible to add multiple modifiers to one test, each with their own label.
Based on the type of modifier, addModifier() will do the following:
- array - Applies
this.addModifier(x)to each element, x, of the modifier array. - string - Executes
this.addModifier({Value: modifiers}). - number - Executes
this.addModifier({Value: modifiers}). - object
- Defaults
modifier.Nameto'Other'. - Converts
modifier.Valueto a number. - If
modifier.Valueis zero, the input will be ignored. - Adds
modifiertothis.Modifiers.
- Defaults
Adding a string modifier.
var myTest = INQTest();
myTest.addModifier('40');
log(myTest.Modifiers)
//[{Value: 40, Name: 'Other'}]
Adding a number modifier.
var myTest = INQTest();
myTest.addModifier(-12);
log(myTest.Modifiers)
//[{Value: -12, Name: 'Other'}]
Adding an object modifier.
var myTest = INQTest();
myTest.addModifier({Name: 'Balanced', Value: '10'});
log(myTest.Modifiers)
//[{Value: 10, Name: 'Balanced'}]
Adding an array modifier.
var myTest = INQTest();
myTest.addModifier([{ Value: '10', Name: 'Balanced'}, -12, '0']);
log(myTest.Modifiers)
//[{Value: 10, Name: 'Balanced'}, {Value: -12, Name: 'Other'}]