Ejemplo n.º 1
0
        public void TestJournalMessageReceived2()
        {
            string line = @"{ ""timestamp"":""2016-10-06T12:48:56Z"", ""event"":""ReceiveText"", ""From"":""$npc_name_decorate:#name=Jonathan Dallard;"", ""From_Localised"":""Jonathan Dallard"", ""Message"":""$Pirate_OnStartScanCargo07;"", ""Message_Localised"":""Do you have anything of value?"", ""Channel"":""npc"" }";

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

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

            MessageReceivedEvent event1 = (MessageReceivedEvent)events[0];

            Assert.IsFalse(event1.player);
            Assert.AreEqual("Pirate", event1.source);
            Assert.AreEqual("Jonathan Dallard", event1.from);

            NPCCargoScanCommencedEvent event2 = (NPCCargoScanCommencedEvent)events[1];

            Assert.AreEqual("Pirate", event2.by);
        }
Ejemplo n.º 2
0
        private void testScript(object sender, RoutedEventArgs e)
        {
            Script          script    = ((KeyValuePair <string, Script>)((Button)e.Source).DataContext).Value;
            SpeechResponder responder = new SpeechResponder();

            responder.Start();
            // See if we have a sample
            List <Event> sampleEvents;
            object       sample = Events.SampleByName(script.Name);

            if (sample == null)
            {
                sampleEvents = new List <Event>();
            }
            else if (sample is string)
            {
                // It's as tring so a journal entry.  Parse it
                sampleEvents = JournalMonitor.ParseJournalEntry((string)sample);
            }
            else if (sample is Event)
            {
                // It's a direct event
                sampleEvents = new List <Event>()
                {
                    (Event)sample
                };
            }
            else
            {
                Logging.Warn("Unknown sample type " + sample.GetType());
                sampleEvents = new List <Event>();
            }

            ScriptResolver scriptResolver = new ScriptResolver(Personality.Scripts);

            if (sampleEvents.Count == 0)
            {
                sampleEvents.Add(null);
            }
            foreach (Event sampleEvent in sampleEvents)
            {
                responder.Say(scriptResolver, ((ShipMonitor)EDDI.Instance.ObtainMonitor("Ship monitor"))?.GetCurrentShip(), script.Name, sampleEvent, scriptResolver.priority(script.Name));
            }
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            /*
             * var Api = new SpanchApi();
             * var result = Api.PlotRoute("Kashyapa", "Sol", 48);
             *
             * StringBuilder route = new StringBuilder();
             *
             * foreach (var system in result.SystemJumps)
             * {
             * route.AppendLine(system.System);
             * }
             *
             * Console.Write(route);*/

            /*
             * var router = EdRouter.Instance;
             * router.Start = "Sol";
             * router.Destination = "Ao Shun";
             * router.Range = 48;
             * router.Efficiency = 60;
             *
             * router.CalculateRoute();
             *
             * Console.WriteLine("Start Sys: {0}", router.CurrentWaypoint);
             *
             * router.NextWaypoint();
             * Console.WriteLine("Sys 1: {0}", router.CurrentWaypoint);
             *
             * router.NextWaypoint();
             * Console.WriteLine("Sys 2: {0}", router.CurrentWaypoint);
             *
             * router.NextWaypoint();
             * Console.WriteLine("Sys 3: {0}", router.CurrentWaypoint);
             *
             * router.PreviousWaypoint();
             * Console.WriteLine("Sys 2: {0}", router.CurrentWaypoint);
             * Console.ReadLine();
             */

            //var l1 = JournalMonitor.GetLocaction("{ \"timestamp\":\"2018 - 03 - 17T20: 05:59Z\", \"event\":\"StartJump\", \"JumpType\":\"Hyperspace\", \"StarSystem\":\"Kyloarph IN-S d4-2021\", \"SystemAddress\":69449931411883, \"StarClass\":\"N\" }");
            //var l2 = JournalMonitor.GetLocaction("{ \"timestamp\":\"2018-03-17T20:03:25Z\", \"event\":\"Location\", \"Docked\":false, \"StarSystem\":\"Kyloarph DB-X e1-5559\", \"SystemAddress\":23876836747476, \"StarPos\":[-7504.34375,-727.28125,21081.59375], \"SystemAllegiance\":\"\", \"SystemEconomy\":\"$economy_None;\", \"SystemEconomy_Localised\":\"n/v\", \"SystemGovernment\":\"$government_None;\", \"SystemGovernment_Localised\":\"n/v\", \"SystemSecurity\":\"$GAlAXY_MAP_INFO_state_anarchy;\", \"SystemSecurity_Localised\":\"Anarchie\", \"Population\":0, \"Body\":\"Kyloarph DB-X e1-5559 1\", \"BodyID\":1, \"BodyType\":\"Planet\" }");
            var l3 = JournalMonitor.GetLocation("{ \"timestamp\":\"2018-03-17T20:09:52Z\", \"event\":\"Scan\", \"ScanType\":\"Detailed\", \"BodyName\":\"Kyloarph PT-Q d5-3862 A 1\", \"BodyID\":7, \"Parents\":[ {\"Star\":1}, {\"Null\":0} ], \"DistanceFromArrivalLS\":239.561920, \"TidalLock\":false, \"TerraformState\":\"\", \"PlanetClass\":\"High metal content body\", \"Atmosphere\":\"thin sulfur dioxide atmosphere\", \"AtmosphereType\":\"SulphurDioxide\", \"AtmosphereComposition\":[ { \"Name\":\"SulphurDioxide\", \"Percent\":100.000000 } ], \"Volcanism\":\"\", \"MassEM\":0.134808, \"Radius\":3276403.500000, \"SurfaceGravity\":5.005291, \"SurfaceTemperature\":378.430450, \"SurfacePressure\":359.917908, \"Landable\":false, \"Composition\":{ \"Ice\":0.000000, \"Rock\":0.672977, \"Metal\":0.327023 }, \"SemiMajorAxis\":71812833280.000000, \"Eccentricity\":0.000085, \"OrbitalInclination\":-0.000587, \"Periapsis\":246.785690, \"OrbitalPeriod\":10816627.000000, \"RotationPeriod\":208069.937500, \"AxialTilt\":-0.499019 }");
        }
Ejemplo n.º 4
0
        public void TestMaterialInventoryEvent()
        {
            var    materialMonitor        = new MaterialMonitor();
            string line                   = @"{ ""timestamp"":""2021-01-23T02:50:29Z"", ""event"":""Materials"", ""Raw"":[ { ""Name"":""phosphorus"", ""Count"":231 }, { ""Name"":""mercury"", ""Count"":100 }, { ""Name"":""germanium"", ""Count"":244 }, { ""Name"":""manganese"", ""Count"":222 }, { ""Name"":""zirconium"", ""Count"":107 }, { ""Name"":""niobium"", ""Count"":130 }, { ""Name"":""vanadium"", ""Count"":164 }, { ""Name"":""yttrium"", ""Count"":112 }, { ""Name"":""carbon"", ""Count"":278 }, { ""Name"":""polonium"", ""Count"":65 }, { ""Name"":""nickel"", ""Count"":266 }, { ""Name"":""zinc"", ""Count"":167 }, { ""Name"":""molybdenum"", ""Count"":119 }, { ""Name"":""tungsten"", ""Count"":103 }, { ""Name"":""tin"", ""Count"":177 }, { ""Name"":""iron"", ""Count"":189 }, { ""Name"":""selenium"", ""Count"":75 }, { ""Name"":""arsenic"", ""Count"":101 }, { ""Name"":""chromium"", ""Count"":239 }, { ""Name"":""tellurium"", ""Count"":18 }, { ""Name"":""ruthenium"", ""Count"":39 }, { ""Name"":""technetium"", ""Count"":101 }, { ""Name"":""sulphur"", ""Count"":241 }, { ""Name"":""cadmium"", ""Count"":166 }, { ""Name"":""rhenium"", ""Count"":285 }, { ""Name"":""lead"", ""Count"":283 }, { ""Name"":""boron"", ""Count"":188 } ], ""Manufactured"":[ { ""Name"":""salvagedalloys"", ""Name_Localised"":""Salvaged Alloys"", ""Count"":257 }, { ""Name"":""shieldemitters"", ""Name_Localised"":""Shield Emitters"", ""Count"":227 }, { ""Name"":""conductivecomponents"", ""Name_Localised"":""Conductive Components"", ""Count"":179 }, { ""Name"":""mechanicalcomponents"", ""Name_Localised"":""Mechanical Components"", ""Count"":149 }, { ""Name"":""protolightalloys"", ""Name_Localised"":""Proto Light Alloys"", ""Count"":138 }, { ""Name"":""heatvanes"", ""Name_Localised"":""Heat Vanes"", ""Count"":122 }, { ""Name"":""hybridcapacitors"", ""Name_Localised"":""Hybrid Capacitors"", ""Count"":209 }, { ""Name"":""fedcorecomposites"", ""Name_Localised"":""Core Dynamics Composites"", ""Count"":29 }, { ""Name"":""highdensitycomposites"", ""Name_Localised"":""High Density Composites"", ""Count"":183 }, { ""Name"":""thermicalloys"", ""Name_Localised"":""Thermic Alloys"", ""Count"":150 }, { ""Name"":""heatexchangers"", ""Name_Localised"":""Heat Exchangers"", ""Count"":184 }, { ""Name"":""fedproprietarycomposites"", ""Name_Localised"":""Proprietary Composites"", ""Count"":116 }, { ""Name"":""improvisedcomponents"", ""Name_Localised"":""Improvised Components"", ""Count"":5 }, { ""Name"":""biotechconductors"", ""Name_Localised"":""Biotech Conductors"", ""Count"":71 }, { ""Name"":""gridresistors"", ""Name_Localised"":""Grid Resistors"", ""Count"":241 }, { ""Name"":""militarygradealloys"", ""Name_Localised"":""Military Grade Alloys"", ""Count"":100 }, { ""Name"":""heatdispersionplate"", ""Name_Localised"":""Heat Dispersion Plate"", ""Count"":238 }, { ""Name"":""exquisitefocuscrystals"", ""Name_Localised"":""Exquisite Focus Crystals"", ""Count"":99 }, { ""Name"":""mechanicalequipment"", ""Name_Localised"":""Mechanical Equipment"", ""Count"":231 }, { ""Name"":""conductiveceramics"", ""Name_Localised"":""Conductive Ceramics"", ""Count"":126 }, { ""Name"":""mechanicalscrap"", ""Name_Localised"":""Mechanical Scrap"", ""Count"":190 }, { ""Name"":""conductivepolymers"", ""Name_Localised"":""Conductive Polymers"", ""Count"":101 }, { ""Name"":""polymercapacitors"", ""Name_Localised"":""Polymer Capacitors"", ""Count"":93 }, { ""Name"":""compoundshielding"", ""Name_Localised"":""Compound Shielding"", ""Count"":124 }, { ""Name"":""refinedfocuscrystals"", ""Name_Localised"":""Refined Focus Crystals"", ""Count"":117 }, { ""Name"":""protoheatradiators"", ""Name_Localised"":""Proto Heat Radiators"", ""Count"":92 }, { ""Name"":""heatconductionwiring"", ""Name_Localised"":""Heat Conduction Wiring"", ""Count"":250 }, { ""Name"":""chemicalmanipulators"", ""Name_Localised"":""Chemical Manipulators"", ""Count"":135 }, { ""Name"":""configurablecomponents"", ""Name_Localised"":""Configurable Components"", ""Count"":120 }, { ""Name"":""precipitatedalloys"", ""Name_Localised"":""Precipitated Alloys"", ""Count"":195 }, { ""Name"":""unknowntechnologycomponents"", ""Name_Localised"":""Thargoid Technological Components"", ""Count"":30 }, { ""Name"":""unknownorganiccircuitry"", ""Name_Localised"":""Thargoid Organic Circuitry"", ""Count"":12 }, { ""Name"":""unknownenergycell"", ""Name_Localised"":""Thargoid Energy Cell"", ""Count"":19 }, { ""Name"":""unknownenergysource"", ""Name_Localised"":""Sensor Fragment"", ""Count"":13 }, { ""Name"":""unknowncarapace"", ""Name_Localised"":""Thargoid Carapace"", ""Count"":36 }, { ""Name"":""chemicaldistillery"", ""Name_Localised"":""Chemical Distillery"", ""Count"":200 }, { ""Name"":""shieldingsensors"", ""Name_Localised"":""Shielding Sensors"", ""Count"":188 }, { ""Name"":""focuscrystals"", ""Name_Localised"":""Focus Crystals"", ""Count"":189 }, { ""Name"":""wornshieldemitters"", ""Name_Localised"":""Worn Shield Emitters"", ""Count"":222 }, { ""Name"":""electrochemicalarrays"", ""Name_Localised"":""Electrochemical Arrays"", ""Count"":190 }, { ""Name"":""militarysupercapacitors"", ""Name_Localised"":""Military Supercapacitors"", ""Count"":3 }, { ""Name"":""uncutfocuscrystals"", ""Name_Localised"":""Flawed Focus Crystals"", ""Count"":235 }, { ""Name"":""protoradiolicalloys"", ""Name_Localised"":""Proto Radiolic Alloys"", ""Count"":44 }, { ""Name"":""phasealloys"", ""Name_Localised"":""Phase Alloys"", ""Count"":200 }, { ""Name"":""pharmaceuticalisolators"", ""Name_Localised"":""Pharmaceutical Isolators"", ""Count"":59 }, { ""Name"":""imperialshielding"", ""Name_Localised"":""Imperial Shielding"", ""Count"":97 }, { ""Name"":""chemicalprocessors"", ""Name_Localised"":""Chemical Processors"", ""Count"":230 }, { ""Name"":""galvanisingalloys"", ""Name_Localised"":""Galvanising Alloys"", ""Count"":241 }, { ""Name"":""basicconductors"", ""Name_Localised"":""Basic Conductors"", ""Count"":286 }, { ""Name"":""heatresistantceramics"", ""Name_Localised"":""Heat Resistant Ceramics"", ""Count"":231 }, { ""Name"":""temperedalloys"", ""Name_Localised"":""Tempered Alloys"", ""Count"":270 }, { ""Name"":""crystalshards"", ""Name_Localised"":""Crystal Shards"", ""Count"":232 }, { ""Name"":""guardian_powerconduit"", ""Name_Localised"":""Guardian Power Conduit"", ""Count"":219 }, { ""Name"":""guardian_powercell"", ""Name_Localised"":""Guardian Power Cell"", ""Count"":231 }, { ""Name"":""guardian_techcomponent"", ""Name_Localised"":""Guardian Technology Component"", ""Count"":30 }, { ""Name"":""guardian_sentinel_wreckagecomponents"", ""Name_Localised"":""Guardian Wreckage Components"", ""Count"":78 }, { ""Name"":""guardian_sentinel_weaponparts"", ""Name_Localised"":""Guardian Sentinel Weapon Parts"", ""Count"":162 }, { ""Name"":""compactcomposites"", ""Name_Localised"":""Compact Composites"", ""Count"":209 }, { ""Name"":""chemicalstorageunits"", ""Name_Localised"":""Chemical Storage Units"", ""Count"":269 }, { ""Name"":""filamentcomposites"", ""Name_Localised"":""Filament Composites"", ""Count"":224 }, { ""Name"":""tg_propulsionelement"", ""Name_Localised"":""Propulsion Elements"", ""Count"":66 }, { ""Name"":""tg_biomechanicalconduits"", ""Name_Localised"":""Bio-Mechanical Conduits"", ""Count"":75 }, { ""Name"":""tg_wreckagecomponents"", ""Name_Localised"":""Wreckage Components"", ""Count"":61 }, { ""Name"":""tg_weaponparts"", ""Name_Localised"":""Weapon Parts"", ""Count"":111 } ], ""Encoded"":[ { ""Name"":""shieldsoakanalysis"", ""Name_Localised"":""Inconsistent Shield Soak Analysis"", ""Count"":241 }, { ""Name"":""scrambledemissiondata"", ""Name_Localised"":""Exceptional Scrambled Emission Data"", ""Count"":263 }, { ""Name"":""encodedscandata"", ""Name_Localised"":""Divergent Scan Data"", ""Count"":73 }, { ""Name"":""hyperspacetrajectories"", ""Name_Localised"":""Eccentric Hyperspace Trajectories"", ""Count"":133 }, { ""Name"":""encryptioncodes"", ""Name_Localised"":""Tagged Encryption Codes"", ""Count"":217 }, { ""Name"":""disruptedwakeechoes"", ""Name_Localised"":""Atypical Disrupted Wake Echoes"", ""Count"":267 }, { ""Name"":""wakesolutions"", ""Name_Localised"":""Strange Wake Solutions"", ""Count"":169 }, { ""Name"":""symmetrickeys"", ""Name_Localised"":""Open Symmetric Keys"", ""Count"":158 }, { ""Name"":""securityfirmware"", ""Name_Localised"":""Security Firmware Patch"", ""Count"":85 }, { ""Name"":""decodedemissiondata"", ""Name_Localised"":""Decoded Emission Data"", ""Count"":148 }, { ""Name"":""shieldpatternanalysis"", ""Name_Localised"":""Aberrant Shield Pattern Analysis"", ""Count"":150 }, { ""Name"":""unknownshipsignature"", ""Name_Localised"":""Thargoid Ship Signature"", ""Count"":45 }, { ""Name"":""unknownwakedata"", ""Name_Localised"":""Thargoid Wake Data"", ""Count"":9 }, { ""Name"":""ancienttechnologicaldata"", ""Name_Localised"":""Pattern Epsilon Obelisk Data"", ""Count"":75 }, { ""Name"":""ancientlanguagedata"", ""Name_Localised"":""Pattern Delta Obelisk Data"", ""Count"":150 }, { ""Name"":""ancienthistoricaldata"", ""Name_Localised"":""Pattern Gamma Obelisk Data"", ""Count"":150 }, { ""Name"":""ancientbiologicaldata"", ""Name_Localised"":""Pattern Alpha Obelisk Data"", ""Count"":150 }, { ""Name"":""ancientculturaldata"", ""Name_Localised"":""Pattern Beta Obelisk Data"", ""Count"":150 }, { ""Name"":""fsdtelemetry"", ""Name_Localised"":""Anomalous FSD Telemetry"", ""Count"":249 }, { ""Name"":""bulkscandata"", ""Name_Localised"":""Anomalous Bulk Scan Data"", ""Count"":282 }, { ""Name"":""emissiondata"", ""Name_Localised"":""Unexpected Emission Data"", ""Count"":142 }, { ""Name"":""shieldcyclerecordings"", ""Name_Localised"":""Distorted Shield Cycle Recordings"", ""Count"":300 }, { ""Name"":""embeddedfirmware"", ""Name_Localised"":""Modified Embedded Firmware"", ""Count"":39 }, { ""Name"":""legacyfirmware"", ""Name_Localised"":""Specialised Legacy Firmware"", ""Count"":247 }, { ""Name"":""encryptedfiles"", ""Name_Localised"":""Unusual Encrypted Files"", ""Count"":283 }, { ""Name"":""archivedemissiondata"", ""Name_Localised"":""Irregular Emission Data"", ""Count"":213 }, { ""Name"":""consumerfirmware"", ""Name_Localised"":""Modified Consumer Firmware"", ""Count"":212 }, { ""Name"":""shieldfrequencydata"", ""Name_Localised"":""Peculiar Shield Frequency Data"", ""Count"":36 }, { ""Name"":""tg_residuedata"", ""Name_Localised"":""Thargoid Residue Data"", ""Count"":24 }, { ""Name"":""tg_structuraldata"", ""Name_Localised"":""Thargoid Structural Data"", ""Count"":33 }, { ""Name"":""tg_compositiondata"", ""Name_Localised"":""Thargoid Material Composition Data"", ""Count"":30 }, { ""Name"":""classifiedscandata"", ""Name_Localised"":""Classified Scan Fragment"", ""Count"":38 }, { ""Name"":""compactemissionsdata"", ""Name_Localised"":""Abnormal Compact Emissions Data"", ""Count"":31 }, { ""Name"":""encryptionarchives"", ""Name_Localised"":""Atypical Encryption Archives"", ""Count"":121 }, { ""Name"":""shielddensityreports"", ""Name_Localised"":""Untypical Shield Scans "", ""Count"":182 }, { ""Name"":""industrialfirmware"", ""Name_Localised"":""Cracked Industrial Firmware"", ""Count"":25 }, { ""Name"":""dataminedwake"", ""Name_Localised"":""Datamined Wake Exceptions"", ""Count"":29 }, { ""Name"":""scandatabanks"", ""Name_Localised"":""Classified Scan Databanks"", ""Count"":181 }, { ""Name"":""scanarchives"", ""Name_Localised"":""Unidentified Scan Archives"", ""Count"":234 }, { ""Name"":""adaptiveencryptors"", ""Name_Localised"":""Adaptive Encryptors Capture"", ""Count"":40 }, { ""Name"":""guardian_vesselblueprint"", ""Name_Localised"":""Guardian Vessel Blueprint Fragment"", ""Count"":5 }, { ""Name"":""guardian_moduleblueprint"", ""Name_Localised"":""Guardian Module Blueprint Fragment"", ""Count"":6 } ] }";
            var    events                 = JournalMonitor.ParseJournalEntry(line);
            MaterialInventoryEvent @event = (MaterialInventoryEvent)events[0];

            int?InventoryAmount(string edname)
            {
                return(materialMonitor.inventory
                       .SingleOrDefault(m => string.Equals(m.edname, edname, StringComparison.InvariantCultureIgnoreCase))
                       ?.amount);
            }

            // Add antimony so that we can test whether obsolete data in our inventory but not listed in the event is corrected
            var antimony = materialMonitor.inventory.Single(m => string.Equals(m.edname, "antimony", StringComparison.InvariantCultureIgnoreCase));

            if (antimony is null)
            {
                antimony = new MaterialAmount("antimony", 5, 25, 50, 75);
                materialMonitor.inventory.Add(antimony);
            }
            else
            {
                antimony.amount = 5;
            }
            Assert.AreEqual(5, InventoryAmount("antimony"));

            // Handle our event
            materialMonitor.PreHandle(@event);

            // Test materials listed in the event
            Assert.AreEqual(231, InventoryAmount("phosphorus"));
            Assert.AreEqual(100, InventoryAmount("mercury"));
            Assert.AreEqual(244, InventoryAmount("germanium"));

            // Test materials not listed in the event
            Assert.AreEqual(0, InventoryAmount("antimony"));
            Assert.AreEqual(0, InventoryAmount("guardian_weaponblueprint"));

            // Test unknown materials
            Assert.IsNull(InventoryAmount("unobtainum"));
        }
Ejemplo n.º 5
0
        public void TestRingMappedCurrentBody()
        {
            string line = @"{ ""timestamp"":""2018-12-16T23:04:38Z"", ""event"":""SAAScanComplete"", ""BodyName"":""BD-01 2784 10 A Ring"", ""SystemAddress"":2282942960346, ""BodyID"":42, ""ProbesUsed"":1, ""EfficiencyTarget"":0 }";

            PrivateObject privateObject = new PrivateObject(EDDI.Instance);

            privateObject.Invoke("updateCurrentSystem", new object[] { "BD-01 2784" });

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

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

            Assert.IsNotNull(@event);

            privateObject.Invoke("eventRingMapped", new object[] { @event });
            Assert.AreEqual("BD-01 2784 10", EDDI.Instance.CurrentStellarBody?.bodyname);
        }
