Example #1
0
 def otrosAtaquesA1H8(self, pz, desde, hasta):
     self.calculaEstado()
     li = self.listaMovimientos()
     posDesde = Movimientos.a1Pos(desde)
     posHasta = Movimientos.a1Pos(hasta)
     lir = []
     for movim in li:
         if movim.pz == pz and posHasta == movim.npos and posDesde != movim.apos:
             lir.append(Movimientos.posA1(movim.apos))
     return lir
Example #2
0
 def otrosAtaquesA1H8(self, pz, desde, hasta):
     self.calculaEstado()
     li = self.listaMovimientos()
     posDesde = Movimientos.a1Pos(desde)
     posHasta = Movimientos.a1Pos(hasta)
     lir = []
     for movim in li:
         if movim.pz == pz and posHasta == movim.npos and posDesde != movim.apos:
             lir.append(Movimientos.posA1(movim.apos))
     return lir
Example #3
0
    def posAtacada(self, pos):

        f, c = Movimientos.posFC(pos)

        FCpos = Movimientos.FCpos

        def mp(fi, ci, contras):
            for x in range(1, 8):
                ft = f + fi * x
                if ft < 0 or ft > 7:
                    break
                ct = c + ci * x
                if ct < 0 or ct > 7:
                    break
                pt = FCpos(ft, ct)
                pz = self.tb[pt]
                if pz:
                    return pz in contras

        contras = "rq" if self.siW else "RQ"
        for fi, ci in ((+1, 0), (-1, 0), (0, +1), (0, -1)):
            if mp(fi, ci, contras):
                return True

        contras = "qb" if self.siW else "QB"
        for fi, ci in ((+1, +1), (-1, -1), (+1, -1), (-1, +1)):
            if mp(fi, ci, contras):
                return True

        def mp1(contra, li):
            if self.siW:
                contra = contra.lower()
            for fi, ci in li:
                ft = f + fi
                if ft < 0 or ft > 7:
                    continue
                ct = c + ci
                if ct < 0 or ct > 7:
                    continue
                pt = FCpos(ft, ct)
                pz = self.tb[pt]
                if pz == contra:
                    return True

        # Caballo
        if mp1("N", ((+1, +2), (+1, -2), (-1, +2), (-1, -2), (+2, +1),
                     (+2, -1), (-2, +1), (-2, -1))):
            return True

        # Peon
        if mp1("P", ((+1, +1), (+1, -1)) if self.siW else
               ((-1, -1), (-1, +1))):
            return True

        # Rey
        if mp1("K", ((+1, +1), (+1, -1), (-1, +1), (-1, -1), (+1, 0), (-1, 0),
                     (0, +1), (0, -1))):
            return True

        return False
Example #4
0
    def posAtacada(self, pos):

        f, c = Movimientos.posFC(pos)

        FCpos = Movimientos.FCpos

        def mp(fi, ci, contras):
            for x in range(1, 8):
                ft = f + fi * x
                if ft < 0 or ft > 7:
                    break
                ct = c + ci * x
                if ct < 0 or ct > 7:
                    break
                pt = FCpos(ft, ct)
                pz = self.tb[pt]
                if pz:
                    return pz in contras

        contras = "rq" if self.siW else "RQ"
        for fi, ci in ( (+1, 0), (-1, 0), (0, +1), (0, -1) ):
            if mp(fi, ci, contras):
                return True

        contras = "qb" if self.siW else "QB"
        for fi, ci in ( (+1, +1), (-1, -1), (+1, -1), (-1, +1) ):
            if mp(fi, ci, contras):
                return True

        def mp1(contra, li):
            if self.siW:
                contra = contra.lower()
            for fi, ci in li:
                ft = f + fi
                if ft < 0 or ft > 7:
                    continue
                ct = c + ci
                if ct < 0 or ct > 7:
                    continue
                pt = FCpos(ft, ct)
                pz = self.tb[pt]
                if pz == contra:
                    return True

        # Caballo
        if mp1("N", ( (+1, +2), (+1, -2), (-1, +2), (-1, -2), (+2, +1), (+2, -1), (-2, +1), (-2, -1) )):
            return True

        # Peon
        if mp1("P", ( (+1, +1), (+1, -1) ) if self.siW else ( (-1, -1), (-1, +1) )):
            return True

        # Rey
        if mp1("K", ( (+1, +1), (+1, -1), (-1, +1), (-1, -1), (+1, 0), (-1, 0), (0, +1), (0, -1) )):
            return True

        return False
