// qualifyParsedVerb.js
(function () {
/*global adventurejs A*/
var p = adventurejs.Parser.prototype;
/**
* End turn if input verb can't act upon noun or in current circumstance.
* @memberOf adventurejs.Parser
* @method adventurejs.Parser#qualifyParsedVerb
* @param {Object} params
* @returns {adventurejs.parsedVerb}
*/
p.qualifyParsedVerb = function Parser_qualifyParsedVerb(params) {
if (!params.parsed_verb_name) return false;
this.game.log(
"L1252",
"log",
"high",
"qualifyParsedVerb.js > " + params.parsed_verb_name,
"Parser"
);
let dictionary_verb = this.dictionary.verbs[params.parsed_verb_name];
if (!dictionary_verb) return false;
let player = this.game.getPlayer();
let room = this.game.getCurrentRoom();
let nest_asset = player.getNestOrPlaceAsset();
let nest_aspect = player.getNestOrPlaceAspect();
let nest_prep = player.getNestOrPlacePreposition();
let output_class = "";
const player_cant = !player.can[dictionary_verb.name];
const nest_cant = !nest_aspect.player.can[dictionary_verb.name];
const player_cant_msg = ` and ${player.id}.can.${dictionary_verb.name} is false`;
const nest_cant_msg = ` and ${nest_aspect.parent_id}.aspects.${nest_aspect.id}.can.${dictionary_verb.name} is false`;
let msg = "";
let qualifiers = dictionary_verb.player_must_be;
if (qualifiers.not_on_floor) {
if (player.isOnFloor()) {
this.game.debug(
`D1878 | qualifyParsedVerb.js | ${dictionary_verb.name}.player_must_be.not_on_floor `
);
msg += `$(We) can't do that from $(our) position
${player.getPostureGerund()} on the
${player.isNested() ? player.getNestAsset().name : "floor"}. `;
this.game.print(msg, output_class);
return false;
}
}
if (qualifiers.not_constrained) {
if (player.is.constrained) {
this.game.debug(
`D1879 | qualifyParsedVerb.js | ${dictionary_verb.name}.player_must_be.not_constrained `
);
msg +=
A.getSAF.call(this.game, player.constrained_msg) ||
"$(We're) constrained. ";
this.game.print(msg, output_class);
return false;
}
}
if (qualifiers.not_under) {
// if( ) {
// msg += "The verb \""
// + dictionary_verb.prettyname
// this.game.print( msg, output_class );
// return false;
//}
}
if (qualifiers.not_behind) {
// if( ) {
// msg += "The verb \""
// + dictionary_verb.prettyname
// this.game.print( msg, output_class );
// return false;
//}
}
if (qualifiers.not_nested_elsewhere) {
// if( ) {
// msg += "The verb \""
// + dictionary_verb.prettyname
// this.game.print( msg, output_class );
// return false;
//}
}
if (qualifiers[`able_to_${dictionary_verb.name}`]) {
if (
!player.can[dictionary_verb.name] ||
!nest_aspect.player.can[dictionary_verb.name]
) {
this.game.debug(
`D1410 | qualifyParsedVerb.js | ${dictionary_verb.name}.player_must_be.able_to_${dictionary_verb.name}${
player_cant ? player_cant_msg : ""
}${nest_cant ? nest_cant_msg : ""}`
);
msg += `$(We) can't ${dictionary_verb.name} `;
if (nest_cant)
msg += `while $(we're) ${nest_prep} ${nest_asset.articlename}. `;
else msg += `right now. `;
this.game.print(msg, output_class);
return false;
}
}
return dictionary_verb;
};
})();