Exemplo n.º 1
0
 private void AssertEvent(DockedEvent @event)
 {
     Assert.NotNull(@event);
     Assert.Equal(DateTime.Parse("2019-09-08T09:53:44Z"), @event.Timestamp);
     Assert.Equal("Docked", @event.Event);
     Assert.Equal("Krikalev Hangar", @event.StationName);
     Assert.Equal("Outpost", @event.StationType);
     Assert.Equal("Njortamool", @event.StarSystem);
     Assert.Equal(5372466973488, @event.SystemAddress);
     Assert.Equal(3223662592, @event.MarketId);
     Assert.Equal("Eurybia Blue Mafia", @event.StationFaction.Name);
     Assert.Equal("Expansion", @event.StationFaction.State);
     Assert.Equal("$government_Anarchy;", @event.StationGovernment);
     Assert.Equal(GovernmentType.Anarchy, @event.StationGovernmentType);
     Assert.Equal("Анархия", @event.StationGovernmentLocalised);
     Assert.Equal(17, @event.StationServices.Length);
     Assert.Equal("$economy_Refinery;", @event.StationEconomy);
     Assert.Equal(EconomyType.Refinery, @event.StationEconomyType);
     Assert.Equal("Переработка", @event.StationEconomyLocalised);
     Assert.Equal("$economy_Refinery;", @event.StationEconomies[0].Name);
     Assert.Equal(EconomyType.Refinery, @event.StationEconomies[0].Type);
     Assert.Equal("Переработка", @event.StationEconomies[0].NameLocalised);
     Assert.Equal(1.000000, @event.StationEconomies[0].Proportion, 6);
     Assert.Equal(4479.807617, @event.DistFromStarLs, 6);
 }
Exemplo n.º 2
0
 private void handleDockedEvent(DockedEvent theEvent)
 {
     // When we dock we have access to commodity and outfitting information
     sendCommodityInformation();
     sendOutfittingInformation();
     sendShipyardInformation();
 }
Exemplo n.º 3
0
        private bool eventDocked(DockedEvent theEvent)
        {
            updateCurrentSystem(theEvent.system);

            // Update the station
            Station station = CurrentStarSystem.stations.Find(s => s.name == theEvent.station);

            if (station == null)
            {
                // This station is unknown to us, might not be in EDDB or we might not have connectivity.  Use a placeholder
                station            = new Station();
                station.name       = theEvent.station;
                station.systemname = theEvent.system;
            }

            // Information from the event might be more current than that from EDDB so use it in preference
            station.state      = theEvent.factionstate;
            station.faction    = theEvent.faction;
            station.government = theEvent.government;
            station.allegiance = theEvent.allegiance;

            LastStation = station;

            // Now call refreshProfile() to obtain the outfitting and commodity information
            refreshProfile();

            return(true);
        }
 private async void TravelOnDockedAsync(object sender, DockedEvent e) =>
 await AddCommand(new AddCommanderTravelDock(e.StarSystem, e.StationName)
 {
     MarketId = e.MarketId != 0 ? e.MarketId : (long?)null,
     ShipId   = _eliteAPI.Ship.ShipId,
     ShipType = _eliteAPI.Ship.ShipType
 }).SendAsync()
 .ConfigureAwait(false);
Exemplo n.º 5
0
 internal DockedEvent InvokeEvent(DockedEvent arg)
 {
     if (_api.ValidateEvent(arg))
     {
         Docked?.Invoke(_api, arg);
     }
     return(arg);
 }
Exemplo n.º 6
0
 private void handleDockedEvent(DockedEvent theEvent)
 {
     if (eventSystemNameMatches(theEvent.system))
     {
         // When we dock we have access to commodity and outfitting information
         sendCommodityInformation();
         sendOutfittingInformation();
         sendShipyardInformation();
     }
 }
