blob: 47b105c8e19b143dd1bdfb1c47881e051824d26d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# -*- coding: utf-8 -*-
import random
import os
import datetime
from puzzle import *
class Session:
def __init__(self, topic, difficulty):
self.topic = topic
self.difficulty = difficulty
#obtener puzzles
list_files = os.listdir('./puzzles/' + str(self.difficulty) + '/' + self.topic)
print list_files
self.list_puzzles = []
for item in list_files:
self.list_puzzles.append(Puzzle('./puzzles/' + str(self.difficulty) + '/' + self.topic + '/' + item))
self.time = datetime.datetime.now()
self.old_puzzles = []
self.score=0
def nextPuzzle(self):
l=len(self.list_puzzles)
if l>0:
i = random.randrange(0, l)
self.old_puzzles.append(self.list_puzzles[i])
self.current=self.list_puzzles.pop(i)
return True
else:
self.current.question='Juego Terminado\nPuntaje='+str(self.score)
return False
def currentPuzzle(self):
return self.current
def evaluateAnswer(self,answer):
test=self.currentPuzzle().evaluateAnswer(answer)
if test:
self.score+=self.currentPuzzle().getScore()
return test
def __str__(self):
return 'SesiĆ³n de topico = ' + str(self.topic) + ' y dificultad = ' + str(self.difficulty)
|