// getLongestKey.js
(function () {
/* global adventurejs A */
var p = adventurejs.Game.prototype;
/**
* Get the key with the longest word count in the
* world lookup table.
* Used for iterating through lookup table from longest
* to shortest.
* @method adventurejs.Game#getLongestKey
* @memberOf adventurejs.Game
*/
p.getLongestKey = function Game_getLongestLookup() {
var lookupKeys = Object.keys(this.game.world_lookup);
var maxwords = 0;
// figure the longest word count
for (var l = 0; l < lookupKeys.length; l++) {
var length = lookupKeys[l].split(" ").length;
if (length > maxwords) {
maxwords = length;
}
}
this.game.longest_key = maxwords;
};
})();