// splitByThens.js
(function() {
/*global adventurejs A*/
"use strict";
var p = adventurejs.Parser.prototype;
/**
* Each clause separated by 'then' is a distinct input.
* We treat clauses as unrelated without depencencies
* and stack each into a queue.
* <br><br>
* Example: "take sword then go north"
* @memberOf adventurejs.Parser
* @method adventurejs.Parser#splitByThens
* @param {String} input
* @returns {String}
*/
p.splitByThens = function Parser_splitByThens(input)
{
input = input.split(' then ' );
/**
* We also do a comma test here because English
* speakers may be inclined to use a comma
* before "then", as in:
*
* take sword, then go north
*
* We want to strip that comma if we find it, but note that
* in parseInput.js, commas are being substitued
* as a shorthand for " and ", so we have two different
* comma searches in an effort to catch either case.
*/
for( var i = 0; i < input.length; i++ )
{
input[i].trim();
if( "," === input[i].charAt( input[i].length-1 ) )
{
input[i] = input[i].slice(0,-1);
}
}
return input;
}
}());