Exemplo n.º 7
0
        public void TestJournalDocked1()
        {
            string       line   = @"{ ""timestamp"":""2017-04-14T19:34:32Z"",""event"":""Docked"",""StationName"":""Freeholm"",""StationType"":""AsteroidBase"",""StarSystem"":""Artemis"",""StationFaction"":""Artemis Empire Assembly"",""FactionState"":""Boom"",""StationGovernment"":""$government_Patronage;"",""StationGovernment_Localised"":""Patronage"",""StationAllegiance"":""Empire"",""StationEconomy"":""$economy_Industrial;"",""StationEconomy_Localised"":""Industrial"",""DistFromStarLS"":2527.211914}";
            List <Event> events = JournalMonitor.ParseJournalEntry(line);

            Assert.IsTrue(events.Count == 1);

            DockedEvent theEvent = (DockedEvent)events[0];

            Assert.AreEqual("AsteroidBase", theEvent.model);
        }
Exemplo n.º 8
0
        private void handleDockedEvent(DockedEvent theEvent)
        {
            // Set all of the information available from the event
            systemName    = theEvent.system;
            systemAddress = theEvent.systemAddress;
            stationName   = theEvent.station;
            marketId      = theEvent.marketId;

            if (eventConfirmCoordinates(theEvent.system, theEvent.systemAddress))
            {
                // When we dock we have access to commodity and outfitting information
                sendCommodityInformation();
                sendOutfittingInformation();
                sendShipyardInformation();
            }
        }
Exemplo n.º 9
0
        public void TestJournalDocked2()
        {
            string       line   = @"{ ""timestamp"":""2018-04-01T05:21:24Z"", ""event"":""Docked"", ""StationName"":""Donaldson"", ""StationType"":""Orbis"", ""StarSystem"":""Alioth"", ""SystemAddress"":1109989017963, ""MarketID"":128141048, ""StationFaction"":""Alioth Pro-Alliance Group"", ""FactionState"":""Boom"", ""StationGovernment"":""$government_Democracy;"", ""StationGovernment_Localised"":""Democracy"", ""StationAllegiance"":""Alliance"", ""StationServices"":[ ""Dock"", ""Autodock"", ""BlackMarket"", ""Commodities"", ""Contacts"", ""Exploration"", ""Missions"", ""Outfitting"", ""CrewLounge"", ""Rearm"", ""Refuel"", ""Repair"", ""Shipyard"", ""Tuning"", ""Workshop"", ""MissionsGenerated"", ""FlightController"", ""StationOperations"", ""Powerplay"", ""SearchAndRescue"" ], ""StationEconomy"":""$economy_Service;"", ""StationEconomy_Localised"":""Service"", ""StationEconomies"":[ { ""Name"":""$economy_Service;"", ""Name_Localised"":""Service"", ""Proportion"":1.000000 } ], ""DistFromStarLS"":4632.417480 }";
            List <Event> events = JournalMonitor.ParseJournalEntry(line);

            Assert.IsTrue(events.Count == 1);

            DockedEvent theEvent = (DockedEvent)events[0];

            Assert.AreEqual("Orbis", theEvent.stationModel.edname);
            Assert.AreEqual("Donaldson", theEvent.station);
            Assert.AreEqual("Alioth", theEvent.system);
            Assert.AreEqual("Boom", theEvent.factionState.invariantName);
            Assert.AreEqual("Democracy", theEvent.Government.invariantName);
            Assert.AreEqual("Alliance", theEvent.Allegiance.invariantName);
            Assert.AreEqual(20, theEvent.stationservices.Count);
            Assert.AreEqual(1, theEvent.economyShares.Count);
            Assert.AreEqual("Service", theEvent.economyShares[0].economy.invariantName);
            Assert.AreEqual(1.0M, theEvent.economyShares[0].proportion);
        }
