// up.js
// OK 09 2023
(function () {
/*global adventurejs A*/
/**
* @augments {adventurejs.Verb}
* @class up
* @ajsnode game.dictionary.verbs.up
* @ajsconstruct MyGame.createVerb({ "name": "up", [...] });
* @ajsconstructedby adventurejs.Dictionary#createVerb
* @hideconstructor
* @ajsinstanceof Verb
* @ajsnavheading DirectionVerbs
* @summary Verb meaning travel to up direction.
* @tutorial Scripting_VerbSubscriptions
* @tutorial Verbs_VerbAnatomy
* @tutorial Verbs_VerbProcess
* @tutorial Verbs_ModifyVerbs
* @tutorial Verbs_WriteVerbs
* @classdesc
* <pre class="display border outline">
* <span class="input">> up</span>
* You leap up and fail to avoid the rapidly spinning fan.
* </pre>
* <p>
* Direction verb: go <strong>up</strong>.
* To learn about {@link adventurejs.Exit|Exits},
* see <a href="/doc/GetStarted_CreateAnExit.html">Create an Exit</a>.
* </p>
* @ajsverbreactions doRemoveThisFromThat, doRemoveThatFromThis, doMoveThisToThat, doMoveThatToThis
* @ajsverbphases doBeforeTry, doAfterTry, doBeforeSuccess, doAfterSuccess
*/
A.Preverbs.up = {
name: "up",
is_direction: true,
is_relative_direction: true,
synonyms: ["up", "u"],
type: { direction: true },
adjective: "upward",
/**
* @ajsverbstructures
* @memberof up
*/
accepts_structures: ["verb"],
doTry: function () {
var input = this.game.getInput();
var verb_phrase = input.verb_phrase;
var player = this.game.getPlayer();
var nest_asset = player.getNestAsset();
var results;
var newverb, newprep;
// climb up?
if (nest_asset && player.position.y < nest_asset.getYTop()) {
newverb = this.game.hasVerb("climb") ? "climb" : "go";
newprep = "up";
this.game.debug(
`D1142 | ${this.name}.js | player is nested below the top of ${nest_asset.id}, which is scalable, infer doVerb ${newverb} ${newprep}`
);
input.input_verb = newverb;
input.setVerb(1, newverb);
input.setAsset(1, nest_asset);
input.setPreposition(1, newprep);
input.setStructure("verb preposition noun");
return this.game.dictionary.doVerb(newverb);
}
// just go up
results = this.game.tryTravel(this.name);
if (!results) {
this.handleFailure();
}
return results;
},
doSuccess: function () {
return this.handleSuccess();
},
};
})();