示例#1
0
        public HechizoModel MapearHechizoModel(string tipo, string nombre, string idImagen, string idEfecto, string idSonido, string descripcion,
                                               string palabrasMagicas, string maxMana, string minMana, string maxEnergia, string minEnergia, string paralizar,
                                               string inmovilizar, string congelar, string maxDaño, string minDaño, bool envenenar)
        {
            HechizoModel hm = new HechizoModel();

            try
            {
                hm.Tipo            = Convert.ToInt16(tipo);
                hm.Nombre          = nombre;
                hm.IdImagen        = Convert.ToInt16(idImagen);
                hm.IdEfecto        = Convert.ToInt16(idEfecto);
                hm.IdSonido        = Convert.ToInt16(idSonido);
                hm.Descripcion     = descripcion;
                hm.PalabrasMagicas = palabrasMagicas;
                hm.Consumo         = ConsumoModel.Mapear(Convert.ToInt16(maxMana), Convert.ToInt16(minMana), Convert.ToInt16(maxEnergia), Convert.ToInt16(minEnergia));
                hm.Temporales      = TemporalesModel.Mapear(Convert.ToInt16(paralizar), Convert.ToInt16(inmovilizar), Convert.ToInt16(congelar));
                hm.Ataque          = AtaqueModel.Mapear(Convert.ToInt16(maxDaño), Convert.ToInt16(minDaño), envenenar);
            }
            catch (Exception)
            {
                return(new HechizoModel());
            }

            return(hm);
        }
示例#2
0
        public Hechizo MapearObjeto(HechizoModel hm, short id = 0)
        {
            Hechizo h = new Hechizo();

            h.id                     = id == 0 ? GenerarId() : id;
            h.tipo                   = hm.Tipo;
            h.nombre                 = hm.Nombre;
            h.idImagen               = hm.IdImagen;
            h.idEfecto               = hm.IdEfecto;
            h.idSonido               = hm.IdSonido;
            h.descripcion            = hm.Descripcion;
            h.palabrasMagicas        = hm.PalabrasMagicas;
            h.consumo.maxMana        = hm.Consumo.MaxMana;
            h.consumo.minMana        = hm.Consumo.MinMana;
            h.consumo.maxEnergia     = hm.Consumo.MaxEnergia;
            h.consumo.minEnergia     = hm.Consumo.MinEnergia;
            h.temporales.paralizar   = hm.Temporales.Paralizar;
            h.temporales.inmovilizar = hm.Temporales.Inmovilizar;
            h.temporales.congelar    = hm.Temporales.Congelar;
            h.ataque.maxDaño         = hm.Ataque.MaxDaño;
            h.ataque.minDaño         = hm.Ataque.MinDaño;
            h.ataque.envenenar       = hm.Ataque.Envenenar;

            return(h);
        }
示例#3
0
        public HechizoModel MapearHechizoModel(Hechizo h)
        {
            HechizoModel hm = new HechizoModel();

            try
            {
                hm.Id              = h.id;
                hm.Tipo            = Convert.ToInt16(h.tipo);
                hm.Nombre          = h.nombre;
                hm.IdImagen        = Convert.ToInt16(h.idImagen);
                hm.IdEfecto        = Convert.ToInt16(h.idEfecto);
                hm.IdSonido        = Convert.ToInt16(h.idSonido);
                hm.Descripcion     = h.descripcion;
                hm.PalabrasMagicas = h.palabrasMagicas;
                hm.Consumo         = ConsumoModel.Mapear(h.consumo.maxMana, h.consumo.minMana, h.consumo.maxEnergia, h.consumo.minEnergia);
                hm.Temporales      = TemporalesModel.Mapear(h.temporales.paralizar, h.temporales.inmovilizar, h.temporales.congelar);
                hm.Ataque          = AtaqueModel.Mapear(h.ataque.maxDaño, h.ataque.minDaño, h.ataque.envenenar);
            }
            catch (Exception)
            {
                return(new HechizoModel());
            }

            return(hm);
        }
示例#4
0
        public bool GuadarDatos(HechizoModel hechizoModel)
        {
            try
            {
                Hechizo hechizo = MapearObjeto(hechizoModel);

                hechizoRepository.Guardar(hechizo);

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
示例#5
0
        public bool EditarPorId(short id, HechizoModel hechizoModel)
        {
            try
            {
                Hechizo hechizo = MapearObjeto(hechizoModel, id);

                hechizoRepository.Editar(id, hechizo);

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
示例#6
0
 public bool ValidarDatos(HechizoModel hechizo)
 {
     // TODO: validar usando logica de negocio
     return(!String.IsNullOrEmpty(hechizo.Nombre));
 }