Esempio n. 1
0
        public void Handle(Event theEvent)
        {
            if (EDDI.Instance.inCQC)
            {
                // We don't do anything whilst in CQC
                return;
            }

            if (EDDI.Instance.inBeta)
            {
                // We don't send data whilst in beta
                return;
            }

            if (starMapService != null)
            {
                // We could receive either or both of JumpingEvent and JumpedEvent.  Send EDSM update as soon as possible,
                // but don't send it twice
                if (theEvent is JumpingEvent)
                {
                    JumpingEvent jumpingEvent = (JumpingEvent)theEvent;

                    if (jumpingEvent.system != system)
                    {
                        Logging.Debug("Sending jump data to EDSM (jumping)");
                        starMapService.sendStarMapLog(jumpingEvent.timestamp, jumpingEvent.system, jumpingEvent.x, jumpingEvent.y, jumpingEvent.z);
                        system = jumpingEvent.system;
                    }
                }
                else if (theEvent is JumpedEvent)
                {
                    JumpedEvent jumpedEvent = (JumpedEvent)theEvent;

                    if (jumpedEvent.system != system)
                    {
                        Logging.Debug("Sending jump data to EDSM (jumped)");
                        starMapService.sendStarMapLog(jumpedEvent.timestamp, jumpedEvent.system, jumpedEvent.x, jumpedEvent.y, jumpedEvent.z);
                        system = jumpedEvent.system;
                    }
                }
                else if (theEvent is CommanderContinuedEvent)
                {
                    CommanderContinuedEvent continuedEvent = (CommanderContinuedEvent)theEvent;
                    starMapService.sendCredits(continuedEvent.credits, continuedEvent.loan);
                }
                else if (theEvent is CommanderProgressEvent)
                {
                    CommanderProgressEvent progressEvent = (CommanderProgressEvent)theEvent;
                    if (EDDI.Instance.Cmdr != null && EDDI.Instance.Cmdr.federationrating != null)
                    {
                        starMapService.sendRanks(EDDI.Instance.Cmdr.combatrating.rank, (int)progressEvent.combat,
                                                 EDDI.Instance.Cmdr.traderating.rank, (int)progressEvent.trade,
                                                 EDDI.Instance.Cmdr.explorationrating.rank, (int)progressEvent.exploration,
                                                 EDDI.Instance.Cmdr.cqcrating.rank, (int)progressEvent.cqc,
                                                 EDDI.Instance.Cmdr.federationrating.rank, (int)progressEvent.federation,
                                                 EDDI.Instance.Cmdr.empirerating.rank, (int)progressEvent.empire);
                    }
                }
            }
        }
