Example #1
0
        public void al_jugar_y_pedir_una_nueva_partida_se_vuelven_a_iniciar_el_tablero_y_el_turno()
        {
            //Arrange
            var juego = new Juego();
            var turno = juego.Turno;
            var tablero = juego.Tablero;

            //jugar!!!!
            var ficha = turno.GetFichaActual();
            tablero.AddFicha(ficha, new Posicion(0, 0));
            var fichaAntesDeNuevaPartida = turno.GetFichaActual();
            var numeroDeFichasAntesDeNuevaPartida = tablero.GetNumeroFichas();

            //Act
            juego.NuevaPartida();

            //limbo
            //turno = juego.Turno;
            tablero = juego.Tablero;

            //Assert: Comprobar el estado inicial del turno y que si has jugado la ficha anterior a nueva partida no tiene porquƩ ser un aspa
            var fichaActual = turno.GetFichaActual();
            Assert.NotEqual(fichaAntesDeNuevaPartida,fichaActual);
            Assert.Equal(Fichas.Aspa, fichaActual);

            //Assert: Comprobar el estado inicial del tablero
            var numeroDeFichasConPartidaReiniciada = tablero.GetNumeroFichas();
            Assert.True(numeroDeFichasAntesDeNuevaPartida != numeroDeFichasConPartidaReiniciada);
            Assert.Equal(0, numeroDeFichasConPartidaReiniciada);
        }
Example #2
0
 public Menu(Juego juego)
 {
     this.juego = juego;
     opciones = new List<Opcion>();
     opciones.Add(new OpcionContinuar(new System.Drawing.Point(50, 50), this));
     opciones.Add(new OpcionSalir(new System.Drawing.Point(50, 120), this));
 }
Example #3
0
        public void al_iniciar_el_juego_se_inicia_el_tablero_y_el_turno()
        {
            //Arrange

            //Act
            var juego = new Juego();

            //limbo
            var turno = juego.Turno;
            var tablero = juego.Tablero;

            //Assert: Comprobar el estado inicial del turno
            var fichaActual = turno.GetFichaActual();
            Assert.Equal(Fichas.Aspa,fichaActual);

            //Assert: Comprobar el estado inicial del tablero
            Assert.Equal(0, tablero.GetNumeroFichas());
        }
Example #4
0
 //Aqui se agrega el numero con sus respectivos juegos
 public void agregarJuegoCantidad(Juego agregarJuego)
 {
     for (int i = 0; i < agregarJuego.jugadoresJuego.Count; i++)
     {
         List <Juego> listaJuegos;
         if (cantidadJugJuegos.TryGetValue(agregarJuego.jugadoresJuego[i], out listaJuegos))
         {
             listaJuegos.Add(agregarJuego);
             cantidadJugJuegos[agregarJuego.jugadoresJuego[i]] = listaJuegos;
         }
         else
         {
             //Si no existe la cantidad, se crea
             listaJuegos = new List <Juego>();
             listaJuegos.Add(agregarJuego);
             cantidadJugJuegos.Add(agregarJuego.jugadoresJuego[i], listaJuegos);
         }
     }
 }
Example #5
0
        internal Suelo[,] obtenerTablero(String nombreTablero, Grafico grafico)   //Metodo que genera los tableros
        {
            Suelo[,] tmp = new Suelo[X, Y];
            XmlDocument xml = new XmlDocument();
            XmlNodeList tablero, pieza, casilla;
            string      piezaPrincipal = string.Empty;

            xml.Load(Juego.appPath() + "\\Imagenes\\Tableros\\" + nombreTablero + "\\" + nombreTablero + ".xml");

            tablero = xml.GetElementsByTagName("board");
            pieza   = ((XmlElement)tablero[0]).GetElementsByTagName("piece");
            casilla = ((XmlElement)tablero[0]).GetElementsByTagName("box");

            foreach (XmlElement p in pieza)
            {
                if (!p.GetAttribute("default").Equals(string.Empty))
                {
                    piezaPrincipal = p.InnerText;
                }

                img[p.GetAttribute("id")] = grafico.cargarImagen("\\Imagenes\\Tableros\\" + nombreTablero + "\\" + p.InnerText);
            }

            for (int i = 0; i < ConstructorTablero.X; i++)
            {
                for (int j = 0; j < ConstructorTablero.Y; j++)
                {
                    string idPiezaPrincipal = piezaPrincipal.Substring(0, piezaPrincipal.LastIndexOf('.'));
                    tmp[i, j] = new Suelo(idPiezaPrincipal, false, img[idPiezaPrincipal]);
                }
            }

            foreach (XmlElement c in casilla)
            {
                int    x  = int.Parse(c.GetAttribute("x"));
                int    y  = int.Parse(c.GetAttribute("y"));
                string id = c.GetAttribute("id");

                tmp[x, y] = new Suelo(id, true, img[id]);
            }

            return(tmp);
        }