Ejemplo n.º 6
0
        public void TestNearSurfaceEvent()
        {
            string           line   = @"{ ""timestamp"":""2018-07-24T07:08:37Z"", ""event"":""ApproachBody"", ""StarSystem"":""Ageno"", ""SystemAddress"":18262335038849, ""Body"":""Ageno B 2 a"", ""BodyID"":17 }";
            List <Event>     events = JournalMonitor.ParseJournalEntry(line);
            NearSurfaceEvent @event = (NearSurfaceEvent)events[0];

            Assert.AreEqual("Ageno", @event.system);
            Assert.AreEqual(18262335038849, @event.systemAddress);
            Assert.AreEqual("Ageno B 2 a", @event.body);

            string line2 = @"{ ""timestamp"":""2018 - 07 - 24T07: 08:58Z"", ""event"":""LeaveBody"", ""StarSystem"":""Ageno"", ""SystemAddress"":18262335038849, ""Body"":""Ageno B 2 a"", ""BodyID"":17 }";

            events = JournalMonitor.ParseJournalEntry(line2);
            NearSurfaceEvent @event2 = (NearSurfaceEvent)events[0];

            Assert.AreEqual("Ageno", @event2.system);
            Assert.AreEqual(18262335038849, @event2.systemAddress);
            Assert.AreEqual("Ageno B 2 a", @event2.body);
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
0
        public void TestJumped()
        {
            var joystickResponder = new EddiJoystickResponder.JoystickResponder();

            joystickResponder.Start();

            using (var file = new System.IO.StreamReader("Journal.171230210516.01.log"))
            {
                var journalEntry = "";
                while ((journalEntry = file.ReadLine()) != null)
                {
                    var events = JournalMonitor.ParseJournalEntry(journalEntry);

                    foreach (var journalEvent in events)
                    {
                        joystickResponder.Handle(journalEvent);
                    }
                }
            }
        }
Ejemplo n.º 9
0
        private void testButtonClick(object sender, RoutedEventArgs e)
        {
            // Splice the new script in to the existing scripts
            Dictionary <string, Script> newScripts = new Dictionary <string, Script>(scripts);
            Script testScript = new Script(ScriptName, ScriptDescription, false, ScriptValue);

            newScripts.Remove(ScriptName);
            newScripts.Add(ScriptName, testScript);

            SpeechResponder responder = new SpeechResponder();

            responder.Start();

            // See if we have a sample
            Event  sampleEvent;
            object sample = Events.SampleByName(script.Name);

            if (sample == null)
            {
                sampleEvent = null;
            }
            else if (sample.GetType() == typeof(string))
            {
                // It's as tring so a journal entry.  Parse it
                sampleEvent = JournalMonitor.ParseJournalEntry((string)sample);
            }
            else if (sample.GetType() == typeof(Event))
            {
                // It's a direct event
                sampleEvent = (Event)sample;
            }
            else
            {
                Logging.Warn("Unknown sample type " + sample.GetType());
                sampleEvent = null;
            }

            ScriptResolver scriptResolver = new ScriptResolver(newScripts);

            responder.Say(scriptResolver, ScriptName, sampleEvent, 3, false);
        }
        public async Task ShouldPickUpEvents()
        {
            var directoryProvider = new TestDirectoryProvider();

            Directory.Delete(directoryProvider.Directory, true);
            var events = new ConcurrentBag <LogEvent>();

            CollectionAssert.IsEmpty(events);

            string testFile1 = Path.Combine(directoryProvider.Directory, "Journal.1234.log");
            string testFile2 = Path.Combine(directoryProvider.Directory, "Journal.2345.log");

            File.WriteAllText(testFile1, EventsAsJson.Skip(5).First());
            var journalMonitor = new JournalMonitor(directoryProvider, 5);

            journalMonitor.Subscribe(events.Add);

            File.AppendAllText(testFile1, EventsAsJson.Skip(8).First());
            await Delay;

            CollectionAssert.IsNotEmpty(events);

            while (events.Count > 0)
            {
                events.TryTake(out var e);
            }

            File.WriteAllText(testFile2, EventsAsJson.Skip(9).First());
            await Delay;

            CollectionAssert.IsNotEmpty(events);

            while (events.Count > 0)
            {
                events.TryTake(out var e);
            }

            await Delay;

            CollectionAssert.IsEmpty(events);
        }
Ejemplo n.º 11
0
        public void TestBodyMappedEventHandler()
        {
            string       line   = @"{ ""timestamp"":""2016 - 11 - 01T18: 49:07Z"", ""event"":""Scan"", ""ScanType"":""Detailed"", ""BodyName"":""Grea Bloae HH-T d4-44 4"", ""BodyID"":3, ""DistanceFromArrivalLS"":703.763611, ""TidalLock"":false, ""TerraformState"":""Terraformable"", ""PlanetClass"":""High metal content body"", ""Atmosphere"":""hot thick carbon dioxide atmosphere"", ""Volcanism"":""minor metallic magma volcanism"", ""MassEM"":2.171783, ""Radius"":7622170.500000, ""SurfaceGravity"":14.899396, ""SurfaceTemperature"":836.165466, ""SurfacePressure"":33000114.000000, ""Landable"":false, ""SemiMajorAxis"":210957926400.000000, ""Eccentricity"":0.000248, ""OrbitalInclination"":0.015659, ""Periapsis"":104.416656, ""OrbitalPeriod"":48801056.000000, ""RotationPeriod"":79442.242188 }";
            List <Event> events = JournalMonitor.ParseJournalEntry(line);

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

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

            PrivateObject privateObject = new PrivateObject(EDDI.Instance);

            privateObject.Invoke("updateCurrentSystem", new object[] { "Grea Bloae HH-T d4-44" });
            Assert.AreEqual("Grea Bloae HH-T d4-44", EDDI.Instance.CurrentStarSystem?.systemname);

            // Set up conditions to test the first scan of the body
            var body = EDDI.Instance.CurrentStarSystem?.bodies.Find(b => b.bodyname == "Grea Bloae HH-T d4-44 4");

            if (body != null)
            {
                body.scanned = null;
            }
            var result = (bool)privateObject.Invoke("eventBodyScanned", new object[] { @event });

            Assert.AreEqual(@event.timestamp, EDDI.Instance.CurrentStarSystem?.bodies.Find(b => b.bodyname == "Grea Bloae HH-T d4-44 4").scanned);
            long event1EstimatedValue = EDDI.Instance.CurrentStarSystem.bodies.Find(b => b.bodyname == "Grea Bloae HH-T d4-44 4").estimatedvalue;

            // Map the body
            string line2 = @"{ ""timestamp"":""2016 - 11 - 01T18: 59:07Z"", ""event"":""SAAScanComplete"", ""BodyName"":""Grea Bloae HH-T d4-44 4"", ""BodyID"":3, ""ProbesUsed"":5, ""EfficiencyTarget"":6 }";

            events = JournalMonitor.ParseJournalEntry(line2);
            Assert.AreEqual(1, events.Count);
            BodyMappedEvent @event2 = (BodyMappedEvent)events[0];

            result = (bool)privateObject.Invoke("eventBodyMapped", new object[] { @event2 });

            Assert.AreEqual(@event.timestamp, EDDI.Instance.CurrentStarSystem.bodies.Find(b => b.bodyname == "Grea Bloae HH-T d4-44 4").scanned);
            Assert.AreEqual(@event2.timestamp, EDDI.Instance.CurrentStarSystem.bodies.Find(b => b.bodyname == "Grea Bloae HH-T d4-44 4").mapped);
            Assert.IsTrue(EDDI.Instance.CurrentStarSystem.bodies.Find(b => b.bodyname == "Grea Bloae HH-T d4-44 4").estimatedvalue > event1EstimatedValue);
        }
Ejemplo n.º 12
0
        public void TestLoadoutParsing()
        {
            string data = System.IO.File.ReadAllText("loadout.json");

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

            Assert.AreEqual(1, events.Count);
            ShipLoadoutEvent loadoutEvent = events[0] as ShipLoadoutEvent;

            Assert.AreEqual("Peppermint", loadoutEvent.shipname);
            Assert.AreEqual(18, loadoutEvent.compartments.Count);
            Assert.AreEqual(7, loadoutEvent.hardpoints.Count);

            ShipMonitor shipMonitor   = new ShipMonitor();
            var         privateObject = new PrivateObject(shipMonitor);

            object[] args = new object[] { loadoutEvent };
            Ship     ship = privateObject.Invoke("ParseShipLoadoutEvent", args) as Ship;

            Assert.AreEqual("Peppermint", ship.name);
        }
Ejemplo n.º 13
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);
        }
Ejemplo n.º 14
0
        public void TestScript(string scriptName, Dictionary <string, Script> scripts)
        {
            // See if we have a sample
            List <Event> sampleEvents;
            object       sample = Events.SampleByName(scriptName);

            if (sample == null)
            {
                sampleEvents = new List <Event>();
            }
            else if (sample is string)
            {
                // It's a string so a journal entry.  Parse it
                sampleEvents = JournalMonitor.ParseJournalEntry((string)sample);
            }
            else if (sample is Event)
            {
                // It's a direct event
                sampleEvents = new List <Event>()
                {
                    (Event)sample
                };
            }
            else
            {
                Logging.Warn("Unknown sample type " + sample.GetType());
                sampleEvents = new List <Event>();
            }

            ScriptResolver testScriptResolver = new ScriptResolver(scripts);

            if (sampleEvents.Count == 0)
            {
                sampleEvents.Add(null);
            }
            foreach (Event sampleEvent in sampleEvents)
            {
                Say(testScriptResolver, ((ShipMonitor)EDDI.Instance.ObtainMonitor("Ship monitor"))?.GetCurrentShip(), scriptName, sampleEvent, testScriptResolver.priority(scriptName));
            }
        }
Ejemplo n.º 15
0
        public async Task ShouldPickUpEvents()
        {
            var directoryProvider = new TestDirectoryProvider();
            var events            = new ConcurrentBag <JournalEvent>();

            CollectionAssert.IsEmpty(events);

            string testFile1 = Path.Combine(directoryProvider.Directory, "Journal.1234.log");
            string testFile2 = Path.Combine(directoryProvider.Directory, "Journal.2345.log");

            File.WriteAllText(testFile1, EventsAsJson.ElementAt(0));
            var journalMonitor = new JournalMonitor(directoryProvider, 5);

            journalMonitor.Subscribe(events.Add);

            File.AppendAllText(testFile1, EventsAsJson.ElementAt(1));
            await Delay;

            CollectionAssert.IsNotEmpty(events);

            while (!events.IsEmpty)
            {
                events.TryTake(out var e);
            }

            File.WriteAllText(testFile2, EventsAsJson.ElementAt(2));
            await Delay;

            CollectionAssert.IsNotEmpty(events);

            while (!events.IsEmpty)
            {
                events.TryTake(out var e);
            }

            await Delay;

            CollectionAssert.IsEmpty(events);
        }
Ejemplo n.º 16
0
        public void TestVADiscoveryScanEvent()
        {
            string       line   = @"{ ""timestamp"":""2019-10-26T02:15:49Z"", ""event"":""FSSDiscoveryScan"", ""Progress"":0.439435, ""BodyCount"":7, ""NonBodyCount"":3, ""SystemName"":""Outotz WO-A d1"", ""SystemAddress"":44870715523 }";
            List <Event> events = JournalMonitor.ParseJournalEntry(line);

            Assert.IsTrue(events.Count == 1);
            Assert.IsInstanceOfType(events[0], typeof(DiscoveryScanEvent));
            DiscoveryScanEvent ev = events[0] as DiscoveryScanEvent;

            Assert.AreEqual(7, ev.totalbodies);
            Assert.AreEqual(3, ev.nonbodies);
            Assert.AreEqual(44, ev.progress);

            List <string> setKeys = new List <string>();

            EddiVoiceAttackResponder.VoiceAttackVariables.setEventValues(vaProxy, ev, setKeys);
            EddiVoiceAttackResponder.VoiceAttackVariables.setEventExtendedValues(vaProxy, "EDDI " + ev.type.ToLowerInvariant(), JsonConvert.DeserializeObject(JsonConvert.SerializeObject(ev)), setKeys);

            Assert.AreEqual(7, vaProxy.vaVars.FirstOrDefault(k => k.Key == "EDDI discovery scan totalbodies").Value);
            Assert.AreEqual(3, vaProxy.vaVars.FirstOrDefault(k => k.Key == "EDDI discovery scan nonbodies").Value);
            Assert.AreEqual(44M, vaProxy.vaVars.FirstOrDefault(k => k.Key == "EDDI discovery scan progress").Value);
        }
