// Rope.js
(function () {
/*global adventurejs A*/
"use strict";
/**
* @ajspath adventurejs.Atom.Asset.Matter.Tangible.Thing.Rope
* @augments adventurejs.Thing
* @class adventurejs.Rope
* @ajsconstruct MyGame.createAsset({ "class":"Rope", "name":"foo", [...] })
* @ajsconstructedby adventurejs.Game#createAsset
* @ajsnavheading MiscAssetClasses
* @param {String} game_name The name of the top level game object.
* @param {String} name A name for the object, to be serialized and used as ID.
* @summary Tie to things, tie things to other things.
* @classdesc
* <p>
* <strong>Rope</strong> is a subclass of
* {@link adventurejs.Thing|Thing} that can be tied
* to other Things. Ropes can be used to lasso other Things,
* and can be used to swing across other things.
* In theory a Rope can be tied to an item in a Room
* and stretched across multiple Rooms.
* </p>
* <h3 class="examples">Example:</h3>
* <pre class="display"><code class="language-javascript">MyGame.createAsset({
* class: "Rope",
* name: "rope",
* place: { in: "Standing Room" },
* description: "It's a cotton rope. ",
* adjectives: [ "cotton" ],
* can: { be_in_multiple_rooms: false, },
* length_in_rooms: 1,
* });
* </code></pre>
**/
class Rope extends adventurejs.Thing {
constructor(name, game_name) {
super(name, game_name);
this.class = "Rope";
this.singlePluralPairs = [["rope", "ropes"]];
this.setDOVs([
"hold",
"take",
"give",
"untie",
"tie",
"pull",
"lasso",
"tie",
]);
this.unsetDOV("cut"); // ??
this.descriptions.look = "It's a rope.";
this.can.be_in_multiple_rooms = false;
this.length_in_rooms = 0; // TODO traveling with rope
this.can_cut_in_half = false; // ??
//this.can.swing_on_if_holding = true;
//this.must_be_supported_to_swing_on = true;
this.can.swing_on_if_holding_and_supported = true;
this.must.let_go_after_swing = true;
}
/**
* A rope that is tied to things can be held but not taken.
* @var adventurejs.Rope#can_hold
*/
get can_hold() {
var bool = false;
var player = this.game.getPlayer();
if (
this.dov.tie?.with_params.connections.length ===
this.dov.tie.with_params.max_connections
) {
bool = true;
}
return bool;
}
}
adventurejs.Rope = Rope;
})();