Example #6
0
 public static void DesplegarTablero(String[] tablero, int pTamano, Juego pJuego1, Jugador pJugador1, Jugador pJugador2)
 {
     if (pTamano.Equals(1))
     {
         Console.WriteLine("\n     " + tablero[0] + " | " + tablero[1] + "  | " + tablero[2]);
         Console.WriteLine("\n   ___  ___  ___");
         Console.WriteLine("\n     " + tablero[3] + " | " + tablero[4] + "  | " + tablero[5]);
         Console.WriteLine("\n   ___  ___  ___");
         Console.WriteLine("\n     " + tablero[6] + " | " + tablero[7] + "  | " + tablero[8]);
     }
     else if (pTamano.Equals(2))
     {
         Console.WriteLine("\n     " + tablero[0] + " | " + tablero[1] + "  | " + tablero[2] + "  | " + tablero[3]);
         Console.WriteLine("\n   ___  ___  ___  ___");
         Console.WriteLine("\n     " + tablero[4] + " | " + tablero[5] + "  | " + tablero[6] + "  | " + tablero[7]);
         Console.WriteLine("\n   ___  ___  ___  ___");
         Console.WriteLine("\n     " + tablero[8] + " | " + tablero[9] + "  | " + tablero[10] + "  | " + tablero[11]);
         Console.WriteLine("\n   ___  ___  ___  ___");
         Console.WriteLine("\n     " + tablero[12] + " | " + tablero[13] + "  | " + tablero[14] + "  | " + tablero[15]);
     }
     else if (pTamano.Equals(3))
     {
         Console.WriteLine("\n     " + tablero[0] + " | " + tablero[1] + "  | " + tablero[2] + "  | " + tablero[3] + "  | " + tablero[4]);
         Console.WriteLine("\n   ___  ___  ___  ___  ___");
         Console.WriteLine("\n     " + tablero[5] + " | " + tablero[6] + "  | " + tablero[7] + "  | " + tablero[8] + "  | " + tablero[9]);
         Console.WriteLine("\n   ___  ___  ___  ___  ___");
         Console.WriteLine("\n     " + tablero[10] + " | " + tablero[11] + "  | " + tablero[12] + "  | " + tablero[13] + "  | " + tablero[14]);
         Console.WriteLine("\n   ___  ___  ___  ___  ___");
         Console.WriteLine("\n     " + tablero[15] + " | " + tablero[16] + "  | " + tablero[17] + "  | " + tablero[18] + "  | " + tablero[19]);
         Console.WriteLine("\n   ___  ___  ___  ___  ___");
         Console.WriteLine("\n     " + tablero[20] + " | " + tablero[21] + "  | " + tablero[22] + "  | " + tablero[23] + "  | " + tablero[24]);
     }
     if (pJuego1.GetTurnoJugar().Equals(pJugador1.GetJugada()))
     {
         Console.WriteLine($"Turno de jugador: {pJugador1.GetNombreJugador()}");
     }
     else
     {
         Console.WriteLine($"Turno de jugador: {pJugador2.GetNombreJugador()}");
     }
     Console.WriteLine("Seleccione posicion a llenar:");
     pJuego1.SetPosicionLlenar(Convert.ToInt32(Console.ReadLine()));
 }