Ejemplo n.º 17
0
        public void TestVAExplorationDataSoldEvent()
        {
            string       line   = @"{ ""timestamp"":""2016-09-23T18:57:55Z"", ""event"":""SellExplorationData"", ""Systems"":[ ""Gamma Tucanae"", ""Rho Capricorni"", ""Dain"", ""Col 285 Sector BR-S b18-0"", ""LP 571-80"", ""Kawilocidi"", ""Irulachan"", ""Alrai Sector MC-M a7-0"", ""Col 285 Sector FX-Q b19-5"", ""Col 285 Sector EX-Q b19-7"", ""Alrai Sector FB-O a6-3"" ], ""Discovered"":[ ""Irulachan"" ], ""BaseValue"":63573, ""Bonus"":1445, ""TotalEarnings"":65018 }";
            List <Event> events = JournalMonitor.ParseJournalEntry(line);

            Assert.IsTrue(events.Count == 1);
            Assert.IsInstanceOfType(events[0], typeof(ExplorationDataSoldEvent));
            var ev = events[0] as ExplorationDataSoldEvent;

            var vars = new MetaVariables(ev.GetType(), ev).Results;

            var vaVars = vars.AsVoiceAttackVariables("EDDI", ev.type);

            foreach (var @var in vaVars)
            {
                @var.Set(vaProxy);
            }
            Assert.AreEqual(15, vaVars.Count);
            Assert.AreEqual("Gamma Tucanae", vaProxy.vaVars.FirstOrDefault(k => k.Key == "EDDI exploration data sold systems 1").Value);
            Assert.AreEqual("Rho Capricorni", vaProxy.vaVars.FirstOrDefault(k => k.Key == "EDDI exploration data sold systems 2").Value);
            Assert.AreEqual("Dain", vaProxy.vaVars.FirstOrDefault(k => k.Key == "EDDI exploration data sold systems 3").Value);
            Assert.AreEqual("Col 285 Sector BR-S b18-0", vaProxy.vaVars.FirstOrDefault(k => k.Key == "EDDI exploration data sold systems 4").Value);
            Assert.AreEqual("LP 571-80", vaProxy.vaVars.FirstOrDefault(k => k.Key == "EDDI exploration data sold systems 5").Value);
            Assert.AreEqual("Kawilocidi", vaProxy.vaVars.FirstOrDefault(k => k.Key == "EDDI exploration data sold systems 6").Value);
            Assert.AreEqual("Irulachan", vaProxy.vaVars.FirstOrDefault(k => k.Key == "EDDI exploration data sold systems 7").Value);
            Assert.AreEqual("Alrai Sector MC-M a7-0", vaProxy.vaVars.FirstOrDefault(k => k.Key == "EDDI exploration data sold systems 8").Value);
            Assert.AreEqual("Col 285 Sector FX-Q b19-5", vaProxy.vaVars.FirstOrDefault(k => k.Key == "EDDI exploration data sold systems 9").Value);
            Assert.AreEqual("Col 285 Sector EX-Q b19-7", vaProxy.vaVars.FirstOrDefault(k => k.Key == "EDDI exploration data sold systems 10").Value);
            Assert.AreEqual("Alrai Sector FB-O a6-3", vaProxy.vaVars.FirstOrDefault(k => k.Key == "EDDI exploration data sold systems 11").Value);
            Assert.AreEqual(11, vaProxy.vaVars.FirstOrDefault(k => k.Key == "EDDI exploration data sold systems").Value);
            Assert.AreEqual(63573M, vaProxy.vaVars.FirstOrDefault(k => k.Key == "EDDI exploration data sold reward").Value);
            Assert.AreEqual(1445M, vaProxy.vaVars.FirstOrDefault(k => k.Key == "EDDI exploration data sold bonus").Value);
            Assert.AreEqual(65018M, vaProxy.vaVars.FirstOrDefault(k => k.Key == "EDDI exploration data sold total").Value);
            foreach (VoiceAttackVariable variable in vaVars)
            {
                Assert.IsTrue(vaProxy.vaVars.ContainsKey(variable.key), "Unmatched key");
            }
        }
Ejemplo n.º 18
0
        public void TestMultiSystemScanCompleted()
        {
            // If the game writes the `FSSAllBodiesFound` event multiple times for a single star system,
            // we will take the first and reject any repetitions within the same star system.

            string             line   = @"{ ""timestamp"":""2019 - 07 - 01T19: 30:17Z"", ""event"":""FSSAllBodiesFound"", ""SystemName"":""Pyria Thua IX-L d7-3"", ""SystemAddress"":113321713859, ""Count"":4 }";
            List <Event>       events = JournalMonitor.ParseJournalEntry(line);
            SystemScanComplete @event = (SystemScanComplete)events[0];

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

            PrivateObject privateObject = new PrivateObject(EDDI.Instance);

            privateObject.SetFieldOrProperty("CurrentStarSystem", new StarSystem()
            {
                systemname = "TestSystem"
            });
            Assert.IsFalse(EDDI.Instance.CurrentStarSystem.systemScanCompleted);

            // Test whether the first `SystemScanCompleted` event is accepted and passed to monitors / responders
            var eventPassed = (bool)privateObject.Invoke("eventSystemScanComplete", new object[] { @event });

            Assert.IsTrue(EDDI.Instance.CurrentStarSystem.systemScanCompleted);
            Assert.IsTrue(eventPassed);

            // Test a second `SystemScanCompleted` event to make sure the repetition is surpressed and not passed to monitors / responders
            eventPassed = (bool)privateObject.Invoke("eventSystemScanComplete", new object[] { @event });
            Assert.IsTrue(EDDI.Instance.CurrentStarSystem.systemScanCompleted);
            Assert.IsFalse(eventPassed);

            // Switch systems and verify that the `systemScanCompleted` bool returns to it's default state
            privateObject.SetFieldOrProperty("CurrentStarSystem", new StarSystem()
            {
                systemname = "TestSystem2"
            });
            Assert.IsFalse(EDDI.Instance.CurrentStarSystem.systemScanCompleted);
        }
Ejemplo n.º 19
0
        public void TestCargoSearchAndRescue()
        {
            cargoMonitor.initializeCargoMonitor(new CargoMonitorConfiguration());

            line   = @"{""timestamp"": ""2018-05-05T19:12:10Z"", ""event"": ""Cargo"", ""Inventory"": [ { ""Name"": ""damagedescapepod"", ""Name_Localised"": ""Damaged Escape Pod"", ""Count"": 4, ""Stolen"": 0 }, { ""Name"": ""usscargoblackbox"", ""Name_Localised"": ""Black Box"", ""Count"": 4, ""Stolen"": 4 }, { ""Name"": ""drones"", ""Name_Localised"": ""Limpet"", ""Count"": 21, ""Stolen"": 0 } ] }";
            events = JournalMonitor.ParseJournalEntry(line);
            cargoMonitor._handleCargoInventoryEvent((CargoInventoryEvent)events[0]);

            cargo = cargoMonitor.inventory.ToList().FirstOrDefault(c => c.edname == "DamagedEscapePod");
            Assert.AreEqual(4, cargo.total);
            Assert.AreEqual(4, cargo.owned);
            Assert.AreEqual(0, cargo.need + cargo.stolen + cargo.haulage);

            // CargoSearchAndRescueEvent
            line   = @"{ ""timestamp"":""2017-08-26T01:58:24Z"", ""event"":""SearchAndRescue"", ""Name"":""damagedescapepod"", ""Count"":2, ""Reward"":5310 }";
            events = JournalMonitor.ParseJournalEntry(line);
            cargoMonitor._handleSearchAndRescueEvent((SearchAndRescueEvent)events[0]);

            cargo = cargoMonitor.inventory.ToList().FirstOrDefault(c => c.edname == "DamagedEscapePod");
            Assert.AreEqual(2, cargo.total);
            Assert.AreEqual(2, cargo.owned);
            Assert.AreEqual(0, cargo.need + cargo.stolen + cargo.haulage);
        }
Ejemplo n.º 20
0
        public void TestCargoTechnologyBroker()
        {
            cargoMonitor.initializeCargoMonitor(new CargoMonitorConfiguration());

            line   = @"{""timestamp"": ""2018-05-05T19:12:10Z"", ""event"": ""Cargo"", ""Inventory"": [ { ""Name"": ""iondistributor"", ""Name_Localised"": ""Ion Distributor"", ""Count"": 10, ""Stolen"": 0 }, { ""Name"": ""usscargoblackbox"", ""Name_Localised"": ""Black Box"", ""Count"": 4, ""Stolen"": 4 }, { ""Name"": ""drones"", ""Name_Localised"": ""Limpet"", ""Count"": 21, ""Stolen"": 0 } ] }";
            events = JournalMonitor.ParseJournalEntry(line);
            cargoMonitor._handleCargoInventoryEvent((CargoInventoryEvent)events[0]);

            cargo = cargoMonitor.inventory.ToList().FirstOrDefault(c => c.edname == "IonDistributor");
            Assert.AreEqual(10, cargo.total);
            Assert.AreEqual(10, cargo.owned);
            Assert.AreEqual(0, cargo.need + cargo.stolen + cargo.haulage);

            // CargoTechnologyBrokerEvent
            line   = @"{ ""timestamp"":""2018-03-02T11:28:44Z"", ""event"":""TechnologyBroker"", ""BrokerType"":""Human"", ""MarketID"":128151032, ""ItemsUnlocked"":[{ ""Name"":""Hpt_PlasmaShockCannon_Fixed_Medium"", ""Name_Localised"":""Shock Cannon"" }], ""Commodities"":[{ ""Name"":""iondistributor"", ""Name_Localised"":""Ion Distributor"", ""Count"":6 }], ""Materials"":[ { ""Name"":""vanadium"", ""Count"":30, ""Category"":""Raw"" }, { ""Name"":""tungsten"", ""Count"":30, ""Category"":""Raw"" }, { ""Name"":""rhenium"", ""Count"":36, ""Category"":""Raw"" }, { ""Name"":""technetium"", ""Count"":30, ""Category"":""Raw""}]}";
            events = JournalMonitor.ParseJournalEntry(line);
            cargoMonitor._handleTechnologyBrokerEvent((TechnologyBrokerEvent)events[0]);

            cargo = cargoMonitor.inventory.ToList().FirstOrDefault(c => c.edname == "IonDistributor");
            Assert.AreEqual(4, cargo.total);
            Assert.AreEqual(4, cargo.owned);
            Assert.AreEqual(0, cargo.need + cargo.stolen + cargo.haulage);
        }
Ejemplo n.º 21
0
        public void TestCrimeShipTargeted()
        {
            var privateObject = new PrivateObject(crimeMonitor);

            crimeMonitor.targetSystem = EDDI.Instance?.CurrentStarSystem?.systemname;
            line   = "{ \"timestamp\":\"2019-04-24T00:13:35Z\", \"event\":\"ShipTargeted\", \"TargetLocked\":true, \"Ship\":\"federation_corvette\", \"Ship_Localised\":\"Federal Corvette\", \"ScanStage\":3, \"PilotName\":\"$npc_name_decorate:#name=Kurt Pettersen;\", \"PilotName_Localised\":\"Kurt Pettersen\", \"PilotRank\":\"Deadly\", \"ShieldHealth\":100.000000, \"HullHealth\":100.000000, \"Faction\":\"Calennero Crew\", \"LegalStatus\":\"Wanted\", \"Bounty\":295785 }";
            events = JournalMonitor.ParseJournalEntry(line);
            Assert.IsTrue(events.Count == 1);
            privateObject.Invoke("handleShipTargetedEvent", new object[] { events[0] });
            Assert.IsNotNull(crimeMonitor.shipTargets);
            Assert.AreEqual(1, crimeMonitor.shipTargets.Count);
            Target target = crimeMonitor.shipTargets.FirstOrDefault(t => t.name == "Kurt Pettersen");

            Assert.AreEqual(CombatRating.FromEDName("Deadly"), target.CombatRank);
            Assert.AreEqual("Calennero Crew", target.faction);
            Assert.AreEqual(Superpower.Independent, target.Allegiance);
            Assert.AreEqual(295785, target.bounty);

            line   = "{ \"timestamp\":\"2019-04-24T00:44:32Z\", \"event\":\"FSDJump\", \"StarSystem\":\"HIP 20277\", \"SystemAddress\":84053791442, \"StarPos\":[106.43750,-95.68750,-0.18750], \"SystemAllegiance\":\"Empire\", \"SystemEconomy\":\"$economy_Industrial;\", \"SystemEconomy_Localised\":\"Industrial\", \"SystemSecondEconomy\":\"$economy_Extraction;\", \"SystemSecondEconomy_Localised\":\"Extraction\", \"SystemGovernment\":\"$government_Corporate;\", \"SystemGovernment_Localised\":\"Corporate\", \"SystemSecurity\":\"$SYSTEM_SECURITY_high;\", \"SystemSecurity_Localised\":\"High Security\", \"Population\":11247202, \"Body\":\"HIP 20277\", \"BodyID\":0, \"BodyType\":\"Star\", \"JumpDist\":7.473, \"FuelUsed\":1.140420, \"FuelLevel\":61.122398, \"SystemFaction\":{ \"Name\":\"Calennero State Industries\", \"FactionState\":\"Boom\" } }";
            events = JournalMonitor.ParseJournalEntry(line);
            Assert.IsTrue(events.Count == 1);
            privateObject.Invoke("_handleJumpedEvent", new object[] { events[0] });
            Assert.AreEqual(0, crimeMonitor.shipTargets.Count);
        }
