lib/Dice.js
function (notation) {
            var tokens = this.notationRe.exec(notation);

            this.rolls = tokens[1] === undefined ? this.defaultRolls : parseInt(tokens[1]); // default if omitted
            this.sides = tokens[2] === undefined ? this.defaultSides : parseInt(tokens[2]); // default if omitted

            var after = tokens[3];
            var additionTokens;

            if (after) { // we have third part of notation
                if (after === '-L') {
                    this.specials.chooseLowest = true;
                } else if (after === '-H') {
                    this.specials.chooseHighest = true;
                } else {
                    additionTokens = this.additionRe.exec(after);
                    this.specials.add = parseInt(additionTokens[2]);
                    if (additionTokens[1] === '-') {
                        this.specials.add *= -1;
                    }
                }
            }

            return this;
        }
function (notation) {
            var tokens = this.notationRe.exec(notation);

            this.rolls = tokens[1] === undefined ? this.defaultRolls : parseInt(tokens[1]); // default if omitted
            this.sides = tokens[2] === undefined ? this.defaultSides : parseInt(tokens[2]); // default if omitted

            var after = tokens[3];
            var additionTokens;

            if (after) { // we have third part of notation
                if (after === '-L') {
                    this.specials.chooseLowest = true;
                } else if (after === '-H') {
                    this.specials.chooseHighest = true;
                } else {
                    additionTokens = this.additionRe.exec(after);
                    this.specials.add = parseInt(additionTokens[2]);
                    if (additionTokens[1] === '-') {
                        this.specials.add *= -1;
                    }
                }
            }

            return this;
        }
function ( notation ) { var tokens = this . notationRe . exec ( notation ) ; this . rolls = tokens [ 1 ] === undefined ? this . defaultRolls : parseInt ( tokens [ 1 ] ) ; // default if omitted this . sides = tokens [ 2 ] === undefined ? this . defaultSides : parseInt ( tokens [ 2 ] ) ; // default if omitted var after = tokens [ 3 ] ; var additionTokens ; if ( after ) { // we have third part of notation if ( after === '-L' ) { this . specials . chooseLowest = true ; } else if ( after === '-H' ) { this . specials . chooseHighest = true ; } else { additionTokens = this . additionRe . exec ( after ) ; this . specials . add = parseInt ( additionTokens [ 2 ] ) ; if ( additionTokens [ 1 ] === '-' ) { this . specials . add *= - 1 ; } } } return this ; }
Parses a notation
@param {String} notation e.g. "3d6+6"
@returns {Dice} this instance (for chaining)
Parses a notation