Skip to content
This repository has been archived by the owner on May 4, 2021. It is now read-only.

Commit

Permalink
Version 10.08
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasmonk committed Nov 19, 2016
1 parent ca6902b commit d44f3a5
Show file tree
Hide file tree
Showing 15 changed files with 318 additions and 129 deletions.
4 changes: 4 additions & 0 deletions Code/Configuracion.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os

from PyQt4 import QtGui
from PyQt4.QtCore import Qt

from Code import BaseConfig
from Code import CajonDesastre
Expand Down Expand Up @@ -110,6 +111,7 @@ def __init__(self, user):

self.puntosTB = 11
self.boldTB = False
self.iconsTB = Qt.ToolButtonTextUnderIcon

self.centipawns = False

Expand Down Expand Up @@ -467,6 +469,7 @@ def graba(self, aplazamiento=None):

dic["PUNTOSTB"] = self.puntosTB
dic["BOLDTB"] = self.boldTB
dic["ICONSTB"] = self.iconsTB

dic["COLOR_NAG1"] = self.color_nag1
dic["COLOR_NAG2"] = self.color_nag2
Expand Down Expand Up @@ -591,6 +594,7 @@ def lee(self):

self.puntosTB = dg("PUNTOSTB", self.puntosTB)
self.boldTB = dg("BOLDTB", self.boldTB)
self.iconsTB = dg("ICONSTB", self.iconsTB)

self.color_nag1 = dg("COLOR_NAG1", self.color_nag1)
self.color_nag2 = dg("COLOR_NAG2", self.color_nag2)
Expand Down
10 changes: 8 additions & 2 deletions Code/GM.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,10 @@ def listaGMpersonal(carpeta):
siW = siB = False
with open(os.path.join(carpeta, fich)) as f:
for linea in f:
gmp = GMpartida(linea.strip())
try:
gmp = GMpartida(linea.strip())
except:
continue
if not siW:
siW = gmp.isWhite(True)
if not siB:
Expand Down Expand Up @@ -337,7 +340,10 @@ def masMaderaUno(self, dic, partida, xblancas, xnegras, tpResult):
else:
if not (siEmpate or (xblancas and siGanaBlancas) or (xnegras and siGanaNegras)):
return
self.write("%s|%s|%s|%s|%s|%s|%s\n" % (pv2xpv(pk.strip()), event, oponente, date, eco, result, color))
def nopipe(txt):
return txt.replace("|", " ").strip() if "|" in txt else txt

self.write("%s|%s|%s|%s|%s|%s|%s\n" % (pv2xpv(pk.strip()), nopipe(event), nopipe(oponente), nopipe(date), eco, result, color))

def xprocesa(self):
self.close()
Expand Down
20 changes: 19 additions & 1 deletion Code/Gestor.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ def __init__(self, procesador):
# Informacion
self.informacionActivable = True

self.nonDistract = None

# x Control del tutor
# asi sabemos si ha habido intento de analisis previo (por ejemplo el usuario mientras piensa decide activar el tutor)
self.siIniAnalizaTutor = False
Expand Down Expand Up @@ -127,6 +129,8 @@ def ponFinJuego(self):
def finGestor(self):
# se llama desde procesador.inicio, antes de borrar el gestor
self.tablero.atajosRaton = None
if self.nonDistract:
self.pantalla.base.tb.setVisible(True)

def atajosRatonReset(self):
self.atajosRatonDestino = None
Expand Down Expand Up @@ -711,7 +715,6 @@ def guardarPGN(self):
"It is saved in the clipboard to paste it wherever you want.")))

def guardarGanados(self, siGanado):

conf = self.configuracion

if siGanado:
Expand Down Expand Up @@ -758,6 +761,21 @@ def quitaCapturas(self):
self.pantalla.activaCapturas(False)
self.ponVista()

def rightMouse(self, siShift, siControl, siAlt):
if siControl:
self.capturas()
elif siAlt:
self.nonDistract = self.pantalla.base.nonDistractMode(self.nonDistract)
else:
self.pgnInformacion(None, None)
self.pantalla.ajustaTam()

