public void TestJournalPlayerLocalChat() { string line = @"{ ""timestamp"":""2017 - 10 - 12T20: 39:25Z"", ""event"":""ReceiveText"", ""From"":""Rebecca Lansing"", ""Message"":""Hi there"", ""Channel"":""local"" }"; List <Event> events = JournalMonitor.ParseJournalEntry(line); Assert.IsTrue(events.Count == 1); MessageReceivedEvent event1 = (MessageReceivedEvent)events[0]; Assert.IsTrue(event1.player); Assert.AreEqual("Commander", event1.source); Assert.AreEqual("Rebecca Lansing", event1.from); Assert.AreEqual("Hi there", event1.message); }
public void TestJournalPlayerWingChat() { string line = @"{ ""timestamp"":""2017-10-12T21:11:10Z"", ""event"":""ReceiveText"", ""From"":""SlowIce"", ""Message"":""hello"", ""Channel"":""wing"" }"; List <Event> events = JournalMonitor.ParseJournalEntry(line); Assert.IsTrue(events.Count == 1); MessageReceivedEvent event1 = (MessageReceivedEvent)events[0]; Assert.IsTrue(event1.player); Assert.AreEqual("Wing mate", event1.source); Assert.AreEqual("SlowIce", event1.from); Assert.AreEqual("hello", event1.message); }
public void TestJournalMessageReceived1() { string line = @"{ ""timestamp"":""2016-10-07T03:02:44Z"", ""event"":""ReceiveText"", ""From"":""$ShipName_Police_Federation;"", ""From_Localised"":""Federal Security Service"", ""Message"":""$Police_StartPatrol03;"", ""Message_Localised"":""Receiving five by five, I'm in the air now, joining patrol."", ""Channel"":""npc"" }"; List <Event> events = JournalMonitor.ParseJournalEntry(line); Assert.IsTrue(events.Count == 1); MessageReceivedEvent theEvent = (MessageReceivedEvent)events[0]; Assert.IsFalse(theEvent.player); Assert.AreEqual("Police", theEvent.source); Assert.AreEqual("Federal Security Service", theEvent.from); }
public void TestStoredModulesEvent() { string line = "{ \"timestamp\":\"2019-01-25T00:06:36Z\", \"event\":\"StoredModules\", \"MarketID\":128928173, \"StationName\":\"Rock of Isolation\", \"StarSystem\":\"Omega Sector OD-S b4-0\", \"Items\":[ { \"Name\":\"$int_shieldgenerator_size7_class3_fast_name;\", \"Name_Localised\":\"Bi-Weave Shield\", \"StorageSlot\":52, \"StarSystem\":\"Omega Sector VE-Q b5-15\", \"MarketID\":128757071, \"TransferCost\":9729, \"TransferTime\":480, \"BuyPrice\":7501033, \"Hot\":false, \"EngineerModifications\":\"ShieldGenerator_Thermic\", \"Level\":5, \"Quality\":0.000000 }, { \"Name\":\"$int_cargorack_size7_class1_name;\", \"Name_Localised\":\"Cargo Rack\", \"StorageSlot\":101, \"StarSystem\":\"Omega Sector OD-S b4-0\", \"MarketID\":128928173, \"TransferCost\":0, \"TransferTime\":0, \"BuyPrice\":976616, \"Hot\":false }, { \"Name\":\"$int_hyperdrive_size6_class5_name;\", \"Name_Localised\":\"FSD\", \"StorageSlot\":53, \"StarSystem\":\"Shinrarta Dezhra\", \"MarketID\":128666762, \"TransferCost\":4535529, \"TransferTime\":55231, \"BuyPrice\":13752602, \"Hot\":false, \"EngineerModifications\":\"FSD_LongRange\", \"Level\":5, \"Quality\":0.000000 }, { \"Name\":\"$int_shieldgenerator_size5_class3_fast_name;\", \"Name_Localised\":\"Bi-Weave Shield\", \"StorageSlot\":116, \"StarSystem\":\"Shinrarta Dezhra\", \"MarketID\":128666762, \"TransferCost\":280636, \"TransferTime\":55231, \"BuyPrice\":850659, \"Hot\":false, \"EngineerModifications\":\"ShieldGenerator_Optimised\", \"Level\":3, \"Quality\":0.000000 }, { \"Name\":\"$hpt_multicannon_gimbal_huge_name;\", \"Name_Localised\":\"Multi-Cannon\", \"StorageSlot\":107, \"StarSystem\":\"Shinrarta Dezhra\", \"MarketID\":128666762, \"TransferCost\":1787862, \"TransferTime\":55231, \"BuyPrice\":5420960, \"Hot\":false, \"EngineerModifications\":\"Weapon_Overcharged\", \"Level\":4, \"Quality\":0.838000 }, { \"Name\":\"$int_repairer_size4_class5_name;\", \"Name_Localised\":\"AFM Unit\", \"StorageSlot\":114, \"StarSystem\":\"Shinrarta Dezhra\", \"MarketID\":128666762, \"TransferCost\":1367146, \"TransferTime\":55231, \"BuyPrice\":4145240, \"Hot\":false, \"EngineerModifications\":\"Misc_Shielded\", \"Level\":3, \"Quality\":1.000000 }, { \"Name\":\"$int_refinery_size4_class5_name;\", \"Name_Localised\":\"Refinery\", \"StorageSlot\":102, \"StarSystem\":\"Omega Sector OD-S b4-0\", \"MarketID\":128928173, \"TransferCost\":0, \"TransferTime\":0, \"BuyPrice\":3730077, \"Hot\":false }, { \"Name\":\"$int_fsdinterdictor_size4_class3_name;\", \"Name_Localised\":\"FSD Interdictor\", \"StorageSlot\":110, \"InTransit\":true, \"BuyPrice\":2311546, \"Hot\":false, \"EngineerModifications\":\"FSDinterdictor_Expanded\", \"Level\":4, \"Quality\":0.979500 }, { \"Name\":\"$int_hullreinforcement_size4_class2_name;\", \"Name_Localised\":\"Hull Reinforcement\", \"StorageSlot\":105, \"InTransit\":true, \"BuyPrice\":171113, \"Hot\":false, \"EngineerModifications\":\"HullReinforcement_HeavyDuty\", \"Level\":4, \"Quality\":0.000000 }, { \"Name\":\"$int_shieldgenerator_size3_class3_fast_name;\", \"Name_Localised\":\"Bi-Weave Shield\", \"StorageSlot\":113, \"StarSystem\":\"Shinrarta Dezhra\", \"MarketID\":128666762, \"TransferCost\":24597, \"TransferTime\":55231, \"BuyPrice\":74284, \"Hot\":false, \"EngineerModifications\":\"ShieldGenerator_Optimised\", \"Level\":5, \"Quality\":0.956700 }, { \"Name\":\"$int_modulereinforcement_size3_class2_name;\", \"Name_Localised\":\"Module Reinforcement\", \"StorageSlot\":120, \"StarSystem\":\"HIP 21066\", \"MarketID\":3221959680, \"TransferCost\":27804, \"TransferTime\":56644, \"BuyPrice\":81900, \"Hot\":false }, { \"Name\":\"$int_hullreinforcement_size3_class2_name;\", \"Name_Localised\":\"Hull Reinforcement\", \"StorageSlot\":115, \"StarSystem\":\"Shinrarta Dezhra\", \"MarketID\":128666762, \"TransferCost\":24408, \"TransferTime\":55231, \"BuyPrice\":73710, \"Hot\":false, \"EngineerModifications\":\"HullReinforcement_HeavyDuty\", \"Level\":4, \"Quality\":0.605000 }, { \"Name\":\"$int_dronecontrol_collection_size3_class2_name;\", \"Name_Localised\":\"Collector\", \"StorageSlot\":118, \"StarSystem\":\"Omega Sector OD-S b4-0\", \"MarketID\":128928173, \"TransferCost\":0, \"TransferTime\":0, \"BuyPrice\":10530, \"Hot\":false, \"EngineerModifications\":\"CollectionLimpet_LightWeight\", \"Level\":5, \"Quality\":0.000000 }, { \"Name\":\"$int_dronecontrol_fueltransfer_size3_class2_name;\", \"Name_Localised\":\"Fuel Transfer\", \"StorageSlot\":57, \"StarSystem\":\"Shinrarta Dezhra\", \"MarketID\":128666762, \"TransferCost\":3225, \"TransferTime\":55231, \"BuyPrice\":9477, \"Hot\":false, \"EngineerModifications\":\"FuelTransferLimpet_LightWeight\", \"Level\":4, \"Quality\":0.000000 }, { \"Name\":\"$hpt_mining_seismchrgwarhd_turret_medium_name;\", \"Name_Localised\":\"Seismic Charge\", \"StorageSlot\":111, \"StarSystem\":\"Omega Sector OD-S b4-0\", \"MarketID\":128928173, \"TransferCost\":0, \"TransferTime\":0, \"BuyPrice\":390988, \"Hot\":false }, { \"Name\":\"$hpt_mining_subsurfdispmisle_turret_medium_name;\", \"Name_Localised\":\"Disp. Missile\", \"StorageSlot\":109, \"StarSystem\":\"Omega Sector OD-S b4-0\", \"MarketID\":128928173, \"TransferCost\":0, \"TransferTime\":0, \"BuyPrice\":334986, \"Hot\":false }, { \"Name\":\"$int_modulereinforcement_size2_class2_name;\", \"Name_Localised\":\"Module Reinforcement\", \"StorageSlot\":112, \"StarSystem\":\"Wayutabal\", \"MarketID\":3224777984, \"TransferCost\":11773, \"TransferTime\":55696, \"BuyPrice\":35100, \"Hot\":false }, { \"Name\":\"$hpt_mininglaser_turret_medium_name;\", \"Name_Localised\":\"Mining Laser\", \"StorageSlot\":108, \"StarSystem\":\"Omega Sector OD-S b4-0\", \"MarketID\":128928173, \"TransferCost\":0, \"TransferTime\":0, \"BuyPrice\":28587, \"Hot\":false }, { \"Name\":\"$int_dronecontrol_prospector_size1_class5_name;\", \"Name_Localised\":\"Prospector\", \"StorageSlot\":104, \"StarSystem\":\"Omega Sector OD-S b4-0\", \"MarketID\":128928173, \"TransferCost\":0, \"TransferTime\":0, \"BuyPrice\":8424, \"Hot\":false }, { \"Name\":\"$hpt_mining_abrblstr_turret_small_name;\", \"Name_Localised\":\"Abrasion Blaster\", \"StorageSlot\":106, \"StarSystem\":\"Omega Sector OD-S b4-0\", \"MarketID\":128928173, \"TransferCost\":0, \"TransferTime\":0, \"BuyPrice\":24114, \"Hot\":false }, { \"Name\":\"$int_corrosionproofcargorack_size1_class2_name;\", \"Name_Localised\":\"Corrosion Resistant Cargo Rack\", \"StorageSlot\":59, \"StarSystem\":\"Maia\", \"MarketID\":128679559, \"TransferCost\":4376, \"TransferTime\":58455, \"BuyPrice\":12249, \"Hot\":false }, { \"Name\":\"$int_corrosionproofcargorack_size1_class2_name;\", \"Name_Localised\":\"Corrosion Resistant Cargo Rack\", \"StorageSlot\":51, \"StarSystem\":\"Maia\", \"MarketID\":128679559, \"TransferCost\":4376, \"TransferTime\":58455, \"BuyPrice\":12249, \"Hot\":false }, { \"Name\":\"$int_corrosionproofcargorack_size1_class2_name;\", \"Name_Localised\":\"Corrosion Resistant Cargo Rack\", \"StorageSlot\":58, \"StarSystem\":\"Shinrarta Dezhra\", \"MarketID\":128666762, \"TransferCost\":3621, \"TransferTime\":55231, \"BuyPrice\":10679, \"Hot\":false }, { \"Name\":\"$hpt_mrascanner_size0_class5_name;\", \"Name_Localised\":\"Pulse Wave\", \"StorageSlot\":100, \"StarSystem\":\"Omega Sector OD-S b4-0\", \"MarketID\":128928173, \"TransferCost\":0, \"TransferTime\":0, \"BuyPrice\":909217, \"Hot\":false }, { \"Name\":\"$hpt_heatsinklauncher_turret_tiny_name;\", \"Name_Localised\":\"Heatsink\", \"StorageSlot\":119, \"StarSystem\":\"Shinrarta Dezhra\", \"MarketID\":128666762, \"TransferCost\":1254, \"TransferTime\":55231, \"BuyPrice\":3500, \"Hot\":false, \"EngineerModifications\":\"HeatSinkLauncher_HeatSinkCapacity\", \"Level\":3, \"Quality\":0.000000 } ] }"; List <Event> events = JournalMonitor.ParseJournalEntry(line); StoredModulesEvent @event = (StoredModulesEvent)events[0]; Assert.AreEqual("Omega Sector OD-S b4-0", @event.system); Assert.AreEqual("Rock of Isolation", @event.station); Assert.AreEqual(128928173, @event.marketId); StoredModule storedModule = @event.storedmodules.FirstOrDefault(m => m.module.EDName.ToLowerInvariant() == "int_hyperdrive_size6_class5"); Assert.AreEqual("Shinrarta Dezhra", storedModule.system); Assert.AreEqual(128666762, storedModule.marketid); Assert.AreEqual("Jameson Memorial", storedModule.station); }
public void TestModuleSwappedEvent() { string line = @"{ ""timestamp"":""2018 - 06 - 29T02: 38:30Z"", ""event"":""ModuleSwap"", ""MarketID"":128132856, ""FromSlot"":""Slot06_Size3"", ""ToSlot"":""Slot07_Size3"", ""FromItem"":""$int_stellarbodydiscoveryscanner_advanced_name;"", ""FromItem_Localised"":""D - Scanner"", ""ToItem"":""Null"", ""Ship"":""krait_mkii"", ""ShipID"":81 }"; List <Event> events = JournalMonitor.ParseJournalEntry(line); ModuleSwappedEvent @event = (ModuleSwappedEvent)events[0]; Assert.AreEqual(128132856, @event.marketId); Assert.AreEqual("Slot06_Size3", @event.fromslot); Assert.AreEqual("Slot07_Size3", @event.toslot); Assert.AreEqual("int_stellarbodydiscoveryscanner_advanced", @event.frommodule.edname.ToLowerInvariant()); Assert.AreEqual("advanced discovery scanner", @event.frommodule.invariantName.ToLowerInvariant()); Assert.IsNull(@event.tomodule); Assert.AreEqual("Krait Mk. II", @event.ship); Assert.AreEqual(81, @event.shipid); }
public void TestJournalPlayerDirectMessage() { string line = "{ \"timestamp\":\"2017-10-12T19:58:46Z\", \"event\":\"ReceiveText\", \"From\":\"SlowIce\", \"Message\":\"good luck\", \"Channel\":\"player\" }"; List <Event> events = JournalMonitor.ParseJournalEntry(line); Assert.IsTrue(events.Count == 1); MessageReceivedEvent event1 = (MessageReceivedEvent)events[0]; Assert.IsTrue(event1.player); Assert.AreEqual("Commander", event1.source); Assert.AreEqual("SlowIce", event1.from); Assert.AreEqual("good luck", event1.message); }
public void TestCargoSynthesis() { cargoMonitor.initializeCargoMonitor(new CargoMonitorConfiguration()); // CargoSynthesisedEvent line = @"{ ""timestamp"": ""2018-05-05T21:08:41Z"", ""event"": ""Synthesis"", ""Name"": ""Limpet Basic"", ""Materials"": [ { ""Name"": ""iron"", ""Count"": 10 }, { ""Name"": ""nickel"", ""Count"": 10 } ] }"; events = JournalMonitor.ParseJournalEntry(line); cargoMonitor._handleSynthesisedEvent(); Assert.AreEqual(1, cargoMonitor.inventory.Count); cargo = cargoMonitor.inventory.ToList().FirstOrDefault(c => c.edname == "Drones"); Assert.AreEqual(4, cargo.total); Assert.AreEqual(4, cargo.owned); Assert.AreEqual(0, cargo.need + cargo.stolen + cargo.haulage); }
private void testButtonClick(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); if (openFileDialog.ShowDialog() == true) { string line; System.IO.StreamReader file = new System.IO.StreamReader(openFileDialog.FileName); while ((line = file.ReadLine()) != null) { var journalEvent = JournalMonitor.ParseJournalEntry(line); TestHack.Handle(journalEvent); } } }
public void TestCargoLimpetScenario() { cargoMonitor.initializeCargoMonitor(new CargoMonitorConfiguration()); var privateObject = new PrivateObject(cargoMonitor); 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); privateObject.Invoke("_handleCargoInventoryEvent", new object[] { events[0] }); cargo = cargoMonitor.inventory.ToList().FirstOrDefault(c => c.edname == "Drones"); Assert.AreEqual("Limpet", cargo.invariantName); Assert.AreEqual(21, cargo.total); Assert.AreEqual(21, cargo.owned); Assert.AreEqual(0, cargo.need + cargo.stolen + cargo.haulage); // CargoLimpetPurchasedEvent line = @"{ ""timestamp"":""2016-09-21T06:53:53Z"", ""event"":""BuyDrones"", ""Type"":""Drones"", ""Count"":19, ""BuyPrice"":101, ""TotalCost"":1919 }"; events = JournalMonitor.ParseJournalEntry(line); privateObject.Invoke("_handleLimpetPurchasedEvent", new object[] { events[0] }); cargo = cargoMonitor.inventory.ToList().FirstOrDefault(c => c.edname == "Drones"); Assert.AreEqual("Limpet", cargo.invariantName); Assert.AreEqual(40, cargo.total); Assert.AreEqual(40, cargo.owned); Assert.AreEqual(0, cargo.need + cargo.stolen + cargo.haulage); // CargoLimpetSoldEvent line = @"{ ""timestamp"":""2016-09-24T00:03:25Z"", ""event"":""SellDrones"", ""Type"":""Drones"", ""Count"":8, ""SellPrice"":101, ""TotalSale"":808 }"; events = JournalMonitor.ParseJournalEntry(line); privateObject.Invoke("_handleLimpetSoldEvent", new object[] { events[0] }); cargo = cargoMonitor.inventory.ToList().FirstOrDefault(c => c.edname == "Drones"); Assert.AreEqual("Limpet", cargo.invariantName); Assert.AreEqual(32, cargo.total); Assert.AreEqual(32, cargo.owned); Assert.AreEqual(0, cargo.need + cargo.stolen + cargo.haulage); // CargoLimpetLaunchedEvent line = @"{ ""timestamp"":""2018-04-07T20:05:07Z"", ""event"":""LaunchDrone"", ""Type"":""Collection"" }"; events = JournalMonitor.ParseJournalEntry(line); privateObject.Invoke("_handleLimpetLaunchedEvent", new object[] {}); cargo = cargoMonitor.inventory.ToList().FirstOrDefault(c => c.edname == "Drones"); Assert.AreEqual("Limpet", cargo.invariantName); Assert.AreEqual(31, cargo.total); Assert.AreEqual(31, cargo.owned); Assert.AreEqual(0, cargo.need + cargo.stolen + cargo.haulage); }
public void TestJournalPlayerMulticrewChat() { // Test for messages received from multicrew. These are received without a defined key for 'Channel' in the player journal. string line = @"{ ""timestamp"":""2017 - 12 - 06T22: 40:54Z"", ""event"":""ReceiveText"", ""From"":""Nexonoid"", ""Message"":""whats up"" }"; List <Event> events = JournalMonitor.ParseJournalEntry(line); Assert.IsTrue(events.Count == 1); MessageReceivedEvent event1 = (MessageReceivedEvent)events[0]; Assert.IsTrue(event1.player); Assert.AreEqual("multicrew", event1.channel); Assert.AreEqual("Crew mate", event1.source); Assert.AreEqual("Nexonoid", event1.from); Assert.AreEqual("whats up", event1.message); }
public void TestRingCurrentBody() { string line = @"{ ""timestamp"":""2018-12-02T07:59:04Z"", ""event"":""SupercruiseExit"", ""StarSystem"":""HR 6421"", ""SystemAddress"":27076330676, ""Body"":""HR 6421 4 A Ring"", ""BodyID"":18, ""BodyType"":""PlanetaryRing"" }"; List <Event> events = JournalMonitor.ParseJournalEntry(line); EnteredNormalSpaceEvent @event = (EnteredNormalSpaceEvent)events[0]; Assert.IsInstanceOfType(@event, typeof(EnteredNormalSpaceEvent)); var system = DeserializeJsonResource <StarSystem>(Resources.sqlStarSystem5); PrivateObject privateObject = new PrivateObject(EDDI.Instance); privateObject.SetFieldOrProperty("CurrentStarSystem", system); privateObject.Invoke("updateCurrentStellarBody", new object[] { @event.bodyname, @event.systemname, @event.systemAddress }); Assert.AreEqual("HR 6421 4", EDDI.Instance.CurrentStellarBody?.bodyname); }
public void TestLocationEventHandler() { string line = "{ \"timestamp\":\"2018-12-27T08:05:23Z\", \"event\":\"Location\", \"Docked\":true, \"MarketID\":3230448384, \"StationName\":\"Cleve Hub\", \"StationType\":\"Orbis\", \"StarSystem\":\"Eravate\", \"SystemAddress\":5856221467362, \"StarPos\":[-42.43750,-3.15625,59.65625], \"SystemAllegiance\":\"Federation\", \"SystemEconomy\":\"$economy_Agri;\", \"SystemEconomy_Localised\":\"Agriculture\", \"SystemSecondEconomy\":\"$economy_Industrial;\", \"SystemSecondEconomy_Localised\":\"Industrial\", \"SystemGovernment\":\"$government_Corporate;\", \"SystemGovernment_Localised\":\"Corporate\", \"SystemSecurity\":\"$SYSTEM_SECURITY_high;\", \"SystemSecurity_Localised\":\"High Security\", \"Population\":740380179, \"Body\":\"Cleve Hub\", \"BodyID\":48, \"BodyType\":\"Station\", \"Powers\":[ \"Zachary Hudson\" ], \"PowerplayState\":\"Exploited\", \"Factions\":[ { \"Name\":\"Eravate School of Commerce\", \"FactionState\":\"None\", \"Government\":\"Cooperative\", \"Influence\":0.086913, \"Allegiance\":\"Independent\", \"Happiness\":\"$Faction_HappinessBand2;\", \"Happiness_Localised\":\"Happy\", \"MyReputation\":91.840103 }, { \"Name\":\"Pilots Federation Local Branch\", \"FactionState\":\"None\", \"Government\":\"Democracy\", \"Influence\":0.000000, \"Allegiance\":\"PilotsFederation\", \"Happiness\":\"$Faction_HappinessBand2;\", \"Happiness_Localised\":\"Happy\", \"MyReputation\":42.790199 }, { \"Name\":\"Independent Eravate Free\", \"FactionState\":\"None\", \"Government\":\"Democracy\", \"Influence\":0.123876, \"Allegiance\":\"Independent\", \"Happiness\":\"$Faction_HappinessBand2;\", \"Happiness_Localised\":\"Happy\", \"MyReputation\":100.000000 }, { \"Name\":\"Eravate Network\", \"FactionState\":\"None\", \"Government\":\"Corporate\", \"Influence\":0.036963, \"Allegiance\":\"Federation\", \"Happiness\":\"$Faction_HappinessBand2;\", \"Happiness_Localised\":\"Happy\", \"MyReputation\":100.000000 }, { \"Name\":\"Traditional Eravate Autocracy\", \"FactionState\":\"None\", \"Government\":\"Dictatorship\", \"Influence\":0.064935, \"Allegiance\":\"Independent\", \"Happiness\":\"$Faction_HappinessBand2;\", \"Happiness_Localised\":\"Happy\", \"MyReputation\":100.000000 }, { \"Name\":\"Eravate Life Services\", \"FactionState\":\"None\", \"Government\":\"Corporate\", \"Influence\":0.095904, \"Allegiance\":\"Independent\", \"Happiness\":\"$Faction_HappinessBand2;\", \"Happiness_Localised\":\"Happy\", \"MyReputation\":100.000000 }, { \"Name\":\"Official Eravate Flag\", \"FactionState\":\"None\", \"Government\":\"Dictatorship\", \"Influence\":0.179820, \"Allegiance\":\"Independent\", \"Happiness\":\"$Faction_HappinessBand2;\", \"Happiness_Localised\":\"Happy\", \"MyReputation\":100.000000 }, { \"Name\":\"Adle's Armada\", \"FactionState\":\"None\", \"Government\":\"Corporate\", \"Influence\":0.411588, \"Allegiance\":\"Federation\", \"Happiness\":\"$Faction_HappinessBand2;\", \"Happiness_Localised\":\"Happy\", \"SquadronFaction\":true, \"HappiestSystem\":true, \"HomeSystem\":true, \"MyReputation\":100.000000, \"PendingStates\":[ { \"State\":\"Boom\", \"Trend\":0 } ] } ], \"SystemFaction\":{ \"Name\":\"Adle's Armada\", \"FactionState\":\"None\" } }"; List <Event> events = JournalMonitor.ParseJournalEntry(line); Assert.AreEqual(1, events.Count); LocationEvent @event = (LocationEvent)events[0]; Assert.IsNotNull(@event); Assert.IsInstanceOfType(@event, typeof(LocationEvent)); PrivateObject privateObject = new PrivateObject(Eddi.EDDI.Instance); var result = (bool)privateObject.Invoke("eventLocation", new object[] { @event }); Assert.IsTrue(result); }
public void TestRingCurrentBody() { string line = @"{ ""timestamp"":""2018-12-02T07:59:04Z"", ""event"":""SupercruiseExit"", ""StarSystem"":""HIP 17704"", ""SystemAddress"":246119654564, ""Body"":""HIP 17704 4 A Ring"", ""BodyID"":18, ""BodyType"":""PlanetaryRing"" }"; List <Event> events = JournalMonitor.ParseJournalEntry(line); Assert.AreEqual(1, events.Count); EnteredNormalSpaceEvent @event = (EnteredNormalSpaceEvent)events[0]; Assert.IsNotNull(@event); Assert.IsInstanceOfType(@event, typeof(EnteredNormalSpaceEvent)); PrivateObject privateObject = new PrivateObject(Eddi.EDDI.Instance); privateObject.Invoke("updateCurrentStellarBody", new object[] { @event.bodyname, @event.systemname, @event.systemAddress }); Assert.AreEqual("HIP 17704 4", EDDI.Instance.CurrentStellarBody?.bodyname); }
public void TestJumpedEventHandler() { string line = "{ \"timestamp\":\"2018-12-25T20:07:06Z\", \"event\":\"FSDJump\", \"StarSystem\":\"LHS 20\", \"SystemAddress\":33656303199641, \"StarPos\":[11.18750,-37.37500,-31.84375], \"SystemAllegiance\":\"Federation\", \"SystemEconomy\":\"$economy_HighTech;\", \"SystemEconomy_Localised\":\"High Tech\", \"SystemSecondEconomy\":\"$economy_Refinery;\", \"SystemSecondEconomy_Localised\":\"Refinery\", \"SystemGovernment\":\"$government_Democracy;\", \"SystemGovernment_Localised\":\"Democracy\", \"SystemSecurity\":\"$SYSTEM_SECURITY_medium;\", \"SystemSecurity_Localised\":\"Medium Security\", \"Population\":9500553, \"JumpDist\":20.361, \"FuelUsed\":3.065896, \"FuelLevel\":19.762932, \"Factions\":[ { \"Name\":\"Pilots Federation Local Branch\", \"FactionState\":\"None\", \"Government\":\"Democracy\", \"Influence\":0.000000, \"Allegiance\":\"PilotsFederation\", \"Happiness\":\"\", \"MyReputation\":6.106290 }, { \"Name\":\"Shenetserii Confederation\", \"FactionState\":\"None\", \"Government\":\"Confederacy\", \"Influence\":0.127000, \"Allegiance\":\"Federation\", \"Happiness\":\"$Faction_HappinessBand2;\", \"Happiness_Localised\":\"Happy\", \"MyReputation\":18.809999, \"PendingStates\":[ { \"State\":\"War\", \"Trend\":0 } ] }, { \"Name\":\"LHS 20 Company\", \"FactionState\":\"None\", \"Government\":\"Corporate\", \"Influence\":0.127000, \"Allegiance\":\"Federation\", \"Happiness\":\"$Faction_HappinessBand2;\", \"Happiness_Localised\":\"Happy\", \"MyReputation\":4.950000, \"PendingStates\":[ { \"State\":\"War\", \"Trend\":0 } ] }, { \"Name\":\"Traditional LHS 20 Defence Party\", \"FactionState\":\"None\", \"Government\":\"Dictatorship\", \"Influence\":0.087000, \"Allegiance\":\"Independent\", \"Happiness\":\"$Faction_HappinessBand2;\", \"Happiness_Localised\":\"Happy\", \"MyReputation\":2.640000 }, { \"Name\":\"Movement for LHS 20 Liberals\", \"FactionState\":\"CivilWar\", \"Government\":\"Democracy\", \"Influence\":0.226000, \"Allegiance\":\"Federation\", \"Happiness\":\"$Faction_HappinessBand2;\", \"Happiness_Localised\":\"Happy\", \"SquadronFaction\":true, \"HomeSystem\":true, \"MyReputation\":100.000000, \"ActiveStates\":[ { \"State\":\"CivilLiberty\" }, { \"State\":\"Investment\" }, { \"State\":\"CivilWar\" } ] }, { \"Name\":\"Nationalists of LHS 20\", \"FactionState\":\"None\", \"Government\":\"Dictatorship\", \"Influence\":0.105000, \"Allegiance\":\"Independent\", \"Happiness\":\"$Faction_HappinessBand2;\", \"Happiness_Localised\":\"Happy\", \"MyReputation\":0.000000 }, { \"Name\":\"LHS 20 Organisation\", \"FactionState\":\"CivilWar\", \"Government\":\"Anarchy\", \"Influence\":0.166000, \"Allegiance\":\"Independent\", \"Happiness\":\"$Faction_HappinessBand2;\", \"Happiness_Localised\":\"Happy\", \"MyReputation\":5.940000, \"ActiveStates\":[ { \"State\":\"CivilWar\" } ] }, { \"Name\":\"LHS 20 Engineers\", \"FactionState\":\"None\", \"Government\":\"Corporate\", \"Influence\":0.162000, \"Allegiance\":\"Federation\", \"Happiness\":\"$Faction_HappinessBand2;\", \"Happiness_Localised\":\"Happy\", \"MyReputation\":15.000000 } ], \"SystemFaction\":{ \"Name\":\"Movement for LHS 20 Liberals\", \"FactionState\":\"CivilWar\" } }"; List <Event> events = JournalMonitor.ParseJournalEntry(line); Assert.AreEqual(1, events.Count); JumpedEvent @event = (JumpedEvent)events[0]; Assert.IsNotNull(@event); Assert.IsInstanceOfType(@event, typeof(JumpedEvent)); PrivateObject privateObject = new PrivateObject(Eddi.EDDI.Instance); var result = (bool)privateObject.Invoke("eventJumped", new object[] { @event }); Assert.IsTrue(result); }
public void TestCargoEventsScenario() { // Save original data CargoMonitorConfiguration data = CargoMonitorConfiguration.FromFile(); var privateObject = new PrivateObject(cargoMonitor); Haulage haulage = new Haulage(); // 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\":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 == "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); // Restore original data data.ToFile(); }
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 }"; 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 privateObject = new PrivateObject(Eddi.EDDI.Instance); privateObject.Invoke("updateCurrentSystem", new object[] { "BD-01 2784" }); privateObject.Invoke("eventRingMapped", new object[] { @event }); Assert.AreEqual("BD-01 2784 10", EDDI.Instance.CurrentStellarBody?.bodyname); }
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("NPC", event1.source); Assert.AreEqual("Jonathan Dallard", event1.from); NPCCargoScanCommencedEvent event2 = (NPCCargoScanCommencedEvent)events[1]; Assert.AreEqual("Pirate", event2.by); }
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)); } }
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); }
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")); }
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); }
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); } } } }
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); }
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 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); }
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); }
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)); } }
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); }
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"); } }
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); }