//getWordCount.js
(function() {
/*global adventurejs A*/
"use strict";
var p = adventurejs.Game.prototype;
/**
* <p>
* <strong>getWordCount()</strong> is a utility method to get
* a count of all the unique words the game "knows".
* </p>
* @memberOf adventurejs.Game
* @method adventurejs.Game#getWordCount
* @kind function
* @returns {Array}
*/
p.getWordCount = function Game_getWordCount()
{
let unique_words = [];
let keys = Object.keys(this.world_lookup);
for( let index in keys )
{
let key = keys[index];
let words = key.split(" ");
for(let ind in words)
{
let word = words[ind];
if( -1 === word.indexOf('_')
&& -1 === unique_words.indexOf(word)) unique_words.push(word);
}
}
keys = Object.keys(this.dictionary.verb_lookup);
for( let index in keys )
{
let word = keys[index];
if(-1 === unique_words.indexOf(word)) unique_words.push(word);
let sins = this.dictionary.verb_lookup[word].synonyms;
for( let s in sins )
{
let sin = sins[s];
if(-1 === unique_words.indexOf(sin)) unique_words.push(sin);
}
}
unique_words = unique_words.concat( this.dictionary.adjectives );
unique_words = unique_words.concat( this.dictionary.adverbs );
unique_words = unique_words.concat( this.dictionary.prepositions );
return(unique_words);
}
}());