// printNounDisambiguation.js
(function () {
/*global adventurejs A*/
var p = adventurejs.Parser.prototype;
/**
*
* @memberOf adventurejs.Parser
* @method adventurejs.Parser#printNounDisambiguation
* @param {Object} params
*/
p.printNounDisambiguation = function Parser_printNounDisambiguation(params) {
var parsedNoun = params.parsedNoun;
var nounIndex = params.nounIndex;
var output_class = "";
var definite_names = [];
var names = [];
//console.warn( "parsedNoun",parsedNoun );
// is parsedNoun plural?
// and we need the singular form?
var msg = "Which did $(we) mean? ";
//+ parsedNoun.original_input
//+ ("undefined" !== typeof parsedNoun.singular ? parsedNoun.singular : "")
// present choices in ordered list
if (this.game.settings.show_disambiguation_as_ordered_list) {
msg += "<ol>";
for (var i = 0; i < parsedNoun.matches.qualified.length; i++) {
msg += `<li>${
this.game.getAsset(parsedNoun.matches.qualified[i]).articlename
}</li>`;
}
msg += "</ol>";
}
// present choices in paragraph
else {
for (var i = 0; i < parsedNoun.matches.qualified.length; i++) {
var asset = this.game.getAsset(parsedNoun.matches.qualified[i]);
var name = asset.name;
var definite_name = asset.definite_name;
if (i === parsedNoun.matches.qualified.length - 1) {
msg += "or ";
}
if (this.game.settings.show_disambiguation_as_numbered_paragraph) {
msg += `<span class='choice'>${i + 1}) </span>`;
}
names.push(name);
definite_names.push(definite_name);
if (i === 0) {
definite_name = A.propercase(definite_name);
}
msg += definite_name;
if (i < parsedNoun.matches.qualified.length - 1) {
msg += ", ";
}
if (i === parsedNoun.matches.qualified.length - 1) {
msg += "? ";
}
}
}
let newparams = {
["noun" + nounIndex]: true,
index: nounIndex,
};
if (params.container) newparams.container = true;
// save for next turn disambiguation
this.input_history[0].setDisambiguate(newparams);
if (msg) this.game.print(msg, output_class);
return;
};
})();