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 = []
for i in range(0, len(self.answers)):
ss = []
for j in range(0, len(self.questions)):
ss.append(self.answers[(j+i) % len(self.answers)][j])
s.append( '\n'.join(ss) )
return '\n--------------\n'.join(s)
def getStatus(self):
return { "questions": self.questions, "answers": len(self.answers) }
games = {}
questions = {}