// feel.js
(function () {
/* global adventurejs A */
/**
* @augments {adventurejs.Verb}
* @class feel
* @ajsnode game.dictionary.verbs.feel
* @ajsconstruct MyGame.createVerb({ "name": "feel", [...] });
* @ajsconstructedby adventurejs.Dictionary#createVerb
* @hideconstructor
* @ajsinstanceof Verb
* @ajsnavheading SensationVerbs
* @summary Verb meaning feel, as in "feel blob of jelly".
* @tutorial Verbs_Subscriptions
* @tutorial AdvancedVerbs_VerbAnatomy
* @tutorial AdvancedVerbs_VerbProcess
* @tutorial AdvancedVerbs_ModifyVerbs
* @tutorial AdvancedVerbs_ModifyVerbs
* @classdesc
* <pre class="display border outline">
* <span class="ajs-player-input">> feel blob</span>
* You feel the blob. Ew, it's squishy! Oh! And it sticks! In fact, you can't get it off your finger. Oh, uh, and it's starting to burn. You shake your hand in a panic. Not only is the blob not dislodged, but it advances further up your finger, increasing the burning sensation.
* </pre>
* <p>
* <strong>Touch</strong> a
* {@link adventurejs.Tangible|Tangible}
* {@link adventurejs.Asset|Asset}.
* Requires that the Asset to be felt has
* asset.dov.feel.enabled
* set to true. If successful, returns the Asset's
* <code class="property">descriptions.feel</code> property.
* </p>
* @ajsverbreactions
* @ajsverbphases doBeforeTry, doAfterTry, doBeforeSuccess, doAfterSuccess
*/
A.Preverbs.feel = {
name: "feel",
prettyname: "feel",
past_tense: "felt",
synonyms: ["touch", "feel", "finger"],
gerund: "feeling",
/**
* @ajsverbstructures
* @memberof feel
*/
accepts_structures: ["verb noun", "verb noun preposition noun"],
/**
* @memberof feel
* @ajsverbphrase
* phrase1:
* {
* accepts_noun: true,
* requires_noun: true,
* noun_must_be:
* {
* known: true,
* matter: true,
* present_if_tangible: true,
* reachable_if_tangible: true,
* },
* },
*/
phrase1: {
accepts_noun: true,
requires_noun: true,
noun_must_be: {
known: true,
matter: true,
present_if_tangible: true,
reachable_if_tangible: true,
},
},
/**
* @memberof feel
* @ajsverbphrase
* phrase2:
* {
* accepts_noun: true,
* noun_must_be:
* {
* known: true,
* matter: true,
* present_if_tangible: true,
* reachable_if_tangible: true,
* },
* accepts_preposition: true,
* requires_preposition: true,
* },
*/
phrase2: {
accepts_noun: true,
noun_must_be: {
known: true,
matter: true,
present_if_tangible: true,
reachable_if_tangible: true,
},
accepts_preposition: true,
requires_preposition: true,
},
/**
* @memberof feel
* @ajsverbparams
* with_params: {},
*/
with_params: {},
doTry: function () {
var input = this.game.getInput();
var subject = input.getSubject();
var output_class = input.output_class;
var direct_object = input.getAsset(1);
var indirect_preposition = input.getPreposition(2);
var indirect_object = input.getAsset(2);
var room = this.game.getRoom();
var direct_substance;
var indirect_substance;
var results;
var msg = "";
direct_substance = direct_object instanceof adventurejs.Substance;
// sentence structure: verb
if (input.hasStructure("verb")) {
}
// sentence structure: verb noun
if (input.hasStructure("verb noun")) {
} // verb noun
// sentence structure: verb noun
if (input.hasStructure("verb noun preposition noun")) {
indirect_substance = indirect_object instanceof adventurejs.Substance;
} // verb noun
if (!direct_object && input.input_verb === "feel") {
if (room.hasDescription("feel")) {
input.setAsset(1, room);
input.verb_params.source = room.descriptions.feel;
return true;
}
}
if (indirect_object) {
// did player try something like "feel sand in water" ?
// we don't handle it
if (direct_substance && indirect_substance) {
this.game.debug(
`D1641 | ${this.name}.js | both items are substances `
);
msg += `{We} can't ${this.name} ${direct_object.name} ${indirect_preposition} ${indirect_object.name}. `;
this.handleFailure(msg);
return null;
}
if (
direct_substance &&
(!indirect_object.hasAspectAt(indirect_preposition) ||
indirect_object.getAspectAt(indirect_preposition).vessel
.substance_id !== direct_object.id)
) {
this.game.debug(
`D1643 | ${this.name}.js | ${indirect_object.id} does not contain ${direct_object.id} `
);
msg += `${indirect_object.Articlename} doesn't contain ${direct_object.name}. `;
this.handleFailure(msg);
return null;
}
// did player try to feel something in a non-existent aspect?
if (
!indirect_substance &&
!indirect_object.hasAspectAt(indirect_preposition)
) {
this.game.debug(
`D1639 | ${this.name}.js | ${indirect_object.id} has no aspect at ${indirect_preposition} `
);
msg += `There's nothing ${indirect_preposition} ${indirect_object.articlename}. `;
this.handleFailure(msg);
return null;
}
// did player try to feel something in a thing it's not in?
if (
!direct_substance &&
!indirect_substance &&
!direct_object.isWithin(indirect_object)
) {
this.game.debug(
`D1640 | ${this.name}.js | ${direct_object.id} not in ${direct_object.id} `
);
msg += `${direct_object.Articlename} doesn't appear to be ${indirect_preposition} ${indirect_object.articlename}. `;
this.handleFailure(msg);
return null;
}
// did player try to feel something in a substance?
// like "feel toy in sand" ?
if (indirect_substance) {
// is direct_object inside an asset
// that also contains indirect_substance?
var daspect = direct_object.getPlaceAspect();
if (
!daspect ||
!daspect.vessel ||
daspect.vessel.substance_id !== indirect_object.id
) {
this.game.debug(
`D1642 | ${this.name}.js | ${direct_object.id} is not in something that contains ${indirect_object.id} `
);
msg += `${direct_object.Articlename} doesn't appear to be ${indirect_preposition} ${indirect_object.name}. `;
this.handleFailure(msg);
return null;
}
}
} // has indirect_object
if (!direct_object.isDOV(this.name)) {
this.game.debug(
`D1452 | ${this.name}.js | ${direct_object.id}.dov.${this.name}.enabled is false `
);
msg += `{We} can't ${this.name} ${direct_object.articlename}. `;
this.handleFailure(msg);
return null;
}
if (!direct_object.hasDescription(this.name)) {
this.game.debug(
`D1453 | ${this.name}.js | ${direct_object.id}.descriptions.${this.name} is unset `
);
msg += `{We} {don't} ${this.name} anything special. `;
this.handleFailure(msg);
return null;
}
return true;
},
doSuccess: function () {
var input = this.game.getInput();
var subject = input.getSubject();
var direct_object = input.getAsset(1);
var direct_preposition = input.getPreposition(1);
var indirect_object = input.getAsset(2);
var indirect_preposition = input.getPreposition(2);
var results;
var msg = "";
// sentence structure: verb
if (input.hasStructure("verb")) {
}
// sentence structure: verb noun
if (input.hasStructure("verb noun")) {
} // verb noun
msg += `{We} ${this.name} ${direct_object.articlename}. `;
if (input.verb_params.source) {
msg += A.getSAF.call(this.game, input.verb_params.source);
} else if (direct_object.hasDescription(this.name)) {
msg += this.game.getDescription({
asset: direct_object,
identifier: this.name,
});
} else {
msg += `{We} {don't} feel anything in particular. `;
}
// --------------------------------------------------
// print output
// --------------------------------------------------
return this.handleSuccess(msg);
},
};
})(); // feel