Exemplo n.º 10
0
        public void TestJournalDocked1()
        {
            string       line   = @"{ ""timestamp"":""2017-04-14T19:34:32Z"",""event"":""Docked"",""StationName"":""Freeholm"",""StationType"":""AsteroidBase"",""StarSystem"":""Artemis"",""StationFaction"":""Artemis Empire Assembly"",""FactionState"":""Boom"",""StationGovernment"":""$government_Patronage;"",""StationGovernment_Localised"":""Patronage"",""StationAllegiance"":""Empire"",""StationEconomy"":""$economy_Industrial;"",""StationEconomy_Localised"":""Industrial"", ""StationEconomies"": [ { ""Name"": ""$economy_Industrial;"", ""Proportion"": 0.7 }, { ""Name"": ""$economy_Extraction;"", ""Proportion"": 0.3 } ], ""DistFromStarLS"":2527.211914,""StationServices"":[""Refuel""], ""MarketID"": 128169720, ""SystemAddress"": 3107509474002}";
            List <Event> events = JournalMonitor.ParseJournalEntry(line);

            Assert.IsTrue(events.Count == 1);

            DockedEvent theEvent = (DockedEvent)events[0];

            Assert.AreEqual("AsteroidBase", theEvent.stationModel.edname);

            Assert.AreEqual(128169720, theEvent.marketId);
            Assert.AreEqual(3107509474002, theEvent.systemAddress);
            Assert.AreEqual(1, theEvent.stationservices.Count);
            Assert.AreEqual("Refuel", theEvent.stationservices[0]);
            Assert.AreEqual(2, theEvent.economyShares.Count);
            Assert.AreEqual("Industrial", theEvent.economyShares[0].economy.invariantName);
            Assert.AreEqual(0.7M, theEvent.economyShares[0].proportion);
            Assert.AreEqual("Extraction", theEvent.economyShares[1].economy.invariantName);
            Assert.AreEqual(0.3M, theEvent.economyShares[1].proportion);
        }
Exemplo n.º 11
0
 public static void DockedEvent(Client client, DockedEvent actionEvent)
 {
 }
Exemplo n.º 12
0
 internal void InvokeDockedEvent(DockedEvent arg)
 {
     DockedEvent?.Invoke(this, arg);
 }
