import uuid
def filterId(id):
r = []
for c in str(id):
if c.isalnum():
r.append(c)
return ''.join(r)
class Game:
def __init__(self, questions):
self.id = filterId(uuid.uuid4())
self.questions = questions
self.answers = [ ]
games[self.id] = self
def addAnswers(self, answers):
answers = [str(a) for a in answers][0:len(self.questions)]
while len(answers) < len(self.questions):
answers.append('')
self.answers.append(answers)
def getStory(self):
s = ''
if self.answers:
for i in range(0, len(self.questions)):
s = s + self.answers[i % len(self.answers)][i] + "\n"
return s
def getStatus(self):
return { "questions": self.questions, "answers": len(self.answers) }
games = {}
questions = {}