// down.js
// OK 09 2023
(function () {
/*global adventurejs A*/
"use strict";
/**
* @augments {adventurejs.Verb}
* @class down
* @ajsnode game.dictionary.verbs.down
* @ajsconstruct MyGame.createVerb({ "name": "down", [...] });
* @ajsconstructedby adventurejs.Dictionary#createVerb
* @hideconstructor
* @ajsinstanceof Verb
* @ajsnavheading DirectionVerbs
* @summary Verb meaning travel down.
* @tutorial Scripting_VerbSubscriptions
* @tutorial Verbs_VerbAnatomy
* @tutorial Verbs_VerbProcess
* @tutorial Verbs_ModifyVerbs
* @tutorial Verbs_WriteVerbs
* @classdesc
* <pre class="display border outline">
* <span class="input">> down</span>
* You slide down through the dark hole and quickly get eaten by a grue.
* </pre>
* <p>
* Direction verb: go <strong>down</strong>.
* To learn about {@link adventurejs.Exit|Exits},
* see <a href="/doc/GetStarted_CreateAnExit.html">Create an Exit</a>.
* </p>
* @ajsverbphases doBeforeTry, doAfterTry, doBeforeSuccess, doAfterSuccess
*/
A.Preverbs.down = {
name: "down",
is_direction: true,
is_spatial_direction: true,
synonyms: ["down", "d"],
type: { direction: true },
/**
* @ajsverbstructures
* @memberof down
*/
accepts_structures: ["verb"],
doTry: function () {
var player = this.game.getPlayer();
var nest_asset = player.getNestAsset();
var input = this.game.getInput();
var msg = "";
if (player.isNested()) {
if (
nest_asset.is.climbable &&
player.position.y > nest_asset.position.y
) {
this.game.debug(
`F1137 | ${
this.name
}.js | player is nested ${player.getNestPreposition()} ${player.getNestId()}, doVerb climb`
);
input.input_verb = "climb";
input.setAsset(1, nest_asset);
input.setPreposition(1, "down");
input.setStructure("verb preposition noun");
this.game.dictionary.doVerb("climb");
return null;
} // ordinary nest
else {
this.game.debug(
`F1136 | ${
this.name
}.js | infer 'get off ${player.getNestId()}, doVerb go off`
);
input.setVerb("go");
input.setAsset(1, nest_asset);
input.setPreposition(1, "off");
input.setStructure("verb preposition noun");
this.game.dictionary.doVerb("go");
return null;
}
} // player.isNested()
},
doSuccess: function () {
this.game.tryTravel(this.name);
return true;
},
};
})();