def right_button_block(self, num_theme, num_block): block = self.tol.get_block(num_theme, num_block) litimes = block.times nmoves = block.num_moves() if not litimes and not block.reinits: return menu = QTVarios.LCMenu(self) menu.ponTipoLetra(name=Code.font_mono, puntos=10) tt = 0 te = 0 ta = 0 mixed_results = False for dato in litimes: segs, fecha, time_used, errores, hints = dato txt, ico = TurnOnLights.qualification( segs, self.tol.is_calculation_mode()) menu.opcion( None, "%d-%02d-%02d %02d:%02d %6.02f %6.02f %s" % (fecha.year, fecha.month, fecha.day, fecha.hour, fecha.minute, segs, time_used, txt), self.dicIconos[ico], ) tt += time_used te += errores ta += hints if litimes: menu.separador() menu.opcion( None, "%16s %6.02f" % (_("Average"), tt / (nmoves * len(litimes)))) menu.separador() plant = "%16s %15.02f %s" if block.reinits: tr = 0.0 for dato in block.reinits: segs, fecha, errores, hints = dato tr += segs tt += segs te += errores ta += hints menu.separador() menu.opcion( None, plant % (_("Restarts"), tr, time.strftime("%H:%M:%S", time.gmtime(tr)))) if not mixed_results: menu.separador() menu.opcion(None, "%16s %6d" % (_("Errors"), te)) menu.separador() menu.opcion(None, "%16s %6d" % (_("Hints"), ta)) menu.separador() menu.opcion( None, plant % (_("Total time"), tt, time.strftime("%H:%M:%S", time.gmtime(tt)))) menu.lanza()
def end_line(self): self.num_line += 1 islast_line = self.num_line == self.num_lines if islast_line: # Previous ant_tm = self.block.av_seconds() ant_done = self.tol.done_level() ant_cat_level, nada = self.tol.cat_num_level() ant_cat_global = self.tol.cat_global() num_moves = self.block.num_moves() ta = self.total_time_used + self.errores * self.penaltyError + self.hints * self.penaltyHelp tm = ta / num_moves self.block.new_result(tm, self.total_time_used, self.errores, self.hints) TurnOnLights.write_tol(self.tol) cat_block, ico = TurnOnLights.qualification( tm, self.calculation_mode) cat_level, ico = self.tol.cat_num_level() cat_global = self.tol.cat_global() txt_more_time = "" txt_more_cat = "" txt_more_line = "" txt_more_global = "" if ant_tm is None or tm < ant_tm: txt_more_time = '<span style="color:red">%s</span>' % _( "New record") done = self.tol.done_level() if done and (not ant_done): if not self.tol.islast_level(): txt_more_line = "%s<hr>" % _("Open the next level") if cat_level != ant_cat_level: txt_more_cat = '<span style="color:red">%s</span>' % _( "New") if cat_global != ant_cat_global: txt_more_global = '<span style="color:red">%s</span>' % _( "New") 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 "") cAyudas = ( '<tr><td align=right> %s </td><td> %d (x%d"=%d")</td></tr>' % (_("Hints"), self.hints, self.penaltyHelp, self.hints * self.penaltyHelp) if self.hints else "") mens = ("<hr><center><big>" + _("You have finished this block of positions") + "<hr><table>" + '<tr><td align=right> %s </td><td> %0.2f"</td></tr>' % (_("Time used"), self.total_time_used) + cErrores + cAyudas + '<tr><td align=right> %s: </td><td> %0.2f" %s</td></tr>' % (_("Time assigned"), ta, txt_more_time) + "<tr><td align=right> %s: </td><td> %d</td></tr>" % (_("Total moves"), num_moves) + '<tr><td align=right> %s: </td><td> %0.2f"</td></tr>' % (_("Average time"), tm) + "<tr><td align=right> %s: </td><td> %s</td></tr>" % (_("Block qualification"), cat_block) + "<tr><td align=right> %s: </td><td> %s %s</td></tr>" % (_("Level qualification"), cat_level, txt_more_cat) + "<tr><td align=right> %s: </td><td> %s %s</td></tr>" % (_("Global qualification"), cat_global, txt_more_global) + "</table></center></big><hr>" + txt_more_line) self.pon_rotulos(None) QTUtil2.message_bold(self.main_window, mens, _("Result of training")) self.total_time_used = 0 else: if (self.tol.go_fast is True) or ((self.tol.go_fast is None) and self.tol.work_level > 0): self.next_line_run() return QTUtil2.mensajeTemporal(self.main_window, _("Line completed"), 1.3) self.pon_rotulos(0) self.state = ST_ENDGAME self.disable_all() li_options = [TB_CLOSE, TB_REINIT, TB_CONFIG, TB_UTILITIES] if not islast_line: li_options.append(TB_NEXT) self.main_window.pon_toolbar(li_options)