@kayahr/ed-journal
Version:
Typescript library to read/watch the player journal of Frontier's game Elite Dangerous
62 lines • 2.05 kB
JavaScript
/*
* Copyright (C) 2022 Klaus Reimer <k@ailis.de>
* See LICENSE.md for licensing information.
*/
import { registerJournalEventUpdate } from "../../JournalEvent.js";
import { correctStationService } from "../types/StationService.js";
registerJournalEventUpdate("Location", (from, to) => {
if (from.Faction != null) {
to.SystemFaction = { Name: from.Faction };
delete from.Faction;
}
if (from.Government != null) {
to.SystemGovernment = from.Government;
delete from.Government;
}
if (from.Government_Localised != null) {
to.SystemGovernment_Localised = from.Government_Localised;
delete from.Government_Localised;
}
if (from.Economy != null) {
to.SystemEconomy = from.Economy;
delete from.Economy;
}
if (from.Economy_Localised != null) {
to.SystemEconomy_Localised = from.Economy_Localised;
delete from.Economy_Localised;
}
if (from.Security != null) {
to.SystemSecurity = from.Security;
delete from.Security;
}
if (from.Security_Localised != null) {
to.SystemSecurity_Localised = from.Security_Localised;
delete from.Security_Localised;
}
if (from.Allegiance != null) {
to.SystemAllegiance = from.Allegiance;
delete from.Allegiance;
}
if (typeof from.SystemFaction === "string") {
to.SystemFaction = {
Name: from.SystemFaction
};
}
if (typeof from.StationFaction === "string") {
to.StationFaction = {
Name: from.StationFaction
};
}
if (from.FactionState != null && to.SystemFaction instanceof Object) {
to.SystemFaction.FactionState = from.FactionState;
delete from.FactionState;
}
if (from.StationServices instanceof Array) {
to.StationServices = from.StationServices.map(correctStationService);
}
if (to.StationType === "") {
// Remove empty station type
delete to.StationType;
}
});
//# sourceMappingURL=Location.js.map