class TriviaMaster
  def initialize()
    @questions = []

    File.open("triv_questions_new.txt").each_line{|line|
      @questions.push(line)
    }    
  end
  
  def get_question()
    q = @questions.sample
    questionBits = q.split('*')
#    m.reply questionBits.inspect

    qData = {}
    qData['question'] = questionBits[0].strip
    qData['answer'] = questionBits[1].strip
 
    # mask this somehow.  answer "I did it" would become "* *** **"
    mask = ""
    questionBits[1].strip().each_char{|c| 
      # this is so ugly.
      if c == '-' or c == '\'' or c == ':' or c == "," or c == "." or c == "!" or c == "?" or c == "%" or c == "&" then 
        mask = mask + c
      elsif c == ' ' then
        mask = mask + ' '
      else
        mask = mask + '*' 
      end
    }

    qData['answer_mask'] = mask 

    return qData
  end
end
