Exemplo n.º 1
0
        private void sendOutfittingInformation(MarketInformationUpdatedEvent theEvent)
        {
            if (theEvent.outfittingModules?.Count > 0)
            {
                List <string> eddnModules = new List <string>();
                foreach (string moduleEdName in theEvent.outfittingModules)
                {
                    if (!EddiDataDefinitions.Module.PowerPlayModules.Contains(moduleEdName) &&
                        (moduleEdName.StartsWith("Int_") || moduleEdName.StartsWith("Hpt_") || moduleEdName.Contains("_Armour_")) &&
                        moduleEdName != "Int_PlanetApproachSuite")
                    {
                        eddnModules.Add(moduleEdName);
                    }
                }

                // Only send the message if we have modules
                if (eddnModules.Count > 0)
                {
                    IDictionary <string, object> data = new Dictionary <string, object>
                    {
                        { "timestamp", Dates.FromDateTimeToString(theEvent.timestamp) },
                        { "systemName", theEvent.starSystem },
                        { "stationName", theEvent.stationName },
                        { "marketId", theEvent.marketId },
                        { "modules", eddnModules },
                        { "horizons", theEvent.inHorizons }
                    };

                    SendToEDDN("https://eddn.edcd.io/schemas/outfitting/2", data);
                }
            }
        }
Exemplo n.º 2
0
        private void sendOutfittingInformation(MarketInformationUpdatedEvent theEvent)
        {
            if (theEvent.outfitting != null)
            {
                List <string> eddnModules = new List <string>();
                foreach (Module module in theEvent.outfitting)
                {
                    if (!module.IsPowerPlay() &&
                        (module.EDName.StartsWith("Int_") || module.EDName.StartsWith("Hpt_") || module.EDName.Contains("_Armour_")) &&
                        module.EDName != "Int_PlanetApproachSuite")
                    {
                        eddnModules.Add(module.EDName);
                    }
                }

                // Only send the message if we have modules
                if (eddnModules.Count > 0)
                {
                    IDictionary <string, object> data = new Dictionary <string, object>
                    {
                        { "timestamp", theEvent.timestamp.ToString("yyyy-MM-ddTHH:mm:ssZ") },
                        { "systemName", theEvent.starSystem },
                        { "stationName", theEvent.stationName },
                        { "marketId", theEvent.marketId },
                        { "modules", eddnModules },
                        { "horizons", theEvent.inHorizons }
                    };

                    SendToEDDN("https://eddn.edcd.io/schemas/outfitting/2", data);
                }
            }
        }
Exemplo n.º 3
0
        private void sendCommodityInformation(MarketInformationUpdatedEvent theEvent)
        {
            if (theEvent.commodityQuotes?.Count > 0)
            {
                var commodities = theEvent.commodityQuotes
                                  .Where(c => c.IsMarketable())
                                  .ToList();

                // Only send the message if we have commodities
                if (commodities.Count > 0)
                {
                    IDictionary <string, object> data = new Dictionary <string, object>
                    {
                        { "timestamp", Dates.FromDateTimeToString(theEvent.timestamp) },
                        { "systemName", theEvent.starSystem },
                        { "stationName", theEvent.stationName },
                        { "marketId", theEvent.marketId },
                        { "horizons", theEvent.inHorizons }
                    };
                    data.Add("commodities", commodities);
                    if (theEvent.prohibitedCommodities?.Count > 0)
                    {
                        data.Add("prohibited", theEvent.prohibitedCommodities);
                    }

                    SendToEDDN("https://eddn.edcd.io/schemas/commodity/3", data);
                }
            }
        }
Exemplo n.º 4
0
        private void sendShipyardInformation(MarketInformationUpdatedEvent theEvent)
        {
            if (theEvent.shipyard != null)
            {
                List <string> eddnShips = new List <string>();
                foreach (Ship ship in theEvent.shipyard)
                {
                    if (ship?.EDName != null)
                    {
                        eddnShips.Add(ship.EDName);
                    }
                }
                eddnShips = eddnShips.Distinct().ToList();

                // Only send the message if we have ships
                if (eddnShips.Count > 0)
                {
                    IDictionary <string, object> data = new Dictionary <string, object>
                    {
                        { "timestamp", theEvent.timestamp.ToString("yyyy-MM-ddTHH:mm:ssZ") },
                        { "systemName", theEvent.starSystem },
                        { "stationName", theEvent.stationName },
                        { "marketId", theEvent.marketId },
                        { "ships", eddnShips },
                        { "horizons", theEvent.inHorizons }
                    };

                    SendToEDDN("https://eddn.edcd.io/schemas/shipyard/2", data);
                }
            }
        }