Example #7
0
        /// <summary>
        /// LĆ³gica para notificar la creaciĆ³n de la sala.
        /// </summary>
        /// <param name="salaCreada">Sala que fue creada</param>
        public void NotificarCreacionDeSala(Sala salaCreada)
        {
            Juego ventanaJuego = new Juego();

            ventanaJuego.Show();
            Paginas.Lobby paginaLobby = new Paginas.Lobby
            {
                Jugadores   = new ObservableCollection <Jugador>(salaCreada.JugadoresEnSala.Keys),
                DataContext = salaCreada
            };
            paginaLobby.jugadoresEnSala.ItemsSource = paginaLobby.Jugadores;
            paginaLobby.ConfigurarSalaParaHost();
            ventanaJuego.PaginaActual            = paginaLobby;
            ventanaJuego.frameNavegacion.Content = paginaLobby;

            MenuPrincipal menuPrincipal = Application.Current.Windows.OfType <MenuPrincipal>().SingleOrDefault();

            menuPrincipal.Hide();
        }
        public List <Juego> getAllJuegos()
        {
            List <Juego> juegos = new List <Juego>();

            try
            {
                List <Entities.Juego> juegosTmp = ctx.Juego.ToList();
                foreach (Entities.Juego item in juegosTmp)
                {
                    Juego game = new Juego(item.nombreJuego, item.dominio, item.id, item.estado, item.descripcion);
                    juegos.Add(game);
                }
                return(juegos);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #9
0
 //Aqui se agrega el numero con su respectivo juego
 public void agregarJuegoCategoria(Juego agregarJuego)
 {
     for (int i = 0; i < agregarJuego.categoria.Count; i++)
     {
         List <Juego> listaJuegos;
         if (categorĆ­as.TryGetValue(agregarJuego.categoria[i], out listaJuegos))
         {
             listaJuegos.Add(agregarJuego);
             categorĆ­as[agregarJuego.categoria[i]] = listaJuegos;
         }
         else
         {
             //Si no existe la cantidad, se crea
             listaJuegos = new List <Juego>();
             listaJuegos.Add(agregarJuego);
             categorĆ­as.Add(agregarJuego.categoria[i], listaJuegos);
         }
     }
 }
Example #10
0
        static void Main(string[] args)
        {
            Jugador jugador1 = new Jugador();
            Jugador jugador2 = new Jugador();
            Juego   juego1   = new Juego();

            String[] tablero = new String[0];
            do
            {
                MetodosGenerales.DesplegarMenu(jugador1, jugador2, juego1);
                MetodosGenerales.AsignarFicha(jugador1, jugador2);
                tablero = MetodosGenerales.CrearTablero(juego1.GetTamanoTablero(), tablero);
                MetodosGenerales.DesplegarIndicacionesJuego(jugador1, jugador2);
                Console.Clear();
                MetodosGenerales.Jugar(tablero, jugador1, jugador2, juego1);
            } while (juego1.GetOpcionJuego().Equals(2));
            Console.WriteLine("Saliendo del Juego...!!!!");
            System.Threading.Thread.Sleep(2000);
        }
Example #11
0
        public static void UnidadesDisponiblesDesplegarJugadorTurnoActual(Juego objJuego)
        {
            //Obtener todos los territorios del juegador
            int numeroTerritorios = objJuego.Territorios.Where(x => x.IpJugadorPropietario == objJuego.IpJugadorTurnoActual).Count();
            int bonoTerritorios   = 0;

            if (numeroTerritorios >= 7)
            {
                bonoTerritorios++;
            }
            if (numeroTerritorios >= 9)
            {
                bonoTerritorios++;
            }
            if (numeroTerritorios >= 12)
            {
                bonoTerritorios++;
            }
            if (numeroTerritorios >= 15)
            {
                bonoTerritorios++;
            }
            if (numeroTerritorios >= 18)
            {
                bonoTerritorios++;
            }
            if (numeroTerritorios >= 21)
            {
                bonoTerritorios++;
            }
            //Obtner el numero de continentes
            int territoriosRegion1 = objJuego.Territorios.Where(x => x.IpJugadorPropietario == objJuego.IpJugadorTurnoActual && x.NroRegion == 1).Count();
            int territoriosRegion2 = objJuego.Territorios.Where(x => x.IpJugadorPropietario == objJuego.IpJugadorTurnoActual && x.NroRegion == 2).Count();
            int territoriosRegion3 = objJuego.Territorios.Where(x => x.IpJugadorPropietario == objJuego.IpJugadorTurnoActual && x.NroRegion == 3).Count();
            int territoriosRegion4 = objJuego.Territorios.Where(x => x.IpJugadorPropietario == objJuego.IpJugadorTurnoActual && x.NroRegion == 4).Count();
            int bonoRegion1        = territoriosRegion1 == 6 ? Constantes.BonoTerritoriosRegion1 : 0;
            int bonoRegion2        = territoriosRegion2 == 6 ? Constantes.BonoTerritoriosRegion2 : 0;
            int bonoRegion3        = territoriosRegion3 == 6 ? Constantes.BonoTerritoriosRegion3 : 0;
            int bonoRegion4        = territoriosRegion4 == 6 ? Constantes.BonoTerritoriosRegion4 : 0;

            objJuego.UnidadesDisponiblesParaDesplegar = Constantes.BonoUnidadesBaseParaDespliegue + bonoTerritorios + bonoRegion1 + bonoRegion2 + bonoRegion3 + bonoRegion4;
        }
Example #12
0
        public void TestMemento()
        {
            Juego juego = new Juego();

            juego.setProgress("10%");
            juego.setCheckpoint(1);

            Caretaker  caretaker  = new Caretaker();
            Originator originator = new Originator();

            juego = new Juego();
            juego.setProgress("40%");
            juego.setCheckpoint(2);
            originator.setEstado(juego);

            juego = new Juego();
            juego.setProgress("50%");
            juego.setCheckpoint(3);
            originator.setEstado(juego);

            caretaker.addMemento(originator.guardar());             // ESTADO POSICION 0

            juego = new Juego();
            juego.setProgress("70%");
            juego.setCheckpoint(4);
            originator.setEstado(juego);

            caretaker.addMemento(originator.guardar());             // ESTADO POSICION 1

            juego = new Juego();
            juego.setProgress("80%");
            juego.setCheckpoint(5);
            originator.setEstado(juego);

            caretaker.addMemento(originator.guardar());             // ESTADO POSICION 2

            originator.setEstado(juego);
            originator.restaurar(caretaker.getMemento(1));

            juego = originator.getEstado();
            Assert.AreEqual("Juego [Progreso=70%, checkpoint=4]", juego.toString());
        }
Example #13
0
 //AquĆ­ se agregan el juego con su respectivo autor
 public void agregarJuegoAutor(Juego agregarJuego)
 {
     //Si ya existe el autor, solo se agrega la lista de los juegos
     for (int i = 0; i < agregarJuego.autores.Count; i++)
     {
         List <Juego> listaJuegos;
         if (coleccionUsuario.TryGetValue(agregarJuego.autores[i], out listaJuegos))
         {
             listaJuegos.Add(agregarJuego);
             coleccionUsuario[agregarJuego.autores[i]] = listaJuegos;
         }
         else
         {
             //Si no existe el autor, se crea
             listaJuegos = new List <Juego>();
             listaJuegos.Add(agregarJuego);
             coleccionUsuario.Add(agregarJuego.autores[i], listaJuegos);
         }
     }
 }
Example #14
0
        public void JugarPiedra_CuandoEsValido_GuardaPiedra()
        {
            string punto = "9X2Y2";

            Juego juego = new Juego(Tablero.nueveXnueve);

            _juegoRepo.Setup(metodo => metodo.ObtenerJuego(juego.Guid))
            .Returns(juego);
            _puntoRepo.Setup(metodo => metodo.ExistePuntoEnTablero(punto, Tablero.nueveXnueve))
            .Returns(true);
            _puntoRepo.Setup(metodo => metodo.ObtenerPuntoPorId(punto))
            .Returns(new Punto(Tablero.nueveXnueve, 2, 2));


            Juego juegoConJugada = _partida.JugarPiedra(juego.Guid, punto);

            _juegoRepo.Verify(metodo => metodo.GuardarCambios(), Times.Once());

            Assert.AreEqual(1, juegoConJugada.Movimientos.Count);
        }
Example #15
0
 public static void Create(Juego p)
 {
     using (DeliveryJWEntities db = new DeliveryJWEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 db.Juego.Add(p);
                 db.SaveChanges();
                 transaction.Commit();
             }
             catch (Exception)
             {
                 transaction.Rollback();
                 throw;
             }
         }
     }
 }
