// incrementTryVerbCount.js
(function() {
/*global adventurejs A*/
"use strict";
var p = adventurejs.Asset.prototype;
/**
* <strong>incrementTryVerbCount</strong> takes a verb and an index and
* updates this asset's count of the number of times the verb has
* attempted upon it.
* @method adventurejs.Asset#incrementTryVerbCount
* @memberOf adventurejs.Asset
* @param {String} verb
* @param {Int} index
*/
p.incrementTryVerbCount = function Asset_incrementTryVerbCount( verb, index )
{
this.did_try_verb[verb] = true;
var linked_asset;
if( this.linked_asset )
{
linked_asset = this.game.getAsset( this.linked_asset );
if(linked_asset) linked_asset.did_try_verb[verb] = true;
}
if( !this.did_try_verb_count[ verb ] )
{
this.did_try_verb_count[ verb ] = { all:1, noun1:0, noun2:0, noun3:0 };
if( linked_asset ) linked_asset.did_try_verb_count[ verb ] = { all:1, noun1:0, noun2:0, noun3:0 };
}
else
{
this.did_try_verb_count[ verb ].all++;
if( linked_asset ) linked_asset.did_try_verb_count[ verb ].all++;
}
if( index )
{
// we have two verb counting systems
// did_try_verb_count is the original
// it counts verb attempts on all assets
// regardless of verb subscriptions
this.did_try_verb_count[ verb ][ "noun" + index ]++;
if( linked_asset ) linked_asset.did_try_verb_count[ verb ][ "noun" + index ]++;
// DOVincrementTryCount came with verb subscriptions
// it only counts verb attempts
// on assets with verb subscriptions
switch(index){
case 1: this.DOVincrementTryCount( verb ); break;
case 2:
if(this.isIOV(verb) )
{
this.IOVincrementTryCount( verb );
}
// noun2 is usually indirect object but
// may be a direct object with some verbs
else if(this.isDOV(verb) )
{
this.DOVincrementTryCount( verb );
}
break;
case 3: this.IOVincrementTryCount( verb ); break;
}
}
}
}());