Esempio n. 1
0
    def config(self):
        menu = QTVarios.LCMenu(self)
        if self.one_line:
            menu.opcion("change", _("Change options and create new training"),
                        Iconos.TOLchange())
            menu.separador()
        smenu = menu.submenu(_("What to do after solving"), Iconos.Tacticas())
        go_fast = self.tol.go_fast
        dico = {True: Iconos.Aceptar(), False: Iconos.PuntoAmarillo()}
        smenu.opcion("t_False", _("Stop"), dico[go_fast is False])
        smenu.opcion("t_True", _("Jump to the next"), dico[go_fast is True])
        smenu.opcion("t_None", _("Jump to the next from level 2"),
                     dico[go_fast is None])
        menu.separador()
        menu.opcion("remove", _("Remove all results of all levels"),
                    Iconos.Cancelar())

        resp = menu.lanza()
        if resp:
            if resp.startswith("t_"):
                self.tol.go_fast = eval(resp[2:])
                TurnOnLights.write_tol(self.tol)
            elif resp == "remove":
                self.rebuild()
            elif resp == "change":
                self.cambiar_one_line()
Esempio n. 2
0
 def config(self):
     menu = QTVarios.LCMenu(self)
     smenu = menu.submenu(_("Tactics"), Iconos.Tacticas())
     go_fast = self.tol.go_fast
     dico = {True: Iconos.Aceptar(), False: Iconos.PuntoAmarillo()}
     smenu.opcion("t_false", _("Stop after solve"), dico[not go_fast])
     smenu.opcion("t_true", _("Jump to the next after solve"),
                  dico[go_fast])
     menu.separador()
     menu.opcion("remove", _("Remove all results of all levels"),
                 Iconos.Cancelar())
     resp = menu.lanza()
     if resp:
         if resp.startswith("t_"):
             self.tol.go_fast = resp == "t_true"
             TurnOnLights.write_tol(self.tol)
         elif resp == "remove":
             if not QTUtil2.pregunta(
                     self,
                     _("Are you sure you want to delete all results of all levels and start again from scratch?"
                       )):
                 return
             TurnOnLights.remove_tol(self.tol)
             self.reinit = True
             self.guardarVideo()
             self.accept()
 def reiniciar(self):
     if self.estado == kJugando:
         if self.ini_time:
             self.total_time_used += time.time() - self.ini_time
     if self.total_time_used:
         self.block.new_reinit(self.total_time_used)
         self.total_time_used = 0.0
         TurnOnLights.write_tol(self.tol)
     self.inicio(self.num_theme, self.num_block, self.tol)
Esempio n. 4
0
 def reiniciar(self):
     if self.state == ST_PLAYING:
         if self.ini_time:
             self.total_time_used += time.time() - self.ini_time
     if self.total_time_used:
         self.block.new_reinit(self.total_time_used, self.errores,
                               self.ayudas)
         self.total_time_used = 0.0
         TurnOnLights.write_tol(self.tol)
     self.inicio(self.num_theme, self.num_block, self.tol)
Esempio n. 5
0
    def config(self):
        menu = QTVarios.LCMenu(self)
        smenu = menu.submenu(_("Tactics"), Iconos.Tacticas())
        go_fast = self.tol.go_fast
        dico = {True: Iconos.Aceptar(), False: Iconos.PuntoAmarillo()}
        smenu.opcion("t_false", _("Stop after solve"), dico[not go_fast])
        smenu.opcion("t_true", _("Jump to the next after solve"),
                     dico[go_fast])
        menu.separador()
        menu.opcion("remove", _("Remove all results of all levels"),
                    Iconos.Cancelar())

        resp = menu.lanza()
        if resp:
            if resp.startswith("t_"):
                self.tol.go_fast = resp == "t_true"
                TurnOnLights.write_tol(self.tol)
            elif resp == "remove":
                self.rebuild()
Esempio n. 6
0
 def goto_next(self):
     self.tol.work_level += 1
     TurnOnLights.write_tol(self.tol)
     self.reinit = True
     self.guardarVideo()
     self.accept()
Esempio n. 7
0
 def goto_previous(self):
     self.tol.work_level -= 1
     TurnOnLights.write_tol(self.tol)
     self.reinit = True
     self.save_video()
     self.accept()
Esempio n. 8
0
    def finLinea(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 * 5.0 + self.ayudas * 10.0
            tm = ta / num_moves
            self.block.new_result(tm)
            TurnOnLights.write_tol(self.tol)
            cat_block, ico = TurnOnLights.qualification(tm)
            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 (x5"=%d")</td></tr>' % (
                _('Errors'), self.errores,
                self.errores * 5) if self.errores else ""
            cAyudas = '<tr><td align=right> %s </td><td> %d (x10"=%d")</td></tr>' % (
                _('Hints'), self.ayudas,
                self.ayudas * 10) if self.ayudas 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)
            QTUtil2.mensaje(self.pantalla, mens, _("Result of training"))

        else:
            if self.tol.go_fast:
                self.next_line_run()
                return
            QTUtil2.mensajeTemporal(self.pantalla,
                                    _("This line training is completed."), 1.3)

        self.estado = kFinJuego
        self.desactivaTodas()

        liOpciones = [k_mainmenu, k_reiniciar, k_configurar, k_utilidades]

        if not islast_line:
            liOpciones.append(k_siguiente)

        self.pantalla.ponToolBar(liOpciones)
Esempio n. 9
0
    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.ayudas * self.penaltyHelp
            tm = ta / num_moves
            self.block.new_result(tm, self.total_time_used, self.errores,
                                  self.ayudas)
            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.ayudas, self.penaltyHelp,
                 self.ayudas * self.penaltyHelp) if self.ayudas 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,
                                    _("This line training is 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)