Skip to content

INQTest.js.addModifier.js

kyleady edited this page Jan 28, 2018 · 1 revision

Purpose

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.

Usage

INQTest.prototype.addModifier(modifier)

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
    1. Defaults modifier.Name to 'Other'.
    2. Converts modifier.Value to a number.
    3. If modifier.Value is zero, the input will be ignored.
    4. Adds modifier to this.Modifiers.

Examples

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'}]

Clone this wiki locally