Exemplo n.º 13
0
        public void TestEDDNResponderDockedEvent()
        {
            string line = @"{
                ""timestamp"": ""2018-07-30T04:50:32Z"",
	            ""event"": ""FSDJump"",
	            ""StarSystem"": ""Diaguandri"",
	            ""SystemAddress"": 670417429889,
	            ""StarPos"": [-41.06250, -62.15625, -103.25000],
	            ""SystemAllegiance"": ""Independent"",
	            ""SystemEconomy"": ""$economy_HighTech;"",
	            ""SystemEconomy_Localised"": ""High Tech"",
	            ""SystemSecondEconomy"": ""$economy_Refinery;"",
	            ""SystemSecondEconomy_Localised"": ""Refinery"",
	            ""SystemGovernment"": ""$government_Democracy;"",
	            ""SystemGovernment_Localised"": ""Democracy"",
	            ""SystemSecurity"": ""$SYSTEM_SECURITY_medium;"",
	            ""SystemSecurity_Localised"": ""Medium Security"",
	            ""Population"": 10303479,
	            ""JumpDist"": 8.018,
	            ""FuelUsed"": 0.917520,
	            ""FuelLevel"": 29.021893,
	            ""Factions"": [{
		            ""Name"": ""Diaguandri Interstellar"",
		            ""FactionState"": ""Election"",
		            ""Government"": ""Corporate"",
		            ""Influence"": 0.072565,
		            ""Allegiance"": ""Independent"",
		            ""RecoveringStates"": [{
			            ""State"": ""Boom"",
			            ""Trend"": 0
		            }]
	            },
	            {
		            ""Name"": ""People's MET 20 Liberals"",
		            ""FactionState"": ""Boom"",
		            ""Government"": ""Democracy"",
		            ""Influence"": 0.092445,
		            ""Allegiance"": ""Federation""
	            },
	            {
		            ""Name"": ""Pilots Federation Local Branch"",
		            ""FactionState"": ""None"",
		            ""Government"": ""Democracy"",
		            ""Influence"": 0.000000,
		            ""Allegiance"": ""PilotsFederation""
	            },
	            {
		            ""Name"": ""Natural Diaguandri Regulatory State"",
		            ""FactionState"": ""CivilWar"",
		            ""Government"": ""Dictatorship"",
		            ""Influence"": 0.009940,
		            ""Allegiance"": ""Independent""
	            },
	            {
		            ""Name"": ""Cartel of Diaguandri"",
		            ""FactionState"": ""CivilWar"",
		            ""Government"": ""Anarchy"",
		            ""Influence"": 0.009940,
		            ""Allegiance"": ""Independent"",
		            ""PendingStates"": [{
			            ""State"": ""Bust"",
			            ""Trend"": 0
		            }]
	            },
	            {
		            ""Name"": ""Revolutionary Party of Diaguandri"",
		            ""FactionState"": ""None"",
		            ""Government"": ""Democracy"",
		            ""Influence"": 0.050696,
		            ""Allegiance"": ""Federation"",
		            ""PendingStates"": [{
			            ""State"": ""Bust"",
			            ""Trend"": 1
		            }]
	            },
	            {
		            ""Name"": ""The Brotherhood of the Dark Circle"",
		            ""FactionState"": ""Election"",
		            ""Government"": ""Corporate"",
		            ""Influence"": 0.078529,
		            ""Allegiance"": ""Independent"",
		            ""PendingStates"": [{
			            ""State"": ""CivilUnrest"",
			            ""Trend"": 0
		            }],
		            ""RecoveringStates"": [{
			            ""State"": ""Boom"",
			            ""Trend"": 0
		            }]
	            },
	            {
		            ""Name"": ""EXO"",
		            ""FactionState"": ""Boom"",
		            ""Government"": ""Democracy"",
		            ""Influence"": 0.685885,
		            ""Allegiance"": ""Independent"",
		            ""PendingStates"": [{
			            ""State"": ""Expansion"",
			            ""Trend"": 0
		            }]
	            }],
	            ""SystemFaction"": {
		            ""Name"": ""EXO"",
		            ""FactionState"": ""Boom""
	            }
            }";

            string line2 = @"{
                ""timestamp"": ""2018-07-30T06: 07: 47Z"",
	            ""event"": ""Docked"",
	            ""StationName"": ""Ray Gateway"",
	            ""StationType"": ""Coriolis"",
	            ""StarSystem"": ""Diaguandri"",
	            ""SystemAddress"": 670417429889,
	            ""MarketID"": 3223343616,
	            ""StationFaction"": {
		            ""Name"": ""EXO"",
		            ""FactionState"": ""Boom""
	            },
	            ""StationGovernment"": ""$government_Democracy;"",
	            ""StationGovernment_Localised"": ""Democracy"",
	            ""StationServices"": [""Dock"",
	            ""Autodock"",
	            ""BlackMarket"",
	            ""Commodities"",
	            ""Contacts"",
	            ""Exploration"",
	            ""Missions"",
	            ""Outfitting"",
	            ""CrewLounge"",
	            ""Rearm"",
	            ""Refuel"",
	            ""Repair"",
	            ""Shipyard"",
	            ""Tuning"",
	            ""Workshop"",
	            ""MissionsGenerated"",
	            ""FlightController"",
	            ""StationOperations"",
	            ""Powerplay"",
	            ""SearchAndRescue"",
	            ""MaterialTrader"",
	            ""TechBroker""],
	            ""StationEconomy"": ""$economy_HighTech;"",
	            ""StationEconomy_Localised"": ""HighTech"",
	            ""StationEconomies"": [{
		            ""Name"": ""$economy_HighTech;"",
		            ""Name_Localised"": ""HighTech"",
		            ""Proportion"": 0.800000
	            },
	            {
		            ""Name"": ""$economy_Refinery;"",
		            ""Name_Localised"": ""Refinery"",
		            ""Proportion"": 0.200000
	            }],
	            ""DistFromStarLS"": 566.487976
            }";

            List <Event> events = JournalMonitor.ParseJournalEntry(line);

            Assert.IsTrue(events.Count == 1);
            JumpedEvent @jumpedEvent = (JumpedEvent)events[0];

            events = JournalMonitor.ParseJournalEntry(line2);
            Assert.IsTrue(events.Count == 1);
            DockedEvent @dockedEvent = (DockedEvent)events[0];

            EDDNResponder.EDDNResponder responder = makeTestEDDNResponder();
            responder.Handle(@jumpedEvent);
            responder.Handle(@dockedEvent);

            // Test that data available from the event is set correctly
            Assert.AreEqual("Diaguandri", responder.systemName);
            Assert.AreEqual(670417429889, responder.systemAddress);
            Assert.AreEqual("Ray Gateway", responder.stationName);
            Assert.AreEqual(3223343616, responder.marketId);

            // Test metadata not in the event itself but retrieved from memory and confirmed by our local database
            Assert.AreEqual(-41.06250M, responder.systemX);
            Assert.AreEqual(-62.15625M, responder.systemY);
            Assert.AreEqual(-103.25000M, responder.systemZ);
        }
