// jump_aspect.js
(function () {
/*global adventurejs A*/
/**
* @augments {adventurejs.Verb}
* @class jump
* @ajsnode game.dictionary.verbs.jump
* @ajsconstruct MyGame.createVerb({ "name": "jump", [...] });
* @ajsconstructedby adventurejs.Dictionary#createVerb
* @hideconstructor
* @ajsinstanceof Verb
* @ajsnavheading DeprecatedVerbs
* @summary Summary.
* @tutorial Scripting_VerbSubscriptions
* @tutorial Verbs_VerbAnatomy
* @tutorial Verbs_VerbProcess
* @tutorial Verbs_ModifyVerbs
* @tutorial Verbs_WriteVerbs
* @classdesc
* <pre class="display border outline">
* <span class="input">> jump over threshold</span>
* You jump over the threshold, carrying your new bride, careful to
* avoid tripping over your own comically large feet. Your bride runs
* her gloved hand through your rainbow colored perm, tickling your nose
* with her colorful yellow and fuscia frill. She raises her head for
* a kiss, and you mash your brightly painted red lips into hers,
* commingling both your makeups into smears of red and white pancake.
* You part breathlessly, and she honks your foam nose in connubial bliss.
* </pre>
* <p>
* When used with a preposition,
* <strong>jump</strong> requires that the
* {@link adventurejs.Tangible|Tangible}
* {@link adventurejs.Asset|Asset}
* has an enabled
* {@link adventurejs.Aspect|Aspect}
* matching the player's preposition, with its
* aspect.player.can.jump</a>
* property set to true. By default, no special results will occur.
* Authors wanting to make use of it may need to use a method such
* as verb hooks. See
* <a href="/doc/Scripting_VerbPhases.html">Verb Phases</a>
* to learn more.
* </p>
*/
A.Preverbs.jump_aspect = {
name: "jumpover",
prettyname: "jump",
synonyms: [],
player_must_be: {
not_constrained: true,
not_on_floor: true,
not_nested_elsewhere: true,
},
phrase1: {
accepts_noun: true,
noun_must_be: {
known: true,
tangible: true,
present: true,
visible: true,
reachable: true,
},
},
doTry: function () {
var input, direct_object, direct_preposition, fail, msg;
input = this.game.getInput();
// player entered verb without aspect or noun
// in which case we've already passed qualifiers via mustBe
if (
input.found_word &&
this.canBeIntransitive() &&
true !== input.soft_prompt.satisfied
)
return true;
// we won't have got here with direct_object undefined
direct_object = input.getAsset(1);
// but preposition might be
direct_preposition = input.getPreposition(1);
// this can be a travel verb - is noun a direction?
if (!direct_preposition && direct_object.direction) {
this.game.tryTravel(direct_object.direction);
return null;
}
/* we received an asset with no preposition and asset can't respond directly to verb */
if (!direct_preposition) {
fail = true;
} else if (
/* asset hasn't got or doesn't allow verb at the specified preposition */
direct_preposition &&
(!direct_object.hasAspectAt(direct_preposition) ||
!direct_object.aspects[direct_preposition].player.can.jump)
) {
fail = true;
}
if (fail) {
msg =
"$(We) can't jump " +
(direct_preposition ? direct_preposition : "") +
(direct_object ? " " + direct_object.articlename : "") +
". ";
this.handleFailure(msg);
return null;
}
return true;
},
doSuccess: function () {
var input, direct_object, direct_preposition, msg;
input = this.game.getInput();
if (input.found_word && true !== input.soft_prompt.satisfied) {
msg = "$(We) jump. ";
} else {
direct_object = input.getAsset(1);
direct_preposition = input.getPreposition(1);
msg =
"$(We) jump " +
(direct_preposition ? direct_preposition : "") +
" " +
direct_object.articlename +
". ";
}
this.handleSuccess(msg, direct_object);
return true;
},
}; // END jump
})();