Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/session.py
blob: 81fc3b353e975beb7150241ff71a0450136c074b (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
# -*- 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.nextPuzzle()

    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 self.current
        else:
            return False

    def currentPuzzle(self):
        return self.current
    
    def __str__(self):
        return 'SesiĆ³n de topico = ' + str(self.topic) + ' y dificultad = ' + str(self.difficulty)