Ejemplo n.º 1
0
        /// <summary>
        /// Create a moon job for a moon pull calendar event.
        /// </summary>
        /// <param name="e"></param>
        /// <returns></returns>
        IJob MoonJobFactory(EsiCalendarEvent e)
        {
            SystemMoon moon = MoonParser.Parse(e.Title.Split(' '));

            if (!TryGetMoon(moon, out MoonComposition moonComp))
            {
                throw new NullReferenceException("Moon not found");
            }

            return(new MoonJob("MoonModule", moonComp.Name, e.EventDate - DateTime.UtcNow - new TimeSpan(0, 10, 0)));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Job for sending a discord message ten minutes before a moon is about to pop.
        /// </summary>
        /// <param name="job"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        Task MoonPoppedJob(MoonJob job, MethodContext context)
        {
            SystemMoon moon = this.MoonParser.Parse(job.Moon.Split(' '));

            if (TryGetMoon(moon, out MoonComposition comp))
            {
                return(LogModule.LogMessage(Config.MoonPingMessage, Config.MoonPingChannel, embed: comp.PrettyMoon()));
            }

            return(Task.CompletedTask);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Try to get the moon composition from a parsed moon.
        /// </summary>
        /// <param name="moon"></param>
        /// <param name="composition"></param>
        /// <returns></returns>
        bool TryGetMoon(SystemMoon moon, out MoonComposition composition)
        {
            composition = null;

            // Query for retriving a list of all ore types as well as the quantity for a moon.
            string moonDataQuery = $"SELECT c.type_name, b.quantity FROM mapdata a, moondata b, typedata c WHERE a.item_name = '{moon.Name}' AND b.moon_id = a.item_id AND c.type_id = b.type_id;";
            // Query for checking wether the moon station is a tatara or not.
            string isTataraQuery = $"SELECT EXISTS(SELECT * FROM moonrefinery a, mapdata b WHERE a.moon_id = b.item_id and b.item_name = '{moon.Name}');";

            List <DatabaseRow> moonData = DatabaseModule.RunQuery(Config.Database, moonDataQuery);
            List <DatabaseRow> isTatara = DatabaseModule.RunQuery(Config.Database, isTataraQuery);

            if (moonData.Count == 0)
            {
                return(false);
            }

            composition = new MoonComposition(moon, isTatara[0].GetData <long>(0) == 1, moonData);
            return(true);
        }
        public MoonComposition(SystemMoon systemMoon, bool isTatara, List <DatabaseRow> data) : base(systemMoon)
        {
            IsTatara = isTatara;

            for (int i = 0; i < data.Count; i++)
            {
                DatabaseRow row = data[i];

                #region MoonOre

                // Ubiquituous
                if (row.GetData <string>(0) == "Bitumens")
                {
                    Bitumens = (float)row.GetData <decimal>(1);
                }
                else if (row.GetData <string>(0) == "Sylvite")
                {
                    Sylvite = (float)row.GetData <decimal>(1);
                }
                else if (row.GetData <string>(0) == "Coesite")
                {
                    Coesite = (float)row.GetData <decimal>(1);
                }
                else if (row.GetData <string>(0) == "Zeolites")
                {
                    Zeolites = (float)row.GetData <decimal>(1);
                }

                // Common
                if (row.GetData <string>(0) == "Cobaltite")
                {
                    Cobaltite = (float)row.GetData <decimal>(1);
                }
                else if (row.GetData <string>(0) == "Euxenite")
                {
                    Euxenite = (float)row.GetData <decimal>(1);
                }
                else if (row.GetData <string>(0) == "Scheelite")
                {
                    Scheelite = (float)row.GetData <decimal>(1);
                }
                else if (row.GetData <string>(0) == "Titanite")
                {
                    Titanite = (float)row.GetData <decimal>(1);
                }

                // Uncommon
                if (row.GetData <string>(0) == "Chromite")
                {
                    Chromite = (float)row.GetData <decimal>(1);
                }
                else if (row.GetData <string>(0) == "Otavite")
                {
                    Otavite = (float)row.GetData <decimal>(1);
                }
                else if (row.GetData <string>(0) == "Sperrylite")
                {
                    Sperrylite = (float)row.GetData <decimal>(1);
                }
                else if (row.GetData <string>(0) == "Vanadinite")
                {
                    Vanadinite = (float)row.GetData <decimal>(1);
                }

                // Rare
                if (row.GetData <string>(0) == "Carnotite")
                {
                    Carnotite = (float)row.GetData <decimal>(1);
                }
                else if (row.GetData <string>(0) == "Cinnabar")
                {
                    Cinnabar = (float)row.GetData <decimal>(1);
                }
                else if (row.GetData <string>(0) == "Pollucite")
                {
                    Pollucite = (float)row.GetData <decimal>(1);
                }
                else if (row.GetData <string>(0) == "Zircon")
                {
                    Zircon = (float)row.GetData <decimal>(1);
                }

                // Exceptional
                if (row.GetData <string>(0) == "Loparite")
                {
                    Loparite = (float)row.GetData <decimal>(1);
                }
                else if (row.GetData <string>(0) == "Monazite")
                {
                    Monazite = (float)row.GetData <decimal>(1);
                }
                else if (row.GetData <string>(0) == "Xenotime")
                {
                    Xenotime = (float)row.GetData <decimal>(1);
                }
                else if (row.GetData <string>(0) == "Ytterbite")
                {
                    Ytterbite = (float)row.GetData <decimal>(1);
                }

                // High sec
                if (row.GetData <string>(0) == "Veldspar")
                {
                    Veldspar = (float)row.GetData <decimal>(1);
                }
                else if (row.GetData <string>(0) == "Scordite")
                {
                    Scordite = (float)row.GetData <decimal>(1);
                }
                else if (row.GetData <string>(0) == "Pyroxeres")
                {
                    Pyroxeres = (float)row.GetData <decimal>(1);
                }
                else if (row.GetData <string>(0) == "Plagioclase")
                {
                    Plagioclase = (float)row.GetData <decimal>(1);
                }
                else if (row.GetData <string>(0) == "Omber")
                {
                    Omber = (float)row.GetData <decimal>(1);
                }
                else if (row.GetData <string>(0) == "Kernite")
                {
                    Kernite = (float)row.GetData <decimal>(1);
                }
                else if (row.GetData <string>(0) == "Jaspet")
                {
                    Jaspet = (float)row.GetData <decimal>(1);
                }
                else if (row.GetData <string>(0) == "Hemorphite")
                {
                    Hemorphite = (float)row.GetData <decimal>(1);
                }
                else if (row.GetData <string>(0) == "Hedbergite")
                {
                    Hedbergite = (float)row.GetData <decimal>(1);
                }

                // Null sec
                if (row.GetData <string>(0) == "Gneiss")
                {
                    Gneiss = (float)row.GetData <decimal>(1);
                }
                else if (row.GetData <string>(0) == "Ochre" || row.GetData <string>(0) == "Dark Ochre")
                {
                    Ochre = (float)row.GetData <decimal>(1);
                }
                else if (row.GetData <string>(0) == "Spodumain")
                {
                    Spodumain = (float)row.GetData <decimal>(1);
                }
                else if (row.GetData <string>(0) == "Crokite")
                {
                    Crokite = (float)row.GetData <decimal>(1);
                }
                else if (row.GetData <string>(0) == "Bistot")
                {
                    Bistot = (float)row.GetData <decimal>(1);
                }
                else if (row.GetData <string>(0) == "Arkonor")
                {
                    Arkonor = (float)row.GetData <decimal>(1);
                }

                #endregion

                #region Rarity

                if (Exceptional > 0)
                {
                    Rarity = "R64";

                    if (Loparite > 0)
                    {
                        RarityCount++;
                    }
                    else if (Monazite > 0)
                    {
                        RarityCount++;
                    }
                    else if (Xenotime > 0)
                    {
                        RarityCount++;
                    }
                    else if (Ytterbite > 0)
                    {
                        RarityCount++;
                    }
                }
                else if (Rare > 0)
                {
                    Rarity = "R32";

                    if (Carnotite > 0)
                    {
                        RarityCount++;
                    }
                    else if (Cinnabar > 0)
                    {
                        RarityCount++;
                    }
                    else if (Pollucite > 0)
                    {
                        RarityCount++;
                    }
                    else if (Zircon > 0)
                    {
                        RarityCount++;
                    }
                }
                else if (Uncommon > 0)
                {
                    Rarity = "R32";

                    if (Chromite > 0)
                    {
                        RarityCount++;
                    }
                    else if (Otavite > 0)
                    {
                        RarityCount++;
                    }
                    else if (Sperrylite > 0)
                    {
                        RarityCount++;
                    }
                    else if (Vanadinite > 0)
                    {
                        RarityCount++;
                    }
                }
                else if (Common > 0)
                {
                    Rarity = "R16";

                    if (Cobaltite > 0)
                    {
                        RarityCount++;
                    }
                    else if (Euxenite > 0)
                    {
                        RarityCount++;
                    }
                    else if (Scheelite > 0)
                    {
                        RarityCount++;
                    }
                    else if (Titanite > 0)
                    {
                        RarityCount++;
                    }
                }
                else if (Ubiquitous > 0)
                {
                    Rarity = "R8";

                    if (Bitumens > 0)
                    {
                        RarityCount++;
                    }
                    else if (Coesite > 0)
                    {
                        RarityCount++;
                    }
                    else if (Sylvite > 0)
                    {
                        RarityCount++;
                    }
                    else if (Zeolites > 0)
                    {
                        RarityCount++;
                    }
                }

                #endregion
            }
        }
 public SystemMoon(SystemMoon systemMoon)
 {
     System = systemMoon.System;
     Planet = systemMoon.Planet;
     Moon   = systemMoon.Moon;
 }