Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <sstream>
- #include <fstream>
- using namespace std;
- struct Luchador{
- string nombre;
- string contextura;
- Luchador *prox;
- };
- struct Movimientos{
- string combo;
- int damage;
- string ventajas;
- Movimientos *prox;
- };
- struct Jugador{
- string nombre;
- int nivel;
- Jugador *prox;
- };
- struct Pila_Luchadores{
- string nombre;
- Pila_Luchadores *prox;
- };
- void Agregar_Luchadores(Pila_Luchadores *&pila, string n){
- Pila_Luchadores *nuevo_nodo = new Pila_Luchadores();
- nuevo_nodo->nombre = n;
- nuevo_nodo->prox = pila;
- pila = nuevo_nodo;
- }//end-push
- void Sacar_Luchadores(Pila_Luchadores *&pila, string &n){
- Pila_Luchadores *aux = pila;
- n = aux->nombre;
- pila = aux->prox;
- delete aux;
- }//end-pop
- /*Funciones para el Luchador*/
- bool Buscar_Luchador(Luchador *Listado_Luchadores, string nombre){
- Luchador *actual = new Luchador();
- actual = Listado_Luchadores;
- while(actual != NULL){
- if(actual->nombre == nombre){
- return true;
- }
- actual = actual->prox;
- }
- return false;
- }//end-busqueda
- void Insertar_Luchadores(Luchador *&Listado_Luchadores, string nombre, string contextura){
- Luchador *nuevo_luchador = new Luchador();
- nuevo_luchador->nombre = nombre;
- nuevo_luchador->contextura = contextura;
- Luchador *aux1 = Listado_Luchadores;
- Luchador *aux2;
- while(aux1 != NULL){
- aux2 = aux1;
- aux1 = aux1->prox;
- }
- if(Listado_Luchadores == aux1){
- Listado_Luchadores = nuevo_luchador;
- }else{
- aux2 -> prox = nuevo_luchador;
- }
- }//end-insertar
- /*Funciones para los Movimientos*/
- void Insertar_Movimientos(Movimientos *&Listado_Movimientos, string nombre, int damage, string contextura){
- Movimientos *nuevo_movimiento = new Movimientos();
- nuevo_movimiento->combo = nombre;
- nuevo_movimiento->damage = damage;
- nuevo_movimiento->ventajas = contextura;
- Movimientos *aux1 = Listado_Movimientos;
- Movimientos *aux2;
- while(aux1 != NULL){
- aux2 = aux1;
- aux1 = aux1->prox;
- }
- if(Listado_Movimientos == aux1){
- Listado_Movimientos = nuevo_movimiento;
- }else{
- aux2 ->prox = nuevo_movimiento;
- }
- }//end-insertar
- /*Funciones para el Jugador*/
- void Insertar_Jugador(Jugador *&Listado_Jugadores, string nombre, int level){
- Jugador *nuevo_jugador = new Jugador();
- nuevo_jugador->nombre = nombre;
- nuevo_jugador->nivel = level;
- Jugador *aux1 = Listado_Jugadores;
- Jugador *aux2;
- while(aux1 != NULL){
- aux2 = aux1;
- aux1 = aux1->prox;
- }
- if(Listado_Jugadores == aux1){
- Listado_Jugadores = nuevo_jugador;
- }else{
- aux2->prox=nuevo_jugador;
- }
- }//end-insertar-jugador
- bool Buscar_Jugador(Jugador *Listado_Jugadores, string nombre){
- Jugador *actual = new Jugador();
- actual = Listado_Jugadores;
- while(actual != NULL){
- if(actual->nombre == nombre){
- return true;
- }
- actual = actual->prox;
- }
- return false;
- }//end-Buscar_Jugador
- bool validar_nivel(int n){
- return (n < 0 || n > 100)? true : false;
- }
- bool validar_contextura(string a){
- if(a == "ligero" || a == "pesado" || a == "equilibrado" ||
- a == "[ligero]" || a == "[pesado]" || a == "[equilibrado]" || a =="[]"){
- return true;
- }else{
- return false;
- }
- }
- Luchador *Listado_Luchadores = NULL;
- Movimientos *Listado_Movimientos = NULL;
- Jugador *Listado_Jugadores = NULL;
- Pila_Luchadores *pila = NULL;
- int main(){
- string peticion, aux, contextura;
- int damage = 0;
- ifstream Entrada;
- Entrada.open("Entrada.in");
- while(getline(Entrada,peticion)){
- damage = 0;
- stringstream line(peticion);
- line >> peticion;
- if(peticion == "Luchador"){
- line >> aux >> contextura;
- if(validar_contextura(contextura)){
- Insertar_Luchadores(Listado_Luchadores, aux, contextura);
- }else{
- cout << "Lo sentimos contextura no valida \n";
- }
- }else if(peticion == "Movimiento"){
- line >> aux;
- if(Buscar_Luchador(Listado_Luchadores,aux)){
- line >> aux >> damage >> contextura;
- //cout << "ventajas: " << contextura << "\n";
- if(validar_contextura(contextura)){
- Insertar_Movimientos(Listado_Movimientos, aux, damage, contextura);
- }else{
- cout << "El combo a utilizar no contiene ventajas validas \n";
- }
- }else{
- cout << "Nombre del Luchador no existe \n";
- }
- }else if(peticion == "Jugador"){
- line >> aux >> damage;
- if(!validar_nivel(damage)){
- Insertar_Jugador(Listado_Jugadores, aux, damage);
- }else{
- cout << "Lo sentimos nivel requerido 0-100 \n";
- }
- }else if(peticion == "Asignar"){
- line >> aux >> contextura;
- if(Buscar_Jugador(Listado_Jugadores,aux)){
- Agregar_Luchadores(pila,contextura);
- }else{
- cout << "Jugador no existe \n";
- }
- }else if(peticion == "Combate"){
- cout << "Entras en la team-fight \n";
- }else{
- cout << "Lo sentimos Comando invalido \n";
- }//end-validacion
- //cout << aux << "\n";
- //cout << damage << "\n";
- //cout << contextura << "\n";
- }//end-while
- Entrada.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement