Advertisement
Guest User

MIRAESTAVAINA

a guest
Jan 20th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 42.07 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cstdio>
  4. #include <cstdlib>
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <sstream>
  8.  
  9. using namespace std;
  10.  
  11. template <class T>
  12. class nodo
  13. {
  14.   public:
  15.     T info;
  16.     nodo<T>* next, *prev;
  17.     nodo()
  18.     {
  19.       this->next = NULL;
  20.       this->prev = NULL;
  21.     }
  22.     nodo(T info)
  23.     {
  24.       this->info = info;
  25.       this->next = NULL;
  26.       this->prev = NULL;
  27.     }
  28. };
  29. template <class T>
  30. class lista : public nodo<T>
  31. {
  32.   protected:
  33.     nodo<T>* primero, *ultimo;
  34.     int size = 0;
  35.     nodo<T>* crear_nodo(T info)
  36.     {
  37.       nodo<T>* nuevo;
  38.       nuevo = new nodo<T>(info);
  39.       return nuevo;
  40.     }
  41.   public:
  42.     bool vacia()
  43.     {
  44.       return ((primero == NULL && ultimo == NULL) || getsize() == 0);
  45.     }
  46.     int imprimir()
  47.     {
  48.       printf("Tamanio de la lista: %d\n", getsize());
  49.       nodo<T>* temp;
  50.       temp = primero;
  51.       for(int i = 1; i <= getsize(); ++i)
  52.       {
  53.         cout << "Elemento N" << i << ": " << temp->info << "\n";
  54.         temp = temp->next;
  55.       }
  56.       return 1;
  57.     }
  58.     int insertar_primero(T info)
  59.     {
  60.       nodo<T>* aux;
  61.       aux = crear_nodo(info);
  62.       if(primero == NULL || vacia())
  63.       {
  64.         primero = aux;
  65.         ultimo = primero;
  66.       }
  67.       else
  68.       {    
  69.         aux->next = primero;
  70.         primero->prev = aux;
  71.         primero = aux; // primero = primero->prev;
  72.       }
  73.       size = size + 1;
  74.       return 1;
  75.     }
  76.     int insertar_ultimo(T info)
  77.     {
  78.       nodo<T>* aux;
  79.       aux = crear_nodo(info);
  80.       if(ultimo == NULL || primero == NULL || vacia())
  81.         insertar_primero(info);
  82.       else
  83.       {    
  84.         aux->prev = ultimo;
  85.         ultimo->next = aux;
  86.         ultimo = aux; // ultimo = ultimo->next;
  87.         size = size + 1;
  88.       }
  89.       return 1;
  90.     }
  91.     int insertar_ordenado(T info)
  92.     {
  93.       if(vacia())
  94.       {
  95.         insertar_primero(info);
  96.       }
  97.       else{
  98.         nodo<T>* aux, *nuevo;
  99.         //int pos = 1;
  100.         aux = primero;
  101.         nuevo = crear_nodo(info);
  102.         if(info < primero->info){
  103.           insertar_primero(info);
  104.         }else{
  105.           while((aux->next != NULL) && (info > (aux->next)->info))
  106.           {
  107.             //printf("%d > %d\n", info, (aux->next)->info);
  108.             aux = aux->next;
  109.             //pos = pos + 1;
  110.           }
  111.           //insertar_pos(pos, info);
  112.           if(aux == primero){
  113.             insertar_primero(info);
  114.             //printf("INSERTE PRIMERO\n");
  115.           }
  116.           else{
  117.             if(aux == ultimo){
  118.               insertar_ultimo(info);
  119.               //printf("INSERTE ULTIMO\n");
  120.             }
  121.             else{
  122.               nuevo->next = aux->next;
  123.               nuevo->prev = aux;
  124.               (aux->next)->prev = nuevo;
  125.               aux->next = nuevo;
  126.               this->size = this->size + 1;
  127.               //printf("INSERTE_ORDENADO\n");
  128.             }  
  129.           }
  130.         }
  131.       }
  132.       return 1;
  133.     }
  134.     int insertar_pos(int pos, T info)
  135.     {
  136.       if(primero == NULL)
  137.         insertar_primero(info);
  138.       else{
  139.         if(pos-1 == getsize())
  140.           insertar_ultimo(info);  
  141.         else{
  142.           nodo<T>* aux, *temp;
  143.           aux = crear_nodo(info);
  144.           temp = primero;
  145.           for(int i = 1; i <= pos-1; i++)
  146.           {
  147.             temp = temp->next;
  148.           }
  149.           (temp->prev)->next = aux;
  150.           temp->prev = aux;
  151.           aux->prev = temp->prev;
  152.           aux->next = temp;
  153.           temp->prev = aux;
  154.           this->size = this->size + 1;
  155.         }
  156.       }
  157.       return 1;
  158.     }
  159.     int insertar(int pos, T info)
  160.     {
  161.       if(pos == 1)
  162.         insertar_primero(info);
  163.       else{
  164.         if(pos == this->size)
  165.           insertar_ultimo(info);
  166.         else
  167.           insertar_pos(pos, info);
  168.       }
  169.       return 1;
  170.     }
  171.     int eliminar_primero()
  172.     {
  173.       nodo<T>* aux;
  174.       aux = primero;
  175.       primero = aux->next;
  176.       if(primero != NULL)
  177.         primero->prev = NULL;
  178.       delete aux;
  179.       this->size = this->size - 1;
  180.       return 1;
  181.     }
  182.     int eliminar_ultimo()
  183.     {
  184.       nodo<T>* aux;
  185.       aux = ultimo;
  186.       ultimo = aux->prev;
  187.       if(ultimo != NULL)
  188.         ultimo->next = NULL;
  189.       delete aux;
  190.       this->size = this->size - 1;
  191.       return 1;
  192.     }
  193.     int eliminar(int pos)
  194.     {
  195.       if(pos == 1)
  196.         eliminar_primero();
  197.       else{
  198.         if(pos == getsize())
  199.           eliminar_ultimo();
  200.         else{
  201.           nodo<T>* aux;
  202.           aux = primero;
  203.           for(int i = 1; i < pos; ++i){
  204.             aux = aux->next;
  205.           }
  206.           (aux->prev)->next = aux->next;
  207.           (aux->next)->prev = aux->prev;
  208.           delete aux;
  209.           this->size = this->size - 1;
  210.         }
  211.       }
  212.       return 1;
  213.     }
  214.     T extraer_primero()
  215.     {
  216.       //printf("Extraer_primero\n");
  217.       //system("pause");
  218.       T aux;
  219.       aux = primero->info;
  220.       eliminar_primero();
  221.       //printf("Extraje %d\n", aux);
  222.       return aux;
  223.     }
  224.     T extraer_ultimo()
  225.     {
  226.       T aux;
  227.       aux = ultimo->info;
  228.       eliminar_ultimo();
  229.       //printf("Extraje %d\n", aux);
  230.       return aux;
  231.     }
  232.     T extraer(int pos)
  233.     {
  234.       T aux;
  235.       if(pos == 1)
  236.         aux = extraer_primero();
  237.       else{
  238.         if(pos == getsize())
  239.           aux = extraer_ultimo();
  240.         else{
  241.           nodo<T>* nodoaux;
  242.           nodoaux = primero;
  243.           for(int i = 1; i < pos; i++)
  244.           {
  245.             nodoaux = nodoaux->next;
  246.           }
  247.           aux = nodoaux->info;
  248.           eliminar(pos);
  249.         }
  250.       }
  251.       //printf("Extraje %d\n", aux);
  252.       return aux;
  253.     }
  254.     int ordenar()
  255.     {
  256.       T aux;
  257.       lista<T> l;
  258.       while(!vacia())
  259.       {
  260.         aux = extraer_primero();
  261.         l.insertar_ordenado(aux);
  262.       }
  263.       while(!l.vacia())
  264.       {
  265.         aux = l.extraer_primero();
  266.         insertar_ordenado(aux);
  267.       }
  268.       return 1;
  269.     }
  270.     int vaciar()
  271.     {
  272.       while(!vacia()){
  273.         eliminar_primero();
  274.       }
  275.       return 1;
  276.     }
  277.     T mostrar(int pos)
  278.     {
  279.       nodo<T>* aux;
  280.       aux = primero;
  281.       if(pos == 1)
  282.       {
  283.         //cout << "Mostrar " << (aux->info).getnombre() << "\n";
  284.         return aux->info;
  285.       }
  286.       for(int i = 1; i <= pos && !(vacia()) && aux->next != NULL; ++i)
  287.       {
  288.         aux = aux->next;
  289.       }
  290.       //cout << "Mostrar " << (aux->info).getnombre() << "\n";
  291.       return aux->info;
  292.     }
  293.     T* mostrarp(int pos)
  294.     {
  295.       nodo<T>* aux;
  296.       aux = primero;
  297.       T* pT;
  298.       if(pos == 1)
  299.       {
  300.         cout << "Mostrar 1 " << (aux->info).getnombre() << "\n";
  301.         pT = &(aux->info);
  302.         return pT;
  303.       }
  304.       for(int i = 1; i <= pos && !(vacia()) && aux->next != NULL; ++i)
  305.       {
  306.         aux = aux->next;
  307.       }
  308.       cout << "Mostrar 2 " << (aux->info).getnombre() << "\n";
  309.      
  310.       pT = &(aux->info);
  311.       return pT;
  312.     }
  313.     T* buscar(T info)
  314.     {
  315.       nodo<T>* aux;
  316.       aux = primero;
  317.       for(int i = 1; i <= getsize() && !(vacia()) && aux != NULL; ++i)
  318.       {
  319.         if(aux->info == info)
  320.         {
  321.           T* pT;
  322.           pT = &(aux->info);
  323.           return pT;
  324.         }
  325.         aux = aux->next;
  326.       }
  327.       return NULL;
  328.     }
  329.     bool pertenece(T info)
  330.     {
  331.       T* aux;
  332.       return (aux = this->buscar(info));
  333.     }
  334.     int getsize()
  335.     {
  336.       //int tamano = this->size;
  337.       //return tamano;
  338.       return size;
  339.     }
  340. };
  341.  string Borrar_substr(string &str, string del)
  342. //Borra todas las ocurrencias del string del que se encuentren dentro del string str
  343. {
  344.   while(str.find(del) != string::npos)
  345.   {
  346.     str.erase(str.begin() + str.find(del));
  347.   }
  348.   return str;
  349. }
  350.  
  351. int Buscar_substr(string &str, string find, int start)
  352. //Busca la poscicion de la ultima cadena consecutiva
  353. {
  354.   int posfind;
  355.   posfind = str.find(find, start);
  356.   while((posfind != string::npos) && (posfind + 1 == str.find(find, posfind + 1)))
  357.   {
  358.     posfind = str.find(find, posfind + 1);
  359.   }
  360.   return posfind;
  361. }
  362.  
  363. string Picar_substr(string origen, string &str , int &start, int &end, string principio, string fin)
  364. //Crea en str un substr de origen segun ciertos criterios
  365. {
  366.     start = Buscar_substr(origen, principio, end);
  367.     end = origen.find(fin, start + 1);
  368.     if(fin != "final")
  369.       str = origen.substr(start+1, end - start - 1);
  370.     else
  371.       str = origen.substr(start+1);
  372.     cout << str << "|\n";
  373.     Borrar_substr(str, " ");
  374.     cout << str << "|\n";
  375.     return str;
  376. }
  377. template <class T>
  378. bool Existe_T(T lista, string nombre)
  379. //Retorna true si existe el elemento con el nombre nombre en la lista
  380. {
  381.   bool existe;
  382.   existe = false;
  383.   if(lista.vacia())
  384.   {
  385.     //cout << "NO Existe\n";
  386.     return false;
  387.   }
  388.   for(int i = 1; i <= lista.getsize(); ++i)
  389.   {
  390.     //cout << "Entre\n";
  391.     if(nombre == (lista.mostrar(i)).getnombre())
  392.     {
  393.       existe = true;
  394.       //cout << "Existe1\n";
  395.       return existe;
  396.       break;
  397.     }
  398.   }
  399.   //cout << "Existe1.1\n";
  400.   return existe;
  401. }
  402. template <class T>
  403. int Buscar_T_pos(T lista, string nombre)
  404. //Busca el elemento con el nombre nombre en la lista
  405. {
  406.   if(lista.vacia())
  407.   {
  408.     return 0;
  409.   }
  410.   for(int i = 1; i <= lista.getsize(); ++i)
  411.   {
  412.     if(nombre == (lista.mostrar(i)).getnombre())
  413.     {
  414.       return i;
  415.     }
  416.   }
  417.   return -1;
  418. }
  419. int Error(int codigo, string &mensaje)
  420. {
  421.   /*
  422.   -Codigos de Error:
  423.     0: Comando inválido
  424.     1: La contextura no existe
  425.     2: El Luchador ya existe
  426.     3: El Luchador no existe
  427.     4: El Jugador ya existe
  428.     5: EL nivel de habilidad es invalido
  429.     6: El Jugador no existe
  430.     7: Imposible realizar combate: El Jugador <nombrejugador> no tiene luchadores
  431.     8: El número de jugadores tiene que ser 2
  432.   */
  433.   switch (codigo)
  434.   {
  435.     case 0:
  436.       cout << "Comando invalido: " << mensaje << "\n";
  437.       return 0;
  438.     case 1:
  439.       cout << "La contextura " << mensaje << "no existe\n";
  440.       return 1;
  441.     case 2:
  442.       cout << "El Luchador " << mensaje << " ya existe\n";
  443.       return 2;
  444.     case 3:
  445.       cout << "El Luchador " << mensaje << " no existe\n";
  446.       return 3;
  447.     case 4:
  448.       cout << "El Jugador " << mensaje << " ya existe\n";
  449.       return 4;
  450.     case 5:
  451.       cout << "EL nivel de habilidad " << mensaje << " es invalido\n";
  452.       return 5;
  453.     case 6:
  454.       cout << "El Jugador " << mensaje << " no existe\n";
  455.       return 6;
  456.     case 7:
  457.       cout << "Imposible realizar combate: El Jugador " << mensaje << " no tiene luchadores\n";
  458.       return 7;
  459.     case 8:
  460.       //Podría juntar el Error 8 y 9 en uno génerico:
  461.       //cout << "El número de jugadores tiene que ser << mensaje <<"\n";
  462.       //return 8; Con mensaje = al numero minimo de jugadores requeridos.
  463.       //Pero no quise c: (Dime que opinas).
  464.       cout << "El número de jugadores tiene que ser 2\n";
  465.       return 8;
  466.     case 9:
  467.       cout << "El número de jugadores tiene que ser 4\n";
  468.       return 9;
  469.     default:
  470.       cout << "Comando invalido: " << mensaje << "\n";
  471.       return -1;
  472.   }
  473. }
  474. template <class T>
  475. int Picar_sublista(T lista, string &participantes, string &comando)
  476.   {
  477.     /*
  478.     if(this->buscar(jugador)){
  479.         //El Jugador no existe
  480.         Error(0, comando);
  481.     }else{
  482.     */
  483.         if(participantes.find("[") != 0 || participantes.find("]") != participantes.size() - 1
  484.         || ((participantes.find(",") + 1 == participantes.find(",", participantes.find(",") + 1)
  485.         || participantes.find(",") < participantes.find("[") || participantes.find(",") > participantes.find("]"))
  486.         && participantes.find(",")!= string::npos && participantes.find(",", participantes.find(",") + 1) != string::npos))
  487.       //Comando invalido
  488.         {
  489.           Error(0, comando);
  490.         }
  491.         else
  492.         //Comando valido
  493.         {
  494.           cout << "Voy a picar\n";
  495.           int start, end;
  496.           start = 0;
  497.           end = 0;
  498.           while(participantes.find(",",end+1) != string::npos || participantes.find("]",end+1) != string::npos)
  499.           {
  500.             string jugadoraux;
  501.             start = end;
  502.             if(start == 0)
  503.             {
  504.               if(participantes.find(",",start) != string::npos)
  505.               //Caso mas de un luchador
  506.               {
  507.                 Picar_substr(participantes, jugadoraux, start, end, "[", ",");
  508.               }
  509.               else
  510.               //Caso un luchador
  511.               {
  512.                 Picar_substr(participantes, jugadoraux, start, end, "[", "]");
  513.               }
  514.             }
  515.             else
  516.             {
  517.               if(participantes.find(",",end+1) != string::npos)
  518.               //Caso mas de un luchador
  519.               {
  520.                 Picar_substr(participantes, jugadoraux, start, end, ",", ",");
  521.               }
  522.               else
  523.               //Caso ultimo luchador
  524.               {
  525.                 Picar_substr(participantes, jugadoraux, start, end, ",", "]");
  526.               }
  527.             }
  528.             if(J.buscar(jugadoraux))
  529.             //Apila la direccion de memoria del luchador
  530.             {
  531.               Jugador *aux;
  532.               cout << "Jugador a buscar: " << jugadoraux << "\n";
  533.               aux = J.buscar(jugadoraux);
  534.               if((aux->pila.vacia()))
  535.               //Si la pila del jugador esta vacia muestra un error
  536.               {
  537.                 Error(7, jugadoraux);
  538.                 return 7;
  539.               }
  540.               else
  541.               //Jufador con luchadores
  542.               {          
  543.                 cout << "Insertare: " << jugadoraux << " en la lista de particpantes\n";
  544.                 lista.insertar_primero(aux);
  545.                 cout << "Inserte: " << jugadoraux << " en la lista de particpantes\n";
  546.                 //cout << "pop: " << (luchadores.pop())->getnombre() << "\n";
  547.                 //luchadores.push(pluchador);
  548.               }
  549.             }
  550.             else
  551.             //Luchador no existe
  552.             {
  553.               Error(6, jugadoraux);
  554.               return 6;
  555.             }      
  556.           }
  557.         }  
  558.     //}
  559.   }
  560.  /*
  561. struct ventaja{// Estructura de los movimientos
  562.     string contex = "";
  563.     ventaja *next = NULL;
  564. };
  565.  
  566. class lisven{
  567. public:
  568. ventaja * inicio = NULL;
  569. lisven(){ inicio = NULL;}
  570.  
  571.  
  572.     void insertar(string c){
  573.     if(c == "-1"){
  574.         printf(" contextura invalida");
  575.     }
  576.         if(inicio = NULL){
  577.             inicio = new ventaja;
  578.         }else{
  579.             ventaja * actual = inicio;
  580.             while(actual->next!=NULL && actual->contex != c){//||
  581.                 actual = actual->next;
  582.             }
  583.             if(actual->contex == c){
  584.                 free(actual);
  585.             }else{
  586.                 actual->next = new ventaja;
  587.                 actual->next->contex = c;
  588.             }
  589.         }
  590.     }
  591.  
  592.     ventaja * ret(){
  593.         return inicio;
  594.     }  
  595. };
  596. */
  597. struct Movimiento{// Estructura de los movimientos
  598.     string combo;
  599.     int danno;
  600.     lista<string*> ventajas;
  601.     Movimiento * next = NULL;
  602. };
  603.  
  604.  
  605.  
  606. class lismovimientos{//Lista de los movimientos con sus respectivos metodos
  607. public:
  608.     Movimiento * inicio = NULL;
  609.  
  610.  
  611.     void sobreescribir(Movimiento * a, int d, string &v, string &comando){
  612.         a->danno = d;
  613.         aplicarventajas(a, v, comando);
  614.     }
  615.     void aplicarventajas(Movimiento *&pmove, string &ventajas2, string &comando){
  616.         if( ventajas2.find("[") != 0 || ventajas2.find("]") != ventajas2.size() - 1
  617.         || ((ventajas2.find(",") + 1 == ventajas2.find(",", ventajas2.find(",") + 1)  
  618.         || ventajas2.find(",") < ventajas2.find("[") || ventajas2.find(",") > ventajas2.find("]"))
  619.         && ventajas2.find(",") != string::npos && ventajas2.find(",", ventajas2.find(",") + 1) != string::npos)
  620.         )
  621.       //Comando invalido
  622.       {
  623.         printf(" pos ']': %d size: %d", ventajas2.find("]"), ventajas2.size());
  624.         Error(0, comando);
  625.       }
  626.       else
  627.       //Comando valido
  628.       {
  629.         int start, end;
  630.         start = 0;
  631.         end = 0;
  632.         while(ventajas2.find(",",end+1) != string::npos || ventajas2.find("]",end+1) != string::npos)
  633.         {
  634.           string contextura;
  635.           start = end;
  636.           if(start == 0)
  637.           {
  638.             if(ventajas2.find(",",start) != string::npos)
  639.             //Caso mas de una ventaja
  640.             {
  641.               Picar_substr(ventajas2, contextura, start, end, "[", ",");
  642.             }
  643.             else
  644.             //Caso una ventaja o ninguna
  645.             {
  646.               Picar_substr(ventajas2, contextura, start, end, "[", "]");
  647.             }
  648.           }
  649.           else
  650.           {
  651.             if(ventajas2.find(",",end+1) != string::npos)
  652.             //Caso mas de una ventaja
  653.             {
  654.               Picar_substr(ventajas2, contextura, start, end, ",", ",");
  655.             }
  656.             else
  657.             //Caso ultima ventaja
  658.             {
  659.               Picar_substr(ventajas2, contextura, start, end, ",", "]");
  660.             }
  661.           }
  662.           if(contexturas.pertenece(contextura))
  663.           //Almacena la direccion de memoria de la contextura
  664.           {
  665.             string* pcontextura;
  666.             pcontextura = contexturas.buscar(contextura);
  667.             pmove->ventajas.insertar_ultimo(pcontextura);
  668.           }
  669.           else{
  670.             if(ventajas2.find("]") - ventajas2.find("[") == 1)
  671.             //Sin ventajas
  672.             {
  673.               pmove->ventajas.vaciar();
  674.               continue;
  675.             }
  676.             else
  677.             //Contextura invalida
  678.             {
  679.               Error(1, contextura);
  680.             }
  681.           }      
  682.         }
  683.       }
  684.     }
  685.     void insertar(string c, int d, string &v, string &comando){
  686.         if(inicio == NULL){
  687.             inicio = new Movimiento();
  688.             inicio->combo = c;
  689.             inicio->danno = d;
  690.             this->aplicarventajas(inicio, v, comando);
  691.         }else{
  692.             Movimiento * actual = inicio;
  693.             while(actual->next!=NULL && actual->combo != c){//||
  694.                 actual = actual->next;
  695.             }
  696.             if(actual->combo == c){
  697.                 sobreescribir(actual, d, v, comando);
  698.             }else{
  699.                 actual->next = new Movimiento;
  700.                 (actual->next)->combo = c;
  701.                 (actual->next)->danno = d;
  702.                 this->aplicarventajas(actual->next, v, comando);
  703.             }
  704.         }
  705.     }
  706. };
  707.  
  708. struct Luchador{//Estructura de Luchador
  709.     string nombre;
  710.     string *contextura;
  711.     lismovimientos lsmovimientos;
  712.     Luchador * next = NULL;
  713. };
  714.  
  715. class listadeluchadores{// Lista de luchadores con sus respectivos metodos
  716. public:
  717.     bool estado = false;
  718.     Luchador * inicio = NULL;
  719.  
  720.     void insertar(string a, string b){
  721.         if(!contexturas.pertenece(b)){
  722.                 Error(1, b);
  723.                 return;
  724.         }
  725.         cout << "toy aqui\n";
  726.         if(!estado){
  727.             cout << "entre a inicio papu\n";
  728.             inicio = new Luchador;
  729.             inicio->nombre = a;
  730.             inicio->contextura = contexturas.buscar(b);
  731.             estado = true;
  732.         }else{
  733.             cout << inicio->nombre <<" " <<inicio->contextura<<" inicio \n";
  734.             cout << "entre al peo papu\n";
  735.             Luchador * actual = inicio;
  736.             cout << actual->nombre <<" " <<actual->contextura<<"\n";
  737.             while(actual->next != NULL){
  738.                 cout << actual->nombre <<" " <<actual->contextura<<"\n";
  739.                 actual = actual->next;
  740.             }
  741.             cout << actual->nombre <<" " <<actual->contextura<<"\n";
  742.             actual->next=new Luchador;
  743.             (actual->next)->nombre = a;
  744.             (actual->next)->contextura = contexturas.buscar(b);
  745.         }
  746.     }
  747.  
  748.     Luchador * buscar(string busqueda){
  749.         if(inicio == NULL){
  750.             return NULL;
  751.         }else{
  752.             Luchador * actual = inicio;
  753.             while(actual->next != NULL){
  754.                 if(actual->nombre == busqueda){
  755.                     return actual;
  756.                 }
  757.                 actual = actual->next;
  758.             }
  759.             if(actual->nombre == busqueda){
  760.                 return actual;
  761.             }else{
  762.                 return NULL;
  763.             }
  764.         }
  765.     }
  766.  
  767.     void buscar(){
  768.         Luchador * actual = inicio;
  769.         while(actual->next != NULL){
  770.             actual = actual->next;
  771.             cout << actual->nombre <<" " <<actual->contextura<<"\n";
  772.         }
  773.     }
  774.  
  775. };
  776.  
  777. //lismovimientos M;
  778. listadeluchadores L;
  779.  
  780. struct nodopilaluchadores{//Estructura de apuntadores que apuntan a los odos de la lista de luchadores
  781.     Luchador * per;
  782.     nodopilaluchadores * next;
  783. };
  784.  
  785.  
  786. class piladeluchadores{//Pila de luchadores, donde los nodos que apuntan a los luchadores son los que son apilados
  787. public:
  788.     bool estado = false;
  789.     nodopilaluchadores * inicio = NULL;
  790.   bool vacia()
  791.   {
  792.     return (inicio == NULL)
  793.   }
  794.     void insertar(Luchador *luchador){
  795.         if(!estado){
  796.             inicio = new nodopilaluchadores;
  797.             inicio->per = luchador;
  798.         }else{
  799.             nodopilaluchadores * aux = inicio;
  800.             inicio = new nodopilaluchadores;
  801.             inicio->per = luchador;
  802.             inicio->next = aux;
  803.         }
  804.     }
  805.  
  806.     /*Luchador * retluch(){//Esta funcion retorna el tope de la pila (especificamente el nodo al que apunta el nodo que esta en el tope)
  807.         if(inicio == NULL){
  808.             return NULL;
  809.         }
  810.         return inicio->per;
  811.     }*/
  812.  
  813.     nodopilaluchadores * rettop(){//Esta funcion a diferencia de la otra, la cual esta comentada, retorna el nodo que esta en el tope de la pila de nodos apuntadores.
  814.         if(inicio == NULL){
  815.             return NULL;
  816.         }
  817.         return inicio;
  818.     }
  819.     void Desapilar(){
  820.         if(inicio->next == NULL){
  821.             inicio=NULL;
  822.             return;
  823.         }
  824.         inicio = inicio->next;
  825.     }
  826.  
  827.     void rein(){
  828.         while(inicio != NULL){
  829.             Desapilar();
  830.         }
  831.     }
  832.  
  833.     void enpilar(nodopilaluchadores * &a){
  834.       //Esta funcion utiliza las primitivas de la pila para hacer que
  835.       //la pila ~(sea pro, y tenga trastornos de identidad para que se comporte como nosotros queremos, mientras sigue siendo una pila c:)~ nunca este vacia
  836.         if(inicio == NULL){
  837.             inicio=a;
  838.             inicio->next = NULL;
  839.             return;
  840.         }
  841.         nodopilaluchadores * z = rettop();
  842.         Desapilar();
  843.         enpilar(a);
  844.         z->next = inicio;
  845.         inicio = z;
  846.     }
  847. };
  848.  
  849. class Jugador{
  850.   //Esto, es una clase, a diferencia de otros nodos que son estructuras ya que esto nos permite agilizar el calculo de daño e implmentar los diferentes metodos de los Jugadores.
  851. public:
  852.     string nombre;
  853.     int lvl;
  854.     piladeluchadores pila;
  855.     int acumulado;
  856.     int acumuladotot;
  857.     Jugador * next = NULL;
  858.  
  859.     void calcular(Luchador * ali, Luchador * riv){//Esta accion actualiza el daño que realiza el judador por combate
  860.         acumulado = 0;
  861.         bool r = true;
  862.         if(ali->lsmovimientos.inicio != NULL){
  863.             Movimiento * actual = ali->lsmovimientos.inicio;
  864.             ventaja * ven;
  865.             while(actual->next != NULL){
  866.                 ven = actual->lista.ret();
  867.                 while(r && ven->next !=NULL ){
  868.                     if(ven->contex == ""){//debes arreglar esto
  869.                         acumulado = acumulado + actual->danno + lvl;
  870.                         r = false;
  871.                     }else if(ven->contex != riv->contextura){//y esto
  872.                         acumulado = acumulado + (actual->danno/2) + lvl;
  873.                         r = false;
  874.                     }else if(ven->contex == riv->contextura){//y esto
  875.                         acumulado = acumulado + (actual->danno*2) + lvl;
  876.                         r = false;
  877.                     }
  878.                     actual = actual->next;
  879.                 }
  880.             }
  881.             if(ven->contex == "" && r){
  882.                 acumulado = acumulado + actual->danno + lvl;//y esto
  883.                 r = false;
  884.             }else if(ven->contex != riv->contextura && r){
  885.                 acumulado = acumulado + (actual->danno/2) + lvl;//y esto
  886.                 r = false;
  887.             }else if(ven->contex == riv->contextura && r){
  888.                 acumulado = acumulado + (actual->danno*2) + lvl;//y esto
  889.                 r = false;
  890.             }
  891.         }
  892.     }
  893.  
  894.     void acum(){//acumula los valores totales de daño para todos contra todos
  895.         acumuladotot = acumuladotot + acumulado;
  896.     }
  897.     void rein(){//reinicia los valores totales
  898.         acumuladotot = 0;
  899.     }
  900. };
  901.  
  902. class listadejugadores{
  903. public:
  904.     Jugador * inicio = NULL;
  905.  
  906.     bool vacio(){
  907.         return inicio==NULL;
  908.     }
  909.  
  910.     void insertar(string n, string& habilidad){//crea e insterta nodos a la lista de jugadores
  911.       int l;
  912.       l = atoi(habilidad.c_str());
  913.       if(l >= 0 && l <= 100)
  914.       //Habilidad permitida
  915.       {
  916.         if(inicio == NULL){
  917.             inicio = new Jugador;
  918.             inicio->nombre = n;
  919.             inicio->lvl = l;
  920.             inicio->acumuladotot = 0;
  921.             inicio->acumulado = 0;
  922.         }else{
  923.             Jugador * actual = inicio;
  924.             while(actual->next != NULL){
  925.                 actual = actual->next;
  926.             }
  927.             actual->next = new Jugador;
  928.             (actual->next)->nombre = n;
  929.             (actual->next)->lvl = l;
  930.             (actual->next)->acumuladotot = 0;
  931.             (actual->next)->acumulado = 0
  932.         }
  933.       }else{
  934.         //Muy OP no vale
  935.         Error(5, habilidad);
  936.       }
  937.     }
  938.  
  939.  
  940.     Jugador * buscar(string busqueda){
  941.         if(inicio == NULL){
  942.             return NULL;
  943.         }else{
  944.             Jugador * actual = inicio;
  945.             while(actual->next != NULL){
  946.                 if(actual->nombre == busqueda){
  947.                     return actual;
  948.                 }
  949.                 actual = actual->next;
  950.             }
  951.             if(actual->nombre == busqueda){
  952.                 return actual;
  953.             }else{
  954.                 return NULL;
  955.             }
  956.      
  957.        }
  958.     }
  959.  
  960.  
  961.     void imprimir(){
  962.         Jugador * actual = inicio;
  963.         cout << actual->nombre <<" " <<actual->lvl<<"\n";
  964.         while(actual->next != NULL){
  965.             cout << actual->nombre <<" " <<actual->lvl<<"\n";
  966.             actual = actual->next;
  967.         }
  968.     }
  969.  
  970.     void asignar(string &jugador, string &luchadores2, string &comando){
  971.       if(this->buscar(jugador)){
  972.         //El Jugador no existe
  973.         Error(6, jugador);
  974.       }else{
  975.         if(luchadores2.find("[") != 0 || luchadores2.find("]") != luchadores2.size() - 1
  976.         || ((luchadores2.find(",") + 1 == luchadores2.find(",", luchadores2.find(",") + 1)
  977.         || luchadores2.find(",") < luchadores2.find("[") || luchadores2.find(",") > luchadores2.find("]"))
  978.         && luchadores2.find(",")!= string::npos && luchadores2.find(",", luchadores2.find(",") + 1) != string::npos))
  979.       //Comando invalido
  980.       {
  981.         Error(0, comando);
  982.       }
  983.         else
  984.         //Comando valido
  985.         {
  986.           cout << "Voy a asignar\n";
  987.           int start, end;
  988.           start = 0;
  989.           end = 0;
  990.           while(luchadores2.find(",",end+1) != string::npos || luchadores2.find("]",end+1) != string::npos)
  991.           {
  992.             string luchadoraux;
  993.             start = end;
  994.             if(start == 0)
  995.             {
  996.               if(luchadores2.find(",",start) != string::npos)
  997.               //Caso mas de un luchador
  998.               {
  999.                 Picar_substr(luchadores2, luchadoraux, start, end, "[", ",");
  1000.               }
  1001.               else
  1002.               //Caso un luchador
  1003.               {
  1004.                 Picar_substr(luchadores2, luchadoraux, start, end, "[", "]");
  1005.               }
  1006.             }
  1007.             else
  1008.             {
  1009.               if(luchadores2.find(",",end+1) != string::npos)
  1010.               //Caso mas de un luchador
  1011.               {
  1012.                 Picar_substr(luchadores2, luchadoraux, start, end, ",", ",");
  1013.               }
  1014.               else
  1015.               //Caso ultimo luchador
  1016.               {
  1017.                 Picar_substr(luchadores2, luchadoraux, start, end, ",", "]");
  1018.               }
  1019.             }
  1020.             if(L.buscar(luchadoraux))
  1021.             //Apila la direccion de memoria del luchador
  1022.             {
  1023.               Jugador *aux;
  1024.               aux = J.buscar(jugador);
  1025.               Luchador* pluchador;
  1026.               pluchador = L.buscar(luchadoraux);
  1027.               cout << "Luchador a buscar: " << luchadoraux << "\n";
  1028.               cout << "Pusheare: " << pluchador->nombre << " en la pila del jugador: " << jugador << "\n";
  1029.               aux->pila.insertar(pluchador);
  1030.               cout << "Pushee: " << pluchador->nombre << " en la pila del jugador: " << jugador << "\n";
  1031.               //cout << "pop: " << (luchadores.pop())->getnombre() << "\n";
  1032.               //luchadores.push(pluchador);
  1033.             }
  1034.             else
  1035.             //Luchador no existe
  1036.             {
  1037.               Error(3, luchadoraux);
  1038.             }      
  1039.           }
  1040.         }  
  1041.       }
  1042.     }
  1043. };
  1044.  
  1045.  
  1046.  
  1047. listadejugadores J;
  1048.  
  1049. void print1v1(string a, string b){
  1050.     Jugador * J1 = J.buscar(a);
  1051.     Jugador * J2 = J.buscar(b);
  1052.     if(J1->acumulado > J2->acumulado){
  1053.         printf("El ganador es ");
  1054.         cout << J1->nombre;
  1055.         printf(" realizando %d de daño\n", J1->acumulado);
  1056.     }else{
  1057.         printf("El ganador es ");
  1058.         cout << J2->nombre;
  1059.         printf(" realizando %d de daño\n", J2->acumulado);
  1060.     }
  1061.     free(J1);
  1062.     free(J2);
  1063. }
  1064.  
  1065. void comb1v1(lista<Jugador*> Particpantes, comando){
  1066.   if(Particpantes.getsize() != 2)
  1067.   //Numero de Participantes invalido
  1068.   {
  1069.     Error(8, comando)
  1070.   }
  1071.     nodopilaluchadores * aux = J1->pila.rettop();
  1072.     Luchador * Luch1 = aux->per;
  1073.     J1->pila.enpilar(aux);
  1074.     free(aux);
  1075.     aux = J2->pila.rettop();
  1076.     Luchador * Luch2 = aux->per;
  1077.     J2->pila.enpilar(aux);
  1078.     free(aux);
  1079.     J1->calcular(Luch1, Luch2);
  1080.     J2->calcular(Luch2, Luch1);
  1081.     free(J1);
  1082.     free(J2);
  1083. }
  1084.  
  1085. void comb2v2(string a, string b, string c, string d){
  1086.     Jugador * J1 = J.buscar(a);
  1087.     Jugador * J2 = J.buscar(b);
  1088.     Jugador * J3 = J.buscar(c);
  1089.     Jugador * J4 = J.buscar(d);
  1090.     comb1v1(J1, J3);
  1091.     comb1v1(J2, J4);
  1092.     if(J1->acumulado + J2->acumulado > J3->acumulado + J4->acumulado){
  1093.         printf("Los ganadores son ");
  1094.         cout << J1->nombre;
  1095.         printf(" realizando %d de daño y ", J1->acumulado);
  1096.         cout << J2->nombre;
  1097.         printf(" realizando %d de daño\n", J2->acumulado);
  1098.     }else{
  1099.         printf("Los ganadores son ");
  1100.         cout << J3->nombre;
  1101.         printf(" realizando %d de daño", J3->acumulado);
  1102.         cout << J4->nombre;
  1103.         printf(" realizando %d de daño\n", J4->acumulado);
  1104.     }
  1105. }
  1106.  
  1107. void reintot(){
  1108.     Jugador * actual = J.inicio;
  1109.     while(actual->next != NULL){
  1110.         actual->rein();
  1111.     }
  1112.     actual->rein();
  1113. }
  1114.  
  1115. void tvt(){
  1116.     Jugador * actual = J.inicio;
  1117.     while(actual->next != NULL){
  1118.         Jugador * rival = actual->next;
  1119.         while(rival->next != NULL){
  1120.             comb1v1(actual, rival);
  1121.             rival->next;
  1122.         }
  1123.     rival->next;
  1124.     actual->acum();
  1125.     }
  1126.     actual=J.inicio;
  1127.     Jugador * primero = new Jugador;
  1128.     Jugador * segundo = new Jugador;
  1129.     Jugador * tercero = new Jugador;
  1130.     while(actual->next !=NULL){
  1131.         if(actual->acumuladotot > primero->acumuladotot && actual->acumuladotot > segundo->acumuladotot && actual->acumuladotot > tercero->acumuladotot){
  1132.         tercero = segundo;
  1133.         segundo = primero;
  1134.         free(primero);
  1135.         primero = actual;
  1136.         }else if(actual->acumuladotot < primero->acumuladotot && actual->acumuladotot > segundo->acumuladotot && actual->acumuladotot > tercero->acumuladotot){
  1137.             tercero = segundo;
  1138.             free(segundo);
  1139.             segundo = actual;
  1140.         }else if(actual->acumuladotot < primero->acumuladotot && actual->acumuladotot < segundo->acumuladotot && actual->acumuladotot > tercero->acumuladotot){
  1141.             free(tercero);
  1142.             tercero = actual;
  1143.         }
  1144.     }
  1145.     printf("El ganador en 1er puesto es ");
  1146.     cout << primero->nombre;
  1147.     printf(" realizando %d de daño, 2do puesto es ", primero->acumuladotot);
  1148.     cout << segundo->nombre;
  1149.     printf(" realizando %d de daño y 3er Puesto es ", segundo->acumuladotot);
  1150.     cout << tercero->nombre;
  1151.     printf(" %d de daño\n", tercero->acumuladotot);
  1152.     reintot();
  1153. }
  1154. void Combate(string &modalidad, lista<Jugador*> LParticipantes, string &comando)
  1155. {
  1156.   if(modalidad == "1vs1"){
  1157.     comb1v1(LParticipantes, comando);
  1158.     print1v1(J1, J2);
  1159.   }
  1160.   else if(modalidad == "2vs2"){
  1161.     comb2v2(LParticipantes);
  1162.   }
  1163.   else if(modalidad == "Todos"){
  1164.     if(!J.vacio()){
  1165.       printf("Cantidad de jugadores invalida\n");
  1166.     }else{
  1167.       int cont = 2;
  1168.       Jugador * aux = J.inicio;
  1169.       while(aux->next != NULL && cont < 3){
  1170.         cont++;
  1171.       }
  1172.       if(cont >= 3){
  1173.         tvt();
  1174.       }
  1175.     }
  1176.   }
  1177. }
  1178. int Crear_contexturas(lista<string> &contexturas)
  1179. {
  1180.  
  1181.   contexturas.insertar_primero("ligero");
  1182.   contexturas.insertar_primero("equilibrado");
  1183.   contexturas.insertar_primero("pesado");
  1184.   //contexturas.imprimir();
  1185. }
  1186.  
  1187. lista<string> contexturas;
  1188.  
  1189. int main (){
  1190. Crear_contexturas(contexturas);
  1191. ifstream Entrada;
  1192. Entrada.open("Entrada.in");//Aqui se abre el archivo
  1193.  
  1194.  
  1195. if (Entrada.fail()){
  1196.     Entrada.open("Entrada.in.txt");
  1197.     if (Entrada.fail()){
  1198.         Entrada.open("Entrada.txt");
  1199.         if (Entrada.fail()){
  1200.             printf("Entrada.in no fue encontrada \n");
  1201.             return -1;
  1202.         }
  1203.     }
  1204. }
  1205.  
  1206.  
  1207. /*while(!Entrada.eof()){
  1208.     string line;
  1209.     while (getline(Entrada, line)){
  1210.         int posws, pos;
  1211.         posws = 0; //Poscicion white space
  1212.         pos = 0;
  1213.         posws = line.find(" ", posws); //Busca el primer " "
  1214.         //if (posws!=string::npos)
  1215.         cout << line << "\n";
  1216.         // " - Tamanno: " << prueba.size() << " - Espacio: " << posws << "\n";
  1217.         pos = posws;
  1218.         string inst;
  1219.         inst = line.substr(0, posws);
  1220.         cout << inst << "|\n";
  1221.  
  1222.  
  1223.  
  1224.  
  1225.  
  1226.  
  1227.         if(inst == "Luchador"){
  1228.             string nombre = "";
  1229.             string contextura = "";
  1230.  
  1231.  
  1232.  
  1233.  
  1234.             line = line.substr(posws+1);
  1235.             posws = 0; //Poscicion white space
  1236.             pos = 0;
  1237.             posws = line.find(" ", posws); //Busca el primer " "
  1238.             //if (posws!=string::npos)
  1239.             // " - Tamanno: " << prueba.size() << " - Espacio: " << posws << "\n";
  1240.             pos = posws;
  1241.             nombre = line.substr(0, posws);
  1242.  
  1243.  
  1244.  
  1245.             line = line.substr(posws+1);
  1246.             posws = 0; //Poscicion white space
  1247.             pos = 0;
  1248.             posws = line.find(" ", posws); //Busca el primer " "
  1249.             //if (posws!=string::npos)
  1250.             // " - Tamanno: " << prueba.size() << " - Espacio: " << posws << "\n";
  1251.             pos = posws;
  1252.             contextura = line.substr(0, posws);
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258.  
  1259.  
  1260.             L.insertar(nombre, contextura);
  1261.  
  1262.  
  1263.  
  1264.  
  1265.         }else if(inst == "buscar") {
  1266.             L.buscar();
  1267.             cout << "llegue aqui\n";
  1268.  
  1269.  
  1270.  
  1271.  
  1272.  
  1273.  
  1274.  
  1275.  
  1276.     }else if(inst == "Movimiento"){
  1277.         string per = "";
  1278.         Movimiento aux;
  1279.  
  1280.  
  1281.  
  1282.         line = line.substr(posws+1);
  1283.         posws = 0; //Poscicion white space
  1284.         pos = 0;
  1285.         posws = line.find(" ", posws); //Busca el primer " "
  1286.         //if (posws!=string::npos)
  1287.         // " - Tamanno: " << prueba.size() << " - Espacio: " << posws << "\n";
  1288.         pos = posws;
  1289.         aux.combo = line.substr(0, posws);
  1290.  
  1291.  
  1292.         line = line.substr(posws+1);
  1293.         posws = 0; //Poscicion white space
  1294.         pos = 0;
  1295.         posws = line.find(" ", posws); //Busca el primer " "
  1296.         //if (posws!=string::npos)
  1297.         // " - Tamanno: " << prueba.size() << " - Espacio: " << posws << "\n";
  1298.         pos = posws;
  1299.         aux.danno = line.substr(0, posws);
  1300.  
  1301.  
  1302.  
  1303.  
  1304.         line = line.substr(posws+1);
  1305.         posws = 0; //Poscicion white space
  1306.         pos = 0;
  1307.         posws = line.find(" ", posws); //Busca el primer " "
  1308.         //if (posws!=string::npos)
  1309.         // " - Tamanno: " << prueba.size() << " - Espacio: " << posws << "\n";
  1310.         pos = posws;
  1311.         contextura = line.substr(0, posws);
  1312.  
  1313.  
  1314.         if(v1 != "ligero" && v1 != "equilibrado" && v1 != "pesado" && v != "" && v1 != "-1"){
  1315.             printf("Ventaja invalidad");
  1316.             return;
  1317.             free(aux);
  1318.         }
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324.  
  1325.         cout << "woa morir\n";
  1326.  
  1327.     }else if(inst == "Jugador"){
  1328.         string nombre;
  1329.         int nivel;
  1330.  
  1331.  
  1332.         line = line.substr(posws+1);
  1333.         posws = 0; //Poscicion white space
  1334.         pos = 0;
  1335.         posws = line.find(" ", posws); //Busca el primer " "
  1336.         //if (posws!=string::npos)
  1337.         // " - Tamanno: " << prueba.size() << " - Espacio: " << posws << "\n";
  1338.         pos = posws;
  1339.         aux.danno = line.substr(0, posws);
  1340.  
  1341.  
  1342.  
  1343.  
  1344.         line = line.substr(posws+1);
  1345.         posws = 0; //Poscicion white space
  1346.         pos = 0;
  1347.         posws = line.find(" ", posws); //Busca el primer " "
  1348.         //if (posws!=string::npos)
  1349.         // " - Tamanno: " << prueba.size() << " - Espacio: " << posws << "\n";
  1350.         pos = posws;
  1351.         contextura = line.substr(0, posws);
  1352.  
  1353.  
  1354.  
  1355.  
  1356.  
  1357.  
  1358.  
  1359.         J.insertar(nombre, nivel);
  1360.         cout << "woa morir 2\n";
  1361.  
  1362.     }else if(inst == "Asignar"){
  1363.         string luch = "", jug = "";
  1364.         Entrada >> luch >> jug;
  1365.         J.asignar(luch, jug);
  1366.  
  1367.     }else if(inst == "Combate" || inst == "combate"){
  1368.         string type = "";
  1369.         Entrada >> type;
  1370.         if(type == "1vs1"){
  1371.             string J1 = "";
  1372.             string J2 = "";
  1373.             comb1v1(J.buscar(J1), J.buscar(J2));
  1374.             print1v1(J1, J2);
  1375.         }else if(type == "2vs2"){
  1376.             string J1 = "";
  1377.             string J2 = "";
  1378.             string J3 = "";
  1379.             string J4 = "";
  1380.             comb2v2(J1, J2, J3, J4);
  1381.         }else if(type == "Todos"){
  1382.             if(!J.vacio()){
  1383.                 printf("Cantidad de jugadores invalida\n");
  1384.             }else{
  1385.                 int cont = 2;
  1386.                 Jugador * aux = J.inicio;
  1387.                 while(aux->next != NULL && cont < 3){
  1388.                     cont++;
  1389.                 }
  1390.                 if(cont >= 3){
  1391.                     tvt();
  1392.                 }
  1393.             }
  1394.         }
  1395.     }
  1396. }
  1397.     }
  1398. }*/
  1399. string comando;
  1400. while(!Entrada.eof() && getline(Entrada,comando)){
  1401.   //Imprimir_Todo(lcontexturas, lluchadores, ljugadores);
  1402.   //system("pause");
  1403.     int posws, pos;
  1404.     posws = 0; //Poscicion white space
  1405.     pos = 0;
  1406.     posws = comando.find(" ", posws); //Busca el primer " "
  1407.     //if (posws!=string::npos)
  1408.       cout << comando << "\n";
  1409.     // " - Tamanno: " << prueba.size() << " - Espacio: " << posws << "\n";
  1410.     pos = posws;
  1411.     string instruccion;
  1412.     instruccion = comando.substr(0, posws);
  1413.     cout << instruccion << "|\n";
  1414.  
  1415.  
  1416.     if(instruccion == "Luchador"){
  1417.      
  1418.       string nombre;
  1419.       Picar_substr(comando, nombre, pos, posws, " ", " ");
  1420.       if(L.buscar(nombre))
  1421.       //El Luchador ya existe
  1422.       {
  1423.         Error(2, nombre);
  1424.       }
  1425.       else
  1426.       //Crear Luchador
  1427.       {  
  1428.         string contextura;
  1429.         Picar_substr(comando, contextura, pos, posws, " ", "final");
  1430.         L.insertar(nombre, contextura);
  1431.         cout << "Mi menusito sirve\n";
  1432.       }
  1433.     }else if(instruccion == "Movimiento"){
  1434.         /*string per = "";
  1435.         int danno = 0;
  1436.         string aux = "", x = " ";
  1437.         line >> per;
  1438.         L.buscar();
  1439.         line >> aux >> danno >> per;
  1440.         for(int i = 0; i < per.size(); ++i){
  1441.           if(per[i] != ']' || per[i] != '[' || per[i] != ',' ){
  1442.             x += per[i];
  1443.           }
  1444.         }
  1445.         for(int i = 0; i < per.size(); i++){
  1446.             L.buscar(aux)->lista.insertar(v);
  1447.         }*/
  1448.       string luchador;
  1449.       Picar_substr(comando, luchador, pos, posws, " ", " ");
  1450.       if(L.buscar(luchador))
  1451.       //Asignar movimiento
  1452.       {
  1453.         Luchador *pluchador;
  1454.         pluchador = L.buscar(luchador);
  1455.         //cout << "Existe\n";
  1456.         string combo;
  1457.         Picar_substr(comando, combo, pos, posws, " ", " ");
  1458.         string damage;
  1459.         Picar_substr(comando, damage, pos, posws, " ", " ");
  1460.         string ventajas;
  1461.         Picar_substr(comando, ventajas, pos, posws, " ", "final");
  1462.         int damage2;
  1463.         damage2 = atoi(damage.c_str());
  1464.         pluchador->lsmovimientos.insertar(combo, damage2, ventajas, comando);
  1465.       }
  1466.       else
  1467.       //El Luchador no existe
  1468.       {
  1469.         Error(3, luchador);
  1470.         cout << "woa morir1\n";
  1471.       }
  1472.     }else if(instruccion == "Jugador"){
  1473.  
  1474.       string nombre;
  1475.       Picar_substr(instruccion, nombre, pos, posws, " ", " ");
  1476.       if(J.buscar(nombre))
  1477.       //El Jugador ya existe
  1478.       {
  1479.         Error(4, nombre);
  1480.       }
  1481.       else
  1482.       //Crear Jugador
  1483.       {  
  1484.         string habilidad;
  1485.         Picar_substr(instruccion, habilidad, pos, posws, " ", "final");
  1486.         int habilidad2;
  1487.         J.insertar(nombre, habilidad);
  1488.  
  1489.         cout << "woa morir 2\n";
  1490.         }
  1491.       }else if(instruccion == "Asignar"){
  1492.  
  1493.       string jugador;
  1494.       Picar_substr(instruccion, jugador, pos, posws, " ", " ");
  1495.       if(L.buscar(jugador))
  1496.       //Asignar luchadores
  1497.       {
  1498.         string luchadoresasignar;
  1499.         Picar_substr(instruccion, luchadoresasignar, pos, posws, " ", "final");
  1500.         J.asignar(jugador, luchadoresasignar, comando);
  1501.       }
  1502.       else
  1503.       //El Jugador no existe
  1504.       {
  1505.         Error(6, jugador);
  1506.       }
  1507.     }else if(instruccion == "Combate"){
  1508.       string modalidad;
  1509.       Picar_substr(comando, modalidad, pos, posws, " ", " ");
  1510.       string participantes;
  1511.       Picar_substr(comando, participantes, pos, posws, " ", "final");
  1512.  
  1513.       lista<Jugador*> LParticipantes;
  1514.       Picar_sublista(LParticipantes, participantes, comando);
  1515.       Combate(modalidad, LParticipantes, comando);
  1516.     }else{
  1517.       Error(0, comando);
  1518.     }
  1519. }
  1520.  
  1521. Entrada.close();
  1522.  
  1523. return 0;
  1524. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement