Exemplo n.º 1
0
 def __crear_grilla_horizontal(self,graph,mayus):
     matriz = self.__distribuir_palabras()
     print(matriz)
     '''
      Distribuye las palabras por la grilla. METODO PRIVADO
     '''
     dic = dict()
     dicAux = dict()
     y1 = 0
     y2 = 25
     for z in range(len(matriz)):    #cantidad de filas de la matriz
         _x1 = 0
         x2 = 25
         for n in range(len(matriz[z])):     #cantidad de columnas
             pos_sup = (_x1,y1)
             pos_inf = (x2,y2)
             cell = Celda()
             cell.set_coordenada_sup(pos_sup)
             cell.set_coordenada_inf(pos_inf)
             if(mayus == 'Mayuscula'):
                 cell.set_letra(matriz[z][n].upper())
             else:
                 cell.set_letra(matriz[z][n].lower())
             cell.draw_cell(graph)
             self.__dic[(z,n)] = cell
             _x1+=25
             x2+=25
         y1+=25
         y2+=25
Exemplo n.º 2
0
 def __crear_grilla_vertical(self, graph, mayus):
     '''
         Distribuye las palabras por la grilla. METODO PRIVADO
     '''
     matriz = self.__distribuir_palabras()
     _x1 = 0
     x2 = 25
     for z in range(len(matriz)):  #cantidad de columnas
         y1 = 0
         y2 = 25
         for n in range(len(matriz[z])):  #cantidad de filas
             pos_sup = (_x1, y1)
             pos_inf = (x2, y2)
             cell = Celda()
             cell.set_coordenada_sup(pos_sup)
             cell.set_coordenada_inf(pos_inf)
             if (mayus == 'Mayuscula'):
                 cell.set_letra(matriz[z][n].upper())
             else:
                 cell.set_letra(matriz[z][n].lower())
             cell.draw_cell(graph)
             self.__dic[(n, z)] = cell
             y1 += 25
             y2 += 25
         _x1 += 25
         x2 += 25
Exemplo n.º 3
0
    def __init__(self, boardLines=None, level=None):
        """ Constructor."""
        if boardLines != None:
            line1 = boardLines[0].split(" ")
            rest = boardLines[1:]
            mines = 0
            self._rows = int(line1[0])
            self._cols = int(line1[1])
            self._board = []

            for i in rest:
                row = []
                for j in i:
                    if j != '\n':
                        c = Celda(j)
                        row.append(c)
                        if c.mine:
                            mines += 1

                self._board.append(row)

            self._minesLeft = mines

        else:
            self._rows, self._cols = self.DIMENSIONS[level.name]
            self._minesLeft = self.MINES[level.name]
            self.board = level

        self._minesMarked = 0
        self._initTime = time.perf_counter()
        self._ended = False
        self._won = False
        self.configureCells()
Exemplo n.º 4
0
    def board(self, level):
        """ Configura el tablero de forma aleatoria añadiendo el número de
            minas correspondientes al nivel de dificultad """
        rows, cols = self.DIMENSIONS[level.name]
        mLeft = self.minesLeft
        self._board = []

        for i in range(0, rows):
            row = []
            for j in range(0, cols):
                a = rand(0, 5)
                if a == 1 and mLeft > 0:
                    c = Celda('*')
                    mLeft -= 1
                else:
                    c = Celda('.')
                row.append(c)
            self._board.append(row)

        self._minesLeft -= mLeft
Exemplo n.º 5
0
 def construir_tablero(self):
     colores = Color()
     cont = 1
     for i in range(1, 5):
         for j in range(1, 18):
             if j == 1:
                 tipo = TipoDeCelda.LLEGADA
             elif j == 6:
                 tipo = TipoDeCelda.SALIDA
             elif j == 13:
                 tipo = TipoDeCelda.SEGURO
             else:
                 tipo = TipoDeCelda.NORMAL
             celda = Celda(cont, tipo, colores.obtener())
             self.tablero.append(celda)
             cont += 1
     cont = 1
     for i in range(1, 5):
         for j in range(1, 8):
             celda = Celda(cont, TipoDeCelda.CIELO, colores.obtener())
             self.escalera.append(celda)
             cont += 1
Exemplo n.º 6
0
    def graficar(self, efectos=None):
        for f in range(self.filas):
            self.celda.append([])
            for c in range(self.columnas):
                self.celda[f].append(Celda(self.pilas,
                    x=(self.x+c*self.distancia),
                    y=(self.y+f*self.distancia),
                    z=100,
                    color=self.colorDeCelda(c, f),
                    columna=c, fila=f,
                    estiloDeCelda=self.estiloDeCelda))

        if efectos is not None:
            keys = efectos.celdas.keys()
            for k in keys:
                c, f = k.split(" ")
                f=int(f)-1
                c=ord(c)-97
                self.celda[f][c].efecto = fx.generar(efectos.celdas[k])()