Ejemplo n.º 22
0
        public void TestFriends()
        {
            string line  = "{ \"timestamp\":\"2017-08-24T17:22:03Z\", \"event\":\"Friends\", \"Status\":\"Online\", \"Name\":\"_Testy_McTest_\" }";
            string line2 = "{ \"timestamp\":\"2017-08-24T17:22:03Z\", \"event\":\"Friends\", \"Status\":\"Offline\", \"Name\":\"_Testy_McTest_\" }";

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

            events = JournalMonitor.ParseJournalEntry(line2);

            /// Since this friend is unknown to us, the first time we see this friend no event should trigger.
            /// Only the second line, registering the status as offline, should be registered as an event.
            Assert.IsTrue(events.Count == 1);

            FriendsEvent @event     = (FriendsEvent)events[0];
            Friend       testFriend = new Friend();

            testFriend.name   = @event.name;
            testFriend.status = @event.status;

            Assert.AreEqual("Offline", @event.status);

            // Clean up
            Eddi.EDDI.Instance.Cmdr.friends.Remove(testFriend);
        }
Ejemplo n.º 23
0
        public void TestMissionEventsScenario()
        {
            // Save original data
            MissionMonitorConfiguration missionData = MissionMonitorConfiguration.FromFile();

            missionMonitor.initializeMissionMonitor(new MissionMonitorConfiguration());

            //MissionsEvent
            line   = @"{""timestamp"":""2018-08-25T23:27:21Z"", ""event"":""Missions"", ""Active"":[ { ""MissionID"":413563499, ""Name"":""Mission_Courier_Elections_name"", ""PassengerMission"":false, ""Expires"":48916 }, { ""MissionID"":413563678, ""Name"":""Mission_Delivery_name"", ""PassengerMission"":false, ""Expires"":48917 }, { ""MissionID"":413563829, ""Name"":""Mission_Salvage_Planet_name"", ""PassengerMission"":false, ""Expires"":264552 } ], ""Failed"":[  ], ""Complete"":[  ] }";
            events = JournalMonitor.ParseJournalEntry(line);
            Assert.IsTrue(events.Count == 1);
            missionMonitor._handleMissionsEvent((MissionsEvent)events[0]);
            Assert.AreEqual(3, missionMonitor.missions.Count);
            Assert.AreEqual(3, missionMonitor.missions.Where(m => m.statusEDName == "Active").Count());

            //CargoDepotEvent - 'Shared'
            line   = @"{ ""timestamp"":""2018-08-26T02:55:10Z"", ""event"":""CargoDepot"", ""MissionID"":413748365, ""UpdateType"":""WingUpdate"", ""CargoType"":""Gold"", ""Count"":20, ""StartMarketID"":0, ""EndMarketID"":3224777216, ""ItemsCollected"":0, ""ItemsDelivered"":20, ""TotalItemsToDeliver"":54, ""Progress"":0.000000 }";
            events = JournalMonitor.ParseJournalEntry(line);
            Assert.IsTrue(events.Count == 1);
            missionMonitor._handleCargoDepotEvent((CargoDepotEvent)events[0]);
            mission = missionMonitor.missions.ToList().FirstOrDefault(m => m.missionid == 413748365);
            Assert.AreEqual(4, missionMonitor.missions.Count);
            Assert.AreEqual("CollectWing", mission.typeEDName);
            Assert.AreEqual("Active", mission.statusEDName);
            Assert.IsTrue(mission.originreturn);
            Assert.IsTrue(mission.wing);
            Assert.IsTrue(mission.shared);
            line   = @"{ ""timestamp"":""2018-08-26T02:56:16Z"", ""event"":""CargoDepot"", ""MissionID"":413748365, ""UpdateType"":""Deliver"", ""CargoType"":""Gold"", ""Count"":34, ""StartMarketID"":0, ""EndMarketID"":3224777216, ""ItemsCollected"":0, ""ItemsDelivered"":54, ""TotalItemsToDeliver"":54, ""Progress"":0.000000 }";
            events = JournalMonitor.ParseJournalEntry(line);
            missionMonitor._handleCargoDepotEvent((CargoDepotEvent)events[0]);
            Assert.AreEqual(3, missionMonitor.missions.Count);

            //MissionAbandonedEvent
            line   = @"{ ""timestamp"":""2018-08-26T00:50:48Z"", ""event"":""MissionAbandoned"", ""Name"":""Mission_Courier_Elections_name"", ""Fine"":50000, ""MissionID"":413563499 }";
            events = JournalMonitor.ParseJournalEntry(line);
            Assert.IsTrue(events.Count == 1);
            missionMonitor.handleMissionAbandonedEvent((MissionAbandonedEvent)events[0]);
            Assert.AreEqual("Failed", missionMonitor.missions.SingleOrDefault(m => m.missionid == 413563499)?.statusEDName);
            missionMonitor._postHandleMissionAbandonedEvent((MissionAbandonedEvent)events[0]);
            Assert.AreEqual(2, missionMonitor.missions.Count);

            //MissionAcceptedEvent - 'AltruismCredits'
            line   = "{ \"timestamp\":\"2018-09-17T02:54:16Z\", \"event\":\"MissionAccepted\", \"Faction\":\"Merope Expeditionary Fleet\", \"Name\":\"Mission_AltruismCredits\", \"LocalisedName\":\"Donate 450,000 Cr to the cause\", \"Donation\":\"450000\", \"Expiry\":\"2018-09-17T05:01:28Z\", \"Wing\":false, \"Influence\":\"Med\", \"Reputation\":\"Med\", \"MissionID\":419646649 }";
            events = JournalMonitor.ParseJournalEntry(line);
            Assert.IsTrue(events.Count == 1);
            missionMonitor._handleMissionAcceptedEvent((MissionAcceptedEvent)events[0]);
            mission = missionMonitor.missions.ToList().FirstOrDefault(m => m.missionid == 419646649);
            Assert.AreEqual(3, missionMonitor.missions.Count);
            Assert.IsTrue(mission.originreturn);

            //MissionAcceptedEvent - 'Collect'
            line   = @"{ ""timestamp"":""2018-08-26T00:50:48Z"", ""event"":""MissionAccepted"", ""Faction"":""Calennero State Industries"", ""Name"":""Mission_Collect_Industrial"", ""LocalisedName"":""Industry needs 54 units of Tantalum"", ""Commodity"":""$Tantalum_Name;"", ""Commodity_Localised"":""Tantalum"", ""Count"":54, ""DestinationSystem"":""HIP 20277"", ""DestinationStation"":""Fabian City"", ""Expiry"":""2018-08-27T00:48:38Z"", ""Wing"":false, ""Influence"":""Med"", ""Reputation"":""Med"", ""Reward"":1909532, ""MissionID"":413748324 }";
            events = JournalMonitor.ParseJournalEntry(line);
            Assert.IsTrue(events.Count == 1);
            missionMonitor._handleMissionAcceptedEvent((MissionAcceptedEvent)events[0]);
            mission = missionMonitor.missions.ToList().FirstOrDefault(m => m.missionid == 413748324);
            Assert.AreEqual(4, missionMonitor.missions.Count);
            Assert.AreEqual("Collect", mission.typeEDName);
            Assert.AreEqual("Active", mission.statusEDName);
            Assert.IsTrue(mission.originreturn);
            Assert.IsTrue(mission.legal);
            Assert.IsFalse(mission.wing);

            // Verify duplication protection
            events = JournalMonitor.ParseJournalEntry(line);
            Assert.IsTrue(events.Count == 1);
            missionMonitor._handleMissionAcceptedEvent((MissionAcceptedEvent)events[0]);
            Assert.AreEqual(1, missionMonitor.missions.ToList().Where(m => m.missionid == 413748324).Count());
            Assert.AreEqual(4, missionMonitor.missions.Count);

            //CargoDepotEvent - 'Collect'
            line   = @"{ ""timestamp"":""2018-08-26T02:55:10Z"", ""event"":""CargoDepot"", ""MissionID"":413748324, ""UpdateType"":""Deliver"", ""CargoType"":""Tantalum"", ""Count"":54, ""StartMarketID"":0, ""EndMarketID"":3224777216, ""ItemsCollected"":0, ""ItemsDelivered"":54, ""TotalItemsToDeliver"":54, ""Progress"":0.000000 }";
            events = JournalMonitor.ParseJournalEntry(line);
            Assert.IsTrue(events.Count == 1);
            missionMonitor._handleCargoDepotEvent((CargoDepotEvent)events[0]);
            mission = missionMonitor.missions.ToList().FirstOrDefault(m => m.missionid == 413748324);
            Assert.AreEqual("Complete", mission.statusEDName);

            //MissionAcceptedEvent - 'Permit'
            line   = "{ \"timestamp\":\"2018-09-19T01:12:57Z\", \"event\":\"MissionAccepted\", \"Faction\":\"Sublime Order of van Maanen's Star\", \"Name\":\"MISSION_genericPermit1\", \"LocalisedName\":\"Permit Acquisition Opportunity\", \"Wing\":false, \"Influence\":\"None\", \"Reputation\":\"None\", \"MissionID\":420098082 }";
            events = JournalMonitor.ParseJournalEntry(line);
            Assert.IsTrue(events.Count == 1);
            missionMonitor._handleMissionAcceptedEvent((MissionAcceptedEvent)events[0]);
            mission = missionMonitor.missions.ToList().FirstOrDefault(m => m.missionid == 420098082);
            Assert.AreEqual(5, missionMonitor.missions.Count);

            //MissionAcceptedEvent - 'Smuggle'
            line   = @"{ ""timestamp"":""2018-08-29T20:51:56Z"", ""event"":""MissionAccepted"", ""Faction"":""Gcirithang Crimson Mafia"", ""Name"":""Mission_Smuggle_Famine"", ""LocalisedName"":""Smuggle 36 units of Narcotics to combat famine"", ""Commodity"":""$BasicNarcotics_Name;"", ""Commodity_Localised"":""Narcotics"", ""Count"":36, ""DestinationSystem"":""Carcinus"", ""DestinationStation"":""Wye-Delta Station"", ""Expiry"":""2018-08-30T20:55:33Z"", ""Wing"":false, ""Influence"":""Med"", ""Reputation"":""Med"", ""Reward"":180818, ""MissionID"":414732731 }";
            events = JournalMonitor.ParseJournalEntry(line);
            Assert.IsTrue(events.Count == 1);
            missionMonitor._handleMissionAcceptedEvent((MissionAcceptedEvent)events[0]);
            mission = missionMonitor.missions.ToList().FirstOrDefault(m => m.missionid == 414732731);
            Assert.AreEqual(6, missionMonitor.missions.Count);
            Assert.AreEqual("Smuggle", mission.typeEDName);
            Assert.IsFalse(mission.originreturn);
            Assert.IsFalse(mission.legal);

            //MissionCompletedEvent
            line   = @"{ ""timestamp"":""2018-08-26T00:40:14Z"", ""event"":""MissionCompleted"", ""Faction"":""HIP 20277 Inc"", ""Name"":""Mission_Salvage_Planet_name"", ""MissionID"":413563829, ""Commodity"":""$Landmines_Name;"", ""Commodity_Localised"":""Landmines"", ""Count"":4, ""DestinationSystem"":""Carthage"", ""Reward"":465824, ""FactionEffects"":[ { ""Faction"":""HIP 20277 Inc"", ""Effects"":[ { ""Effect"":""$MISSIONUTIL_Interaction_Summary_civilUnrest_down;"", ""Effect_Localised"":""$#MinorFaction; are happy to report improved civil contentment, making a period of civil unrest unlikely."", ""Trend"":""DownGood"" } ], ""Influence"":[ { ""SystemAddress"":84053791442, ""Trend"":""UpGood"" } ], ""Reputation"":""UpGood"" } ] }";
            events = JournalMonitor.ParseJournalEntry(line);
            Assert.IsTrue(events.Count == 1);
            missionMonitor.handleMissionCompletedEvent((MissionCompletedEvent)events[0]);
            Assert.AreEqual("Complete", missionMonitor.missions.SingleOrDefault(m => m.missionid == 413563829)?.statusEDName);
            missionMonitor._postHandleMissionCompletedEvent((MissionCompletedEvent)events[0]);
            Assert.AreEqual(5, missionMonitor.missions.Count);

            //MissionFailedEvent
            line   = @"{ ""timestamp"":""2018-08-26T00:50:48Z"", ""event"":""MissionFailed"", ""Name"":""Mission_Collect_Industrial"", ""Fine"":50000, ""MissionID"":413748324 }";
            events = JournalMonitor.ParseJournalEntry(line);
            Assert.IsTrue(events.Count == 1);

            CrimeMonitorConfiguration crimeData = CrimeMonitorConfiguration.FromFile();
            CrimeMonitor crimeMonitor           = new CrimeMonitor();

            mission = missionMonitor.missions.ToList().FirstOrDefault(m => m.missionid == 413748324);
            long fine = ((MissionFailedEvent)events[0]).fine;

            crimeMonitor._handleMissionFine(events[0].timestamp, mission, fine);
            FactionRecord record = crimeMonitor.criminalrecord.ToList().FirstOrDefault(r => r.faction == mission.faction);

            Assert.IsNotNull(record);
            Assert.AreEqual(50000, record.fines);
            FactionReport report = record.factionReports.FirstOrDefault(r => r.crimeDef == Crime.FromEDName("missionFine"));

            Assert.IsNotNull(report);
            Assert.AreEqual(50000, report.amount);
            crimeData.ToFile();

            missionMonitor.handleMissionFailedEvent((MissionFailedEvent)events[0]);
            Assert.AreEqual("Failed", missionMonitor.missions.SingleOrDefault(m => m.missionid == 413748324)?.statusEDName);
            missionMonitor._postHandleMissionFailedEvent((MissionFailedEvent)events[0]);
            Assert.AreEqual(4, missionMonitor.missions.Count);

            //MissionCompletedEvent - Donation
            line   = @"{ ""timestamp"":""2018-12-18T19:14:32Z"", ""event"":""MissionCompleted"", ""Faction"":""Movement for Rabakshany Democrats"", ""Name"":""Mission_AltruismCredits_name"", ""MissionID"":442085549, ""Donation"":""1000000"", ""Donated"":1000000, ""FactionEffects"":[ { ""Faction"":""Movement for Rabakshany Democrats"", ""Effects"":[ { ""Effect"":""$MISSIONUTIL_Interaction_Summary_EP_up;"", ""Effect_Localised"":""The economic status of $#MinorFaction; has improved in the $#System; system."", ""Trend"":""UpGood"" } ], ""Influence"":[ { ""SystemAddress"":8605201797850, ""Trend"":""UpGood"", ""Influence"":""+++++"" } ], ""ReputationTrend"":""UpGood"", ""Reputation"":""++"" } ] }";
            events = JournalMonitor.ParseJournalEntry(line);
            Assert.IsTrue(events.Count == 1);
            MissionCompletedEvent mcEvent = (MissionCompletedEvent)events[0];

            Assert.AreEqual(1000000, mcEvent.donation);

            // Restore original data
            missionData.ToFile();
        }