Example #16
0
        public SetJuegoResponse SetJuego(Juego juego, string letra)
        {
            var letras = new List <char>();

            letras.AddRange(juego.Palabra.ToLower());

            var coincidencia = letras.Exists(x => x == char.ToLower(char.Parse(letra)));

            string newModelo = this.GetNewModel(juego.Modelo, juego.Palabra, letra);

            var response = new SetJuegoResponse {
                Puntaje      = coincidencia ? (juego.Puntaje += 100) : (juego.Puntaje -= 10),
                Modelo       = coincidencia ? newModelo : juego.Modelo,
                CantIntentos = coincidencia ? juego.CantIntentos : (juego.CantIntentos -= 1),
                Win          = !newModelo.Contains("_"),
                Coincidencia = coincidencia
            };

            return(response);
        }
        public void createJuego(Juego gameTmp)
        {
            Entities.Juego game = new Entities.Juego();
            game.nombreJuego = gameTmp.nombreJuego;
            game.descripcion = gameTmp.descripcion;
            game.estado      = gameTmp.estado;
            game.dominio     = gameTmp.dominio;


            try
            {
                ctx.Juego.Add(game);

                ctx.SaveChanges();
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Example #18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            juegoDetalles = new Juego();
            int IDjuego      = Convert.ToInt32(Request.QueryString["IDJ"]);
            int IDPlataforma = Convert.ToInt32(Request.QueryString["IDP"]);

            try
            {
                if (Request.QueryString["IDJ"] == "" || Request.QueryString["IDP"] == "")
                {
                    //falta redireccionar, no lo hace!!!!!!!........................................
                    Response.Redirect("CatalogoJuegos.aspx");
                }

                juegoDetalles = ((List <Dominio.Juego>)Session["Productos"]).Find(i => i.ID == IDjuego && i.PlataformaJuego.ID == IDPlataforma);
            }
            catch (Exception)
            {
            }
        }
Example #19
0
        public void Puntuacion(int estrellas, String nombre)
        {
            Juego j1 = BuscarJuego(nombre);

            estrellas *= 2;
            if (j1.Nveces == null && j1.Valoracion == null)
            {
                j1.Nveces          = 1;
                j1.Valoracion      = estrellas;
                j1.ValoracionTotal = j1.Valoracion / j1.Nveces;
            }
            else
            {
                j1.Nveces         += 1;
                j1.Valoracion     += estrellas;
                j1.ValoracionTotal = j1.Valoracion / j1.Nveces;
            }

            this.contex.SaveChanges();
        }
Example #20
0
        public void aƱadirDatosNodosAdversariosNombres()
        {
            Juego juego = null;

            foreach (var nombreAdversario in objetoClaseJugadas.adversariosNombresDictionary)
            {
                TreeNode nodoAdversarios_Nombres = tvArbol.GetNodeAt(0, 0).NextNode.NextNode.FirstNode.NextNode;
                TreeNode hijoAdversarios_Nombres;

                hijoAdversarios_Nombres      = new TreeNode(nombreAdversario.Key, 8, 8);
                hijoAdversarios_Nombres.Name = "advnombre" + nombreAdversario.Key;
                hijoAdversarios_Nombres.Tag  = "0";

                nodoAdversarios_Nombres.Nodes.Add(hijoAdversarios_Nombres);

                SortedDictionary <String, int[]> valorNombreAdversarioDictionary = nombreAdversario.Value;
                foreach (var idJuego in valorNombreAdversarioDictionary)
                {
                    foreach (var objetoJuego in objetoClaseColeccion.listaJuegos)
                    {
                        if (objetoJuego.idJuego.Equals(idJuego.Key))
                        {
                            juego = objetoJuego;
                            break;
                        }
                    }
                    TreeNode nietoAdversarios_Juegos;

                    nietoAdversarios_Juegos      = new TreeNode(juego.tituloJuego, 4, 4);
                    nietoAdversarios_Juegos.Name = juego.tituloJuego;
                    nietoAdversarios_Juegos.Tag  = juego.idJuego;

                    agregarImagenesImageList(juego.obtenerImagen(directorioCacheJuegos, juego.idJuego), juego.idJuego);

                    nietoAdversarios_Juegos.ImageIndex         = imglImagenes.Images.Count - 1;
                    nietoAdversarios_Juegos.SelectedImageIndex = imglImagenes.Images.Count - 1;

                    hijoAdversarios_Nombres.Nodes.Add(nietoAdversarios_Juegos);
                }
            }
        }
Example #21
0
        public Juego1Stub()
        {
            juego = new Juego(4);

            Viajero1 = new ViajeroComun("123", "Juan");
            Viajero2 = new ViajeroComun("124", "Ana");
            Viajero3 = new ViajeroComun("125", "Pedro");
            Viajero4 = new ViajeroComun("126", "Antonio");

            List <Viajero> viajeros = new List <Viajero>();

            viajeros.Add(Viajero1);
            viajeros.Add(Viajero2);
            viajeros.Add(Viajero3);
            viajeros.Add(Viajero4);

            Experiencia granja1     = new Granja(3);
            Experiencia granja2     = new Granja(1);
            Experiencia aguaTermal1 = new AguaTermal(1);
            Experiencia aguaTermal2 = new AguaTermal(4);
            Experiencia oceano1     = new Oceano(4);
            Experiencia oceano2     = new Oceano(2);
            Experiencia montania1   = new Montania(3);
            Experiencia montania2   = new Montania(1);

            List <Experiencia> experiencias = new List <Experiencia>();

            experiencias.Add(granja1);
            experiencias.Add(aguaTermal1);
            experiencias.Add(oceano1);
            experiencias.Add(granja2);
            experiencias.Add(montania1);
            experiencias.Add(oceano2);
            experiencias.Add(montania2);
            experiencias.Add(aguaTermal2);

            juego.CargarViajeros(viajeros);
            juego.CargarExperiencias(experiencias);

            Mover = new Movimiento(juego.Camino, juego.Viajeros);
        }
Example #22
0
        //Boton modo diseƱador
        public void modoDis(object sender, EventArgs e)
        {
            int  x, y, moddo;
            bool bx, by, modo;

            //Dimensiones del tablero
            bx = int.TryParse(this.textBox1.Text, out x);
            by = int.TryParse(this.textBox3.Text, out y);
            //En este caso es la cantidad de tipos de caramelos que se decea para el
            //modo no diseƱador, es posible solo hasta 6 tipos de caramelos
            modo = int.TryParse(this.textBox2.Text, out moddo);

            if (bx && by && modo)
            {
                juego = new Juego(j, x, y, 0, moddo);
                Form despues = new Form6(juego, this);//vista del tablero
                this.Hide();
                despues.Show();
            }
            else
            {
                String acum = "";
                int    i    = 0;
                if (!bx)
                {
                    acum = acum + "\nPosicion x";//fila
                    i++;
                }
                if (!by)
                {
                    acum = acum + "\nPosicion y";//columna
                    i++;
                }
                if (!modo)
                {
                    acum = acum + "\nModo ";//Modo (cantidad de tipos de caramelos)
                    i++;
                }
                MessageBox.Show("Error en los datos: " + acum);
            }
        }
Example #23
0
        public static bool CambiarFichaJugador(Juego objJuego, int jugadorId, int jugadorRivalId, int direccion)
        {
            bool huboCambio = false;

            if (direccion == Constantes.Mensajes.Juego.AccionMando.Izquierda)
            {
                objJuego.Jugadores[jugadorId].Elemento.ElementoId--;
                if (objJuego.Jugadores[jugadorId].Elemento.ElementoId < 0)
                {
                    objJuego.Jugadores[jugadorId].Elemento.ElementoId = 3;
                }
                if (objJuego.Jugadores[jugadorId].Elemento.ElementoId == objJuego.Jugadores[jugadorRivalId].Elemento.ElementoId)
                {
                    objJuego.Jugadores[jugadorId].Elemento.ElementoId--;
                }
                if (objJuego.Jugadores[jugadorId].Elemento.ElementoId < 0)
                {
                    objJuego.Jugadores[jugadorId].Elemento.ElementoId = 3;
                }
                huboCambio = true;
            }
            else if (direccion == Constantes.Mensajes.Juego.AccionMando.Derecha)
            {
                objJuego.Jugadores[jugadorId].Elemento.ElementoId++;
                if (objJuego.Jugadores[jugadorId].Elemento.ElementoId > 3)
                {
                    objJuego.Jugadores[jugadorId].Elemento.ElementoId = 0;
                }
                if (objJuego.Jugadores[jugadorId].Elemento.ElementoId == objJuego.Jugadores[jugadorRivalId].Elemento.ElementoId)
                {
                    objJuego.Jugadores[jugadorId].Elemento.ElementoId++;
                }
                if (objJuego.Jugadores[jugadorId].Elemento.ElementoId > 3)
                {
                    objJuego.Jugadores[jugadorId].Elemento.ElementoId = 0;
                }
                huboCambio = true;
            }

            return(huboCambio);
        }
Example #24
0
        private void IniciarSDK()
        {
            try
            {
                App.UIDispatcher = this.Dispatcher;
                App.objSDK       = MainCore.getInstance(Constantes.MULTICAST_ADDRESS, Constantes.MULTICAST_SERVICE_PORT, Constantes.UNICAST_SERVICE_PORT, Constantes.STREAM_SERVICE_PORT, MiMetodoReceptorMesaEspera, Constantes.DELAY);
                int cont = 0;
                while (!App.objSDK.SocketIsConnected && cont < 3)
                {
                    App.objSDK.TearDownSockets();
                    App.objSDK.InitializeSockets();
                    cont++;
                }

                if (App.objSDK.SocketIsConnected)
                {
                    objJuego    = new Juego();
                    objJuego.Ip = App.objSDK.MyIP.ToString();
                    //GENERAR NUMERO UNICO DE LA MESA
                    var numeroMesa = App.objSDK.MyIP.ToString().Split('.');
                    if (numeroMesa.Length == 4)
                    {
                        objJuego.JuegoID   = numeroMesa[2] + numeroMesa[3];
                        lblCodigoMesa.Text = objJuego.JuegoID;
                    }
                    App.objSDK.setObjMetodoReceptorString = MiMetodoReceptorMesaEspera;
                }
                else
                {
                    //No hay conexiĆ³n
                    string strMensaje = "Lo sentimos, no se pudo establecer la conexiĆ³n vĆ­a Wi-Fi. Intente nuevamente.";
                    Helper.MensajeOk(strMensaje);
                    this.Frame.Navigate(typeof(SeleccionarRol));
                    return;
                }
            }
            catch (Exception ex)
            {
                Helper.MensajeOk(ex.Message);
            }
        }
Example #25
0
 public static void Update(Juego p)
 {
     using (DeliveryJWEntities db = new DeliveryJWEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 db.Juego.Attach(p);
                 db.Entry(p).State = System.Data.Entity.EntityState.Modified;
                 db.SaveChanges();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 transaction.Rollback();
                 throw ex;
             }
         }
     }
 }
