// swing_at.js
(function () {
/*global adventurejs A*/
"use strict";
/**
* @augments {adventurejs.Verb}
* @class swing_at
* @ajsnode game.dictionary.verbs.swing_at
* @ajsconstruct MyGame.createVerb({ "name": "swing_at", [...] });
* @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">> </span>
*
* </pre>
* <p>
* Description of the verb.
* </p>
*/
A.Preverbs.swing_at = {
name: "swing_at",
prettyname: "swing",
synonyms: [],
verb_noun_prep_noun: ["swing at"],
phrase1: {
accepts_noun: true,
requires_noun: true,
noun_must_be: {
in_hands: true,
},
},
phrase2: {
accepts_noun: true,
requires_noun: true /* @todo kill on consolidation */,
//accepts_preposition: true,
//requires_preposition: true,
//accepts_these_prepositions: [ 'at' ], /* @todo */
noun_must_be: {
known: true,
tangible: true,
present: true,
visible: true,
//reachable: true,
},
},
doTry: function () {
var input = this.game.getInput();
var direct_object = input.getAsset(1);
var indirect_object = input.getAsset(2);
var player = this.game.getPlayer();
if (false === direct_object.can.be_swung) {
var msg = "$(We) can't swing " + direct_object.articlename + ". ";
this.handleFailure(msg);
return false;
}
if (false === indirect_object.can.be_swung_at) {
var msg =
"$(We) can't swing anything at " + indirect_object.articlename + ". ";
this.handleFailure(msg);
return false;
}
// TODO
// is some special condition preventing player from dropping item?
// underwater
// zero gravity
return true;
},
doSuccess: function () {
var input = this.game.getInput();
console.log("swingat.doSuccess");
var direct_object = input.getAsset(1);
var indirect_object = input.getAsset(2);
var player = this.game.getPlayer();
var currentRoom = this.game.getCurrentRoom();
var msg =
"$(We) swing " +
direct_object.articlename +
" at " +
indirect_object.articlename +
", and it bounces off. ";
direct_object.incrementDoVerbCount("swing");
indirect_object.incrementDoVerbCount("swing");
this.handleSuccess(msg, direct_object);
return true;
},
};
})(); // swing_at