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

Commit

Permalink
Version 11.05
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasmonk committed Jan 14, 2018
1 parent 9ecc1ce commit 304bae9
Show file tree
Hide file tree
Showing 282 changed files with 80,463 additions and 44,634 deletions.
28 changes: 28 additions & 0 deletions Code/Books.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,34 @@ def miraListaJugadas(self, fen):
listaJugadas.append((desde, hasta, coronacion, "%-5s -%7.02f%% -%7d" % (pgn, pc, w), 1.0 * w / maxim))
return listaJugadas

def almListaJugadas(self, fen):
li = self.book.lista(self.path, fen)
posicion = ControlPosicion.ControlPosicion()
posicion.leeFen(fen)

total = 0
maxim = 0
for entry in li:
w = entry.weight
total += w
if w > maxim:
maxim = w

listaJugadas = []
for entry in li:
alm = Util.Almacen()
pv = entry.pv()
w = entry.weight
alm.desde, alm.hasta, alm.coronacion = pv[:2], pv[2:4], pv[4:]
alm.pgn = posicion.pgnSP(alm.desde, alm.hasta, alm.coronacion)
alm.fen = fen
alm.porc = "%0.02f%%" %(w * 100.0 / total,) if total else ""
alm.weight = w
listaJugadas.append(alm)

return listaJugadas


def eligeJugadaTipo(self, fen, tipo):
maxim = 0
liMax = []
Expand Down
99 changes: 89 additions & 10 deletions Code/Configuracion.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import operator
import os
import shutil

from PyQt4 import QtGui
from PyQt4.QtCore import Qt
Expand Down Expand Up @@ -154,6 +155,9 @@ def __init__(self, user):
self.fide = 1600
self.fideNC = 1600

self.lichess = 1600
self.lichessNC = 1600

self.siDGT = False

self.opacityToolBoard = 10
Expand All @@ -171,6 +175,8 @@ def __init__(self, user):
self.altoFilaPGN = 22
self.figurinesPGN = True

self.autocoronacion = False

self.showVariantes = False
self.tipoMaterial = "D"

Expand Down Expand Up @@ -272,14 +278,17 @@ def ponCarpetas(self, user):

self.siPrimeraVez = not Util.existeFichero(self.fichero)

Util.creaCarpeta(self.carpeta + "/confvid")
self.plantillaVideo = self.carpeta + "/confvid/%s.video"
# Util.creaCarpeta()
# self.plantillaVideo = self.carpeta + "/confvid/%s.video"

self.ficheroVideo = "%s/confvid.pkd" % self.carpeta

self.ficheroSounds = "%s/sounds.pkd" % self.carpeta
self.fichEstadElo = "%s/estad.pkli" % self.carpeta
self.fichEstadMicElo = "%s/estadMic.pkli" % self.carpeta
self.fichEstadFicsElo = "%s/estadFics.pkli" % self.carpeta
self.fichEstadFideElo = "%s/estadFide.pkli" % self.carpeta
self.fichEstadLichessElo = "%s/estadLichess.pkli" % self.carpeta
self.ficheroBooks = "%s/books.lkv" % self.carpeta
self.ficheroTrainBooks = "%s/booksTrain.lkv" % self.carpeta
self.ficheroMate = "%s/mate.ddb" % self.carpeta
Expand Down Expand Up @@ -327,9 +336,15 @@ def ponCarpetas(self, user):

Util.creaCarpeta(self.dirPersonalTraining)

self.ficheroDBgames = "%s/%s.lcg" % (self.carpeta, _("Initial Database Games"))
self.carpetaGames = "%s/%s" % (self.carpeta, "DatabasesGames")
Util.creaCarpeta(self.carpetaGames)

self.carpetaPositions = "%s/%s" % (self.carpeta, "DatabasesPositions")
Util.creaCarpeta(self.carpetaPositions)

self.ficheroDBgames = "%s/%s.lcg" % (self.carpetaGames, _("Initial Database Games"))

self.ficheroDBgamesFEN = "%s/%s.lcf" % (self.carpeta, _("Positions Database"))
self.ficheroDBgamesFEN = "%s/%s.lcf" % (self.carpetaPositions, _("Positions Database"))

