예제 #1
0
        //private void AsignarTipoIdPorNombreItem(IEnumerable<eshFittingHardware> itemsHdw)
        //{
        //    RepositorioItems repo = new RepositorioItems();
        //    Dictionary<string, int> itemsBuscados = new Dictionary<string, int>();
        //    foreach (var item in itemsHdw)
        //    {
        //        if (!itemsBuscados.ContainsKey(item.name))
        //        {
        //            //Buscamos el item en la base de datos si es la primera vez que aparece en esta fit
        //            invType tipo = repo.SelectItemTypePorName(item.name);
        //            if (tipo != null)
        //            {
        //                itemsBuscados.Add(item.name, tipo.typeID);
        //            }
        //            item.typeID = itemsBuscados[item.name];
        //        }
        //    }
        //}



        private Enumerados.TipoSlot ObtenerTipoSlotPorNombreEVEXML(string nombreSlot, out short posicion)
        {
            posicion = 0;
            if (nombreSlot.ToLower().Equals("cargo"))
            {
                return(Enumerados.TipoSlot.Cargo);
            }
            if (nombreSlot.ToLower().Equals("drone bay"))
            {
                return(Enumerados.TipoSlot.DroneBay);
            }
            string[]            nombreSeparado = nombreSlot.Split();
            Enumerados.TipoSlot salida         = Enumerados.TipoSlot.High;
            switch (nombreSeparado[0].ToLower())
            {
            case "med":
                salida = Enumerados.TipoSlot.Medium;
                break;

            case "low":
                salida = Enumerados.TipoSlot.Low;
                break;

            case "rig":
                salida = Enumerados.TipoSlot.Rigs;
                break;

            default:
                salida = Enumerados.TipoSlot.High;
                break;
            }
            short.TryParse(nombreSeparado.Last(), out posicion);

            return(salida);
        }
예제 #2
0
        private Enumerados.TipoSlot GetNextSlot(Enumerados.TipoSlot slotActual)
        {
            switch (slotActual)
            {
            case Enumerados.TipoSlot.Ship:
                return(Enumerados.TipoSlot.Low);

            case Enumerados.TipoSlot.High:
                return(Enumerados.TipoSlot.Rigs);

            case Enumerados.TipoSlot.Medium:
                return(Enumerados.TipoSlot.High);

            case Enumerados.TipoSlot.Low:
                return(Enumerados.TipoSlot.Medium);

            case Enumerados.TipoSlot.Rigs:
                return(Enumerados.TipoSlot.DroneBay);

            case Enumerados.TipoSlot.DroneBay:
            case Enumerados.TipoSlot.Cargo:
            default:
                return(Enumerados.TipoSlot.Cargo);
            }
        }
예제 #3
0
        public IEnumerable <FittingAnalyzed> ToFitList(string fitExterna)
        {
            IList <FittingAnalyzed> listaSalida = new List <FittingAnalyzed>();

            SlotActual = Enumerados.TipoSlot.Ship;
            string[] lines = fitExterna.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None);

            FittingAnalyzed fit          = null;
            List <string>   lineasSlot   = new List <string>();
            bool            changingSlot = false;

            foreach (var item in lines)
            {
                if (SlotActual == Enumerados.TipoSlot.Ship)
                {
                    if (!string.IsNullOrEmpty(item))
                    {
                        fit = ObtenerFit(item);
                        listaSalida.Add(fit);
                        SlotActual   = this.GetNextSlot(SlotActual);
                        changingSlot = true;
                    }
                    continue;
                }
                if (string.IsNullOrEmpty(item))
                {
                    if (!changingSlot)
                    {
                        IEnumerable <FittingHardwareAnalyzed> slot = ObtenerFittingHardwareSlot(lineasSlot, SlotActual);
                        foreach (var fha in slot)
                        {
                            fit.Items.Add(fha);
                        }
                        SlotActual = this.GetNextSlot(SlotActual);
                        lineasSlot.Clear();
                    }
                    else
                    {
                        changingSlot = true;
                    }
                }
                else
                {
                    changingSlot = false;
                    lineasSlot.Add(item);
                }
            }
            if (lineasSlot != null && lineasSlot.Count > 0)
            {
                IEnumerable <FittingHardwareAnalyzed> slot = ObtenerFittingHardwareSlot(lineasSlot, SlotActual);
                foreach (var fha in slot)
                {
                    fit.Items.Add(fha);
                }
            }
            return(listaSalida);
        }
예제 #4
0
        private FittingHardwareAnalyzed ExtraerFittingHwdDesdeItemHwdXml(XElement itemHwdXml)
        {
            FittingHardwareAnalyzed fitHardware = new FittingHardwareAnalyzed();
            short qty = 1;

            if (itemHwdXml.Attribute("qty") != null)
            {
                qty = short.Parse(itemHwdXml.Attribute("qty").Value);
            }
            string htype     = itemHwdXml.Attribute("type").Value;
            short  posEnSlot = 0;

            Enumerados.TipoSlot tipoSlot = Enumerados.TipoSlot.High;
            if (itemHwdXml.Attribute("slot") != null)
            {
                tipoSlot = ObtenerTipoSlotPorNombreEVEXML(itemHwdXml.Attribute("slot").Value, out posEnSlot);
            }
            fitHardware.Units = qty;
            fitHardware.Slot  = (short)tipoSlot;
            fitHardware.Name  = htype;
            return(fitHardware);
        }
예제 #5
0
        public static string GetImageName(Enumerados.TipoSlot slot)
        {
            switch (slot)
            {
            case Enumerados.TipoSlot.High:
                return("iconHighSlot32.png");

            case Enumerados.TipoSlot.Medium:
                return("iconMidSlot32.png");

            case Enumerados.TipoSlot.Low:
                return("iconLowSlot32.png");

            case Enumerados.TipoSlot.Rigs:
                return("iconRigSlot32.png");

            case Enumerados.TipoSlot.DroneBay:
                return("iconDroneBay32.png");

            case Enumerados.TipoSlot.Cargo:
            default:
                return("iconCargoBay32.png");
            }
        }
예제 #6
0
        public static string GetSlotName(Enumerados.TipoSlot slot)
        {
            switch (slot)
            {
            case Enumerados.TipoSlot.High:
                return("Fitted - High slot");

            case Enumerados.TipoSlot.Medium:
                return("Fitted - Mid slot");

            case Enumerados.TipoSlot.Low:
                return("Fitted - Low slot");

            case Enumerados.TipoSlot.Rigs:
                return("Fitted - Rig slot");

            case Enumerados.TipoSlot.DroneBay:
                return("Drone bay");

            case Enumerados.TipoSlot.Cargo:
            default:
                return("Cargo bay");
            }
        }
예제 #7
0
        private IEnumerable <FittingHardwareAnalyzed> ObtenerFittingHardwareSlot(IEnumerable <string> lines, Enumerados.TipoSlot slot)
        {
            IDictionary <string, FittingHardwareAnalyzed> fwdicc = new Dictionary <string, FittingHardwareAnalyzed>();
            string hwdname = null;

            foreach (var item in lines)
            {
                int initialUnits            = 1;
                FittingHardwareAnalyzed fha = null;
                hwdname = item.Trim();
                //Si es un Empty slot lo quitamos
                if (hwdname.ToLower().StartsWith("[empty"))
                {
                    break;
                }
                //quitamos la coma para eliminar las ammo de los items que las admiten
                if (hwdname.Contains(','))
                {
                    hwdname = hwdname.Split(',').First();
                }
                //si estamos en el slot de drones o bay, puede aparecer un multiplicador, lo quitamos y tomamos las unidades
                if (slot == Enumerados.TipoSlot.DroneBay || slot == Enumerados.TipoSlot.Cargo)
                {
                    int posX = hwdname.LastIndexOf(" x");
                    if (posX >= 0)
                    {
                        string szunits = hwdname.Substring(posX + 2, hwdname.Length - posX - 2);
                        if (int.TryParse(szunits, out initialUnits))
                        {
                            hwdname = hwdname.Substring(0, posX);
                        }
                    }
                }
                if (!fwdicc.ContainsKey(hwdname))
                {
                    fha       = new FittingHardwareAnalyzed();
                    fha.Name  = hwdname;
                    fha.Slot  = (short)slot;
                    fha.Units = (initialUnits - 1);
                    fwdicc.Add(hwdname, fha);
                }
                else
                {
                    fha = fwdicc[hwdname];
                }
                fha.Units++;
            }
            return(fwdicc.Values);
        }