// 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({
parsedNoun,
nounIndex,
container,
}) {
var output_class = "";
// var print_names = [];
// var names = [];
// is parsedNoun plural?
// and we need the singular form?
var msg = `Which did {we} mean? `;
// 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]).article_name
}</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]);
let print_name = "";
if (asset.id === this.game.world._player) {
print_name = this.game.dictionary.inflect("ourself");
} else if (asset.use_proper_name && asset.proper_name) {
print_name = asset.proper_name;
} else if (asset.use_definite_article) {
print_name = asset.article_name;
} else {
print_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='ajs-choice'>${i + 1}) </span>`;
}
// if (i === 0) {
// print_name = A.sentencecase(print_name);
// }
msg += print_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 (container) newparams.container = true;
// save for next turn disambiguation
this.input_history[0].setDisambiguate(newparams);
if (msg) this.game.print(msg, output_class);
return;
};
})();