Example #26
0
        private void InsertarIntoDataBase(List <TipoJuego> juegos)
        {
            foreach (TipoJuego tipoJuego in juegos)
            {
                Juego juego = db.Juego.First(j => j.IdJuego == tipoJuego.juego.IdJuego); // Esto es una atadura con alambre pero lo hago porque tira excepciĆ³n sino.
                Dias  d     = new Dias {
                    Dia   = this.Numero,
                    Juego = juego
                };

                db.AddToDias(d);
                try
                {
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }
        }
Example #27
0
 public static void Delete(int?id)
 {
     using (DeliveryJWEntities db = new DeliveryJWEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 Juego p = db.Juego.Find(id);
                 db.Entry(p).State = System.Data.Entity.EntityState.Deleted;
                 db.SaveChanges();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 transaction.Rollback();
                 throw ex;
             }
         }
     }
 }
Example #28
0
        private void btn_Jugar_Click(object sender, RoutedEventArgs e)
        {
            var         nombreJugador    = txt_Jugador.Text;
            string      nombreContinente = (string)cmb_Continentes.SelectedItem;
            IContinente continente       =
                Juego.dameElJuego().
                baseDatosGeografica.getContinente(nombreContinente);


            // Mirar si el Jugador existe, sino lo creo y
            // Lo recupero
            IJugador jugador = Juego.dameElJuego().
                               baseDatosJugadores.getOrCreateJugador(nombreJugador);

            // Crearle una partida
            IPartida partida = jugador.nuevaPartida(continente);

            GameWindow ventanaJuego = new GameWindow(partida);

            ventanaJuego.Show();
        }
