public String graficar(listajuegos listado)
        {
            String dotgraph = "Digraph juegos {\nRankdir=TD\nnode [shape =rectangle]\n";

            if (listado != null)
            {
                juego temp = listado.primero;
                while (temp != null)
                {
                    dotgraph += "juego" + temp.cont.ToString() + " [label=\"Jugador 1: " + temp.userbase + "\nJugador 2: " + temp.oponente;
                    dotgraph += "\nUnidades desplegadas: " + temp.desplegadas.ToString() + "\nUnidades sobrevivientes: " + temp.sobrevivientes.ToString() + "\nUnidades destruidas" + temp.destruidas.ToString();
                    if (temp.gano == 0)
                    {
                        dotgraph += "\nGanó: Sí\"];\n";
                    }
                    else if (temp.gano == 1)
                    {
                        dotgraph += "\nGanó: No\"];\n";
                    }
                    if (temp.anterior != null)
                    {
                        dotgraph += "juego" + temp.anterior.cont.ToString() + " -> juego" + temp.cont.ToString() + ";\n";
                        dotgraph += "juego" + temp.cont.ToString() + " -> juego" + temp.anterior.cont.ToString() + ";\n";
                    }
                    temp = temp.siguiente;
                }
            }

            dotgraph += "}";           //finalizar grafo

            return(guardar(dotgraph)); //retornar la dirección de la imagen
        }
Ejemplo n.º 2
0
 public juego(String userbase_, String oponente_, int desplegadas_, int sobrevivientes_, int destruidas_, int gano_)
 {
     userbase       = userbase_;
     oponente       = oponente_;
     desplegadas    = desplegadas_;
     sobrevivientes = sobrevivientes_;
     destruidas     = destruidas_;
     gano           = gano_;
     cont           = 1;
     siguiente      = null;
     anterior       = null;
 }
Ejemplo n.º 3
0
            public void insertar(juego ingreso)
            {
                nodotopjuegos nuevo = new nodotopjuegos(ingreso);

                nodotopjuegos temp = primero;

                if (temp == null)
                {
                    primero = nuevo;
                    ultimo  = nuevo;
                }

                else
                {
                    //insertar al inicio
                    //if(temp.info.)
                }
            }
Ejemplo n.º 4
0
        public String listajuegos(usuario user)
        {
            if (user.listado != null)
            {
                String salida = "Subgraph lista" + user.getnick() + "{\nnode [shape =rectangle]";
                juego  temp   = user.listado.primero;
                //agregar nodos
                while (temp != null)
                {
                    salida += "lista" + user.getnick() + temp.cont.ToString() + " [label=\"Oponente: " + temp.oponente + "\nUnidades desplegadas: " + temp.desplegadas.ToString();
                    salida += "\nUnidades sobrevivientes: " + temp.sobrevivientes.ToString() + "\nUnidades destruidas: " + temp.destruidas.ToString();
                    switch (temp.gano)
                    {
                    case 0:
                        salida += "Resultado: derrota\"];\n";
                        break;

                    case 1:
                        salida += "Resultado: victoria\"];\n";
                        break;
                    }
                    temp = temp.siguiente;
                }
                //agregar apuntadores
                temp    = user.listado.primero;
                salida += user.getnick() + " -> " + "lista" + user.getnick() + temp.cont.ToString() + ";\n";
                while (temp.siguiente != null)
                {
                    salida += "lista" + user.getnick() + temp.cont.ToString() + " -> lista" + user.getnick() + temp.siguiente.cont.ToString() + ";\n";
                    salida += "lista" + user.getnick() + temp.siguiente.cont.ToString() + " -> lista" + user.getnick() + temp.cont.ToString() + ";\n";
                    temp    = temp.siguiente;
                }
                salida += "}\n";
                return(salida);
            }

            else
            {
                return(null);
            }
        }
Ejemplo n.º 5
0
        public juego insertar(String userbase_, String oponente_, int desplegadas_, int sobrevivientes_, int destruidas_, int gano_)
        {
            juego nuevo = new juego(userbase_, oponente_, desplegadas_, sobrevivientes_, destruidas_, gano_);

            nuevo.cont = this.cont;
            juego temp = primero;

            if (temp == null)
            {
                primero = nuevo;
            }
            else
            {
                while (temp.siguiente != null)
                {
                    temp = temp.siguiente;
                }
                temp.siguiente = nuevo;
                nuevo.anterior = temp;
            }
            cont++;
            return(nuevo);
        }
Ejemplo n.º 6
0
        public void insertarjuego(String oponente_, int desplegadas_, int sobrevivientes_, int destruidas_, int gano_)
        {
            if (listado == null)
            {
                listado = new listajuegos();
            }
            juego nuevo = listado.insertar(nick, oponente_, desplegadas_, sobrevivientes_, destruidas_, gano_);

            //agregar contador de juegos
            if (nuevo.gano == 1)
            {
                ganados++;
            }
            //actualizar porcentaje
            double porcentajenuevo = (double)nuevo.destruidas / (double)nuevo.desplegadas;

            if (porcentajenuevo > porcentaje)
            {
                porcentaje = porcentajenuevo;
            }

            destruidos += nuevo.destruidas;
        }
Ejemplo n.º 7
0
 public nodotopjuegos(juego ingreso)
 {
     info      = ingreso;
     anterior  = null;
     siguiente = null;
 }
Ejemplo n.º 8
0
 public listajuegos()
 {
     primero = null;
 }