Beispiel #1
0
        public void Juego_OnFin(object winner, object perdedor, JuegoCromy.JuegoCromy sender)
        {
            Jugador ganador = (Jugador)winner;
            Jugador loser   = (Jugador)perdedor;

            Clients.Client(ganador.ConectionID).ganar();
            Clients.Client(loser.ConectionID).perder();
        }
Beispiel #2
0
        public void NoPuedoRepartirNiMezclarSinMazo()
        {
            var juego = new JuegoCromy.JuegoCromy();

            juego.Jugador1 = new Jugador()
            {
                ConectionID = "12432", Mazo = new List <Cartas>(), Nombre = "Juan"
            };
            juego.Jugador2 = new Jugador()
            {
                ConectionID = "12434", Mazo = new List <Cartas>(), Nombre = "Marcos"
            };

            bool mazoNoExiste = juego.MazoCompleto.Cartas.Count == 0;

            juego.RepartirCartas();                              // Mezcla y reparte
            mazoNoExiste = juego.MazoCompleto.Cartas.Count == 0; // si despues de repartir sigue siendo 0 y no rompio, no permitio Mezclar / Repartir
            bool jugadorSinMano = juego.Jugador1.Mazo.Count == 0 && juego.Jugador2.Mazo.Count == 0;


            Assert.IsTrue(mazoNoExiste && jugadorSinMano);
        }
Beispiel #3
0
        public void NoPermiteRepartirSinJugadores()
        {
            var juego = new JuegoCromy.JuegoCromy();

            Mazo Carta = new Mazo();

            juego.MazoCompleto = Carta;

            Carta.CargarMazo("Armas de videojuegos");

            Cartas[] CartasOrdenadas = new Cartas[Carta.Cartas.Count];
            Carta.Cartas.CopyTo(CartasOrdenadas);

            juego.RepartirCartas(); // mezcla y reparte las cartas

            bool repartido = juego.Jugador1.Mazo.Count != 0;

            repartido = repartido && juego.Jugador2.Mazo.Count != 0;

            bool noMezclado = this.comprobarCartasNoMezcladas(CartasOrdenadas.ToList(), juego.MazoCompleto.Cartas);


            Assert.IsTrue(noMezclado && !repartido);
        }
Beispiel #4
0
        public void PartidaPermiteRepartirCartas()
        {
            Mazo Carta = new Mazo();

            Carta.CargarMazo("Armas de videojuegos");

            int  cont      = 0;
            bool repetidas = true;

            foreach (var item1 in Carta.Cartas)
            {
                if (repetidas)
                {
                    foreach (var item2 in Carta.Cartas)
                    {
                        cont += item1 == item2 ? 1 : 0;
                    }

                    repetidas = (cont == 1);
                    cont      = 0;
                }
            }

            bool CartasIguales;
            var  juego = new JuegoCromy.JuegoCromy();

            juego.Jugador1.ConectionID = "a";
            juego.Jugador2.ConectionID = "a";
            juego.MazoCompleto         = Carta;
            juego.RepartirCartas();
            CartasIguales = (juego.Jugador1.Mazo.Count == juego.Jugador2.Mazo.Count);


            Assert.IsTrue(CartasIguales, "Los jugadores no tienen la misma cantidad de cartas");
            Assert.IsTrue(repetidas, "Hay dos cartas iguales");
        }