Example #5
0
 def hazK(pos):
     f, c = Movimientos.posFC(pos)
     for fi, ci, pts in lidomk:
         ft = f + fi
         if ft < 0 or ft > 7:
             continue
         ct = c + ci
         if ct < 0 or ct > 7:
             continue
         pt = FCpos(ft, ct)
         if pts > dom[pt]:
             dom[pt] = pts
Example #6
0
 def hazK(pos):
     f, c = Movimientos.posFC(pos)
     for fi, ci, pts in lidomk:
         ft = f + fi
         if ft < 0 or ft > 7:
             continue
         ct = c + ci
         if ct < 0 or ct > 7:
             continue
         pt = FCpos(ft, ct)
         if pts > dom[pt]:
             dom[pt] = pts
Example #7
0
 def conv(self, pos):
     f, c = Movimientos.posFC(pos)
     return chr(c + 97) + str(f + 1)
Example #8
0
    def __init__(self, pilas):
        self.pilas = pilas
        self.config = data.Configuracion()
        #Se crea instancia de movimientos , donde estaran todos los movientos
        #almacenados de la manera de tupla ('moviento',cantidad de veces)
        self.moves = Movimientos.iniciar()
        self.giro = (-1, -1)

        #variable para habilitar o deshabilitar los botones!
        self.estado_botones = False
        #inicializo variables
        self.numb = False
        self.retorn_boton_ant = False
        self.press = 0
        #MATRIZ INICIO PARA POSICIONES DE LOS BOTONES NUMERICOS
        self.posiciones = lib.Matriz(3, 3)
        y = 432
        for filas in range(0, 3):
            x = -2000
            for columnas in range(0, 3):
                self.posiciones.set_valor(filas, columnas, (x, y))
                x = x + 135
            y = y - 129

        #MATRIZ INICIO PARA POSICIONES DE CONTROL FLECHAS

        self.posiciones_flechas = lib.Matriz(3, 3)
        y = -134
        for filas in range(0, 3):
            x = -2000
            for columnas in range(0, 3):
                self.posiciones_flechas.set_valor(filas, columnas, (x, y))
                x = x + 135
            y = y - 129

        self.control_prompt = prompt.ControladorDePrompt(self.pilas)

        self.boton_1 = self.pilas.actores.Boton(
            x=self.posiciones.get_valor(0, 0)[0],
            y=432,
            ruta_normal='imag/comando/1off.png',
            ruta_press='imag/comando/1on.png',
            ruta_over='imag/comando/1i.png')
        self.boton_1.conectar_presionado(self.__set_1)
        self.boton_1.conectar_sobre(self.boton_1.pintar_sobre)
        self.boton_1.conectar_normal(self.boton_1.pintar_normal)
        self.boton_1.aprender(self.pilas.habilidades.Arrastrable)

        self.boton_2 = self.pilas.actores.Boton(
            x=self.posiciones.get_valor(0, 1)[0],
            y=self.posiciones.get_valor(0, 1)[1],
            ruta_normal='imag/comando/2off.png',
            ruta_press='imag/comando/2on.png',
            ruta_over='imag/comando/2i.png')
        self.boton_2.conectar_presionado(self.__set_2)
        self.boton_2.conectar_sobre(self.boton_2.pintar_sobre)
        self.boton_2.conectar_normal(self.boton_2.pintar_normal)

        self.boton_3 = self.pilas.actores.Boton(
            x=self.posiciones.get_valor(0, 2)[0],
            y=self.posiciones.get_valor(0, 2)[1],
            ruta_normal='imag/comando/3off.png',
            ruta_press='imag/comando/3on.png',
            ruta_over='imag/comando/3i.png')
        self.boton_3.conectar_presionado(self.__set_3)
        self.boton_3.conectar_sobre(self.boton_3.pintar_sobre)
        self.boton_3.conectar_normal(self.boton_3.pintar_normal)

        self.boton_4 = self.pilas.actores.Boton(
            x=self.posiciones.get_valor(1, 0)[0],
            y=self.posiciones.get_valor(1, 0)[1],
            ruta_normal='imag/comando/4off.png',
            ruta_press='imag/comando/4on.png',
            ruta_over='imag/comando/4i.png')
        self.boton_4.conectar_presionado(self.__set_4)
        self.boton_4.conectar_sobre(self.boton_4.pintar_sobre)
        self.boton_4.conectar_normal(self.boton_4.pintar_normal)

        self.boton_5 = self.pilas.actores.Boton(
            x=self.posiciones.get_valor(1, 1)[0],
            y=self.posiciones.get_valor(1, 1)[1],
            ruta_normal='imag/comando/5off.png',
            ruta_press='imag/comando/5on.png',
            ruta_over='imag/comando/5i.png')
        self.boton_5.conectar_presionado(self.__set_5)
        self.boton_5.conectar_sobre(self.boton_5.pintar_sobre)
        self.boton_5.conectar_normal(self.boton_5.pintar_normal)

        self.boton_6 = self.pilas.actores.Boton(
            x=self.posiciones.get_valor(1, 2)[0],
            y=self.posiciones.get_valor(1, 2)[1],
            ruta_normal='imag/comando/6off.png',
            ruta_press='imag/comando/6on.png',
            ruta_over='imag/comando/6i.png')
        self.boton_6.conectar_presionado(self.__set_6)
        self.boton_6.conectar_sobre(self.boton_6.pintar_sobre)
        self.boton_6.conectar_normal(self.boton_6.pintar_normal)

        self.boton_7 = self.pilas.actores.Boton(
            x=self.posiciones.get_valor(2, 0)[0],
            y=self.posiciones.get_valor(2, 0)[1],
            ruta_normal='imag/comando/7off.png',
            ruta_press='imag/comando/7on.png',
            ruta_over='imag/comando/7i.png')
        self.boton_7.conectar_presionado(self.__set_7)
        self.boton_7.conectar_sobre(self.boton_7.pintar_sobre)
        self.boton_7.conectar_normal(self.boton_7.pintar_normal)

        self.boton_8 = self.pilas.actores.Boton(
            x=self.posiciones.get_valor(2, 1)[0],
            y=self.posiciones.get_valor(2, 1)[1],
            ruta_normal='imag/comando/8off.png',
            ruta_press='imag/comando/8on.png',
            ruta_over='imag/comando/8i.png')
        self.boton_8.conectar_presionado(self.__set_8)
        self.boton_8.conectar_sobre(self.boton_8.pintar_sobre)
        self.boton_8.conectar_normal(self.boton_8.pintar_normal)

        self.boton_9 = self.pilas.actores.Boton(
            x=self.posiciones.get_valor(2, 2)[0],
            y=self.posiciones.get_valor(2, 2)[1],
            ruta_normal='imag/comando/9off.png',
            ruta_press='imag/comando/9on.png',
            ruta_over='imag/comando/9i.png')
        self.boton_9.conectar_presionado(self.__set_9)
        self.boton_9.conectar_sobre(self.boton_9.pintar_sobre)
        self.boton_9.conectar_normal(self.boton_9.pintar_normal)

        self.boton_up = self.pilas.actores.Boton(
            x=self.posiciones_flechas.get_valor(0, 1)[0],
            y=self.posiciones_flechas.get_valor(0, 1)[1],
            ruta_normal='imag/comando/arribaoff.png',
            ruta_press='imag/comando/arribaon.png',
            ruta_over='imag/comando/arribai.png')
        self.boton_up.conectar_presionado(self.__up)
        self.boton_up.conectar_sobre(self.boton_up.pintar_sobre)
        self.boton_up.conectar_normal(self.boton_up.pintar_normal)

        self.boton_left = self.pilas.actores.Boton(
            x=self.posiciones_flechas.get_valor(1, 0)[0],
            y=self.posiciones_flechas.get_valor(1, 0)[1],
            ruta_normal='imag/comando/izquierdaoff.png',
            ruta_press='imag/comando/izquierdaon.png',
            ruta_over='imag/comando/izquierdai.png')
        self.boton_left.conectar_presionado(self.__izquierda)
        self.boton_left.conectar_sobre(self.boton_left.pintar_sobre)
        self.boton_left.conectar_normal(self.boton_left.pintar_normal)

        self.boton_right = self.pilas.actores.Boton(
            x=self.posiciones_flechas.get_valor(1, 2)[0],
            y=self.posiciones_flechas.get_valor(1, 2)[1],
            ruta_normal='imag/comando/derechaoff.png',
            ruta_press='imag/comando/derechaon.png',
            ruta_over='imag/comando/derechai.png')
        self.boton_right.conectar_presionado(self.__derecha)
        self.boton_right.conectar_sobre(self.boton_right.pintar_sobre)
        self.boton_right.conectar_normal(self.boton_right.pintar_normal)

        self.boton_down = self.pilas.actores.Boton(
            x=self.posiciones_flechas.get_valor(2, 1)[0],
            y=self.posiciones_flechas.get_valor(2, 1)[1],
            ruta_normal='imag/comando/abajooff.png',
            ruta_press='imag/comando/abajoon.png',
            ruta_over='imag/comando/abajoi.png')
        self.boton_down.conectar_presionado(self.__down)
        self.boton_down.conectar_sobre(self.boton_down.pintar_sobre)
        self.boton_down.conectar_normal(self.boton_down.pintar_normal)

        #self.boton_duinobot=pilas.actores.boton.Boton(x=1152,y=-1085,ruta_normal='imag/comando/Controles/robotnul.png', ruta_press='imag/comando/Controles/roboton.png', ruta_over='imag/comando/Controles/robotover.png')
        #self.boton_duinobot.conectar_presionado(self.__duinobot)
        #self.boton_duinobot.conectar_sobre(self.boton_duinobot.pintar_sobre)
        #self.boton_duinobot.conectar_normal(self.boton_duinobot.pintar_normal)
        #self.boton_duinobot.y= pilas.interpolar(-485,tipo='lineal',demora=4 , duracion=2)

        self.sumador = 0

        self.posiciones = lib.Matriz(3, 3)
        y = 432
        for filas in range(0, 3):
            x = -1235

            for columnas in range(0, 3):
                self.posiciones.set_valor(filas, columnas, (x, y))
                x = x + 135
            y = y - 129

        self.posiciones_flechas = lib.Matriz(3, 3)
        y = -134
        for filas in range(0, 3):
            x = -1235
            for columnas in range(0, 3):
                self.posiciones_flechas.set_valor(filas, columnas, (x, y))
                x = x + 135
            y = y - 129

        if self.config.graficos and not self.config.lvlup:
            ## comienZo de todas las interpolaciones de los botones
            #self.boton_1.x=pilas.interpolar(self.posiciones.get_valor(0,0)[0],tipo='lineal',demora=1 , duracion=2)
            self.pilas.utils.interpolar(self.boton_1,
                                        'x',
                                        self.posiciones.get_valor(0, 0)[0],
                                        tipo='lineal',
                                        duracion=2)
            self.pilas.utils.interpolar(self.boton_1,
                                        'y',
                                        self.posiciones.get_valor(0, 0)[1],
                                        tipo='lineal',
                                        duracion=2)
            self.pilas.utils.interpolar(self.boton_2,
                                        'x',
                                        self.posiciones.get_valor(0, 1)[0],
                                        tipo='lineal',
                                        duracion=2)
            self.pilas.utils.interpolar(self.boton_2,
                                        'y',
                                        self.posiciones.get_valor(0, 1)[1],
                                        tipo='lineal',
                                        duracion=2)
            self.pilas.utils.interpolar(self.boton_3,
                                        'x',
                                        self.posiciones.get_valor(0, 2)[0],
                                        tipo='lineal',
                                        duracion=2)
            self.pilas.utils.interpolar(self.boton_3,
                                        'y',
                                        self.posiciones.get_valor(0, 2)[1],
                                        tipo='lineal',
                                        duracion=2)
            self.pilas.utils.interpolar(self.boton_4,
                                        'x',
                                        self.posiciones.get_valor(1, 0)[0],
                                        tipo='lineal',
                                        duracion=2)
            self.pilas.utils.interpolar(self.boton_4,
                                        'y',
                                        self.posiciones.get_valor(1, 0)[1],
                                        tipo='lineal',
                                        duracion=2)
            self.pilas.utils.interpolar(self.boton_5,
                                        'x',
                                        self.posiciones.get_valor(1, 1)[0],
                                        tipo='lineal',
                                        duracion=2)
            self.pilas.utils.interpolar(self.boton_5,
                                        'y',
                                        self.posiciones.get_valor(1, 1)[1],
                                        tipo='lineal',
                                        duracion=2)
            self.pilas.utils.interpolar(self.boton_6,
                                        'x',
                                        self.posiciones.get_valor(1, 2)[0],
                                        tipo='lineal',
                                        duracion=2)
            self.pilas.utils.interpolar(self.boton_6,
                                        'y',
                                        self.posiciones.get_valor(1, 2)[1],
                                        tipo='lineal',
                                        duracion=2)
            self.pilas.utils.interpolar(self.boton_7,
                                        'x',
                                        self.posiciones.get_valor(2, 0)[0],
                                        tipo='lineal',
                                        duracion=2)
            self.pilas.utils.interpolar(self.boton_7,
                                        'y',
                                        self.posiciones.get_valor(2, 0)[1],
                                        tipo='lineal',
                                        duracion=2)
            self.pilas.utils.interpolar(self.boton_8,
                                        'x',
                                        self.posiciones.get_valor(2, 1)[0],
                                        tipo='lineal',
                                        duracion=2)
            self.pilas.utils.interpolar(self.boton_8,
                                        'y',
                                        self.posiciones.get_valor(2, 1)[1],
                                        tipo='lineal',
                                        duracion=2)
            self.pilas.utils.interpolar(self.boton_9,
                                        'x',
                                        self.posiciones.get_valor(2, 2)[0],
                                        tipo='lineal',
                                        duracion=2)
            self.pilas.utils.interpolar(self.boton_9,
                                        'y',
                                        self.posiciones.get_valor(2, 0)[1],
                                        tipo='lineal',
                                        duracion=2)
            self.pilas.utils.interpolar(self.boton_up,
                                        'x',
                                        self.posiciones_flechas.get_valor(
                                            0, 1)[0],
                                        tipo='lineal',
                                        duracion=2)
            self.pilas.utils.interpolar(self.boton_up,
                                        'y',
                                        self.posiciones_flechas.get_valor(
                                            0, 1)[1],
                                        tipo='lineal',
                                        duracion=2)
            self.pilas.utils.interpolar(self.boton_down,
                                        'x',
                                        self.posiciones_flechas.get_valor(
                                            2, 1)[0],
                                        tipo='lineal',
                                        duracion=2)
            self.pilas.utils.interpolar(self.boton_down,
                                        'y',
                                        self.posiciones_flechas.get_valor(
                                            2, 1)[1],
                                        tipo='lineal',
                                        duracion=2)
            self.pilas.utils.interpolar(self.boton_left,
                                        'x',
                                        self.posiciones_flechas.get_valor(
                                            1, 0)[0],
                                        tipo='lineal',
                                        duracion=2)
            self.pilas.utils.interpolar(self.boton_left,
                                        'y',
                                        self.posiciones_flechas.get_valor(
                                            1, 0)[1],
                                        tipo='lineal',
                                        duracion=2)
            self.pilas.utils.interpolar(self.boton_right,
                                        'x',
                                        self.posiciones_flechas.get_valor(
                                            1, 2)[0],
                                        tipo='lineal',
                                        duracion=2)
            self.pilas.utils.interpolar(self.boton_right,
                                        'y',
                                        self.posiciones_flechas.get_valor(
                                            1, 2)[1],
                                        tipo='lineal',
                                        duracion=2)

        else:
            self.boton_1.x = self.posiciones.get_valor(0, 0)[0]
            self.boton_1.y = self.posiciones.get_valor(0, 0)[1]
            self.boton_2.x = self.posiciones.get_valor(0, 1)[0]
            self.boton_2.y = self.posiciones.get_valor(0, 1)[1]
            self.boton_3.x = self.posiciones.get_valor(0, 2)[0]
            self.boton_3.y = self.posiciones.get_valor(0, 2)[1]
            self.boton_4.x = self.posiciones.get_valor(1, 0)[0]
            self.boton_4.y = self.posiciones.get_valor(1, 0)[1]
            self.boton_5.x = self.posiciones.get_valor(1, 1)[0]
            self.boton_5.y = self.posiciones.get_valor(1, 1)[1]
            self.boton_6.x = self.posiciones.get_valor(1, 2)[0]
            self.boton_6.y = self.posiciones.get_valor(1, 2)[1]
            self.boton_7.x = self.posiciones.get_valor(2, 0)[0]
            self.boton_7.y = self.posiciones.get_valor(2, 0)[1]
            self.boton_8.x = self.posiciones.get_valor(2, 1)[0]
            self.boton_8.y = self.posiciones.get_valor(2, 1)[1]
            self.boton_9.x = self.posiciones.get_valor(2, 2)[0]
            self.boton_9.y = self.posiciones.get_valor(2, 0)[1]

            self.boton_up.x = self.posiciones_flechas.get_valor(0, 1)[0]
            self.boton_up.y = self.posiciones_flechas.get_valor(0, 1)[1]
            self.boton_down.x = self.posiciones_flechas.get_valor(2, 1)[0]
            self.boton_down.y = self.posiciones_flechas.get_valor(2, 1)[1]
            self.boton_left.x = self.posiciones_flechas.get_valor(1, 0)[0]
            self.boton_left.y = self.posiciones_flechas.get_valor(1, 0)[1]
            self.boton_right.x = self.posiciones_flechas.get_valor(1, 2)[0]
            self.boton_right.y = self.posiciones_flechas.get_valor(1, 2)[1]