Example #29
0
        public void ChangeScene(Scene newScene)
        {
            ActiveScene = newScene;

            if (ActiveScene == Scene.Start)
            {
                ventanaInicio = new VentanaManager(Content);
            }
            if (ActiveScene == Scene.Game)
            {
                ventanaJuego = new Juego(Content);
            }
            if (ActiveScene == Scene.End)
            {
                ventanaFinal = new VentanaManager(Content);
            }
            if (ActiveScene == Scene.Credits)
            {
                ventanaCreditos = new VentanaManager(Content);
            }
        }
        public async Task ModificarJuego(Juego juego, string token)
        {
            using (HttpClient client = new HttpClient())
            {
                String peticion = "api/mini/ModificarJuego";
                Juego  cli      = new Juego();
                cli.Nombre         = juego.Nombre;
                cli.Html           = juego.Html;
                cli.Scritp         = juego.Scritp;
                cli.Css            = juego.Css;
                client.BaseAddress = new Uri(uriapi);
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(headerjson);
                client.DefaultRequestHeaders.Add("Authorization", "bearer "
                                                 + token);

                String              stringJson = JsonConvert.SerializeObject(cli);
                StringContent       content    = new StringContent(stringJson, Encoding.UTF8, "application/json");
                HttpResponseMessage message    = await client.PutAsync(peticion, content);
            }
        }