Exemplo n.º 14
0
        public void TestEDDNResponderDockedEvent()
        {
            string line = @"{
	""timestamp"": ""2018-07-30T06: 07: 47Z"",
	""event"": ""Docked"",
	""StationName"": ""Ray Gateway"",
	""StationType"": ""Coriolis"",
	""StarSystem"": ""Diaguandri"",
	""SystemAddress"": 670417429889,
	""MarketID"": 3223343616,
	""StationFaction"": ""EXO"",
	""FactionState"": ""Boom"",
	""StationGovernment"": ""$government_Democracy;"",
	""StationGovernment_Localised"": ""Democracy"",
	""StationServices"": [""Dock"",
	""Autodock"",
	""BlackMarket"",
	""Commodities"",
	""Contacts"",
	""Exploration"",
	""Missions"",
	""Outfitting"",
	""CrewLounge"",
	""Rearm"",
	""Refuel"",
	""Repair"",
	""Shipyard"",
	""Tuning"",
	""Workshop"",
	""MissionsGenerated"",
	""FlightController"",
	""StationOperations"",
	""Powerplay"",
	""SearchAndRescue"",
	""MaterialTrader"",
	""TechBroker""],
	""StationEconomy"": ""$economy_HighTech;"",
	""StationEconomy_Localised"": ""HighTech"",
	""StationEconomies"": [{
		""Name"": ""$economy_HighTech;"",
		""Name_Localised"": ""HighTech"",
		""Proportion"": 0.800000
	},
	{
		""Name"": ""$economy_Refinery;"",
		""Name_Localised"": ""Refinery"",
		""Proportion"": 0.200000
	}],
	""DistFromStarLS"": 566.487976
}";

            List <Event> events = JournalMonitor.ParseJournalEntry(line);

            Assert.IsTrue(events.Count == 1);
            DockedEvent @event = (DockedEvent)events[0];

            EDDNResponder.EDDNResponder responder = makeTestEDDNResponder();
            responder.Handle(@event);

            // Test that data available from the event is set correctly
            Assert.AreEqual("Diaguandri", responder.systemName);
            Assert.AreEqual(670417429889, responder.systemAddress);
            Assert.AreEqual("Ray Gateway", responder.stationName);
            Assert.AreEqual(3223343616, responder.marketId);

            // Test metadata not in the event itself but retrieved from our local database
            Assert.AreEqual(-41.06250M, responder.systemX);
            Assert.AreEqual(-62.15625M, responder.systemY);
            Assert.AreEqual(-103.25000M, responder.systemZ);
        }
Exemplo n.º 15
0
 private void DockedCallback(DockedEvent obj)
 {
     SetValue(() => DockingState, DockingStates.Docked);
     SetValue(() => CurrentStationname, obj.StationName);
     SetValue(() => CurrentStationMarketId, obj.MarketId);
 }
