// findMatchIn.js
(function () {
/*global adventurejs A*/
"use strict";
var p = adventurejs.Parser.prototype;
/**
* Used by noun disambiguation in handleWord.js,
* typically in cases where user has been asked a question like
* "Which thing do you want, 1) A or 2) B ?",
* to compare this turn's input against last turn's input.
* @memberOf adventurejs.Parser
* @method adventurejs.Parser#findMatchIn
* @param {Object} newQualified
* @param {Object} oldQualified
* @returns {Object} foundMatch
*/
p.findMatchIn = function Parser_findMatchIn(newQualified, oldQualified) {
if (!newQualified || !oldQualified) return false;
var foundMatch;
for (var i = 0; i < newQualified.length; i++) {
// 2023.04.08 in cases of bowl:in:water we only want to compare "bowl"
var nq = newQualified[i].split(":")[0];
for (var j = 0; j < oldQualified.length; j++) {
// 2023.04.08 in cases of bowl:in:water we only want to compare "bowl"
var oq = oldQualified[j].split(":")[0];
if (nq === oq) {
foundMatch = nq;
break;
}
if ("undefined" !== typeof foundMatch) break;
}
}
return foundMatch;
};
})();