Example #31
0
        public void DeberiaActualizarRanking()
        {
            var nuevojuego = new Juego();

            Carta carta1 = new Carta();

            var     nuevapartida1 = new Partida();
            Jugador jugador1      = new Jugador().Nombre("Riquelme").Numero(NumJugador.uno).IdConexion("1");
            Jugador jugador2      = new Jugador().Nombre("Palermo").Numero(NumJugador.dos).IdConexion("1"); jugador2.Cartas.Add(carta1);

            nuevapartida1.jugadores.Add(jugador1);
            nuevapartida1.jugadores.Add(jugador2);

            nuevojuego.Partidas.Add(nuevapartida1);
            nuevojuego.Partidas[0].ActualizarRanking();

            Assert.AreEqual(1, nuevojuego.Partidas[0].Resultado.VecesQueGanoElJugador2);
            Assert.AreEqual(0, nuevojuego.Partidas[0].Resultado.VecesQueGanoElJugador1);
            Assert.AreEqual("Riquelme", nuevojuego.Partidas[0].Resultado.NombreJugador1);
            Assert.AreEqual("Palermo", nuevojuego.Partidas[0].Resultado.NombreJugador2);
        }
Example #32
0
        public void agregarAutoresDictionary(ColeccionJuegosUsuario coleccion)
        {
            foreach (var coleccionJuego in coleccion.listaJuegos)
            {
                Juego juego = new Juego(coleccionJuego.idJuego, directorioCacheJuegos);

                String autores = "";
                foreach (var autor in juego.autorJuego)
                {
                    autores += autor + "\n";
                    coleccion.agregarAutoresDictionary(autor, juego);
                }

                String autorJuego  = autores;
                String idJuego     = juego.idJuego;
                String tituloJuego = juego.tituloJuego;


                objetoClaseColeccion.agregarIdsDictionary(idJuego, juego);
            }
        }
Example #33
0
 public Combate(ref Jugador prota, Bestia salvaje, Juego juego)
 {
     r              = new Random();
     bg             = new Image("data/fondo_combate.png");
     font24         = new Font("data/Joystix.ttf", 25);
     font35         = new Font("data/Joystix.ttf", 35);
     continuar      = true;
     capturando     = false;
     turno          = true;
     posicionFlecha = 560;
     seleccion      = 0;
     this.prota     = prota;
     seleccionado   = ObtenerPokemonDisponible();
     this.salvaje   = salvaje;
     this.juego     = juego;
     salvaje.MoveTo(600, 70);
     fondo_opciones = new Image("data/dialogo_combate.png");
     bgSound        = new Sound("data/sonidos/combate.mp3");
     cantidadMinima = 500;
     cantidadMaxima = 700;
 }
