// lasso.js
(function () {
/*global adventurejs A*/
"use strict";
/**
* @augments {adventurejs.Verb}
* @class lasso
* @ajsnode game.dictionary.verbs.lasso
* @ajsconstruct MyGame.createVerb({ "name": "lasso", [...] });
* @ajsconstructedby adventurejs.Dictionary#createVerb
* @hideconstructor
* @ajsinstanceof Verb
* @ajsnavheading ManipulationVerbs
* @summary Verb meaning lasso asset with rope.
* @tutorial Scripting_VerbSubscriptions
* @tutorial Verbs_VerbAnatomy
* @tutorial Verbs_VerbProcess
* @tutorial Verbs_ModifyVerbs
* @tutorial Verbs_WriteVerbs
* @classdesc
* <pre class="display border outline">
* <span class="input">> lasso crocagator with rope</span>
* You lasso the crocagator with the woven grass rope. The rope
* slips over the croc's long mouth. You pull, and the croc's
* mouth slams shut. The crocagator thrashes angrily and whips
* its jewel-tipped tail and pulls you off balance. You dig in
* and pull. Step by step, you drag the bellowing crocagator out
* of its watering hole. Soon its magic emerald will be yours.
* </pre>
* <p>
* <strong>Lasso</strong> a
* {@link adventurejs.Tangible|Tangible}
* {@link adventurejs.Asset|Asset} with a
* {@link adventurejs.Rope|Rope}. Asset to be lassoed must have
* asset.dov.lasso.enabled
* set to true. If successful, Rope is tied to other Asset.
* </p>
* @ajsverbreactions
* @ajsverbphases doBeforeTry, doAfterTry, doBeforeSuccess, doAfterSuccess
*/
A.Preverbs.lasso = {
name: "lasso",
prettyname: "lasso",
past_tense: "lassoed",
synonyms: ["lasso"],
verb_noun_prep_noun: ["lasso with"],
player_must_be: {
//not_on_floor: true,
not_constrained: true,
//not_under: true,
//not_behind: true,
},
/**
* @memberof lasso
* @ajsverbphrase
* phrase1:
* {
* accepts_noun:true,
* requires_noun: true,
* noun_must_be:
* {
* known: true,
* tangible: true,
* present: true,
* visible: true,
* },
* },
*/
phrase1: {
accepts_noun: true,
requires_noun: true,
noun_must_be: {
known: true,
tangible: true,
present: true,
visible: true,
},
},
/**
* @memberof lasso
* @ajsverbphrase
* phrase2:
* {
* accepts_noun:true,
* noun_must_be:
* {
* known: true,
* in_inventory: true,
* },
* },
*/
phrase2: {
accepts_noun: true,
noun_must_be: {
known: true,
in_inventory: true,
},
},
/**
* @memberof lasso
* @ajsverbparams
* with_params: {},
*/
with_params: {},
doTry: function () {
var input = this.game.getInput();
var direct_object = input.getAsset(1);
var direct_preposition = input.getPreposition(1);
var indirect_object = input.getAsset(2);
var msg = "";
var player = this.game.getPlayer();
if (!indirect_object) {
input.setSoftPrompt({ noun2: true, verb: "lasso" });
this.game.debug(
`F1330 | ${this.name}.js | no indirect object provided, soft prompt noun2 `
);
msg += "What shall $(we) lasso " + direct_object.articlename + " with?";
this.handleFailure(msg);
return null;
}
if (!direct_object.isDOV("lasso") || !direct_object.isDOV("tie")) {
this.game.debug(
`F1330 | ${this.name}.js | ${direct_object.id}.dov.lasso.enabled and dov.tie.enabled are false `
);
msg += `$(We) can't lasso ${direct_object.articlename}. `;
this.handleFailure(msg);
return null;
}
if (!indirect_object.isIOV("lasso") || !indirect_object.isDOV("tie")) {
this.game.debug(
`F1331 | ${this.name}.js | ${indirect_object.id}.iov.lasso.enabled or .dov.tie.enabled is false `
);
msg += `$(We) can't lasso anything with ${indirect_object.articlename}. `;
this.handleFailure(msg);
return null;
}
return true;
},
doSuccess: function () {
var input = this.game.getInput();
var direct_object = input.getAsset(1);
var direct_preposition = input.getPreposition(1);
var indirect_object = input.getAsset(2);
var player = this.game.getPlayer();
var msg = "";
var results;
this.game.debug(`F1329 | ${this.name}.js | print doSuccess `);
msg += `$(We) lasso ${direct_object.articlename} with ${indirect_object.articlename}. `;
// if( player.$has( indirect_object ) ) {
// // remove thing from player
// results = player.onRemoveThatFromThis( indirect_object );
// if( false === results ) { return false; }
// else if ( null === results ) { return null; }
// // is the rope tied to player?
// }
//results = currentRoom.onMoveThatToThis( direct_object, "in" );
// results = direct_object.onMoveThatToThis( direct_object, "attached" );
// if( false === results ) { return false; }
// else if ( null === results ) { return null; }
results = indirect_object.onTieThisToThat(direct_object);
if ("undefined" !== typeof results) return results;
direct_object.can.support_swinging = true;
indirect_object.is.supported = true;
// if the rope is in inventory, switch to holding
// print output
this.handleSuccess(msg, direct_object);
return true;
},
}; // END p.preverbs.push
})();