Ejemplo n.º 24
0
        public void TestCargoEventsScenario()
        {
            var     privateObject = new PrivateObject(cargoMonitor);
            Haulage haulage       = new Haulage();

            // 'Startup' CargoEvent
            line   = "{ \"timestamp\":\"2018-10-31T01:54:40Z\", \"event\":\"Missions\", \"Active\":[  ], \"Failed\":[  ], \"Complete\":[  ] }";
            events = JournalMonitor.ParseJournalEntry(line);
            privateObject.Invoke("_handleMissionsEvent", new object[] { events[0] });
            line   = "{ \"timestamp\":\"2018-10-31T03:39:10Z\", \"event\":\"Cargo\", \"Count\":52, \"Inventory\":[ { \"Name\":\"hydrogenfuel\", \"Name_Localised\":\"Hydrogen Fuel\", \"Count\":1, \"Stolen\":0 }, { \"Name\":\"biowaste\", \"MissionID\":426282789, \"Count\":30, \"Stolen\":0 }, { \"Name\":\"animalmeat\", \"Name_Localised\":\"Animal Meat\", \"Count\":1, \"Stolen\":0 }, { \"Name\":\"drones\", \"Name_Localised\":\"Limpet\", \"Count\":20, \"Stolen\":0 } ] }";
            events = JournalMonitor.ParseJournalEntry(line);
            privateObject.Invoke("_handleCargoEvent", new object[] { events[0] });
            Assert.AreEqual(4, cargoMonitor.inventory.Count);
            Assert.AreEqual(52, cargoMonitor.cargoCarried);

            cargo = cargoMonitor.inventory.ToList().FirstOrDefault(c => c.edname == "Drones");
            Assert.AreEqual("Limpet", cargo.localizedName);
            Assert.AreEqual(20, cargo.total);
            Assert.AreEqual(20, cargo.owned);
            Assert.AreEqual(0, cargo.need + cargo.stolen + cargo.haulage);

            // Drone count reduced with subsequent startup CargoEvent
            line   = "{ \"timestamp\":\"2018-10-31T03:39:10Z\", \"event\":\"Cargo\", \"Count\":42, \"Inventory\":[ { \"Name\":\"hydrogenfuel\", \"Name_Localised\":\"Hydrogen Fuel\", \"Count\":1, \"Stolen\":0 }, { \"Name\":\"biowaste\", \"MissionID\":426282789, \"Count\":30, \"Stolen\":0 }, { \"Name\":\"animalmeat\", \"Name_Localised\":\"Animal Meat\", \"Count\":1, \"Stolen\":0 }, { \"Name\":\"drones\", \"Name_Localised\":\"Limpet\", \"Count\":10, \"Stolen\":0 } ] }";
            events = JournalMonitor.ParseJournalEntry(line);
            privateObject.Invoke("_handleCargoEvent", new object[] { events[0] });
            Assert.AreEqual(4, cargoMonitor.inventory.Count);
            Assert.AreEqual(42, cargoMonitor.cargoCarried);
            cargo = cargoMonitor.inventory.ToList().FirstOrDefault(c => c.edname == "Drones");
            Assert.AreEqual(10, cargo.total);

            // Drones removed from inventory with subsequent startup CargoEvent
            line   = "{ \"timestamp\":\"2018-10-31T03:39:10Z\", \"event\":\"Cargo\", \"Count\":32, \"Inventory\":[ { \"Name\":\"hydrogenfuel\", \"Name_Localised\":\"Hydrogen Fuel\", \"Count\":1, \"Stolen\":0 }, { \"Name\":\"biowaste\", \"MissionID\":426282789, \"Count\":30, \"Stolen\":0 }, { \"Name\":\"animalmeat\", \"Name_Localised\":\"Animal Meat\", \"Count\":1, \"Stolen\":0 } ] }";
            events = JournalMonitor.ParseJournalEntry(line);
            privateObject.Invoke("_handleCargoEvent", new object[] { events[0] });
            Assert.AreEqual(3, cargoMonitor.inventory.Count);
            Assert.AreEqual(32, cargoMonitor.cargoCarried);
            cargo = cargoMonitor.inventory.ToList().FirstOrDefault(c => c.edname == "Drones");
            Assert.IsNull(cargo);

            cargo = cargoMonitor.inventory.ToList().FirstOrDefault(c => c.edname == "HydrogenFuel");
            Assert.AreEqual("Hydrogen Fuel", cargo.localizedName);
            Assert.AreEqual(1, cargo.total);
            Assert.AreEqual(1, cargo.owned);
            Assert.AreEqual(0, cargo.need + cargo.stolen + cargo.haulage);

            cargo = cargoMonitor.inventory.ToList().FirstOrDefault(c => c.edname == "Biowaste");
            Assert.AreEqual(30, cargo.total);
            Assert.AreEqual(30, cargo.haulage);
            haulage = cargo.haulageData.FirstOrDefault();
            Assert.IsNotNull(haulage);
            Assert.AreEqual(426282789, haulage.missionid);
            Assert.AreEqual("Mission_None", haulage.name);
            Assert.AreEqual(30, haulage.amount);
            Assert.AreEqual("Active", haulage.status);

            // CargoEjectedEvent
            haulage.typeEDName = "delivery";
            line   = @"{""timestamp"": ""2016-06-10T14:32:03Z"", ""event"": ""EjectCargo"", ""Type"":""biowaste"", ""Count"":2, ""MissionID"":426282789, ""Abandoned"":true}";
            events = JournalMonitor.ParseJournalEntry(line);
            privateObject.Invoke("_handleCommodityEjectedEvent", new object[] { events[0] });

            cargo   = cargoMonitor.inventory.ToList().FirstOrDefault(c => c.edname == "Biowaste");
            haulage = cargo.haulageData.FirstOrDefault(h => h.missionid == 426282789);
            Assert.AreEqual("Failed", haulage.status);
        }