Exemplo n.º 16
0
        private string prepareEventData(Event theEvent)
        {
            // Prep transient game state info (metadata) per https://www.edsm.net/en/api-journal-v1.
            // Unpackage the event, add transient game state info as applicable, then repackage and send the event
            IDictionary <string, object> eventObject = Deserializtion.DeserializeData(theEvent.raw);
            string eventType = JsonParsing.getString(eventObject, "event");

            if (ignoredEvents.Contains(eventType) || theEvent.raw == null)
            {
                return(null);
            }

            // Add metadata from events
            switch (eventType)
            {
            case "LoadGame":
            {
                eventObject.Add("_systemAddress", null);
                eventObject.Add("_systemName", null);
                eventObject.Add("_systemCoordinates", null);
                eventObject.Add("_marketId", null);
                eventObject.Add("_stationName", null);
                break;
            }

            case "SetUserShipName":
            {
                ShipRenamedEvent shipRenamedEvent = (ShipRenamedEvent)theEvent;
                eventObject.Add("_shipId", shipRenamedEvent.shipid);
                break;
            }

            case "ShipyardBuy":
            {
                eventObject.Add("_shipId", null);
                break;
            }

            case "ShipyardSwap":
            {
                ShipSwappedEvent shipSwappedEvent = (ShipSwappedEvent)theEvent;
                eventObject.Add("_shipId", shipSwappedEvent.shipid);
                break;
            }

            case "Loadout":
            {
                ShipLoadoutEvent shipLoadoutEvent = (ShipLoadoutEvent)theEvent;
                eventObject.Add("_shipId", shipLoadoutEvent.shipid);
                break;
            }

            case "Undocked":
            {
                eventObject.Add("_marketId", null);
                eventObject.Add("_stationName", null);
                break;
            }

            case "Location":
            {
                LocationEvent locationEvent = (LocationEvent)theEvent;
                eventObject.Add("_systemAddress", null);         // We don't collect this info yet
                eventObject.Add("_systemName", locationEvent.system);
                List <decimal?> _systemCoordinates = new List <decimal?>
                {
                    locationEvent.x,
                    locationEvent.y,
                    locationEvent.z
                };
                eventObject.Add("_systemCoordinates", _systemCoordinates);
                eventObject.Add("_marketId", null);         // We don't collect this info yet
                eventObject.Add("_stationName", locationEvent.station);
                break;
            }

            case "FSDJump":
            {
                JumpedEvent jumpedEvent = (JumpedEvent)theEvent;
                eventObject.Add("_systemAddress", null);         // We don't collect this info yet
                eventObject.Add("_systemName", jumpedEvent.system);
                List <decimal?> _systemCoordinates = new List <decimal?>
                {
                    jumpedEvent.x,
                    jumpedEvent.y,
                    jumpedEvent.z
                };
                eventObject.Add("_systemCoordinates", _systemCoordinates);
                break;
            }

            case "Docked":
            {
                DockedEvent dockedEvent = (DockedEvent)theEvent;
                eventObject.Add("_systemAddress", null);         // We don't collect this info yet
                eventObject.Add("_systemName", dockedEvent.system);
                eventObject.Add("_systemCoordinates", null);
                eventObject.Add("_marketId", null);         // We don't collect this info yet
                eventObject.Add("_stationName", dockedEvent.station);
                break;
            }
            }

            // Supplement with metadata from the tracked game state, as applicable
            if (EDDI.Instance.CurrentStarSystem != null)
            {
                if (!eventObject.ContainsKey("_systemAddress") && !eventObject.ContainsKey("SystemAddress"))
                {
                    eventObject.Add("_systemAddress", null); // We don't collect this info yet
                }
                if (!eventObject.ContainsKey("_systemName") && !eventObject.ContainsKey("SystemName"))
                {
                    eventObject.Add("_systemName", EDDI.Instance.CurrentStarSystem.name);
                }
                if (!eventObject.ContainsKey("_systemCoordinates") && !eventObject.ContainsKey("StarPos"))
                {
                    List <decimal?> _coordinates = new List <decimal?>
                    {
                        EDDI.Instance.CurrentStarSystem.x,
                        EDDI.Instance.CurrentStarSystem.y,
                        EDDI.Instance.CurrentStarSystem.z
                    };
                    eventObject.Add("_systemCoordinates", _coordinates);
                }
            }
            if (EDDI.Instance.CurrentStation != null)
            {
                if (!eventObject.ContainsKey("_marketId") && !eventObject.ContainsKey("MarketID"))
                {
                    eventObject.Add("_marketId", null); // We don't collect this info yet
                }
                if (!eventObject.ContainsKey("_stationName") && !eventObject.ContainsKey("StationName"))
                {
                    eventObject.Add("_stationName", EDDI.Instance.CurrentStation.name);
                }
            }
            if (EDDI.Instance.CurrentShip != null && !eventObject.ContainsKey("ShipId") && !eventObject.ContainsKey("_shipId"))
            {
                eventObject.Add("_shipId", EDDI.Instance.CurrentShip.LocalId);
            }

            return(JsonConvert.SerializeObject(eventObject).Normalize());
        }
Exemplo n.º 17
0
 public void DockedEvent(DockedEvent e)
 {
     LandingPad.Destroy();
 }
Exemplo n.º 18
0
 internal void InvokeDockedEvent(DockedEvent arg) => DockedEvent?.Invoke(null, arg);