Esempio n. 2
0
        public void TestJournalJumpedEventFactionStateNull()
        {
            // Test for unpopulated system
            string line = @"{
                ""timestamp"": ""2018-10-17T00:40:45Z"",
                ""event"": ""FSDJump"",
                ""StarSystem"": ""Wredguia WD-K d8-65"",
                ""SystemAddress"": 2243793258827,
                ""StarPos"": [-319.15625,10.37500,-332.31250],
                ""SystemAllegiance"": """",
                ""SystemEconomy"": ""$economy_None;"",
                ""SystemEconomy_Localised"": ""None"",
                ""SystemSecondEconomy"": ""$economy_None;"",
                ""SystemSecondEconomy_Localised"": ""None"",
                ""SystemGovernment"": ""$government_None;"",
                ""SystemGovernment_Localised"": ""None"",
                ""SystemSecurity"": ""$GAlAXY_MAP_INFO_state_anarchy;"",
                ""SystemSecurity_Localised"": ""Anarchy"",
                ""Population"": 0,
                ""JumpDist"": 24.230,
                ""FuelUsed"": 4.271171,
                ""FuelLevel"": 27.728828
            }";

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

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

            Assert.AreEqual("None", jumpedEvent.factionstate);
        }
Esempio n. 3
0
 private void handleJumpedEvent(JumpedEvent @event)
 {
     systemName = @event.system;
     systemX    = @event.x;
     systemY    = @event.y;
     systemZ    = @event.z;
 }
        public void Handle(Event theEvent)
        {
            if (starMapService != null)
            {
                // We could receive either or both of JumpingEvent and JumpedEvent.  Send EDSM update as soon as possible,
                // but don't send it twice
                if (theEvent is JumpingEvent)
                {
                    JumpingEvent jumpingEvent = (JumpingEvent)theEvent;

                    if (jumpingEvent.system != system)
                    {
                        Logging.Debug("Sending jump data to EDSM (jumping)");
                        starMapService.sendStarMapLog(jumpingEvent.timestamp, jumpingEvent.system, jumpingEvent.x, jumpingEvent.y, jumpingEvent.z);
                        system = jumpingEvent.system;
                    }
                }
                else if (theEvent is JumpedEvent)
                {
                    JumpedEvent jumpedEvent = (JumpedEvent)theEvent;

                    if (jumpedEvent.system != system)
                    {
                        Logging.Debug("Sending jump data to EDSM (jumped)");
                        starMapService.sendStarMapLog(jumpedEvent.timestamp, jumpedEvent.system, jumpedEvent.x, jumpedEvent.y, jumpedEvent.z);
                        system = jumpedEvent.system;
                    }
                }
            }
        }
Esempio n. 5
0
        public void TestJumpedEventAllegianceGuardian()
        {
            string       line   = @"{ ""timestamp"":""2018-08-25T06:28:04Z"", ""event"":""FSDJump"", ""StarSystem"":""Synuefe EU-Q c21-10"", ""SystemAddress"":2833906537146, ""StarPos"":[758.65625,-176.90625,-133.21875], ""SystemAllegiance"":""Guardian"", ""SystemEconomy"":""$economy_None;"", ""SystemEconomy_Localised"":""None"", ""SystemSecondEconomy"":""$economy_None;"", ""SystemSecondEconomy_Localised"":""None"", ""SystemGovernment"":""$government_None;"", ""SystemGovernment_Localised"":""None"", ""SystemSecurity"":""$GAlAXY_MAP_INFO_state_anarchy;"", ""SystemSecurity_Localised"":""Anarchy"", ""Population"":0, ""JumpDist"":29.867, ""FuelUsed"":1.269155, ""FuelLevel"":18.824537 }";
            List <Event> events = JournalMonitor.ParseJournalEntry(line);
            JumpedEvent  @event = (JumpedEvent)events[0];

            Assert.AreEqual("Guardian", @event.Allegiance.invariantName);
        }
Esempio n. 6
0
        public void TestJumpedEventAllegianceThargoid()
        {
            string       line   = @"{ ""timestamp"":""2018 - 03 - 25T02: 59:48Z"", ""event"":""FSDJump"", ""StarSystem"":""Pleiades Sector OY-R c4-19"", ""SystemAddress"":5306398479010, ""StarPos"":[-73.81250,-98.62500,-262.31250], ""SystemAllegiance"":""Thargoid"", ""SystemEconomy"":""$economy_None;"", ""SystemEconomy_Localised"":""None"", ""SystemSecondEconomy"":""$economy_None;"", ""SystemSecondEconomy_Localised"":""None"", ""SystemGovernment"":""$government_None;"", ""SystemGovernment_Localised"":""None"", ""SystemSecurity"":""$GAlAXY_MAP_INFO_state_anarchy;"", ""SystemSecurity_Localised"":""Anarchy"", ""Population"":0, ""JumpDist"":13.936, ""FuelUsed"":3.833808, ""FuelLevel"":28.166193 }";
            List <Event> events = JournalMonitor.ParseJournalEntry(line);
            JumpedEvent  @event = (JumpedEvent)events[0];

            Assert.AreEqual("Thargoid", @event.Allegiance.invariantName);
        }
Esempio n. 7
0
 private void handleJumpedEvent(JumpedEvent @event)
 {
     if (@event.timestamp > updateDat)
     {
         updateDat = @event.timestamp;
         _handleJumpedEvent(@event);
         writeRecord();
     }
 }
Esempio n. 8
0
 private void handleJumpedEvent(JumpedEvent @event)
 {
     if (@event.timestamp > updateDat || (@event.timestamp == updateDat && [email protected]))
     {
         updateDat = @event.timestamp;
         _handleJumpedEvent(@event);
         writeRecord();
     }
 }
Esempio n. 9
0
        private void handleJumpedEvent(JumpedEvent @event)
        {
            Ship ship = GetCurrentShip();

            if (@event.fuelused > ship.maxfuel)
            {
                ship.maxfuel = @event.fuelused;
                ship.maxjump = @event.distance;
                writeShips();
            }
        }
Esempio n. 10
0
 private void handleJumpedEvent(JumpedEvent @event)
 {
     // Set all of the information available from the event
     systemName    = @event.system;
     systemAddress = @event.systemAddress;
     systemX       = @event.x;
     systemY       = @event.y;
     systemZ       = @event.z;
     stationName   = null;
     marketId      = null;
 }
        public static void JumpedEvent(Client client, JumpedEvent actionEvent)
        {
            // We have entered a new system
            //StarSystem starSystem = StarSystemSqLiteRepository.Instance.GetOrCreateStarSystem(actionEvent.system, true);
            //var page = Exploration.EliteActions.OutputValuableSystems(client, starSystem);

            //const string local_files_base = "http://127.0.0.1:8080";
            //var httpPage = $"{local_files_base}/{Path.GetFileName(page)}";

            //client.Navigate(httpPage);
        }
Esempio n. 12
0
        public void TestJumpedEventHandler()
        {
            string       line   = "{ \"timestamp\":\"2018-12-25T20:07:06Z\", \"event\":\"FSDJump\", \"StarSystem\":\"LHS 20\", \"SystemAddress\":33656303199641, \"StarPos\":[11.18750,-37.37500,-31.84375], \"SystemAllegiance\":\"Federation\", \"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\":9500553, \"JumpDist\":20.361, \"FuelUsed\":3.065896, \"FuelLevel\":19.762932, \"Factions\":[ { \"Name\":\"Pilots Federation Local Branch\", \"FactionState\":\"None\", \"Government\":\"Democracy\", \"Influence\":0.000000, \"Allegiance\":\"PilotsFederation\", \"Happiness\":\"\", \"MyReputation\":6.106290 }, { \"Name\":\"Shenetserii Confederation\", \"FactionState\":\"None\", \"Government\":\"Confederacy\", \"Influence\":0.127000, \"Allegiance\":\"Federation\", \"Happiness\":\"$Faction_HappinessBand2;\", \"Happiness_Localised\":\"Happy\", \"MyReputation\":18.809999, \"PendingStates\":[ { \"State\":\"War\", \"Trend\":0 } ] }, { \"Name\":\"LHS 20 Company\", \"FactionState\":\"None\", \"Government\":\"Corporate\", \"Influence\":0.127000, \"Allegiance\":\"Federation\", \"Happiness\":\"$Faction_HappinessBand2;\", \"Happiness_Localised\":\"Happy\", \"MyReputation\":4.950000, \"PendingStates\":[ { \"State\":\"War\", \"Trend\":0 } ] }, { \"Name\":\"Traditional LHS 20 Defence Party\", \"FactionState\":\"None\", \"Government\":\"Dictatorship\", \"Influence\":0.087000, \"Allegiance\":\"Independent\", \"Happiness\":\"$Faction_HappinessBand2;\", \"Happiness_Localised\":\"Happy\", \"MyReputation\":2.640000 }, { \"Name\":\"Movement for LHS 20 Liberals\", \"FactionState\":\"CivilWar\", \"Government\":\"Democracy\", \"Influence\":0.226000, \"Allegiance\":\"Federation\", \"Happiness\":\"$Faction_HappinessBand2;\", \"Happiness_Localised\":\"Happy\", \"SquadronFaction\":true, \"HomeSystem\":true, \"MyReputation\":100.000000, \"ActiveStates\":[ { \"State\":\"CivilLiberty\" }, { \"State\":\"Investment\" }, { \"State\":\"CivilWar\" } ] }, { \"Name\":\"Nationalists of LHS 20\", \"FactionState\":\"None\", \"Government\":\"Dictatorship\", \"Influence\":0.105000, \"Allegiance\":\"Independent\", \"Happiness\":\"$Faction_HappinessBand2;\", \"Happiness_Localised\":\"Happy\", \"MyReputation\":0.000000 }, { \"Name\":\"LHS 20 Organisation\", \"FactionState\":\"CivilWar\", \"Government\":\"Anarchy\", \"Influence\":0.166000, \"Allegiance\":\"Independent\", \"Happiness\":\"$Faction_HappinessBand2;\", \"Happiness_Localised\":\"Happy\", \"MyReputation\":5.940000, \"ActiveStates\":[ { \"State\":\"CivilWar\" } ] }, { \"Name\":\"LHS 20 Engineers\", \"FactionState\":\"None\", \"Government\":\"Corporate\", \"Influence\":0.162000, \"Allegiance\":\"Federation\", \"Happiness\":\"$Faction_HappinessBand2;\", \"Happiness_Localised\":\"Happy\", \"MyReputation\":15.000000 } ], \"SystemFaction\":{ \"Name\":\"Movement for LHS 20 Liberals\", \"FactionState\":\"CivilWar\" } }";
            List <Event> events = JournalMonitor.ParseJournalEntry(line);

            Assert.AreEqual(1, events.Count);
            JumpedEvent @event = (JumpedEvent)events[0];

            Assert.IsNotNull(@event);
            Assert.IsInstanceOfType(@event, typeof(JumpedEvent));

            PrivateObject privateObject = new PrivateObject(Eddi.EDDI.Instance);
            var           result        = (bool)privateObject.Invoke("eventJumped", new object[] { @event });

            Assert.IsTrue(result);
        }
Esempio n. 13
0
        private bool eventJumped(JumpedEvent theEvent)
        {
            bool passEvent;

            Logging.Debug("Jumped to " + theEvent.system);
            if (CurrentStarSystem == null || CurrentStarSystem.name != theEvent.system)
            {
                // New system
                passEvent = true;
                updateCurrentSystem(theEvent.system);
                // The information in the event is more up-to-date than the information we obtain from external sources, so update it here
                CurrentStarSystem.x              = theEvent.x;
                CurrentStarSystem.y              = theEvent.y;
                CurrentStarSystem.z              = theEvent.z;
                CurrentStarSystem.allegiance     = theEvent.allegiance;
                CurrentStarSystem.faction        = theEvent.faction;
                CurrentStarSystem.primaryeconomy = theEvent.economy;
                CurrentStarSystem.government     = theEvent.government;
                CurrentStarSystem.security       = theEvent.security;

                CurrentStarSystem.visits++;
                CurrentStarSystem.lastvisit = DateTime.Now;
                StarSystemSqLiteRepository.Instance.SaveStarSystem(CurrentStarSystem);
                setCommanderTitle();
            }
            else if (CurrentStarSystem.name == theEvent.system && Environment == Constants.ENVIRONMENT_SUPERCRUISE)
            {
                // Restatement of current system
                passEvent = false;
            }
            else if (CurrentStarSystem.name == theEvent.system && Environment == Constants.ENVIRONMENT_WITCH_SPACE)
            {
                passEvent = true;

                // Jumped event following a Jumping event, so most information is up-to-date but we should pass this anyway for
                // plugin triggers

                // The information in the event is more up-to-date than the information we obtain from external sources, so update it here
                CurrentStarSystem.allegiance     = theEvent.allegiance;
                CurrentStarSystem.faction        = theEvent.faction;
                CurrentStarSystem.primaryeconomy = theEvent.economy;
                CurrentStarSystem.government     = theEvent.government;
                CurrentStarSystem.security       = theEvent.security;
                setCommanderTitle();
            }
            else
            {
                passEvent = true;
                updateCurrentSystem(theEvent.system);

                // The information in the event is more up-to-date than the information we obtain from external sources, so update it here
                CurrentStarSystem.x              = theEvent.x;
                CurrentStarSystem.y              = theEvent.y;
                CurrentStarSystem.z              = theEvent.z;
                CurrentStarSystem.allegiance     = theEvent.allegiance;
                CurrentStarSystem.faction        = theEvent.faction;
                CurrentStarSystem.primaryeconomy = theEvent.economy;
                CurrentStarSystem.government     = theEvent.government;
                CurrentStarSystem.security       = theEvent.security;

                CurrentStarSystem.visits++;
                CurrentStarSystem.lastvisit = DateTime.Now;
                StarSystemSqLiteRepository.Instance.SaveStarSystem(CurrentStarSystem);
                setCommanderTitle();
            }

            // After jump has completed we are always in supercruise
            Environment = Constants.ENVIRONMENT_SUPERCRUISE;

            return(passEvent);
        }
Esempio n. 14
0
 private void _handleJumpedEvent(JumpedEvent @event)
 {
     shipTargets.Clear();
     targetSystem = @event.system;
 }
Esempio n. 15
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());
        }
Esempio n. 16
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);
        }
Esempio n. 17
0
        public void Handle(Event theEvent)
        {
            if (EDDI.Instance.inCQC)
            {
                // We don't do anything whilst in CQC
                return;
            }

            if (EDDI.Instance.inCrew)
            {
                // We don't do anything whilst in multicrew
                return;
            }

            if (EDDI.Instance.inBeta)
            {
                // We don't send data whilst in beta
                return;
            }

            if (starMapService != null)
            {
                if (theEvent is JumpedEvent)
                {
                    JumpedEvent jumpedEvent = (JumpedEvent)theEvent;

                    if (jumpedEvent.system != system)
                    {
                        Logging.Debug("Sending jump data to EDSM (jumped)");
                        starMapService.sendStarMapLog(jumpedEvent.timestamp, jumpedEvent.system, jumpedEvent.x, jumpedEvent.y, jumpedEvent.z);
                        system = jumpedEvent.system;
                    }
                }
                else if (theEvent is CommanderContinuedEvent)
                {
                    CommanderContinuedEvent continuedEvent = (CommanderContinuedEvent)theEvent;
                    starMapService.sendCredits(continuedEvent.credits, continuedEvent.loan);
                }
                else if (theEvent is MaterialInventoryEvent)
                {
                    MaterialInventoryEvent   materialInventoryEvent = (MaterialInventoryEvent)theEvent;
                    Dictionary <string, int> materials = new Dictionary <string, int>();
                    Dictionary <string, int> data      = new Dictionary <string, int>();
                    foreach (MaterialAmount ma in materialInventoryEvent.inventory)
                    {
                        Material material = Material.FromEDName(ma.edname);
                        if (material.category == "Element" || material.category == "Manufactured")
                        {
                            materials.Add(material.EDName, ma.amount);
                        }
                        else
                        {
                            data.Add(material.EDName, ma.amount);
                        }
                    }
                    starMapService.sendMaterials(materials);
                    starMapService.sendData(data);
                }
                else if (theEvent is ShipLoadoutEvent)
                {
                    ShipLoadoutEvent shipLoadoutEvent = (ShipLoadoutEvent)theEvent;
                    Ship             ship             = ((ShipMonitor)EDDI.Instance.ObtainMonitor("Ship monitor")).GetShip(shipLoadoutEvent.shipid);
                    starMapService.sendShip(ship);
                }
                else if (theEvent is ShipSwappedEvent)
                {
                    ShipSwappedEvent shipSwappedEvent = (ShipSwappedEvent)theEvent;
                    if (shipSwappedEvent.shipid.HasValue)
                    {
                        starMapService.sendShipSwapped((int)shipSwappedEvent.shipid);
                    }
                }
                else if (theEvent is ShipSoldEvent)
                {
                    ShipSoldEvent shipSoldEvent = (ShipSoldEvent)theEvent;
                    if (shipSoldEvent.shipid.HasValue)
                    {
                        starMapService.sendShipSold((int)shipSoldEvent.shipid);
                    }
                }
                else if (theEvent is ShipDeliveredEvent)
                {
                    ShipDeliveredEvent shipDeliveredEvent = (ShipDeliveredEvent)theEvent;
                    if (shipDeliveredEvent.shipid.HasValue)
                    {
                        starMapService.sendShipSwapped((int)shipDeliveredEvent.shipid);
                    }
                }
                else if (theEvent is CommanderProgressEvent)
                {
                    CommanderProgressEvent progressEvent = (CommanderProgressEvent)theEvent;
                    if (EDDI.Instance.Cmdr != null && EDDI.Instance.Cmdr.federationrating != null)
                    {
                        starMapService.sendRanks(EDDI.Instance.Cmdr.combatrating.rank, (int)progressEvent.combat,
                                                 EDDI.Instance.Cmdr.traderating.rank, (int)progressEvent.trade,
                                                 EDDI.Instance.Cmdr.explorationrating.rank, (int)progressEvent.exploration,
                                                 EDDI.Instance.Cmdr.cqcrating.rank, (int)progressEvent.cqc,
                                                 EDDI.Instance.Cmdr.federationrating.rank, (int)progressEvent.federation,
                                                 EDDI.Instance.Cmdr.empirerating.rank, (int)progressEvent.empire);
                    }
                }
            }
        }
Esempio n. 18
0
        public void TestJournalJumpedEvent()
        {
            string       line   = @"{
	""timestamp"": ""2018-08-08T06: 56: 20Z"",
	""event"": ""FSDJump"",
	""StarSystem"": ""Diaguandri"",
	""SystemAddress"": 670417429889,
	""StarPos"": [-41.06250,
	-62.15625,
	-103.25000],
	""SystemAllegiance"": ""Independent"",
	""SystemEconomy"": ""$economy_HighTech;"",
	""SystemEconomy_Localised"": ""HighTech"",
	""SystemSecondEconomy"": ""$economy_Refinery;"",
	""SystemSecondEconomy_Localised"": ""Refinery"",
	""SystemGovernment"": ""$government_Democracy;"",
	""SystemGovernment_Localised"": ""Democracy"",
	""SystemSecurity"": ""$SYSTEM_SECURITY_medium;"",
	""SystemSecurity_Localised"": ""MediumSecurity"",
	""Population"": 10303479,
	""JumpDist"": 19.340,
	""FuelUsed"": 2.218082,
	""FuelLevel"": 23.899260,
	""Factions"": [{
		""Name"": ""DiaguandriInterstellar"",
		""FactionState"": ""Boom"",
		""Government"": ""Corporate"",
		""Influence"": 0.100398,
		""Allegiance"": ""Independent""
	},
	{
		""Name"": ""People'sMET20Liberals"",
		""FactionState"": ""Boom"",
		""Government"": ""Democracy"",
		""Influence"": 0.123260,
		""Allegiance"": ""Federation""
	},
	{
		""Name"": ""PilotsFederationLocalBranch"",
		""FactionState"": ""None"",
		""Government"": ""Democracy"",
		""Influence"": 0.000000,
		""Allegiance"": ""PilotsFederation""
	},
	{
		""Name"": ""NaturalDiaguandriRegulatoryState"",
		""FactionState"": ""None"",
		""Government"": ""Dictatorship"",
		""Influence"": 0.020875,
		""Allegiance"": ""Independent"",
		""RecoveringStates"": [{
			""State"": ""CivilWar"",
			""Trend"": 0
		}]
	},
	{
		""Name"": ""CartelofDiaguandri"",
		""FactionState"": ""None"",
		""Government"": ""Anarchy"",
		""Influence"": 0.009940,
		""Allegiance"": ""Independent"",
		""PendingStates"": [{
			""State"": ""Bust"",
			""Trend"": 0
		},
		{
			""State"": ""CivilUnrest"",
			""Trend"": 1
		}],
		""RecoveringStates"": [{
			""State"": ""CivilWar"",
			""Trend"": 0
		}]
	},
	{
		""Name"": ""RevolutionaryPartyofDiaguandri"",
		""FactionState"": ""None"",
		""Government"": ""Democracy"",
		""Influence"": 0.124254,
		""Allegiance"": ""Federation"",
		""PendingStates"": [{
			""State"": ""Boom"",
			""Trend"": 1
		},
		{
			""State"": ""Bust"",
			""Trend"": 1
		}]
	},
	{
		""Name"": ""TheBrotherhoodoftheDarkCircle"",
		""FactionState"": ""None"",
		""Government"": ""Corporate"",
		""Influence"": 0.093439,
		""Allegiance"": ""Independent"",
		""RecoveringStates"": [{
			""State"": ""CivilUnrest"",
			""Trend"": 1
		}]
	},
	{
		""Name"": ""EXO"",
		""FactionState"": ""Expansion"",
		""Government"": ""Democracy"",
		""Influence"": 0.527833,
		""Allegiance"": ""Independent"",
		""PendingStates"": [{
			""State"": ""Boom"",
			""Trend"": 1
		}]
	}],
	""SystemFaction"": ""EXO"",
	""FactionState"": ""Expansion""
}";
            List <Event> events = JournalMonitor.ParseJournalEntry(line);

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

            Assert.AreEqual("Diaguandri", jumpedEvent.system);
            Assert.AreEqual(670417429889, jumpedEvent.systemAddress);
            Assert.AreEqual(-41.06250M, jumpedEvent.x);
            Assert.AreEqual(-62.15625M, jumpedEvent.y);
            Assert.AreEqual(-103.25000M, jumpedEvent.z);
            Assert.AreEqual("Independent", jumpedEvent.Allegiance.invariantName);
            Assert.AreEqual("High Tech", jumpedEvent.economy);
            Assert.AreEqual("Refinery", jumpedEvent.economy2);
            Assert.AreEqual("Democracy", jumpedEvent.government);
            Assert.AreEqual("Medium", jumpedEvent.security);
            Assert.AreEqual(10303479, jumpedEvent.population);
            Assert.AreEqual(19.340M, jumpedEvent.distance);
            Assert.AreEqual(2.218082M, jumpedEvent.fuelused);
            Assert.AreEqual(23.899260M, jumpedEvent.fuelremaining);
            Assert.AreEqual("EXO", jumpedEvent.faction);
            Assert.AreEqual("Expansion", jumpedEvent.factionstate);
        }