Example #34
0
 // --- Cuerpo del programa -----
 public static void Main()
 {
     Juego juego = new Juego();
     juego.Ejecutar();
 }
        public ActionResult VerPista(int Id)
        {
            String nombreUsuario = User.Identity.Name;
            Partida partida = db.Partidas.Single(x => x.Fecha.CompareTo(DateTime.Today) == 0);
            List<Circuito> circuitosList = db.Circuitos.Where(x => x.Partida.PartidaID == partida.PartidaID).ToList();
            Usuario usuario; //no lo cargo porque puede que ese usuario no exista
            Circuito queCircuito = QueCircuito(Id,circuitosList);
            int queOrden = QueOrden(Id);

            //guardo el usuario si es que ya no existe
            if (!db.Usuarios.Any(x => x.Nombre == nombreUsuario))
            {
                usuario = new Usuario() { Nombre = nombreUsuario, TipoUsuario = "jugador" };
                db.Usuarios.Add(usuario);
                //guardo el usuario
                db.SaveChanges();
            }
            else
            {
                usuario = db.Usuarios.Single(x => x.Nombre == nombreUsuario);
            }

                    Juego juegoNuevo;
                    //si la partida es la primera y no es el mismo dia(si es otro dia deberia solo registrar la partida)
                    if (!db.Juegos.Any(x => x.Jugador.Nombre == nombreUsuario && x.Partida.Fecha.CompareTo(DateTime.Today) == 0))
                    {

                        //agrego un el juego si es que no existe
                        juegoNuevo = new Juego() { HoraInicio = DateTime.Now, horaFin = DateTime.Now, Jugador = usuario, Partida = partida };
                        db.Juegos.Add(juegoNuevo);

                        //guardo la partida
                        db.SaveChanges();
                    }

                    juegoNuevo = db.Juegos.Single(x=> x.Jugador.Nombre == nombreUsuario && x.Partida.Fecha.CompareTo(DateTime.Today)== 0);

            //aca controla que sea un codigo de inicio de camino
            if (Id == 1 || Id == 6 || Id == 11 || Id == 16)
            {

                     //aca controlo si ya no hay un avance registrado, de lo contrario quiere decir que no debo registrar la pista 1 del camino
                    if (!db.Avances.Any(x => x.Circuito.CircuitoID == queCircuito.CircuitoID && x.Juego.JuegoID == juegoNuevo.JuegoID))
                    {

                        Juego juegoAvance = db.Juegos.Single(x => x.Jugador.Nombre == nombreUsuario && x.Partida.Fecha.CompareTo(DateTime.Today) == 0);
                        db.Avances.Add(new Avance() { UltimaPista = 1, Circuito = queCircuito, Juego = juegoAvance });
                        //guardo el avance
                        db.SaveChanges();
                        int orden = QueOrden(Id);
                        Pista pistaSalida = db.Pistas.Single(x => x.Circuito.CircuitoID == queCircuito.CircuitoID && x.orden == orden);
                        pistaSalida.Circuito = db.Circuitos.Single(x => x.Pistas.Any(y => y.PistaID == pistaSalida.PistaID));

                        return View(pistaSalida);
                    }
                    else
                    {
                        Pista pista = db.Pistas.Single(x => x.Circuito.CircuitoID == queCircuito.CircuitoID && x.orden == queOrden);
                        return RedirectToAction("PistaYaEncontrada", pista);
                    }

            }
            //aca controla que sea un codigo de final de camino
            else if (Id == 5 || Id == 10 || Id == 15 || Id == 20)
            {
                Usuario jugador = db.Usuarios.Single(x => x.Nombre == nombreUsuario);
                Juego juego = db.Juegos.Single(x => x.Jugador.UsuarioID == jugador.UsuarioID && x.Partida.PartidaID == partida.PartidaID);
                if (db.Avances.Any(x => x.Juego.JuegoID == juego.JuegoID && x.Circuito.CircuitoID == queCircuito.CircuitoID))
                {
                    Avance avance = db.Avances.Single(x => x.Juego.JuegoID == juego.JuegoID && x.Circuito.CircuitoID == queCircuito.CircuitoID);
                    Pista pista = db.Pistas.Single(x => x.Circuito.CircuitoID == queCircuito.CircuitoID && x.orden == queOrden);

                    if (queOrden == avance.UltimaPista + 1)
                    {

                        avance.UltimaPista = QueOrden(Id);
                        db.SaveChanges();
                        //aca falta registrar en avance que termino ese camino
                        return RedirectToAction("Gano", pista);

                    }
                    else if (queOrden <= avance.UltimaPista)
                    {
                        return RedirectToAction("PistaYaEncontrada", pista);
                    }
                    else
                    {
                        return RedirectToAction("Adelantado", pista);
                    }
                }
                else
                {
                    return RedirectToAction("Index","Home",null);
                }

            }
            //ahora controlemos cualquiera de las otras pista que no son finales!
            else
            {

                Usuario jugador = db.Usuarios.Single(x => x.Nombre == nombreUsuario);
                Juego juego = db.Juegos.Single(x => x.Jugador.UsuarioID == jugador.UsuarioID && x.Partida.PartidaID == partida.PartidaID);
                if (db.Avances.Any(x => x.Juego.JuegoID == juego.JuegoID && x.Circuito.CircuitoID == queCircuito.CircuitoID))
                {
                    Avance avance = db.Avances.Single(x => x.Juego.JuegoID == juego.JuegoID && x.Circuito.CircuitoID == queCircuito.CircuitoID);

                    Pista pista = db.Pistas.Single(x => x.Circuito.CircuitoID == queCircuito.CircuitoID && x.orden == queOrden);

                    if (queOrden == avance.UltimaPista + 1)
                    {
                        avance.UltimaPista = queOrden;
                        db.SaveChanges();

                        return View(pista);
                    }
                    else if (queOrden <= avance.UltimaPista)
                    {
                        return RedirectToAction("PistaYaEncontrada", pista);
                    }
                    else
                    {
                        return RedirectToAction("Adelantado", pista);
                    }
                }
                else
                {
                    return RedirectToAction("Index", "Home", null);
                }

            }
        }
Example #36
0
 void Start()
 {
     rb = GetComponent<Rigidbody> ();
     juego = GameObject.FindGameObjectWithTag("Juego").GetComponent<Juego> ();
 }
Example #37
0
    private void registro(Juego juego)
    {
        this.etiqueta("lblID_" + juego.id, "<span size=\"12000\" foreground=\"#000000\">" + juego.id + "</span>");
        this.x += 100;
        this.etiqueta("lblnombre_" + juego.id, "<span size=\"12000\" foreground=\"#000000\">" + juego.nombre + "</span>");
        this.x += 200;
        this.etiqueta("lblanio_" + juego.id, "<span size=\"12000\" foreground=\"#000000\">" + juego.anio + "</span>");
        this.x += 200;

        this.opciones (juego);  //muestra un boton de mostrar id por cada registro
    }
Example #38
0
 private void opciones(Juego juego)
 {
     this.boton("btnMostrarID"+juego.id, "MostrarID", "gtk-file");
 }