Skip to content

INQTest.js.setSkill.js

kyleady edited this page Jan 30, 2018 · 2 revisions

Purpose

Determines which Skill a user intends to test against. However, it will not determine which Skill Group the user intended to test against. Users should not be expected to get spacing, dashes, capitalization, and alternate names perfectly right. This method tries to account for similar inputs.

The Default Characteristic for the Skill will be saved. This is done so that players do not need to specify which Characteristic they are using for a Skill test, but that Characteristic can easily be overwritten with a user's choice.

Though it will first check INQTest.js.getCharacteristic.js to see if the input was a Characteristic. This allows Characteristics and Skills to be placed in the same input while INQTest distinguishes between the two.

Usage

INQTest.prototype.getSkill(user_input)

user_input is a string. That string is compared to each option in the INQTest.js.skills.js array. This is done so by converting each of the options into a RegExp through toRegex.js.

If a match is found, the proper name for the Skill will be saved to this.Skill, the Default Characteristic will be saved to this.Characteristic and the method will return true.

If no match is found, the method will return false.

Examples

The Default Characteristic can be overwritten by using INQTest.js.setCharacteristic.js after setSkill().

var myTest = new INQTest();
myTest.setSkill('intimidate');
myTest.setCharacteristic('Fellowship');

//myTest.Characteristic == 'Fe';
//myTest.Skill == 'Intimidate';

setSkill() will accept Characteristics.

var myTest = new INQTest();
myTest.setSkill('Pr');

//myTest.Characteristic == 'Per';
//myTest.Skill == undefined;

Clone this wiki locally