Example #9
0
             Mapa[f][c] = '4'
             Mapa[f][c - 1] = '0'
             c = c - 1
         elif Mov == "w":
             Mapa[f][c] = '4'
             Mapa[f - 1][c] = '0'
             f = f - 1
         elif Mov == "s":
             Mapa[f][c] = '4'
             Mapa[f][c + 1] = '0'
             f = f + 1
         elif Mov == "b":
             bomba = False
 elif Mov == "d" or Mov == "D":
     print "D"
     F.Der(f, c, Mapa)
     c = c + 1
 elif Mov == "a" or Mov == "A":
     print "A"
     F.Izq(f, c, Mapa)
     c = c - 1
 elif Mov == "w" or Mov == "W":
     print "W"
     F.Arb(f, c, Mapa)
     f = f - 1
 elif Mov == "s" or Mov == "S":
     print "S"
     F.Abj(f, c, Mapa)
     f = f + 1
 else:
     print "Opps! Tecla incorrecta"
Example #10
0
 def conv(self, pos):
     f, c = Movimientos.posFC(pos)
     return chr(c + 97) + str(f + 1)
Example #11
0
 def evalua(self):
     source = self.sender()
     self.fila=source.coor.x()
     self.col=source.coor.y()
     
 ###Validaciones piezas blancas
 
     if self.turno and source.getColorPieza()=="blancas" and self.modo=="servidor":
         self.ant=source.getCoor()
         self.icono=source.icon()
         self.nombrePieza=source.getNombre()
         self.colorPieza=source.getColorPieza()
         self.pintaTablero()
         nombre=source.getNombre()
         if nombre=="peonB":
             if self.fila==6 and self.matriz[self.fila-1][self.col].getColorPieza()=="vacio" and self.matriz[self.fila-2][self.col].getColorPieza()=="vacio":
                 self.matriz[self.fila-1][self.col].setBackGroundCyan()
                 self.matriz[self.fila-2][self.col].setBackGroundCyan()
                 
             if self.matriz[self.fila-1][self.col].getColorPieza()=="vacio":
                 self.matriz[self.fila-1][self.col].setBackGroundCyan()
             if self.col>1 and self.matriz[self.fila-1][self.col-1].getColorPieza()=="negras":
                 self.matriz[self.fila-1][self.col-1].setBackGroundCyan()
             if self.col<7 and self.matriz[self.fila-1][self.col+1].getColorPieza()=="negras":
                 self.matriz[self.fila-1][self.col+1].setBackGroundCyan()
                 
         if nombre=="torreB":
             mov.validaTorre(self,source)
         
         if nombre=="alfilB":
             mov.validaAlfil(self,source)
         if nombre=="reinaB":
             mov.validaReina(self,source)
         if nombre=="reyB":
             mov.validaRey(self,source)
         if nombre=="caballoB":
             mov.validaCaballo(self,source)
             
             
             
     elif not(self.turno) and source.getColorPieza()=="negras" and self.modo=="cliente":
         self.ant=source.getCoor()
         self.icono=source.icon()
         self.nombrePieza=source.getNombre()
         self.colorPieza=source.getColorPieza()
         self.pintaTablero()
         nombre=source.getNombre()
         if nombre=="peonR":
             if self.fila==1 and self.matriz[self.fila+1][self.col].getColorPieza()=="vacio" and self.matriz[self.fila+2][self.col].getColorPieza()=="vacio":
                 self.matriz[self.fila+1][self.col].setBackGroundCyan()
                 self.matriz[self.fila+2][self.col].setBackGroundCyan()
                 
             if self.matriz[self.fila+1][self.col].getColorPieza()=="vacio":
                 self.matriz[self.fila+1][self.col].setBackGroundCyan()
             if self.col>1 and self.matriz[self.fila+1][self.col-1].getColorPieza()=="blancas":
                 self.matriz[self.fila+1][self.col-1].setBackGroundCyan()
             if self.col<7 and self.matriz[self.fila+1][self.col+1].getColorPieza()=="blancas":
                 self.matriz[self.fila+1][self.col+1].setBackGroundCyan()
                                 
         if nombre=="torreR":
             mov.validaTorre(self,source)
         
         if nombre=="alfilR":
             mov.validaAlfil(self,source)
         if nombre=="reinaR":
             mov.validaReina(self,source)
         if nombre=="reyR":
             mov.validaRey(self,source)
         if nombre=="caballoR":
             mov.validaCaballo(self,source)
         
     elif source.getColor()=="cyan":
         if source.getNombre()=="reyB" or source.getNombre()=="reyR":
             self.ganar=True
         
         self.matriz[self.ant.x()][self.ant.y()].setIcon(QtGui.QIcon(""))
         self.matriz[self.ant.x()][self.ant.y()].setNombre("vacio")
         self.matriz[self.ant.x()][self.ant.y()].setColorPieza("vacio")
         source.setIcon(self.icono)
         source.setNombre(self.nombrePieza)
         source.setColorPieza(self.colorPieza)
         self.act=source.getCoor()
         self.turno=not(self.turno)
         self.pintaTablero()
         if self.turno==True:
             self.actual.setText("Jugador actual: Blancas")
         else:
             self.actual.setText("Jugador actual: Negras")
             
         if (source.coor.x() == 0 and source.getNombre()=="peonB") or (source.coor.x() == 7 and source.getNombre()=="peonR"):
             if source.getNombre()=="peonB":
                 ok=False
                 while ok==False:
                     pieza, ok= QtGui.QInputDialog.getItem(self, "Coronar", "Escoge una pieza: ", self.coronaB)
             if source.getNombre()=="peonR":
                 ok=False
                 while ok==False:
                     pieza, ok= QtGui.QInputDialog.getItem(self, "Coronar", "Escoge una pieza: ", self.coronaR)
                     
             source.setNombre(pieza)
             self.nombrePieza=str(pieza)
             source.setIcon(QtGui.QIcon("images/"+pieza+".gif"))
             
                 
         if self.modo=="cliente":
             with open("datos.dat",'wb') as f:
                 pickle.dump(self.turno,f,2)
                 pickle.dump(self.ant.x(),f,2)  
                 pickle.dump(self.ant.y(),f,2)   
                 pickle.dump(self.act.x(),f,2)  
                 pickle.dump(self.act.y(),f,2)   
                 pickle.dump(self.nombrePieza,f,2)
             with open("datos.dat",'rb') as f:
                 cad=f.read()
                 self.cliente.c.send(cad)
                 
                 
         if self.modo=="servidor": 
             with open("datos.dat",'wb') as f:
                 pickle.dump(self.turno,f,2)
                 pickle.dump(self.ant.x(),f,2)  
                 pickle.dump(self.ant.y(),f,2)   
                 pickle.dump(self.act.x(),f,2)  
                 pickle.dump(self.act.y(),f,2)   
                 pickle.dump(self.nombrePieza,f,2) 
             with open("datos.dat",'rb') as f:
                 cad=f.read()
                 self.servidor.sc.send(cad)
         
         if self.ganar:
             self.rendir()