Ejemplo n.º 25
0
        public void TestCrimeEventsScenario()
        {
            // Save original data
            CrimeMonitorConfiguration data = CrimeMonitorConfiguration.FromFile();

            var privateObject = new PrivateObject(crimeMonitor);
            CrimeMonitorConfiguration config = CrimeMonitorConfiguration.FromJsonString(crimeConfigJson);

            crimeMonitor.readRecord(config);

            // Bond Awarded Event
            line   = "{ \"timestamp\":\"2019-04-22T11:51:30Z\", \"event\":\"FactionKillBond\", \"Reward\":32473, \"AwardingFaction\":\"Constitution Party of Aerial\", \"VictimFaction\":\"Ankou Blue Federal Holdings\" }";
            events = JournalMonitor.ParseJournalEntry(line);
            Assert.IsTrue(events.Count == 1);
            privateObject.Invoke("_handleBondAwardedEvent", new object[] { events[0] });
            record = crimeMonitor.criminalrecord.FirstOrDefault(r => r.faction == "Constitution Party of Aerial");
            Assert.AreEqual(3, record.factionReports.Count);
            Assert.AreEqual(94492, record.bondsAmount);

            // Bounty Awarded Event
            line   = "{ \"timestamp\":\"2019-04-22T03:13:36Z\", \"event\":\"Bounty\", \"Rewards\":[ { \"Faction\":\"Calennero State Industries\", \"Reward\":22265 } ], \"Target\":\"adder\", \"TotalReward\":22265, \"VictimFaction\":\"Natural Amemakarna Movement\" }";
            events = JournalMonitor.ParseJournalEntry(line);
            Assert.IsTrue(events.Count == 1);
            privateObject.Invoke("_handleBountyAwardedEvent", new object[] { events[0], true });
            record = crimeMonitor.criminalrecord.FirstOrDefault(r => r.faction == "Calennero State Industries");
            record.factionReports.FirstOrDefault(r => r.amount == 22265).shipId = 10;
            Assert.AreEqual(2, record.factionReports.Where(r => r.bounty && r.crimeDef == Crime.None).Count());
            Assert.AreEqual(127433, record.bountiesAmount);

            // Fine Incurred Event
            line   = "{ \"timestamp\":\"2019-04-22T03:21:46Z\", \"event\":\"CommitCrime\", \"CrimeType\":\"dockingMinorTresspass\", \"Faction\":\"Constitution Party of Aerial\", \"Fine\":400 }";
            events = JournalMonitor.ParseJournalEntry(line);
            Assert.IsTrue(events.Count == 1);
            privateObject.Invoke("_handleFineIncurredEvent", new object[] { events[0] });
            record = crimeMonitor.criminalrecord.FirstOrDefault(r => r.faction == "Constitution Party of Aerial");
            record.factionReports.FirstOrDefault(r => !r.bounty && r.crimeDef != Crime.None).shipId = 10;
            Assert.AreEqual(1, record.factionReports.Where(r => !r.bounty && r.crimeDef != Crime.None).Count());
            Assert.AreEqual(400, record.finesIncurred.Sum(r => r.amount));

            // Bounty Incurred Event
            line   = "{ \"timestamp\":\"2019-04-13T03:58:29Z\", \"event\":\"CommitCrime\", \"CrimeType\":\"assault\", \"Faction\":\"Calennero State Industries\", \"Victim\":\"Christofer\", \"Bounty\":400 }";
            events = JournalMonitor.ParseJournalEntry(line);
            Assert.IsTrue(events.Count == 1);
            privateObject.Invoke("_handleBountyIncurredEvent", new object[] { events[0] });
            record = crimeMonitor.criminalrecord.FirstOrDefault(r => r.faction == "Calennero State Industries");
            record.factionReports.FirstOrDefault(r => r.bounty && r.crimeDef != Crime.None).shipId = 10;
            Assert.AreEqual(1, record.factionReports.Where(r => r.bounty && r.crimeDef != Crime.None).Count());
            Assert.AreEqual(400, record.bountiesIncurred.Sum(r => r.amount));

            // Redeem Bond Event
            line   = "{ \"timestamp\":\"2019-04-09T10:31:31Z\", \"event\":\"RedeemVoucher\", \"Type\":\"CombatBond\", \"Amount\":94492, \"Factions\":[ { \"Faction\":\"Constitution Party of Aerial\", \"Amount\":94492 } ] }";
            events = JournalMonitor.ParseJournalEntry(line);
            Assert.IsTrue(events.Count == 1);
            privateObject.Invoke("_handleBondRedeemedEvent", new object[] { events[0] });
            record = crimeMonitor.criminalrecord.FirstOrDefault(r => r.faction == "Constitution Party of Aerial");
            Assert.AreEqual(0, record.factionReports.Where(r => !r.bounty && r.crimeDef == Crime.None).Count());

            // Redeem Bounty Event - Multiple
            line   = "{ \"timestamp\":\"2019-04-09T10:31:31Z\", \"event\":\"RedeemVoucher\", \"Type\":\"bounty\", \"Amount\":213896, \"Factions\":[ { \"Faction\":\"Calennero State Industries\", \"Amount\":105168 }, { \"Faction\":\"HIP 20277 Inc\", \"Amount\":108728 } ] }";
            events = JournalMonitor.ParseJournalEntry(line);
            Assert.IsTrue(events.Count == 1);
            privateObject.Invoke("_handleBountyRedeemedEvent", new object[] { events[0] });
            record = crimeMonitor.criminalrecord.FirstOrDefault(r => r.faction == "Calennero State Industries");
            Assert.IsNotNull(record);
            Assert.AreEqual(0, record.factionReports.Where(r => r.bounty && r.crimeDef == Crime.None).Count());
            record = crimeMonitor.criminalrecord.FirstOrDefault(r => r.faction == "HIP 20277 Inc");
            Assert.IsNull(record);

            // Fine Paid Event
            line   = "{ \"timestamp\":\"2019-04-09T15:12:10Z\", \"event\":\"PayFines\", \"Amount\":800, \"AllFines\":true, \"ShipID\":10 }";
            events = JournalMonitor.ParseJournalEntry(line);
            Assert.IsTrue(events.Count == 1);
            privateObject.Invoke("_handleFinePaidEvent", new object[] { events[0] });
            record = crimeMonitor.criminalrecord.FirstOrDefault(r => r.faction == "Calennero State Industries");
            Assert.AreEqual(0, record.factionReports.Where(r => !r.bounty && r.crimeDef != Crime.None).Count());
            Assert.AreEqual(0, record.finesIncurred.Sum(r => r.amount));
            record = crimeMonitor.criminalrecord.FirstOrDefault(r => r.faction == "Constitution Party of Aerial");
            Assert.IsNull(record);

            // Bounty Paid Event
            line   = "{ \"timestamp\":\"2019-04-14T04:43:05Z\", \"event\":\"PayBounties\", \"Amount\":400, \"Faction\":\"$faction_Empire;\", \"Faction_Localised\":\"Empire\", \"ShipID\":10, \"BrokerPercentage\":25.000000 }";
            events = JournalMonitor.ParseJournalEntry(line);
            Assert.IsTrue(events.Count == 1);
            privateObject.Invoke("_handleBountyPaidEvent", new object[] { events[0] });
            record = crimeMonitor.criminalrecord.FirstOrDefault(r => r.faction == "Calennero State Industries");
            Assert.IsNull(record);

            // Restore original data
            data.ToFile();
        }
Ejemplo n.º 26
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);
        }
Ejemplo n.º 27
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);
        }
Ejemplo n.º 28
0
        public void TestCargoMissionScenario()
        {
            var     privateObject = new PrivateObject(cargoMonitor);
            Haulage haulage       = new Haulage();

            // CargoEvent
            line   = "{ \"timestamp\":\"2018-10-31T03:39:10Z\", \"event\":\"Cargo\", \"Count\":32, \"Inventory\":[ { \"Name\":\"hydrogenfuel\", \"Name_Localised\":\"Hydrogen Fuel\", \"Count\":1, \"Stolen\":0 }, { \"Name\":\"biowaste\", \"MissionID\":426282789, \"Count\":30, \"Stolen\":0 }, { \"Name\":\"animalmeat\", \"Name_Localised\":\"Animal Meat\", \"Count\":1, \"Stolen\":0 } ] }";
            events = JournalMonitor.ParseJournalEntry(line);
            privateObject.Invoke("_handleCargoEvent", new object[] { events[0] });

            // CargoMissionAcceptedEvent - Check to see if this is a cargo mission and update our inventory accordingly
            line   = @"{ ""timestamp"": ""2018-05-05T19:42:20Z"", ""event"": ""MissionAccepted"", ""Faction"": ""Elite Knights"", ""Name"": ""Mission_Salvage_Planet"", ""LocalisedName"": ""Salvage 3 Structural Regulators"", ""Commodity"": ""$StructuralRegulators_Name;"", ""Commodity_Localised"": ""Structural Regulators"", ""Count"": 3, ""DestinationSystem"": ""Merope"", ""Expiry"": ""2018-05-12T15:20:27Z"", ""Wing"": false, ""Influence"": ""Med"", ""Reputation"": ""Med"", ""Reward"": 557296, ""MissionID"": 375682327 }";
            events = JournalMonitor.ParseJournalEntry(line);
            privateObject.Invoke("_handleMissionAcceptedEvent", new object[] { events[0] });
            line   = @"{ ""timestamp"": ""2018-05-05T19:42:20Z"", ""event"": ""MissionAccepted"", ""Faction"": ""Merope Expeditionary Fleet"", ""Name"": ""Mission_Salvage_Planet"", ""LocalisedName"": ""Salvage 4 Structural Regulators"", ""Commodity"": ""$StructuralRegulators_Name;"", ""Commodity_Localised"": ""Structural Regulators"", ""Count"": 4, ""DestinationSystem"": ""HIP 17692"", ""Expiry"": ""2018-05-12T15:20:27Z"", ""Wing"": false, ""Influence"": ""Med"", ""Reputation"": ""Med"", ""Reward"": 557296, ""MissionID"": 375660729 }";
            events = JournalMonitor.ParseJournalEntry(line);
            privateObject.Invoke("_handleMissionAcceptedEvent", new object[] { events[0] });

            // Verify cargo populated properly
            cargo = cargoMonitor.inventory.ToList().FirstOrDefault(c => c.edname == "StructuralRegulators");
            Assert.AreEqual("Structural Regulators", cargo.invariantName);
            Assert.AreEqual(0, cargo.total);
            Assert.AreEqual(0, cargo.haulage + cargo.stolen + cargo.owned);
            Assert.AreEqual(7, cargo.need);
            Assert.AreEqual(2, cargo.haulageData.Count);

            // Verify haulage populated properly
            haulage = cargo.haulageData.FirstOrDefault(h => h.missionid == 375682327);
            Assert.AreEqual(3, haulage.amount);
            Assert.AreEqual("Mission_Salvage_Planet", haulage.name);
            Assert.AreEqual(DateTime.Parse("2018-05-12T15:20:27Z").ToUniversalTime(), haulage.expiry);

            // Verify duplication protection
            events = JournalMonitor.ParseJournalEntry(line);
            privateObject.Invoke("_handleMissionAcceptedEvent", new object[] { events[0] });
            cargo = cargoMonitor.inventory.ToList().FirstOrDefault(c => c.edname == "StructuralRegulators");
            Assert.AreEqual(7, cargo.need);
            Assert.AreEqual(2, cargo.haulageData.Count);

            // CargoEvent - Collected 2 Structural Regulators for mission ID 375682327. Verify haulage changed but not need
            line   = "{ \"timestamp\":\"2018-10-31T03:39:10Z\", \"event\":\"Cargo\", \"Count\":34, \"Inventory\":[ { \"Name\":\"hydrogenfuel\", \"Name_Localised\":\"Hydrogen Fuel\", \"Count\":1, \"Stolen\":0 }, { \"Name\":\"biowaste\", \"MissionID\":426282789, \"Count\":30, \"Stolen\":0 }, { \"Name\":\"animalmeat\", \"Name_Localised\":\"Animal Meat\", \"Count\":1, \"Stolen\":0 }, { \"Name\":\"structuralregulators\", \"MissionID\":375682327, \"Count\":2, \"Stolen\":0 } ] }";
            events = JournalMonitor.ParseJournalEntry(line);
            privateObject.Invoke("_handleCargoEvent", new object[] { events[0] });

            cargo = cargoMonitor.inventory.ToList().FirstOrDefault(c => c.edname == "StructuralRegulators");
            Assert.AreEqual(2, cargo.total);
            Assert.AreEqual(2, cargo.haulage);
            Assert.AreEqual(7, cargo.need);
            Assert.AreEqual(0, cargo.stolen + cargo.owned);

            // Cargo MissionAbandonedEvent - Verify haulage data for for mission ID 375682327 has been removed
            line   = @"{ ""timestamp"":""2018-05-05T19:42:20Z"", ""event"":""MissionAbandoned"", ""Name"":""Mission_Salvage_Planet"", ""MissionID"":375682327 }";
            events = JournalMonitor.ParseJournalEntry(line);
            privateObject.Invoke("_handleMissionAbandonedEvent", new object[] { events[0] });
            haulage = cargo.haulageData.FirstOrDefault(h => h.missionid == 375682327);
            Assert.IsNull(haulage);

            // CargoEvent - Verify 2 stolen Structural Regulators and 4 still needed for mission ID 37566072
            line   = "{ \"timestamp\":\"2018-10-31T03:39:10Z\", \"event\":\"Cargo\", \"Count\":34, \"Inventory\":[ { \"Name\":\"hydrogenfuel\", \"Name_Localised\":\"Hydrogen Fuel\", \"Count\":1, \"Stolen\":0 }, { \"Name\":\"biowaste\", \"MissionID\":426282789, \"Count\":30, \"Stolen\":0 }, { \"Name\":\"animalmeat\", \"Name_Localised\":\"Animal Meat\", \"Count\":1, \"Stolen\":0 }, { \"Name\":\"structuralregulators\", \"Count\":2, \"Stolen\":2 } ] }";
            events = JournalMonitor.ParseJournalEntry(line);
            privateObject.Invoke("_handleCargoEvent", new object[] { events[0] });
            cargo = cargoMonitor.inventory.ToList().FirstOrDefault(c => c.edname == "StructuralRegulators");
            Assert.AreEqual(2, cargo.total);
            Assert.AreEqual(2, cargo.stolen);
            Assert.AreEqual(4, cargo.need);
            Assert.AreEqual(0, cargo.haulage + cargo.owned);

            // CargoMissionCompletedEvent - Verify haulage data & cargo has been removed
            line   = @"{ ""timestamp"": ""2018-05-05T22:27:58Z"", ""event"": ""MissionCompleted"", ""Faction"": ""Merope Expeditionary Fleet"", ""Name"": ""Mission_Salvage_Planet_name"", ""MissionID"": 375660729, ""Commodity"": ""$StructuralRegulators_Name;"", ""Commodity_Localised"": ""Structural Regulators"", ""Count"": 4, ""DestinationSystem"": ""HIP 17692"", ""Reward"": 624016, ""FactionEffects"": [ { ""Faction"": ""Merope Expeditionary Fleet"", ""Effects"": [ { ""Effect"": ""$MISSIONUTIL_Interaction_Summary_civilUnrest_down;"", ""Effect_Localised"": ""$#MinorFaction; are happy to report improved civil contentment, making a period of civil unrest unlikely."", ""Trend"": ""DownGood"" } ], ""Influence"": [ { ""SystemAddress"": 224644818084, ""Trend"": ""UpGood"" } ], ""Reputation"": ""UpGood"" } ] }";
            events = JournalMonitor.ParseJournalEntry(line);
            privateObject.Invoke("_handleMissionCompletedEvent", new object[] { events[0] });
            haulage = cargo.haulageData.FirstOrDefault(h => h.missionid == 375660729);
            Assert.IsNull(haulage);

            line   = "{ \"timestamp\":\"2018-10-31T03:39:10Z\", \"event\":\"Cargo\", \"Count\":32, \"Inventory\":[ { \"Name\":\"hydrogenfuel\", \"Name_Localised\":\"Hydrogen Fuel\", \"Count\":1, \"Stolen\":0 }, { \"Name\":\"biowaste\", \"MissionID\":426282789, \"Count\":30, \"Stolen\":0 }, { \"Name\":\"animalmeat\", \"Name_Localised\":\"Animal Meat\", \"Count\":1, \"Stolen\":0 } ] }";
            events = JournalMonitor.ParseJournalEntry(line);
            privateObject.Invoke("_handleCargoEvent", new object[] { events[0] });
            cargo = cargoMonitor.inventory.ToList().FirstOrDefault(c => c.edname == "StructuralRegulators");
            Assert.IsNull(cargo);

            // CargoMissionFailedEvent
            line   = @"{ ""timestamp"": ""2018-05-05T19:42:20Z"", ""event"": ""MissionAccepted"", ""Faction"": ""Elite Knights"", ""Name"": ""Mission_Salvage_Planet"", ""LocalisedName"": ""Salvage 3 Structural Regulators"", ""Commodity"": ""$StructuralRegulators_Name;"", ""Commodity_Localised"": ""Structural Regulators"", ""Count"": 3, ""DestinationSystem"": ""Merope"", ""Expiry"": ""2018-05-12T15:20:27Z"", ""Wing"": false, ""Influence"": ""Med"", ""Reputation"": ""Med"", ""Reward"": 557296, ""MissionID"": 375682327 }";
            events = JournalMonitor.ParseJournalEntry(line);
            privateObject.Invoke("_handleMissionAcceptedEvent", new object[] { events[0] });
            cargo = cargoMonitor.inventory.ToList().FirstOrDefault(c => c.edname == "StructuralRegulators");
            Assert.IsNotNull(cargo);

            line   = @"{ ""timestamp"":""2018-05-05T19:42:20Z"", ""event"":""MissionFailed"", ""Name"":""Mission_Salvage_Planet"", ""MissionID"":375682327 }";
            events = JournalMonitor.ParseJournalEntry(line);
            privateObject.Invoke("_handleMissionFailedEvent", new object[] { events[0] });
            haulage = cargo.haulageData.FirstOrDefault(h => h.missionid == 375682327);
            Assert.IsNull(haulage);

            line   = "{ \"timestamp\":\"2018-10-31T03:39:10Z\", \"event\":\"Cargo\", \"Count\":32, \"Inventory\":[ { \"Name\":\"hydrogenfuel\", \"Name_Localised\":\"Hydrogen Fuel\", \"Count\":1, \"Stolen\":0 }, { \"Name\":\"biowaste\", \"MissionID\":426282789, \"Count\":30, \"Stolen\":0 }, { \"Name\":\"animalmeat\", \"Name_Localised\":\"Animal Meat\", \"Count\":1, \"Stolen\":0 } ] }";
            events = JournalMonitor.ParseJournalEntry(line);
            privateObject.Invoke("_handleCargoEvent", new object[] { events[0] });
            cargo = cargoMonitor.inventory.ToList().FirstOrDefault(c => c.edname == "StructuralRegulators");
            Assert.IsNull(cargo);

            // CargoDepotEvent - Check response for missed 'Mission accepted' event. Verify both cargo and haulage are created
            line   = @"{ ""timestamp"":""2018-08-26T02:55:10Z"", ""event"":""CargoDepot"", ""MissionID"":413748324, ""UpdateType"":""Deliver"", ""CargoType"":""Tantalum"", ""Count"":54, ""StartMarketID"":0, ""EndMarketID"":3224777216, ""ItemsCollected"":0, ""ItemsDelivered"":54, ""TotalItemsToDeliver"":70, ""Progress"":0.000000 }";
            events = JournalMonitor.ParseJournalEntry(line);
            privateObject.Invoke("_handleCargoDepotEvent", new object[] { events[0] });
            cargo = cargoMonitor.inventory.ToList().FirstOrDefault(c => c.edname == "Tantalum");
            Assert.IsNotNull(cargo);
            Assert.AreEqual(0, cargo.total);
            Assert.AreEqual(0, cargo.haulage + cargo.owned);
            Assert.AreEqual(16, cargo.need);
            haulage = cargo.haulageData.FirstOrDefault(h => h.missionid == 413748324);
            Assert.IsNotNull(haulage);
            Assert.AreEqual(16, haulage.remaining);
            Assert.IsTrue(haulage.shared);

            // Cargo Delivery 'Mission accepted' Event with 'Cargo Depot' events
            line   = @"{ ""timestamp"":""2018-08-26T00:50:48Z"", ""event"":""MissionAccepted"", ""Faction"":""Calennero State Industries"", ""Name"":""Mission_Delivery_Boom"", ""LocalisedName"":""Boom time delivery of 60 units of Silver"", ""Commodity"":""$Silver_Name;"", ""Commodity_Localised"":""Silver"", ""Count"":60, ""DestinationSystem"":""HIP 20277"", ""DestinationStation"":""Fabian City"", ""Expiry"":""2018-08-27T00:48:38Z"", ""Wing"":false, ""Influence"":""Med"", ""Reputation"":""Med"", ""Reward"":25000000, ""MissionID"":413748339 }";
            events = JournalMonitor.ParseJournalEntry(line);
            privateObject.Invoke("_handleMissionAcceptedEvent", new object[] { events[0] });
            cargo = cargoMonitor.inventory.ToList().FirstOrDefault(c => c.edname == "Silver");
            Assert.IsNotNull(cargo);
            Assert.AreEqual(0, cargo.total);
            Assert.AreEqual(0, cargo.haulage + cargo.owned);
            Assert.AreEqual(60, cargo.need);
            haulage = cargo.haulageData.FirstOrDefault(h => h.missionid == 413748339);
            Assert.IsNotNull(haulage);
            Assert.AreEqual(60, haulage.remaining);
            Assert.IsFalse(haulage.shared);

            line   = @"{ ""timestamp"":""2018-08-26T02:55:10Z"", ""event"":""CargoDepot"", ""MissionID"":413748339, ""UpdateType"":""Collect"", ""CargoType"":""Silver"", ""Count"":60, ""StartMarketID"":3225297216, ""EndMarketID"":3224777216, ""ItemsCollected"":60, ""ItemsDelivered"":0, ""TotalItemsToDeliver"":60, ""Progress"":0.000000 }";
            events = JournalMonitor.ParseJournalEntry(line);
            privateObject.Invoke("_handleCargoDepotEvent", new object[] { events[0] });

            line   = "{ \"timestamp\":\"2018-10-31T03:39:10Z\", \"event\":\"Cargo\", \"Count\":92, \"Inventory\":[ { \"Name\":\"hydrogenfuel\", \"Name_Localised\":\"Hydrogen Fuel\", \"Count\":1, \"Stolen\":0 }, { \"Name\":\"biowaste\", \"MissionID\":426282789, \"Count\":30, \"Stolen\":0 }, { \"Name\":\"animalmeat\", \"Name_Localised\":\"Animal Meat\", \"Count\":1, \"Stolen\":0 }, { \"Name\":\"silver\", \"MissionID\":413748339, \"Count\":60, \"Stolen\":0 } ] }";
            events = JournalMonitor.ParseJournalEntry(line);
            privateObject.Invoke("_handleCargoEvent", new object[] { events[0] });
            Assert.AreEqual(60, cargo.total);
            Assert.AreEqual(60, cargo.haulage);
            Assert.AreEqual(60, cargo.need);
            Assert.AreEqual(60, haulage.remaining);
            Assert.AreEqual(3225297216, haulage.startmarketid);
            Assert.AreEqual(3224777216, haulage.endmarketid);

            line   = @"{ ""timestamp"":""2018-08-26T03:55:10Z"", ""event"":""CargoDepot"", ""MissionID"":413748339, ""UpdateType"":""Deliver"", ""CargoType"":""Silver"", ""Count"":60, ""StartMarketID"":3225297216, ""EndMarketID"":3224777216, ""ItemsCollected"":60, ""ItemsDelivered"":60, ""TotalItemsToDeliver"":60, ""Progress"":0.000000 }";
            events = JournalMonitor.ParseJournalEntry(line);
            privateObject.Invoke("_handleCargoDepotEvent", new object[] { events[0] });
            Assert.AreEqual(0, haulage.remaining);
            Assert.AreEqual(0, haulage.need);
            Assert.AreEqual(0, cargo.need);
        }
