@@ -23,14 +23,19 @@ def inicio(self, num_theme, num_block, tol):
2323 self .block = self .tol .get_block (self .num_theme , self .num_block )
2424 self .block .shuffle ()
2525
26+ self .calculation_mode = self .tol .is_calculation_mode ()
27+ self .penaltyError = self .block .penaltyError (self .calculation_mode )
28+ self .penaltyHelp = self .block .penaltyHelp (self .calculation_mode )
29+
2630 self .av_seconds = self .block .av_seconds ()
2731 if self .av_seconds :
28- cat , ico = self .block .cqualification ()
32+ cat , ico = self .block .cqualification (self . calculation_mode )
2933 self .lb_previous = "%s - %0.2f\" " % (cat , self .av_seconds )
3034 else :
3135 self .lb_previous = None
3236 self .num_line = 0
3337 self .num_lines = len (self .block )
38+ self .num_moves = 0
3439
3540 self .total_time_used = 0.0
3641 self .ayudas = 0
@@ -53,16 +58,18 @@ def inicio(self, num_theme, num_block, tol):
5358
5459 self .next_line_run ()
5560
56- def pon_rotulos (self ):
57- r1 = self .line .label
61+ def pon_rotulos (self , next ):
62+ r1 = _ ("Calculation mode" ) if self .calculation_mode else _ ("Memory mode" )
63+ r1 += "<br>%s" % self .line .label
64+
5865 if self .lb_previous :
5966 r1 += "<br><b>%s</b>" % self .lb_previous
60- if self .num_line :
61- av_secs , txt = self .block .calc_current (self .num_line - 1 , self .total_time_used , self .errores , self .ayudas )
62- r1 += "<br><b>%s: %s - %0.2f\" " % (_ ("Current" ), txt , av_secs )
67+ if self .num_line :
68+ av_secs , txt = self .block .calc_current (self .num_line - 1 , self .total_time_used , self .errores , self .ayudas , self . calculation_mode )
69+ r1 += "<br><b>%s: %s - %0.2f\" " % (_ ("Current" ), txt , av_secs )
6370 self .ponRotulo1 (r1 )
64- if self . num_line < self . num_lines :
65- r2 = "<b>%d/%d</b>" % (self .num_line + 1 , self .num_lines )
71+ if next is not None :
72+ r2 = "<b>%d/%d</b>" % (self .num_line + next , self .num_lines )
6673 else :
6774 r2 = None
6875 self .ponRotulo2 (r2 )
@@ -71,7 +78,7 @@ def next_line(self):
7178 if self .num_line < self .num_lines :
7279 self .line = self .block .line (self .num_line )
7380 self .num_move = - 1
74- self .time_used = 0.0
81+ self .ini_time = None
7582
7683 cp = ControlPosicion .ControlPosicion ()
7784 cp .leeFen (self .line .fen )
@@ -85,7 +92,7 @@ def next_line(self):
8592 self .pgnRefresh (True )
8693
8794 self .partida .pendienteApertura = False
88- self .pon_rotulos ()
95+ self .pon_rotulos (1 )
8996
9097 def next_line_run (self ):
9198 liOpciones = [k_mainmenu , k_ayuda , k_reiniciar ]
@@ -121,6 +128,13 @@ def procesarAccion(self, clave):
121128 self .next_line_run ()
122129
123130 def reiniciar (self ):
131+ if self .estado == kJugando :
132+ if self .ini_time :
133+ self .total_time_used += time .time () - self .ini_time
134+ if self .total_time_used :
135+ self .block .new_reinit (self .total_time_used )
136+ self .total_time_used = 0.0
137+ TurnOnLights .write_tol (self .tol )
124138 self .inicio (self .num_theme , self .num_block , self .tol )
125139
126140 def siguienteJugada (self ):
@@ -152,8 +166,15 @@ def siguienteJugada(self):
152166
153167 else :
154168 self .siJuegaHumano = True
155- self .ini_time = time .time ()
169+ if not (self .calculation_mode and self .ini_time is None ): # Se inicia salvo que sea el principio de la linea
170+ self .ini_time = time .time ()
156171 self .activaColor (siBlancas )
172+ if self .calculation_mode :
173+ self .tablero .setDispatchMove (self .dispatchMove )
174+
175+ def dispatchMove (self ):
176+ if self .ini_time is None :
177+ self .ini_time = time .time ()
157178
158179 def finLinea (self ):
159180 self .num_line += 1
@@ -167,11 +188,11 @@ def finLinea(self):
167188 ant_cat_global = self .tol .cat_global ()
168189
169190 num_moves = self .block .num_moves ()
170- ta = self .total_time_used + self .errores * 5.0 + self .ayudas * 10.0
191+ ta = self .total_time_used + self .errores * self . penaltyError + self .ayudas * self . penaltyHelp
171192 tm = ta / num_moves
172193 self .block .new_result (tm )
173194 TurnOnLights .write_tol (self .tol )
174- cat_block , ico = TurnOnLights .qualification (tm )
195+ cat_block , ico = TurnOnLights .qualification (tm , self . calculation_mode )
175196 cat_level , ico = self .tol .cat_num_level ()
176197 cat_global = self .tol .cat_global ()
177198
@@ -190,8 +211,8 @@ def finLinea(self):
190211 if cat_global != ant_cat_global :
191212 txt_more_global = '<span style="color:red">%s</span>' % _ ("New" )
192213
193- cErrores = '<tr><td align=right> %s </td><td> %d (x5 "=%d")</td></tr>' % (_ ('Errors' ), self .errores , self .errores * 5 ) if self .errores else ""
194- cAyudas = '<tr><td align=right> %s </td><td> %d (x10 "=%d")</td></tr>' % (_ ('Hints' ), self .ayudas , self .ayudas * 10 ) if self .ayudas else ""
214+ cErrores = '<tr><td align=right> %s </td><td> %d (x%d "=%d")</td></tr>' % (_ ('Errors' ), self .errores , self .penaltyError , self . errores * self . penaltyError ) if self .errores else ""
215+ cAyudas = '<tr><td align=right> %s </td><td> %d (x%d "=%d")</td></tr>' % (_ ('Hints' ), self .ayudas , self .penaltyHelp , self . ayudas * self . penaltyHelp ) if self .ayudas else ""
195216 mens = ('<hr><center><big>' + _ ('You have finished this block of positions' ) +
196217 '<hr><table>' +
197218 '<tr><td align=right> %s </td><td> %0.2f"</td></tr>' % (_ ('Time used' ), self .total_time_used ) +
@@ -206,15 +227,16 @@ def finLinea(self):
206227 '</table></center></big><hr>' +
207228 txt_more_line
208229 )
209- self .pon_rotulos ()
230+ self .pon_rotulos (None )
210231 QTUtil2 .mensaje (self .pantalla , mens , _ ("Result of training" ))
232+ self .total_time_used = 0
211233
212234 else :
213235 if self .tol .go_fast :
214236 self .next_line_run ()
215237 return
216238 QTUtil2 .mensajeTemporal (self .pantalla , _ ("This line training is completed." ), 1.3 )
217- self .pon_rotulos ()
239+ self .pon_rotulos (0 )
218240
219241 self .estado = kFinJuego
220242 self .desactivaTodas ()
0 commit comments