public LocationEvent(DateTime timestamp, string systemName, decimal x, decimal y, decimal z, long systemAddress, decimal?distancefromstar, string bodyName, long?bodyId, BodyType bodytype, bool docked, string station, StationModel stationtype, long?marketId, Faction systemFaction, Faction stationFaction, Economy economy, Economy economy2, SecurityLevel security, long?population, decimal?longitude, decimal?latitude, List <Faction> factions, Power powerplayPower, PowerplayState powerplayState) : base(timestamp, NAME) { this.systemname = systemName; this.x = x; this.y = y; this.z = z; this.systemAddress = systemAddress; this.distancefromstar = distancefromstar; this.bodyname = bodyName; this.bodyId = bodyId; this.bodyType = bodytype; this.docked = docked; this.station = station; this.stationModel = stationtype; this.marketId = marketId; this.controllingsystemfaction = systemFaction; this.controllingstationfaction = stationFaction; this.Economy = (economy ?? Economy.None); this.Economy2 = (economy2 ?? Economy.None); this.securityLevel = security; this.population = population; this.longitude = longitude; this.latitude = latitude; this.factions = factions; this.Power = powerplayPower; this.powerState = powerplayState; }
public void TestEddbGetSystem() { // Setup string resource = "v4/populatedsystems?"; string json = Encoding.UTF8.GetString(Resources.bgsEddbSystemResponse); RestRequest data = new RestRequest(); StarSystem expectedSol = new StarSystem() { systemAddress = 10477373803, systemname = "Sol", EDSMID = 27, Power = Power.FromEDName("ZacharyHudson"), powerState = PowerplayState.FromEDName("Controlled"), updatedat = 1599446773 }; // Act fakeEddbRestClient.Expect(resource, json, data); StarSystem solByName = fakeBgsService.GetSystemByName("Sol"); StarSystem solByAddress = fakeBgsService.GetSystemBySystemAddress(10477373803); fakeEddbRestClient.Expect(resource, "", data); StarSystem nonExistentSystem = fakeBgsService.GetSystemByName("No such system"); // Assert Assert.IsTrue(solByName.DeepEquals(expectedSol)); Assert.IsTrue(solByAddress.DeepEquals(expectedSol)); Assert.IsNull(nonExistentSystem); }
public StarSystem ParseSystem(object response) { try { Logging.Debug($"Response from Elite BGS eddbRestClient endpoint {systemEndpoint} is: ", response); IDictionary <string, object> systemJson = Deserializtion.DeserializeData(response.ToString()); StarSystem system = new StarSystem { systemname = Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(JsonParsing.getString(systemJson, "name")), // This is lower case by default from the API systemAddress = long.Parse(JsonParsing.getString(systemJson, "ed_system_address")), // Stored in this API as a string EDSMID = JsonParsing.getOptionalLong(systemJson, "edsm_id"), updatedat = Dates.fromDateTimeToSeconds(JsonParsing.getDateTime("updated_at", systemJson)) }; // Get powerplay data // Note: EDDB does not report the following powerplay state ednames: // `HomeSystem`, `InPrepareRadius`, `Prepared`, `Turmoil` // We can identify `HomeSystem` from static data, but `InPrepareRadius`, `Prepared`, and `Turmoil` // are only available from the `Jumped` and `Location` events: // When in conflict, EDDB does not report the names of the conflicting powers. string power = JsonParsing.getString(systemJson, "power"); string powerstate = JsonParsing.getString(systemJson, "power_state"); if (!string.IsNullOrEmpty(power)) { system.Power = Power.FromName(power) ?? Power.None; } if (!string.IsNullOrEmpty(powerstate)) { system.powerState = system.systemname == system.Power?.headquarters ? PowerplayState.HomeSystem : PowerplayState.FromName(powerstate) ?? PowerplayState.None; } return(system); } catch (Exception ex) { Dictionary <string, object> data = new Dictionary <string, object>() { { "input", response }, { "exception", ex } }; Logging.Error("Failed to parse BGS EDDB data.", data); return(null); } }
private static void SetStarSystemLegacyData(StarSystem system, JObject json, bool setPowerplayData) { // Set data not currently available from EDSM: Powerplay data and EDDBID // Note: EDDB does not report the following powerplay state ednames: // `HomeSystem`, `InPrepareRadius`, `Prepared`, `Turmoil` // We can identify `HomeSystem` from static data, but `InPrepareRadius`, `Prepared`, and `Turmoil` // are only available from the `Jumped` and `Location` events: // When in conflict, EDDB does not report the names of the conflicting powers. system.EDDBID = (long?)json["id"]; if (setPowerplayData) { system.Power = Power.FromName((string)json["power"]) ?? Power.None; system.powerState = (string)json["power_state"] == "None" ? PowerplayState.None : system.systemname == system.Power?.headquarters ? PowerplayState.HomeSystem : PowerplayState.FromName((string)json["power_state"]); } }
public JumpedEvent(DateTime timestamp, string system, long systemAddress, decimal x, decimal y, decimal z, string star, decimal distance, decimal fuelused, decimal fuelremaining, int?boostUsed, Faction controllingfaction, List <Faction> factions, List <Conflict> conflicts, Economy economy, Economy economy2, SecurityLevel security, long?population, Power powerplayPower, PowerplayState powerplayState) : base(timestamp, NAME) { this.system = system; this.systemAddress = systemAddress; this.x = x; this.y = y; this.z = z; this.star = star; this.distance = distance; this.fuelused = fuelused; this.fuelremaining = fuelremaining; this.boostused = boostUsed; this.controllingfaction = controllingfaction; this.factions = factions; this.conflicts = conflicts; this.Economy = (economy ?? Economy.None); this.Economy2 = (economy2 ?? Economy.None); this.securityLevel = (security ?? SecurityLevel.None); this.population = population; this.Power = powerplayPower; this.powerState = powerplayState; }
public CarrierJumpedEvent(DateTime timestamp, string systemName, long systemAddress, decimal x, decimal y, decimal z, string bodyName, long?bodyId, BodyType bodyType, Faction systemFaction, List <Faction> factions, List <Conflict> conflicts, Economy systemEconomy, Economy systemEconomy2, SecurityLevel systemSecurity, long?systemPopulation, Power powerplayPower, PowerplayState powerplayState, bool docked, string carrierName, StationModel carrierType, long?carrierId, Faction stationFaction, List <StationService> stationServices, List <EconomyShare> stationEconomies) : base(timestamp, NAME) { // System this.systemname = systemName; this.systemAddress = systemAddress; this.x = x; this.y = y; this.z = z; this.controllingsystemfaction = systemFaction; this.systemEconomy = (systemEconomy ?? Economy.None); this.systemEconomy2 = (systemEconomy2 ?? Economy.None); this.securityLevel = systemSecurity ?? SecurityLevel.None; this.population = systemPopulation; this.factions = factions ?? new List <Faction>(); this.conflicts = conflicts ?? new List <Conflict>(); this.Power = powerplayPower; this.powerState = powerplayState ?? PowerplayState.None; // Body this.bodyname = bodyName; this.bodyId = bodyId; this.bodyType = bodyType ?? BodyType.None; // Carrier this.docked = docked; this.carrierId = carrierId; this.carriername = carrierName; this.carrierType = carrierType ?? StationModel.FromEDName("FleetCarrier"); this.carrierFaction = stationFaction; this.carrierServices = stationServices ?? new List <StationService>(); this.carrierEconomies = stationEconomies ?? new List <EconomyShare>(); }