Ejemplo n.º 29
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);
        }
Ejemplo n.º 30
0
        public void TestJournalLocationEvent()
        {
            string line = @"{
	""timestamp"": ""2018-08-12T02: 52: 13Z"",
	""event"": ""Location"",
	""Docked"": true,
	""MarketID"": 3223343616,
	""StationName"": ""RayGateway"",
	""StationType"": ""Coriolis"",
	""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,
	""Body"": ""RayGateway"",
	""BodyID"": 32,
	""BodyType"": ""Station"",
	""Factions"": [{
		""Name"": ""DiaguandriInterstellar"",
		""FactionState"": ""None"",
		""Government"": ""Corporate"",
		""Influence"": 0.090000,
		""Allegiance"": ""Independent"",
		""RecoveringStates"": [{
			""State"": ""Boom"",
			""Trend"": 0
		}]
	},
	{
		""Name"": ""People'sMET20Liberals"",
		""FactionState"": ""Boom"",
		""Government"": ""Democracy"",
		""Influence"": 0.206000,
		""Allegiance"": ""Federation""
	},
	{
		""Name"": ""PilotsFederationLocalBranch"",
		""FactionState"": ""None"",
		""Government"": ""Democracy"",
		""Influence"": 0.000000,
		""Allegiance"": ""PilotsFederation""
	},
	{
		""Name"": ""NaturalDiaguandriRegulatoryState"",
		""FactionState"": ""Boom"",
		""Government"": ""Dictatorship"",
		""Influence"": 0.072000,
		""Allegiance"": ""Independent""
	},
	{
		""Name"": ""CartelofDiaguandri"",
		""FactionState"": ""Bust"",
		""Government"": ""Anarchy"",
		""Influence"": 0.121000,
		""Allegiance"": ""Independent"",
		""PendingStates"": [{
			""State"": ""Boom"",
			""Trend"": 1
		},
		{
			""State"": ""CivilUnrest"",
			""Trend"": -1
		}]
	},
	{
		""Name"": ""RevolutionaryPartyofDiaguandri"",
		""FactionState"": ""Boom"",
		""Government"": ""Democracy"",
		""Influence"": 0.181000,
		""Allegiance"": ""Federation"",
		""PendingStates"": [{
			""State"": ""Bust"",
			""Trend"": 0
		}]
	},
	{
		""Name"": ""TheBrotherhoodoftheDarkCircle"",
		""FactionState"": ""Boom"",
		""Government"": ""Corporate"",
		""Influence"": 0.086000,
		""Allegiance"": ""Independent""
	},
	{
		""Name"": ""EXO"",
		""FactionState"": ""None"",
		""Government"": ""Democracy"",
		""Influence"": 0.244000,
		""Allegiance"": ""Independent"",
		""PendingStates"": [{
			""State"": ""Boom"",
			""Trend"": 1
		}]
	}],
	""SystemFaction"": ""EXO""
}";

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

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

            Assert.AreEqual("Independent", @event.Allegiance.invariantName);
            Assert.AreEqual("RayGateway", @event.body);
            Assert.AreEqual("Station", @event.bodytype);
            Assert.AreEqual(true, @event.docked);
            Assert.AreEqual("High Tech", @event.economy);
            Assert.AreEqual("Refinery", @event.economy2);
            Assert.AreEqual("EXO", @event.faction);
            Assert.AreEqual("Democracy", @event.government);
            Assert.IsNull(@event.latitude);
            Assert.IsNull(@event.longitude);
            Assert.AreEqual(3223343616, @event.marketId);
            Assert.AreEqual(10303479, @event.population);
            Assert.AreEqual("Medium", @event.security);
            Assert.AreEqual("RayGateway", @event.station);
            Assert.AreEqual("Coriolis", @event.stationtype);
            Assert.AreEqual("Diaguandri", @event.system);
            Assert.AreEqual(670417429889, @event.systemAddress);
            Assert.AreEqual(-41.06250M, @event.x);
            Assert.AreEqual(-62.15625M, @event.y);
            Assert.AreEqual(-103.25000M, @event.z);
        }