 # Command:
 #
 # Author:
-#   NNA
+#   Robert Carroll
 
 moment = require 'moment'
+_ = require('underscore')
 
-question_bank = [
-		{
-			id: 0
-			question: "What's the quietest thing you can hear?"
-			answers: []
-		}
-		{
-			id: 1
-			question: "What makes me unique? "
-			answers: []
-		}
-		{
-			id: 2
-			question: "What one word would you use to describe me?"
-			answers: []
-		}
-	]	
+initial_question_bank = {
+	1: {question: "What's the quietest thing you can hear?", my_answer: '', answers: []},
+	2: {question: "What one word would you use to describe me?", my_answer: '', answers: []}
+	3: {question: "What makes me unique?", my_answer: '', answers: []}
+}
 
 # Varied response
 response_to_answer = ["I see. ", "Interesting. "]

# Description:
#   Respond to custom answers
#
# Dependencies:

        a[i] = t
    a

		getQuestion = (cb) -> 
			shuffle (question_ids)
			current_question = question_ids[0]
			if _.isUndefined(current_question)
				question_text = "Thanks for talking to me. "
			else 	 			
				used_questions.push current_question
				robot.logger.info used_questions
				question_ids = _.difference(question_ids, used_questions)
				question_text = question_bank[current_question].question
			cb question_text

		robot.hear /chat/i, (msg) ->
			getQuestion (question_text) ->  			
				msg.send question_text

		robot.hear /answer (.*)$/i, (msg) ->
			answer = msg.match[1]
			current_question_answers = question_bank[current_question].answers
			current_question_answers.push answer
			answers_without_current = current_question_answers.filter (exclude_current) -> exclude_current isnt answer	
			shuffled_answer = shuffle (answers_without_current)
			getQuestion (question_text) ->
				robot.logger.info robot.brain.data.questions
				msg.send [msg.random response_to_answer] + [if shuffled_answer.length > 0 then 'Someone else told me ' + "'" + shuffled_answer[0] + "'. "] + question_text