def boardRightMouse(self, siShift, siControl, siAlt):
self.rightMouse(siShift, siControl, siAlt)

def gridRightMouse(self, siShift, siControl, siAlt):
self.rightMouse(siShift, siControl, siAlt)

def listado(self, tipo):
if tipo == "pgn":
return self.pgn.actual()
Expand Down
15 changes: 12 additions & 3 deletions Code/GestorEntPos.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import codecs
import os

from PyQt4.QtCore import Qt

from Code import ControlPosicion
from Code import Gestor
from Code import Jugada
Expand Down Expand Up @@ -239,15 +241,22 @@ def ent_siguiente(self, tipo):
self.inicio(pos, self.numEntrenos, self.titEntreno, self.liEntrenos, self.siTutorActivado, self.jump)

def controlTeclado(self, nkey):
if nkey in (43, 16777239): # pulsado + o avpag
if nkey in (Qt.Key_Plus, Qt.Key_PageDown):
self.ent_siguiente(k_siguiente)
elif nkey in (45, 16777238): # pulsado - o repag
elif nkey in (Qt.Key_Minus, Qt.Key_PageUp):
self.ent_siguiente(k_anterior)
elif nkey == 80: # P: salva
elif nkey == Qt.Key_T:
li = self.fenInicial.split("|")
li[2] = self.partida.pgnBaseRAW()
self.saveSelectedPosition("|".join(li))

def listHelpTeclado(self):
return [
("+/%s"%_("Page Down"), _("Next position")),
("-/%s"%_("Page Up"), _("Previous position")),
("T", _("Save position in 'Selected positions' file")),
]

def finPartida(self):
self.procesador.inicio()

Expand Down
13 changes: 11 additions & 2 deletions Code/GestorEntTac.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import time

from PyQt4.QtCore import Qt


from Code import ControlPosicion
from Code import Gestor
from Code import Jugada
Expand Down Expand Up @@ -226,12 +229,18 @@ def procesarAccion(self, clave):
Gestor.Gestor.rutinaAccionDef(self, clave)

def controlTeclado(self, nkey):
if nkey in (43, 16777239): # pulsado + o avpag
if nkey in (Qt.Key_Plus, Qt.Key_PageDown):
if self.estado == kFinJuego:
self.ent_siguiente()
elif nkey == 80:
elif nkey == Qt.Key_T:
self.saveSelectedPosition(self.fenInicial)

def listHelpTeclado(self):
return [
("+/%s"%_("Page Down"), _("Next position")),
("T", _("Save position in 'Selected positions' file")),
]

def reiniciar(self):
cp = ControlPosicion.ControlPosicion()
cp.leeFen(self.fen)
Expand Down
9 changes: 8 additions & 1 deletion Code/GestorPartida.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import time

from PyQt4.QtCore import Qt

from Code import Partida
from Code import ControlPosicion
from Code import Gestor
Expand Down Expand Up @@ -411,9 +413,14 @@ def configurarGS(self):
self.reiniciar(dic)

def controlTeclado(self, nkey):
if nkey in (86, 80): # V,P
if nkey in Qt.Key_V: # V
self.paste(QTUtil.traePortapapeles())

def listHelpTeclado(self):
return [
("V", _("Paste position")),
]

def paste(self, texto):
cp = ControlPosicion.ControlPosicion()
try:
Expand Down
74 changes: 44 additions & 30 deletions Code/GestorSolo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import sys
import time

from PyQt4.QtCore import Qt

from Code import ControlPosicion
from Code import Gestor
from Code import PGN
Expand Down Expand Up @@ -676,34 +678,7 @@ def configurarGS(self):
self.reiniciar()

elif resp == "posicion":
resp = XVoyager.xVoyagerFEN(self.pantalla, self.configuracion, self.fen)
if resp is not None:
self.fen = resp
self.bloqueApertura = None
self.posicApertura = None

if self.xpgn:
siInicio = self.fen == ControlPosicion.FEN_INICIAL
li = self.xpgn.split("\n")
lin = []
siFen = False
for linea in li:
if linea.startswith("["):
if "FEN " in linea:
siFen = True
if siInicio:
continue
linea = '[FEN "%s"]' % self.fen
lin.append(linea)
else:
break
if not siFen:
linea = '[FEN "%s"]' % self.fen
lin.append(linea)
self.liPGN = lin
self.xpgn = "\n".join(lin) + "\n\n*"

