// out.js
// OK 09 2023
(function () {
/*global adventurejs A*/
"use strict";
/**
* @augments {adventurejs.Verb}
* @class out
* @ajsnode game.dictionary.verbs.out
* @ajsconstruct MyGame.createVerb({ "name": "out", [...] });
* @ajsconstructedby adventurejs.Dictionary#createVerb
* @hideconstructor
* @ajsinstanceof Verb
* @ajsnavheading DirectionVerbs
* @summary Verb meaning travel out.
* @tutorial Scripting_VerbSubscriptions
* @tutorial Verbs_VerbAnatomy
* @tutorial Verbs_VerbProcess
* @tutorial Verbs_ModifyVerbs
* @tutorial Verbs_WriteVerbs
* @tutorial Scripting_VerbSubscriptions
* @tutorial Verbs_VerbAnatomy
* @tutorial Verbs_VerbProcess
* @tutorial Verbs_ModifyVerbs
* @tutorial Verbs_WriteVerbs
* @classdesc
* <pre class="display border outline">
* <span class="input">> out</span>
* You overcome your fears and leap out of the plane.
* Too bad you forgot the parachute.
* </pre>
* <p>
* Direction verb: go <strong>out</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.out = {
name: "out",
is_direction: true,
is_spatial_direction: true,
synonyms: ["out"],
type: { direction: true },
/**
* @ajsverbstructures
* @memberof out
*/
accepts_structures: ["verb"],
doTry: function () {
var player = this.game.getPlayer();
var input = this.game.getInput();
var msg = "";
if (player.isNested()) {
var p = player.getNestPreposition();
// we'll take "out" to mean out of in, under or behind
if (p === "in" || p === "under" || p === "behind") {
this.game.debug(
`F1141 | ${
this.name
}.js | infer 'get out of ${player.getNestId()}', doVerb go out`
);
input.setVerb("go");
input.setPreposition(1, "out");
input.setStructure("verb preposition noun");
input.setAsset(1, player.getNestAsset());
this.game.dictionary.doVerb("go");
return null;
}
} // player.isNested()
return true;
},
doSuccess: function () {
this.game.tryTravel(this.name);
return true;
},
};
})();