self.carpetaSTS = "%s/sts" % self.carpeta

Expand All @@ -342,6 +357,11 @@ def ponCarpetas(self, user):
if not Util.existeFichero(self.ficheroRecursos):
Util.copiaFichero("IntFiles/recursos.dbl", self.ficheroRecursos)

self.folderOpenings = os.path.join(self.carpeta, "OpeningLines")
Util.creaCarpeta(self.folderOpenings)

if os.path.isdir(self.carpeta + "/confvid"):
self.salto_version()

def compruebaBMT(self):
if not Util.existeFichero(self.ficheroBMT):
Expand Down Expand Up @@ -509,7 +529,7 @@ def graba(self, aplazamiento=None):
dic = {}
dic["VERSION"] = self.version
dic["ID"] = self.id
dic["JUGADOR"] = self.jugador
dic["JUGADOR"] = self.jugador if self.jugador else _("User")
dic["ESTILO"] = self.estilo
dic["TIEMPOTUTOR"] = self.tiempoTutor
dic["DEPTHTUTOR"] = self.depthTutor
Expand Down Expand Up @@ -585,6 +605,7 @@ def graba(self, aplazamiento=None):
dic["PUNTOSPGN"] = self.puntosPGN
dic["ALTOFILAPGN"] = self.altoFilaPGN
dic["FIGURINESPGN"] = self.figurinesPGN
dic["AUTOCORONACION"] = self.autocoronacion

dic["SHOW_VARIANTES"] = self.showVariantes
dic["TIPOMATERIAL"] = self.tipoMaterial
Expand All @@ -597,6 +618,8 @@ def graba(self, aplazamiento=None):
dic["FICSNC"] = self.ficsNC
dic["FIDE"] = self.fide
dic["FIDENC"] = self.fideNC
dic["LICHESS"] = self.lichess
dic["LICHESSNC"] = self.lichessNC
dic["TRASTEROS"] = self.liTrasteros
dic["FAVORITOS"] = self.liFavoritos
dic["PERSONALIDADES"] = self.liPersonalidades
Expand Down Expand Up @@ -636,7 +659,7 @@ def lee(self):
dg = dic.get
self.id = dic["ID"]
self.version = dic.get("VERSION", "")
self.jugador = dic["JUGADOR"]
self.jugador = dic["JUGADOR"] if dic["JUGADOR"] else _("User")
self.estilo = dg("ESTILO", "Cleanlooks")
self.tiempoTutor = dic["TIEMPOTUTOR"]
self.depthTutor = dg("DEPTHTUTOR", 0)
Expand Down Expand Up @@ -696,6 +719,8 @@ def lee(self):
self.ficsNC = dg("FICSNC", self.ficsNC)
self.fide = dg("FIDE", self.fide)
self.fideNC = dg("FIDENC", self.fideNC)
self.lichess = dg("LICHESS", self.fide)
self.lichessNC = dg("LICHESSNC", self.fideNC)

self.siDGT = dg("SIDGT", False)

Expand Down Expand Up @@ -727,6 +752,8 @@ def lee(self):
self.puntosPGN = dg("PUNTOSPGN", self.puntosPGN)
self.altoFilaPGN = dg("ALTOFILAPGN", self.altoFilaPGN)
self.figurinesPGN = dg("FIGURINESPGN", False)

self.autocoronacion = dg("AUTOCORONACION", self.autocoronacion)
self.showVariantes = dg("SHOW_VARIANTES", False)
self.tipoMaterial = dg("TIPOMATERIAL", self.tipoMaterial)

Expand Down Expand Up @@ -802,6 +829,9 @@ def ficsActivo(self, siModoCompetitivo):
def fideActivo(self, siModoCompetitivo):
return self.fide if siModoCompetitivo else self.fideNC

def lichessActivo(self, siModoCompetitivo):
return self.lichess if siModoCompetitivo else self.lichessNC

def ponEloActivo(self, elo, siModoCompetitivo):
if siModoCompetitivo:
self.elo = elo
Expand All @@ -826,14 +856,20 @@ def ponFideActivo(self, elo, siModoCompetitivo):
else:
self.fideNC = elo