Exemplo n.º 5
0
        private void sendCommodityInformation(MarketInformationUpdatedEvent theEvent)
        {
            if (theEvent.commodities?.Count > 0)
            {
                List <EDDNCommodity> eddnCommodities = prepareCommodityInformation(theEvent.commodities);

                // Only send the message if we have commodities
                if (eddnCommodities.Count > 0)
                {
                    IDictionary <string, object> data = new Dictionary <string, object>
                    {
                        { "timestamp", theEvent.timestamp.ToString("yyyy-MM-ddTHH:mm:ssZ") },
                        { "systemName", theEvent.starSystem },
                        { "stationName", theEvent.stationName },
                        { "marketId", theEvent.marketId },
                        { "horizons", theEvent.inHorizons }
                    };
                    data.Add("commodities", eddnCommodities);
                    if (theEvent.prohibitedCommodities?.Count > 0)
                    {
                        data.Add("prohibited", theEvent.prohibitedCommodities);
                    }

                    SendToEDDN("https://eddn.edcd.io/schemas/commodity/3", data);
                }
            }
        }
Exemplo n.º 6
0
 private void handleMarketInformationUpdatedEvent(MarketInformationUpdatedEvent theEvent)
 {
     // When we dock we have access to commodity and outfitting information
     sendCommodityInformation();
     sendOutfittingInformation();
     sendShipyardInformation();
 }
Exemplo n.º 7
0
        private void sendCommodityInformation(MarketInformationUpdatedEvent theEvent)
        {
            if (theEvent.commodityQuotes != null)
            {
                // An empty list is permissible, e.g. if a fleet carrier isn't buying or selling any commodities.
                var commodities = theEvent.commodityQuotes
                                  .Where(c => c.IsMarketable())
                                  .ToList();

                IDictionary <string, object> data = new Dictionary <string, object>
                {
                    { "timestamp", Dates.FromDateTimeToString(theEvent.timestamp) },
                    { "systemName", theEvent.starSystem },
                    { "stationName", theEvent.stationName },
                    { "marketId", theEvent.marketId },
                    { "horizons", theEvent.inHorizons }
                };
                data.Add("commodities", commodities);
                if (theEvent.prohibitedCommodities?.Count > 0)
                {
                    data.Add("prohibited", theEvent.prohibitedCommodities);
                }

                SendToEDDN("https://eddn.edcd.io/schemas/commodity/3", data);
            }
        }
Exemplo n.º 8
0
 private bool eventStationMatches(MarketInformationUpdatedEvent theEvent)
 {
     if (theEvent.starSystem == systemName && theEvent.stationName == stationName && theEvent.marketId == marketId)
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 9
0
 private void handleMarketInformationUpdatedEvent(MarketInformationUpdatedEvent theEvent)
 {
     // This event is triggered by an update to the profile via the Frontier API or via the `Market`, `Outfitting`, or `Shipyard` journal events.
     // Check to make sure the marketId from the event matches our current station's marketId before continuing
     if (eventStationMatches(theEvent))
     {
         // When we dock we have access to commodity, outfitting, and shipyard information
         sendCommodityInformation(theEvent);
         sendOutfittingInformation(theEvent);
         sendShipyardInformation(theEvent);
     }
 }
Exemplo n.º 10
0
 private void handleMarketInformationUpdatedEvent(MarketInformationUpdatedEvent theEvent)
 {
     // This event is triggered by an update to the profile via the Frontier API
     // Check to make sure the marketId from the acquired profile matches our current station's marketId before continuing
     if (eventStationMatches(marketId))
     {
         // When we dock we have access to commodity and outfitting information
         sendCommodityInformation();
         sendOutfittingInformation();
         sendShipyardInformation();
     }
 }
Exemplo n.º 11
0
        private void updateStationInfo(MarketInformationUpdatedEvent dockedEvent)
        {
            if (EDDI.Instance.CurrentStation.commodities != null)
            {
                var lookup = mViewModel.MissionRequirements.ToDictionary(x => x.Name, x => x);

                foreach (Commodity commodity in EDDI.Instance.CurrentStation.commodities)
                {
                    if (lookup.ContainsKey(commodity.name))
                    {
                        if (commodity.buyprice.HasValue && commodity.buyprice > 0 && commodity.stock.HasValue && commodity.stock > 0)
                        {
                            lookup[commodity.name].AtCurrentStation = true;
                        }
                    }
                }
            }
        }
Exemplo n.º 12
0
        private void sendShipyardInformation(MarketInformationUpdatedEvent theEvent)
        {
            // Only send the message if we have ships
            if (theEvent.shipyardModels?.Count > 0)
            {
                IDictionary <string, object> data = new Dictionary <string, object>
                {
                    { "timestamp", Dates.FromDateTimeToString(theEvent.timestamp) },
                    { "systemName", theEvent.starSystem },
                    { "stationName", theEvent.stationName },
                    { "marketId", theEvent.marketId },
                    { "ships", theEvent.shipyardModels },
                    { "horizons", theEvent.inHorizons },
                    { "allowCobraMkIV", theEvent.allowCobraMkIV }
                };

                SendToEDDN("https://eddn.edcd.io/schemas/shipyard/2", data);
            }
        }