#include #include #include "tablero.h" Tablero::Tablero(int x,MainWindow * y): tiempo(x,0),ataque(0,24), tiempoF(1,0) { TiempoPartido=x; window = y; TiempoCorre=false; cuarto =1; puntosIzquierda=0; puntosDerecha=0; window->ChangeText(1,tiempo.getSec()); window->ChangeText(2,tiempo.getSec()); } void Tablero::Empezar()//el boton de inicio llama a esta funcion { if (tiempo.getStatus())//solamente si al contador principal le queda tiempo va { //va ha iniciar TiempoCorre=true; TiempoFuera=false; } } void Tablero::Pausar()//pausa el booleano para que corra el tiempo y tambien reinicia el tiempo de ataque { TiempoCorre=false; ReiniciarAtaque(); } void Tablero::ReiniciarTodo()//reinicia los temporizadores { ConfigurarTiempo(TiempoPartido); ReiniciarAtaque(); tiempoF.cambiarTiempo(1,0); } void Tablero::ReiniciarAtaque()//este es el evento del boton de ataque y reinicia el tiempo de ataque { ataque.cambiarTiempo(0,24); } void Tablero::ReiniciarTimeOut()//para el tiempo fuera { tiempoF.cambiarTiempo(1,0); } void Tablero::AjustarTiempo(int min,int seg=0)//esta es una funcion para ajustar el tiempo de los temporizadores { tiempo.cambiarTiempo(min,seg);//si facilitaria la opcion de modificar el tiempo a gusto } void Tablero::ConfigurarTiempo(int min){//solamente es para el temporizador de minutos del partido tiempo.cambiarTiempo(min,0); } void Tablero::CambiarJugador(int entra,int sale,int equipo)//cambio de jugador { if(entra != sale){//solamente si cambia por un jugador diferente se efectua el registro del cambio registroJ.push_back({cuarto,tiempo.getMin(), tiempo.getSec(), entra, sale,equipo}); //std::cout<<"Time: "<SetFoolsTeam(FoolsI,FoolsD);//actualiza visualmente las faltas totales del equipo std::cout<<"Time: "<=5){ //std::cout<<"falta jugador: "<ChangeText(3,tiempoF.getSec()); } else if(!tiempoF.getStatus()){ ReiniciarTimeOut(); TiempoFuera=false; } window->ChangeText(0,tiempo.getMin());//tambien cada 1 seg actualiza los contadores window->ChangeText(1,tiempo.getSec()); window->ChangeText(2,ataque.getSec()); } void Tablero::Puntoizquierda(int score){//cuando anotan punto pausa el juego Pausar(); puntosIzquierda+=score; window->ChangeScoreLocal(puntosIzquierda); std::cout << "puntosIzquierda:"<ChangeScoreVisita(puntosDerecha); std::cout << "puntosDerecha:"<ChangeCuarto(cuarto); } else if((x==-1)&&(cuarto>1)){ cuarto+=x; window->ChangeCuarto(cuarto); } std::cout<<"x: "<SetFoolsTeam(FoolsI,FoolsD); } void Tablero::GenerarResumen(){//genera el resumen del partido std::ofstream archivo("RegistroPartido.txt"); // Verifica si el archivo se abriĆ³ correctamente if (archivo.is_open()) { // Escribe en el archivo de texto archivo << "Puntaje Local: "<getSpinbox(1),window->getSpinbox(2),0); } void Tablero::eventoBoton15(){ CambiarJugador(window->getSpinbox(1),window->getSpinbox(2),1); } void Tablero::eventoBoton7(){ FaltaJugador(window->getSpinbox(3),0); Pausar(); } void Tablero::eventoBoton14(){ FaltaJugador(window->getSpinbox(3),1); Pausar(); } void Tablero::eventoBoton8(){//botones score Puntoizquierda(1); } void Tablero::eventoBoton9(){ Puntoizquierda(2); } void Tablero::eventoBoton10(){ Puntoizquierda(3); } void Tablero::eventoBoton11(){ Puntoderecha(1); } void Tablero::eventoBoton12(){ Puntoderecha(2); } void Tablero::eventoBoton13(){ Puntoderecha(3); } void Tablero::eventoBoton16(){ FoolsD=0; FoolsI=0; ActualizarCuarto(-1); } void Tablero::eventoBoton17(){ FoolsD=0; FoolsI=0; ActualizarCuarto(1); } void Tablero::eventoBoton18(){ if(puntosIzquierda!=0){ Puntoizquierda(-1); } } void Tablero::eventoBoton19(){ if(puntosDerecha!=0){ Puntoderecha(-1); } } void Tablero::eventoBoton20(){ GenerarResumen(); }