def ponLichessActivo(self, elo, siModoCompetitivo):
if siModoCompetitivo:
self.lichess = elo
else:
self.lichessNC = elo

def listaTraducciones(self):
li = []
dlang = "Locale"
for uno in Util.listdir(dlang):
fini = os.path.join(dlang, uno, "lang.ini")
fini = os.path.join(dlang, uno.name, "lang.ini")
if os.path.isfile(fini):
dic = Util.iniBase8dic(fini)
li.append((uno, dic["NAME"], dic["%"], dic["AUTHOR"]))
li.append((uno.name, dic["NAME"], dic["%"], dic["AUTHOR"]))
li = sorted(li, key=lambda lng: lng[0])
return li

Expand Down Expand Up @@ -873,8 +909,8 @@ def ficheroTemporal(self, extension):
def limpiaTemporal(self):
try:
dirTmp = os.path.join(self.carpeta, "tmp")
for f in Util.listdir(dirTmp):
Util.borraFichero(os.path.join(dirTmp, f))
for entry in Util.listdir(dirTmp):
Util.borraFichero(entry.path)
except:
pass

Expand Down Expand Up @@ -959,3 +995,46 @@ def save_dbFEN(self, fenM2, data):
dbFEN = self.fich_dbFEN()
dbFEN[fenM2] = data

def save_video(self, key, dic):
db = Util.DicSQL(self.ficheroVideo)
db[key] = dic
db.close()

def restore_video(self, key):
db = Util.DicSQL(self.ficheroVideo)
dic = db[key]
db.close()
return dic

def salto_version(self):
def cambio_confvid():
try:
folder = self.carpeta + "/confvid"
if os.path.isdir(folder):
db = Util.DicSQL(self.ficheroVideo)
li = os.listdir(folder)
for fichero in li:
if fichero.endswith(".video") and not fichero.startswith("MOS"):
key = fichero[:-6]
dic = Util.recuperaDIC(os.path.join(folder, fichero))
if dic:
db[key] = dic
db.pack()
db.close()
except:
pass
shutil.rmtree(folder)

def cambio_databases():
li = os.listdir(self.carpeta)
for fichero in li:
if fichero.endswith(".lcg") or fichero.endswith(".lcg_s1"):
origen = os.path.join(self.carpeta, fichero)
shutil.move(origen, self.carpetaGames)
elif fichero.endswith(".lcf"):
origen = os.path.join(self.carpeta, fichero)
shutil.move(origen, self.carpetaPositions)

cambio_confvid()
cambio_databases()

4 changes: 2 additions & 2 deletions Code/Constantes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
kSigueApertura, kSigueUsuario, kMalApertura = range(3)

kJugNueva, kJugEntPos, kJugPGN, kJugEntMaq, kJugGM, kJugRemoto, kJugSolo, kJug60, kJugElo, kJugMicElo, \
kJugBooks, kJugAperturas, kJugBoxing, kJugEntTac, kJugMvM, kJugAlbum, kJugFics, kJugFide, \
kJugBooks, kJugAperturas, kJugBoxing, kJugEntTac, kJugMvM, kJugAlbum, kJugFics, kJugFide, kJugLichess, \
kJugWorldMap, kJugRoute, kJugEntLight, kJugWashingCreate, kJugWashingTactics, kJugWashingReplay, kJugSingularMoves\
= range(25)
= range(26)

kFinNormal, kFinReinicio = range(2)

Expand Down
14 changes: 14 additions & 0 deletions Code/ControlPosicion.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,20 @@ def totalPiezas(self):
num += 1
return num

def numPiezasWB(self):
nW = nB = 0
for i in range(8):
for j in range(8):
cCol = chr(i + 97)
cFil = chr(j + 49)
pz = self.casillas[cCol + cFil]
if pz and pz not in "pkPK":
if pz.islower():
nB += 1
else:
nW += 1
return nW, nB

def pesoWB(self):
dpesos = {"Q": 110, "N": 30, "B": 32, "R": 50, "P": 10}
peso = 0
Expand Down
Loading

0 comments on commit 304bae9

Please sign in to comment.