self.reiniciar()
self.startPosition()

elif resp == "pasteposicion":
texto = QTUtil.traePortapapeles()
Expand Down Expand Up @@ -771,11 +746,50 @@ def configurarGS(self):
self.reiniciar(dic)

def controlTeclado(self, nkey):
if nkey == 86: # V
if nkey == Qt.Key_V:
self.paste(QTUtil.traePortapapeles())
elif nkey == 80: # P
elif nkey == Qt.Key_T:
li = [self.fen if self.fen else ControlPosicion.FEN_INICIAL,"",self.partida.pgnBaseRAW()]
self.saveSelectedPosition("|".join(li))
elif nkey == Qt.Key_S:
self.startPosition()

def listHelpTeclado(self):
return [
("V", _("Paste position")),
("T", _("Save position in 'Selected positions' file")),
("S", _("Set start position"))
]

def startPosition(self):
resp = XVoyager.xVoyagerFEN(self.pantalla, self.configuracion, self.fen)
if resp is not None:
self.fen = resp
self.bloqueApertura = None
self.posicApertura = None

if self.xpgn:
siInicio = self.fen == ControlPosicion.FEN_INICIAL
li = self.xpgn.split("\n")
lin = []
siFen = False
for linea in li:
if linea.startswith("["):
if "FEN " in linea:
siFen = True
if siInicio:
continue
linea = '[FEN "%s"]' % self.fen
lin.append(linea)
else:
break
if not siFen:
linea = '[FEN "%s"]' % self.fen
lin.append(linea)
self.liPGN = lin
self.xpgn = "\n".join(lin) + "\n\n*"

self.reiniciar()

def paste(self, texto):
cp = ControlPosicion.ControlPosicion()
Expand Down
2 changes: 1 addition & 1 deletion Code/Init.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
DEBUG = False
VERSION = "10.07.2"
VERSION = "10.08"

import os
import sys
Expand Down
20 changes: 13 additions & 7 deletions Code/Procesador.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def iniciaConUsuario(self, user):
self.web = "http://www-lucaschess.rhcloud.com"
self.blog = "http://lucaschess.blogspot.com"

self.liOpcionesInicio = [k_terminar, k_play, k_competicion, k_elo,
self.liOpcionesInicio = [k_terminar, k_play,
k_entrenamiento, k_tools, k_opciones, k_informacion] # Lo incluimos aqui porque sino no lo lee, en caso de aplazada

self.configuracion = Configuracion.Configuracion(user)
Expand Down Expand Up @@ -320,6 +320,12 @@ def menuPlay(self):
menu.opcion(("free", None), _("Play against an engine of your choice"), Iconos.Libre())
menu.separador()

menu.opcion(("competition", None), _("Competition"), Iconos.NuevaPartida())
menu.separador()

menu.opcion(("elo", None), _("Elo-Rating"), Iconos.Elo())
menu.separador()

# Principiantes ----------------------------------------------------------------------------------------
menu1 = menu.submenu(_("Opponents for young players"), Iconos.RivalesMP())

Expand Down Expand Up @@ -357,6 +363,12 @@ def menuPlay(self):
if tipo == "free":
self.procesarAccion(k_libre)

elif tipo == "competition":
self.competicion()

elif tipo == "elo":
self.elo()

elif tipo == "person":
self.playPerson(rival)
elif tipo == "animales":
Expand Down Expand Up @@ -440,9 +452,6 @@ def procesarAccion(self, clave):
elif clave == k_libre:
self.libre()

elif clave == k_competicion:
self.competicion()

elif clave == k_entrenamiento:
self.entrenamientos.lanza()

Expand All @@ -452,9 +461,6 @@ def procesarAccion(self, clave):
elif clave == k_tools:
self.tools()

elif clave == k_elo:
self.elo()

elif clave == k_informacion:
self.informacion()

Expand Down
Loading

0 comments on commit d44f3a5

Please sign in to comment.