// verb_template.js - Use this file as a template to create new verbs.
(function () {
/*global adventurejs A*/
"use strict";
/**
* @augments {adventurejs.Verb}
* @class verb_template
* @ajsnode game.dictionary.verbs.verb_template
* @ajsconstruct MyGame.createVerb({ "name": "verb_template", [...] });
* @ajsconstructedby adventurejs.Dictionary#createVerb
* @hideconstructor
* @ajsinstanceof Verb
* @ajsnavheading UtilityVerbs
* @summary Summary.
* @tutorial Scripting_VerbSubscriptions
* @tutorial Verbs_VerbAnatomy
* @tutorial Verbs_VerbProcess
* @tutorial Verbs_ModifyVerbs
* @tutorial Verbs_WriteVerbs
* @classdesc Verbs start out as generic objects, which are converted
* to verb class instances at runtime.
* <br/><br/>
* Verbs have access to the global Input object ( game.getInput() ),
* which contains parsed player input.
* tryVerbThis
* tryVerbThis[Preposition]That
* tryVerbThat[Preposition]This
* doVerbThis
* doVerbThis[Preposition]That
* doVerbThat[Preposition]This
* @ajsverbreactions
* @ajsverbphases doBeforeTry, doAfterTry, doBeforeSuccess, doAfterSuccess
*/
A.Preverbs.verb_template = {
name: "verb_template",
prettyname: "verb to",
past_tense: "verbed",
state: "verbed",
unstate: "unverbed",
synonyms: ["verb"],
verb_noun_prep: [],
verb_prep_noun: [],
verb_prep_prep_noun: [],
verb_prep_prep_prep_noun: [],
verb_noun_prep_noun: [],
verb_noun_prep_prep_noun: [],
verb_noun_prep_noun_prep_noun: [],
verb_prep_noun_prep_noun_prep_noun: [],
/**
* @ajsverbstructures
* @memberof verb
*/
accepts_structures: [
"verb",
"verb noun",
"verb preposition noun",
"verb noun preposition noun",
],
/**
* @memberof verb
* @ajsverbphrase
* phrase1:
* {
* accepts_noun: true,
* // requires_noun: true,
* // accepts_plural_noun: true,
* noun_must_be: {
* // direction: true,
* // not_direction: true,
* // tangible: true,
* // intangible: true,
* // character: true,
* // present: true,
* // visible: true,
* // reachable: true,
* // takeable: true,
* // known: true,
* // in_inventory: true,
* // not_in_inventory: true,
* // worn: true,
* // not_worn: true,
* // in_hands: true,
* // not_in_hands: true,
* },
* // accepts_preposition: true,
* // accepts_preposition_without_noun: true,
* // requires_preposition: true,
* // accepts_these_prepositions: [ 'from' ],
* // declines_these_prepositions: [ 'to' ],
* },
*/
phrase1: {
accepts_noun: true,
// requires_noun: true,
// accepts_plural_noun: true,
noun_must_be: {
// direction: true,
// not_direction: true,
// tangible: true,
// intangible: true,
// character: true,
// present: true,
// visible: true,
// reachable: true,
// takeable: true,
// known: true,
// in_inventory: true,
// not_in_inventory: true,
// worn: true,
// not_worn: true,
// in_hands: true,
// not_in_hands: true,
},
// accepts_preposition: true,
// accepts_preposition_without_noun: true,
// requires_preposition: true,
// accepts_these_prepositions: [ 'from' ],
// declines_these_prepositions: [ 'to' ],
},
/**
* @memberof verb
* @ajsverbphrase
* phrase2:
* {
* accepts_noun: true,
* // requires_noun: true,
* // accepts_plural_noun: true,
* noun_must_be: {
* // direction: true,
* // not_direction: true,
* // tangible: true,
* // intangible: true,
* // character: true,
* // present: true,
* // visible: true,
* // reachable: true,
* // takeable: true,
* // known: true,
* // in_inventory: true,
* // not_in_inventory: true,
* // worn: true,
* // not_worn: true,
* // in_hands: true,
* // not_in_hands: true,
* },
* // accepts_preposition: true,
* // accepts_preposition_without_noun: true,
* // requires_preposition: true,
* // accepts_these_prepositions: [ 'from' ],
* // declines_these_prepositions: [ 'to' ],
* },
*/
phrase2: {
// accepts_noun: true,
// requires_noun: true,
// accepts_plural_noun: true,
noun_must_be: {
// direction: true,
// not_direction: true,
// tangible: true,
// intangible: true,
// character: true,
// present: true,
// visible: true,
// reachable: true,
// takeable: true,
// known: true,
// in_inventory: true,
// not_in_inventory: true,
// worn: true,
// not_worn: true,
// in_hands: true,
// not_in_hands: true,
},
// accepts_preposition: true,
// accepts_preposition_without_noun: true,
// requires_preposition: true,
// accepts_these_prepositions: [ 'from' ],
// declines_these_prepositions: [ 'to' ],
},
/**
* @memberof verb
* @ajsverbphrase
* phrase3:
* {
* accepts_noun: true,
* // requires_noun: true,
* // accepts_plural_noun: true,
* noun_must_be: {
* // direction: true,
* // not_direction: true,
* // tangible: true,
* // intangible: true,
* // character: true,
* // present: true,
* // visible: true,
* // reachable: true,
* // takeable: true,
* // known: true,
* // in_inventory: true,
* // not_in_inventory: true,
* // worn: true,
* // not_worn: true,
* // in_hands: true,
* // not_in_hands: true,
* },
* // accepts_preposition: true,
* // accepts_preposition_without_noun: true,
* // requires_preposition: true,
* // accepts_these_prepositions: [ 'from' ],
* // declines_these_prepositions: [ 'to' ],
* },
*/
phrase3: {
// accepts_noun: true,
// requires_noun: true,
// accepts_plural_noun: true,
noun_must_be: {
// direction: true,
// not_direction: true,
// tangible: true,
// intangible: true,
// character: true,
// present: true,
// visible: true,
// reachable: true,
// takeable: true,
// known: true,
// in_inventory: true,
// not_in_inventory: true,
// worn: true,
// not_worn: true,
// in_hands: true,
// not_in_hands: true,
},
// accepts_preposition: true,
// accepts_preposition_without_noun: true,
// requires_preposition: true,
// accepts_these_prepositions: [ 'from' ],
// declines_these_prepositions: [ 'to' ],
},
let_verb_handle_disambiguation: false,
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 indirect_preposition = input.getPreposition(2);
var player = this.game.getPlayer();
var results;
var msg = "";
if (input.hasStructure("verb")) {
// this.game.debug(` | ${this.name}.js | sentence structure 'verb'`);
// msg += this.game.parser.getUnparsedMessage(input.input);
// this.handleFailure(msg);
// return false;
}
if (input.hasStructure("verb noun")) {
// this.game.debug(` | ${this.name}.js | sentence structure 'verb'`);
// msg += this.game.parser.getUnparsedMessage(input.input);
// this.handleFailure(msg);
// return false;
}
if (input.hasStructure("verb preposition")) {
// this.game.debug(` | ${this.name}.js | sentence structure 'verb'`);
// msg += this.game.parser.getUnparsedMessage(input.input);
// this.handleFailure(msg);
// return false;
}
if (input.hasStructure("verb preposition noun")) {
// this.game.debug(` | ${this.name}.js | sentence structure 'verb'`);
// msg += this.game.parser.getUnparsedMessage(input.input);
// this.handleFailure(msg);
// return false;
}
// sentence structure: verb noun preposition noun ----------
if (input.hasStructure("verb noun preposition noun")) {
}
/*
* If any block in doTry returns false, that ends the parse.
* If the parser is working on stacked input (for example,
* "do this THEN do that"), the parser will move to the next
* item in the stack.
*/
},
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 indirect_preposition = input.getPreposition(2);
var player = this.game.getPlayer();
var results;
var msg = "";
this.game.debug(` | ${this.name}.js | doSuccess `);
// sentence structure: verb noun
if (input.hasStructure("verb noun")) {
} // verb noun
// sentence structure: verb preposition noun
if (input.hasStructure("verb preposition noun")) {
} // verb noun
// sentence structure: verb noun preposition noun
if (input.hasStructure("verb noun preposition noun")) {
} // verb noun preposition noun
// apply state changes
//this.setState(direct_object,false);
// compose output
msg += `$(We) ${this.name}`;
msg += `${direct_preposition ? " " + direct_preposition : ""}`;
msg += `${direct_object ? " " + direct_object.articlename : ""}`;
msg += `${indirect_preposition ? " " + indirect_preposition : ""}`;
msg += `${indirect_object ? " " + indirect_object.articlename : ""}`;
msg += `. `;
// print output
this.handleSuccess(msg, direct_object);
return true;
},
};
})(); // verb