Compare commits

...

5 Commits

Author SHA1 Message Date
6608f33d8d update versions 2022-12-20 18:42:27 +01:00
42987cdb12 update changelog 2022-12-20 18:42:20 +01:00
4f6376d39b remove old code 2022-12-20 18:38:33 +01:00
273d151358 add more mission names 2022-12-20 18:37:18 +01:00
a9ce5be266 fix mission fails 2022-12-20 18:33:09 +01:00
9 changed files with 98 additions and 720 deletions

View File

@ -17,9 +17,9 @@ public class InfluenceSupport : Transaction {
public MissionCompletedEntry? RelevantMission { get; set; }
/// <summary>
/// Mission accepted entry
/// Mission information
/// </summary>
public MissionAcceptedEntry? AcceptedEntry { get; set; }
public Mission? Mission { get; set; }
public override DateTime? CompletedAtDateTime {
get {

View File

@ -9,6 +9,8 @@ public class MissionCompleted : Transaction {
public MissionAcceptedEntry? AcceptedEntry { get; set; }
public Mission? Mission { get; set; }
public MissionCompleted() { }
public override DateTime? CompletedAtDateTime {
@ -45,15 +47,13 @@ public class MissionCompleted : Transaction {
/// </summary>
public override bool SystemContribution {
get {
if (AcceptedEntry == null ||
AcceptedEntry.Mission == null ||
AcceptedEntry.Mission.Name == null) {
if (Mission == null || Mission.Name == null) {
return false;
}
// If the mission starts with the name for thargoid war mission
// names, we assume its a system contribution
if (AcceptedEntry.Mission.Name.Contains("Mission_TW_")) {
if (Mission.Name.Contains("Mission_TW_")) {
return true;
}

View File

@ -4,16 +4,13 @@ using EDPlayerJournal.Entries;
namespace EDPlayerJournal.BGS;
public class MissionFailed : Transaction {
public MissionFailedEntry? Failed { get; set; }
public MissionAcceptedEntry? Accepted { get; set; }
public Mission? Mission { get; set; }
public MissionFailed() { }
public MissionFailed(MissionAcceptedEntry accepted) {
if (accepted.Mission == null) {
throw new Exception("Mission cannot be null");
}
Accepted = accepted;
Faction = accepted.Mission.Faction;
public MissionFailed(MissionFailedEntry failed) {
Entries.Add(failed);
Failed = failed;
}
public override int CompareTo(Transaction? other) {
@ -46,13 +43,13 @@ public class MissionFailed : Transaction {
public override string ToString() {
StringBuilder builder = new StringBuilder();
if (Failed == null || Accepted == null) {
if (Failed == null || Mission == null) {
return "";
}
builder.AppendFormat("{0}x Mission failed: \"{1}\"",
Amount,
Failed?.Mission?.FriendlyName
Mission?.FriendlyName
);
return builder.ToString();

View File

@ -1,666 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using EDPlayerJournal.Entries;
namespace EDPlayerJournal.BGS;
public class Report {
private List<Objective> objectives = new List<Objective>();
public delegate void OnLogDelegate(string log);
public event OnLogDelegate? OnLog;
public List<Objective> Objectives {
get { return objectives; }
set { objectives = value; }
}
public bool AddObjective(Objective objective) {
var found = objectives.Find(x => x.CompareTo(objective) == 0);
bool added = false;
if (found == null) {
objectives.Add(objective);
added = true;
}
return added;
}
public static bool IsRelevant(Entry e) {
return e.Is(Events.CommitCrime) ||
e.Is(Events.Docked) ||
e.Is(Events.FactionKillBond) ||
e.Is(Events.FSDJump) ||
e.Is(Events.Location) ||
e.Is(Events.MarketBuy) ||
e.Is(Events.MarketSell) ||
e.Is(Events.MissionAccepted) ||
e.Is(Events.MissionFailed) ||
e.Is(Events.MultiSellExplorationData) ||
e.Is(Events.RedeemVoucher) ||
e.Is(Events.SearchAndRescue) ||
e.Is(Events.SellExplorationData) ||
e.Is(Events.SellMicroResources) ||
e.Is(Events.SellOrganicData) ||
e.Is(Events.ShipTargeted) ||
e.Is(Events.MissionCompleted)
;
}
public void Scan(PlayerJournal journal, DateTime start, DateTime end) {
/* Log files only get rotated if you restart the game client. This means that there might
* be - say - entries from the 4th of May in the file with a timestamp of 3rd of May. This
* happens if you happen to play a session late into the night.
* At first I tried extracting the first and last line of a file to see the date range, but
* if you have a lot of files this becomes quite slow, and quite the memory hog (as journal
* files have to be read in their entirety to check this). So we assume that you can't play
* three days straight, and keep the code fast.
*/
DateTime actualstart = start.AddDays(-3);
List<Entry> entries = journal.Files
.Where(f => f.NormalisedDateTime >= actualstart && f.NormalisedDateTime <= end)
.SelectMany(e => e.Entries)
.ToList()
;
// Now further sort the list down to entries that are actually within the given datetime
// Note that entry datetimes are not normalised, so we have to sort until end + 1 day
DateTime actualend = end.AddDays(1);
entries = entries
.Where(e => e.Timestamp >= start && e.Timestamp < actualend)
.ToList()
;
Scan(entries);
}
public void Scan(List<Entry> entries) {
if (entries.Count <= 0) {
return;
}
List<Entry> relevant = entries
.Where(x => IsRelevant(x))
.ToList()
;
Dictionary<ulong, MissionAcceptedEntry> acceptedMissions = new Dictionary<ulong, MissionAcceptedEntry>();
Dictionary<string, long> buyCost = new Dictionary<string, long>();
Dictionary<ulong, string> systems = new Dictionary<ulong, string>();
Dictionary<string, string> npcfactions = new Dictionary<string, string>();
Dictionary<string, List<Faction>> system_factions = new Dictionary<string, List<Faction>>();
// A dictionary resolving to a station at which each mission was accepted
Dictionary<ulong, string> acceptedStations = new Dictionary<ulong, string>();
// A dictionary resolving to a system at which each mission was accepted
Dictionary<ulong, ulong> acceptedSystems = new Dictionary<ulong, ulong>();
string? current_system = null;
ulong? current_system_address = null;
string? current_station = null;
string? controlling_faction = null;
objectives.ForEach(x => x.Clear());
foreach (Entry e in relevant) {
List<Transaction> results = new List<Transaction>();
bool collate = false;
if (e.Is(Events.Docked)) {
DockedEntry? docked = e as DockedEntry;
if (docked == null) {
continue;
}
/* gleem the current station from this message
*/
current_station = docked.StationName;
current_system = docked.StarSystem;
controlling_faction = docked.StationFaction;
current_system_address = docked.SystemAddress;
if (current_system_address != null && current_system != null) {
if (!systems.ContainsKey(current_system_address.Value)) {
systems.Add(current_system_address.Value, current_system);
}
}
} else if (e.Is(Events.FSDJump)) {
/* Gleem current system and controlling faction from this message.
*/
FSDJumpEntry? fsd = e as FSDJumpEntry;
if (fsd == null || fsd.StarSystem == null) {
continue;
}
current_system_address = fsd.SystemAddress;
current_system = fsd.StarSystem;
controlling_faction = fsd.SystemFaction;
if (!systems.ContainsKey(fsd.SystemAddress)) {
systems.Add(fsd.SystemAddress, fsd.StarSystem);
}
if (!system_factions.ContainsKey(fsd.StarSystem) &&
fsd.SystemFactions.Count > 0) {
system_factions[fsd.StarSystem] = fsd.SystemFactions;
}
} else if (e.Is(Events.Location)) {
/* Get current system, faction name and station from Location message
*/
LocationEntry? location = e as LocationEntry;
if (location == null || location.StarSystem == null) {
continue;
}
current_system = location.StarSystem;
current_system_address = location.SystemAddress;
if (!systems.ContainsKey(location.SystemAddress)) {
systems.Add(location.SystemAddress, location.StarSystem);
}
if (!string.IsNullOrEmpty(location.SystemFaction)) {
controlling_faction = location.SystemFaction;
}
if (!string.IsNullOrEmpty(location.StationName)) {
current_station = location.StationName;
}
if (!system_factions.ContainsKey(location.StarSystem) &&
location.SystemFactions.Count > 0) {
system_factions[location.StarSystem] = location.SystemFactions;
}
} else if (e.Is(Events.ShipTargeted)) {
ShipTargetedEntry? targeted = e as ShipTargetedEntry;
if (targeted == null) {
continue;
}
if (string.IsNullOrEmpty(targeted.PilotNameLocalised) ||
string.IsNullOrEmpty(targeted.Faction)) {
continue;
}
npcfactions[targeted.PilotNameLocalised] = targeted.Faction;
} else if (e.Is(Events.CommitCrime)) {
CommitCrimeEntry? crime = e as CommitCrimeEntry;
if (crime == null) {
continue;
}
string? faction = crime.Faction;
if (faction == null || !crime.IsMurder) {
/* we don't care about anything but murder for now */
continue;
}
/* use localised victim name if we have it, otherwise use normal name */
string? victim = crime.VictimLocalised;
if (string.IsNullOrEmpty(victim)) {
victim = crime.Victim;
}
if (string.IsNullOrEmpty(victim)) {
continue;
}
if (!npcfactions.ContainsKey(victim)) {
/* The faction in the crime report is the faction that issues the bounty,
* and not the faction of the victim.
*/
OnLog?.Invoke(string.Format(
"No faction found for victim \"{0}\", using faction that issued the bounty instead.",
victim, crime.Faction
));
} else {
faction = npcfactions[victim];
}
results.Add(new FoulMurder(crime) {
System = current_system,
Faction = faction,
});
collate = true;
} else if (e.Is(Events.MissionCompleted)) {
MissionCompletedEntry? completed = e as MissionCompletedEntry;
if (completed == null ||
completed.Mission == null) {
continue;
}
MissionAcceptedEntry? accepted = null;
MissionCompleted? main_mission = null;
ulong accepted_address;
string? accepted_system;
string? target_faction_name = completed.Mission.TargetFaction;
string? source_faction_name = completed.Mission.Faction;
if (!acceptedMissions.TryGetValue(completed.Mission.MissionID, out accepted)) {
OnLog?.Invoke(string.Format(
"Unable to find mission acceptance for mission \"{0}\". " +
"Please extend range to include the mission acceptance.", completed.Mission.LocalisedName
));
continue;
}
if (!acceptedSystems.TryGetValue(completed.Mission.MissionID, out accepted_address)) {
OnLog?.Invoke(string.Format(
"Unable to figure out in which system mission \"{0}\" was accepted.", completed.Mission.LocalisedName
));
continue;
}
if (!systems.TryGetValue(accepted_address, out accepted_system)) {
OnLog?.Invoke(string.Format(
"Unable to figure out in which system mission \"{0}\" was accepted.", completed.Mission.LocalisedName
));
continue;
}
foreach (var other in completed.Mission.Influences) {
string faction = other.Key;
if (string.IsNullOrEmpty(faction)) {
OnLog?.Invoke(string.Format(
"Mission \"{0}\" has empty faction name in influence block, "+
"so this influence support was ignored. " +
"Please check the README on why this happens.", completed.Mission.LocalisedName)
);
continue;
}
/* Now comes the fun part. Sometimes the influence list is empty for a faction.
* This happens if the faction in question
*/
if (other.Value.Count() == 0) {
OnLog?.Invoke(string.Format(
"Mission \"{0}\" gave no influence to \"{1}\", so we assume this is because the " +
"faction is in a conflict and cannot gain influence right now. " +
"If this assessment is wrong, just remove the entry from the objective list.",
completed.Mission.LocalisedName, faction
));
if (string.Compare(target_faction_name, faction, true) == 0) {
/* here we assume that if the faction in question is the target faction,
* that we gave said target faction no influence in the target system, aka
* current system
*/
if (current_system_address == null) {
continue;
}
other.Value.Add(current_system_address.Value, "");
OnLog?.Invoke(string.Format(
"Mission \"{0}\" gave no influence to \"{1}\". Since \"{1}\" is the target faction " +
"of the mission, we assume the influence was gained in \"{2}\". " +
"Please remove the entry if this assumption is wrong.",
completed.Mission.LocalisedName, faction, current_system
));
} else if (string.Compare(source_faction_name, faction, true) == 0) {
/* source faction of the mission is not getting any influence. This could be because
* the source faction is in an election state in its home system and cannot gain any
* influence. It may also very well be that the source and target faction are the same
* since the faction is present in both target and source system. In which case we add
* both and hope for the best.
*/
other.Value.Add(accepted_address, "");
OnLog?.Invoke(string.Format(
"Mission \"{0}\" gave no influence to \"{1}\". Since \"{1}\" is the source faction " +
"of the mission, we assume the influence was gained in \"{2}\". " +
"Please remove the entry if this assumption is wrong.",
completed.Mission.LocalisedName, faction, accepted_system
));
/* check if source/target faction are equal, in which case we also need an entry
* for the target system. As said factions can be present in two systems, and can
* give missions that target each other.
*/
if (string.Compare(source_faction_name, target_faction_name, true) == 0 &&
current_system_address != null) {
other.Value.Add(current_system_address.Value, "");
OnLog?.Invoke(string.Format(
"Mission \"{0}\" gave no influence to \"{1}\". Since \"{1}\" is the source and target faction " +
"of the mission, we assume the influence was also gained in target system \"{2}\". " +
"Please remove the entry if this assumption is wrong.",
completed.Mission.LocalisedName, faction, current_system
));
}
}
}
foreach (var influences in other.Value) {
ulong system_address = influences.Key;
string? system;
string? accepted_station;
if (completed.Mission == null) {
continue;
}
if (!systems.TryGetValue(system_address, out system)) {
OnLog?.Invoke(string.Format(
"Unknown system \"{0}\" unable to assign that mission a target.", system_address
));
continue;
}
if (!acceptedStations.TryGetValue(completed.Mission.MissionID, out accepted_station)) {
OnLog?.Invoke(string.Format(
"Unable to figure out in which station mission \"{0}\" was accepted.", completed.Mission.LocalisedName
));
continue;
}
if (faction.Equals(source_faction_name) && system_address == accepted_address) {
/* This is the influence block for the origin of the mission.
*/
main_mission = new MissionCompleted() {
CompletedEntry = completed,
AcceptedEntry = accepted,
System = accepted_system,
Faction = source_faction_name,
SystemAddress = accepted_address,
Station = accepted_station,
};
results.Add(main_mission);
} else if (!faction.Equals(source_faction_name) ||
(faction.Equals(source_faction_name) && system_address != accepted_address)) {
/* This block is for secondary factions (first if), or if the secondary faction
* is the same as the mission giver, but in another system (second if).
*/
results.Add(new InfluenceSupport() {
Faction = faction,
Influence = influences.Value,
System = system,
SystemAddress = system_address,
RelevantMission = completed
});
}
}
}
} else if (e.Is(Events.MissionAccepted)) {
MissionAcceptedEntry? accepted = e as MissionAcceptedEntry;
if (accepted == null ||
current_station == null ||
current_system_address == null) {
continue;
}
if (accepted.Mission == null) {
continue;
}
ulong id = accepted.Mission.MissionID;
if (!acceptedMissions.ContainsKey(id)) {
acceptedMissions[id] = accepted;
}
if (!acceptedStations.ContainsKey(id)) {
acceptedStations[id] = current_station;
}
if (!acceptedSystems.ContainsKey(id)) {
acceptedSystems[id] = current_system_address.Value;
}
} else if (e.Is(Events.MissionFailed)) {
MissionFailedEntry? failed = e as MissionFailedEntry;
MissionAcceptedEntry? accepted = null;
ulong accepted_address = 0;
string? accepted_system;
string? accepted_station;
if (failed == null || failed.Mission == null) {
continue;
}
if (!acceptedMissions.TryGetValue(failed.Mission.MissionID, out accepted)) {
OnLog?.Invoke("A mission failed which wasn't accepted in the given time frame. " +
"Please adjust start date to when the mission was accepted to include it in the list.");
continue;
}
if (accepted.Mission == null) {
continue;
}
if (!acceptedSystems.TryGetValue(failed.Mission.MissionID, out accepted_address)) {
OnLog?.Invoke(string.Format(
"Unable to figure out in which system mission \"{0}\" was accepted.", accepted.Mission.Name
));
continue;
}
if (!systems.TryGetValue(accepted_address, out accepted_system)) {
OnLog?.Invoke(string.Format(
"Unable to figure out in which system mission \"{0}\" was accepted.", accepted.Mission.Name
));
continue;
}
if (!acceptedStations.TryGetValue(failed.Mission.MissionID, out accepted_station)) {
OnLog?.Invoke(string.Format(
"Unable to figure out in which station mission \"{0}\" was accepted.", accepted.Mission.Name
));
continue;
}
results.Add(new MissionFailed(accepted) {
Failed = failed,
System = accepted_system,
Station = accepted_station,
Faction = accepted.Mission.Faction,
SystemAddress = accepted_address,
});
/* Mission failed should be collated if they are in the same system/station
*/
collate = true;
} else if (e.Is(Events.SellExplorationData)) {
SellExplorationDataEntry? explo = e as SellExplorationDataEntry;
if (explo == null) {
continue;
}
results.Add(new Cartographics(explo) {
System = current_system,
Station = current_station,
Faction = controlling_faction,
});
/* colate single cartographic selling into one */
collate = true;
} else if (e.Is(Events.SellOrganicData)) {
SellOrganicDataEntry? organic = e as SellOrganicDataEntry;
if (organic == null) {
return;
}
/* organic data sold to Vista Genomics */
results.Add(new OrganicData(organic) {
System = current_system,
Station = current_station,
Faction = controlling_faction,
});
collate = true;
} else if (e.Is(Events.MultiSellExplorationData)) {
MultiSellExplorationDataEntry? explo = e as MultiSellExplorationDataEntry;
if (explo == null) {
continue;
}
/* For multi-sell-exploraton-data only the controlling faction of the station sold to matters.
*/
results.Add(new Cartographics(explo) {
System = current_system,
Station = current_station,
Faction = controlling_faction
});
collate = true;
} else if (e.Is(Events.RedeemVoucher)) {
RedeemVoucherEntry? voucher = e as RedeemVoucherEntry;
List<Faction> current_factions = new List<Faction>();
if (voucher == null || current_system == null) {
continue;
}
if (system_factions.ContainsKey(current_system)) {
current_factions = system_factions[current_system];
} else {
OnLog?.Invoke("There are no current system factions, so turned in vouchers were ignored.");
continue;
}
foreach (string faction in voucher.Factions) {
if (current_factions.Find(x => x.Name == faction) == null) {
OnLog?.Invoke(
string.Format("Vouchers for \"{0}\" were ignored in \"{1}\" since said " +
"faction is not present there.", faction, current_system)
);
continue; /* faction is not present, so it is ignored */
}
/* Same for selling combat vouchers. Only the current controlling faction matters here.
*/
results.Add(new Vouchers(voucher) {
System = current_system,
Station = current_station,
Faction = faction,
ControllingFaction = controlling_faction,
});
}
collate = true;
} else if (e.Is(Events.SellMicroResources)) {
SellMicroResourcesEntry? smr = e as SellMicroResourcesEntry;
if (smr == null) {
continue;
}
results.Add(new SellMicroResources(smr) {
Faction = controlling_faction,
Station = current_station,
System = current_system
});
} else if (e.Is(Events.MarketBuy)) {
MarketBuyEntry? buy = e as MarketBuyEntry;
if (buy == null) {
continue;
}
if (string.IsNullOrEmpty(buy.Type) || buy.BuyPrice == 0) {
continue;
}
buyCost[buy.Type] = buy.BuyPrice;
results.Add(new BuyCargo(buy) {
Faction = controlling_faction,
Station = current_station,
System = current_system,
});
collate = true;
} else if (e.Is(Events.SearchAndRescue)) {
SearchAndRescueEntry? sar = e as SearchAndRescueEntry;
if (sar == null) {
continue;
}
results.Add(new SearchAndRescue(sar) {
Faction = controlling_faction,
Station = current_station,
System = current_system,
});
collate = true;
} else if (e.Is(Events.MarketSell)) {
MarketSellEntry? sell = e as MarketSellEntry;
long profit = 0;
if (sell == null || sell.Type == null) {
continue;
}
if (!buyCost.ContainsKey(sell.Type)) {
OnLog?.Invoke("Could not find buy order for the given commodity. Please adjust profit manually.");
} else {
long avg = buyCost[sell.Type];
profit = (long)sell.TotalSale - (avg * sell.Count);
}
results.Add(new SellCargo(sell) {
Faction = controlling_faction,
Station = current_station,
System = current_system,
Profit = profit
});
}
if (results == null || results.Count <= 0) {
continue;
}
foreach (Transaction entry in results) {
/* Find all objectives that generally match.
*/
var matches = objectives
.Where(x => x.Matches(entry) >= 2)
.OrderBy(x => x.Matches(entry))
;
Objective? objective = null;
if (matches != null && matches.Count() > 0) {
/* Then select the one that matches the most.
*/
objective = matches
.OrderBy(x => x.Matches(entry))
.Reverse()
.First()
;
} else {
/* create a new objective if we don't have one */
objective = new Objective() {
Station = (entry.Station ?? ""),
Faction = (entry.Faction ?? ""),
System = (entry.System ?? ""),
};
objectives.Add(objective);
}
Transaction? existing = null;
existing = objective.LogEntries.Find(x => {
try {
return x.CompareTo(entry) == 0;
} catch (NotImplementedException) {
return false;
}
});
if (collate && existing != null) {
existing.Entries.Add(e);
} else if (!collate || existing == null) {
objective.LogEntries.Add(entry);
}
}
}
}
public void Scan(PlayerJournal journal) {
Scan(journal, DateTime.Now, DateTime.Now);
}
}

View File

@ -1,4 +1,5 @@
using EDPlayerJournal.Entries;
using EDPlayerJournal;
using EDPlayerJournal.Entries;
namespace EDPlayerJournal.BGS;
@ -52,7 +53,7 @@ internal class TransactionParserContext {
/// <summary>
/// A list of accepted missions index by their mission ID
/// </summary>
public Dictionary<ulong, MissionAcceptedEntry> AcceptedMissions { get; } = new();
public Dictionary<ulong, Mission> AcceptedMissions { get; } = new();
public Dictionary<ulong, Location> AcceptedMissionLocation { get; } = new();
/// <summary>
/// A way to lookup a system by its system id
@ -187,16 +188,24 @@ internal class TransactionParserContext {
return SystemFactions[system];
}
public void MissionAccepted(MissionAcceptedEntry accepted) {
public void MissionAccepted(MissionAcceptedEntry? entry) {
if (entry == null) {
return;
}
MissionAccepted(entry.Mission);
}
public void MissionAccepted(Mission? mission) {
if (CurrentSystem == null || CurrentSystemAddress == null) {
throw new Exception("Mission accepted without knowing where.");
}
if (accepted.Mission == null) {
if (mission == null) {
throw new Exception("Mission is null");
}
AcceptedMissions.TryAdd(accepted.Mission.MissionID, accepted);
AcceptedMissions.TryAdd(mission.MissionID, mission);
Location location = new() {
StarSystem = CurrentSystem,
@ -204,7 +213,7 @@ internal class TransactionParserContext {
Station = (CurrentStation ?? ""),
};
AcceptedMissionLocation.TryAdd(accepted.Mission.MissionID, location);
AcceptedMissionLocation.TryAdd(mission.MissionID, location);
}
}
@ -420,6 +429,35 @@ internal class CommitCrimeParser : TransactionParserPart {
}
}
internal class MissionsParser : TransactionParserPart {
public void Parse(Entry entry, TransactionParserContext context, TransactionList transactions) {
MissionsEntry? missions = entry as MissionsEntry;
if (missions == null) {
return;
}
if (context.CurrentSystem == null || context.CurrentSystemAddress == null) {
transactions.AddIncomplete(new MissionCompleted(),
"Could not determine current location on Missions event.",
entry
);
return;
}
foreach (Mission mission in missions.Active) {
try {
context.MissionAccepted(mission);
} catch (Exception exception) {
transactions.AddIncomplete(new MissionCompleted(),
exception.Message,
entry
);
}
}
}
}
internal class MissionAcceptedParser : TransactionParserPart {
public void Parse(Entry e, TransactionParserContext context, TransactionList transactions) {
MissionAcceptedEntry? entry = e as MissionAcceptedEntry;
@ -453,13 +491,13 @@ internal class MissionCompletedParser : TransactionParserPart {
throw new NotImplementedException();
}
MissionAcceptedEntry? accepted = null;
Mission? mission = null;
Location? accepted_location = null;
string? target_faction_name = entry.Mission.TargetFaction;
string? source_faction_name = entry.Mission.Faction;
// We did not find when the mission was accepted.
if (!context.AcceptedMissions.TryGetValue(entry.Mission.MissionID, out accepted)) {
if (!context.AcceptedMissions.TryGetValue(entry.Mission.MissionID, out mission)) {
transactions.AddIncomplete(new MissionCompleted(),
String.Format("Mission acceptance for mission id {0} was not found",
entry.Mission.MissionID), e);
@ -529,7 +567,7 @@ internal class MissionCompletedParser : TransactionParserPart {
// for the source system. So we make a full mission completed entry.
transactions.Add(new MissionCompleted() {
CompletedEntry = entry,
AcceptedEntry = accepted,
Mission = mission,
System = accepted_location.StarSystem,
Faction = source_faction_name,
SystemAddress = accepted_location.SystemAddress,
@ -543,7 +581,7 @@ internal class MissionCompletedParser : TransactionParserPart {
// differs. Sometimes missions go to different systems but to
// the same faction.
transactions.Add(new InfluenceSupport() {
AcceptedEntry = accepted,
Mission = mission,
Faction = faction,
Influence = influences.Value,
System = system,
@ -559,7 +597,7 @@ internal class MissionCompletedParser : TransactionParserPart {
internal class MissionFailedParser : TransactionParserPart {
public void Parse(Entry e, TransactionParserContext context, TransactionList transactions) {
MissionAcceptedEntry? accepted = null;
Mission? mission = null;
Location? accepted_location = null;
string? accepted_system = null;
@ -572,14 +610,14 @@ internal class MissionFailedParser : TransactionParserPart {
throw new InvalidJournalEntryException("No mission specified in mission failure");
}
if (!context.AcceptedMissions.TryGetValue(entry.Mission.MissionID, out accepted)) {
if (!context.AcceptedMissions.TryGetValue(entry.Mission.MissionID, out mission)) {
transactions.AddIncomplete(new MissionFailed(),
"Mission acceptance was not found", e
);
return;
}
if (!context.AcceptedMissionLocation.TryGetValue(entry.Mission.MissionID, out accepted_location)) {
if (!context.AcceptedMissionLocation.TryGetValue(mission.MissionID, out accepted_location)) {
transactions.AddIncomplete(new MissionFailed(),
"Unable to figure out where failed mission was accepted", e
);
@ -593,10 +631,9 @@ internal class MissionFailedParser : TransactionParserPart {
return;
}
transactions.Add(new MissionFailed() {
Accepted = accepted,
Faction = accepted.Mission?.Faction,
Failed = entry,
transactions.Add(new MissionFailed(entry) {
Faction = mission?.Faction,
Mission = mission,
Station = accepted_location.Station,
System = accepted_location.StarSystem,
SystemAddress = accepted_location.SystemAddress,
@ -931,6 +968,7 @@ public class TransactionParser {
{ Events.MissionAccepted, new MissionAcceptedParser() },
{ Events.MissionCompleted, new MissionCompletedParser() },
{ Events.MissionFailed, new MissionFailedParser() },
{ Events.Missions, new MissionsParser() },
{ Events.MultiSellExplorationData, new MultiSellExplorationDataParser() },
{ Events.ReceiveText, new ReceiveTextParser() },
{ Events.RedeemVoucher, new RedeemVoucherParser() },

View File

@ -1,14 +1,4 @@
using EDPlayerJournal.BGS;
using static System.Runtime.InteropServices.JavaScript.JSType;
using System.Collections.ObjectModel;
using System.Diagnostics.Metrics;
using System.Net.NetworkInformation;
using System.Numerics;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System;
namespace EDPlayerJournal;
namespace EDPlayerJournal;
public class EnglishMissionNames {
public static Dictionary<string, string> MissionNames { get; } = new Dictionary<string, string>() {
@ -61,12 +51,16 @@ public class EnglishMissionNames {
{"Mission_MassacreWing_name", "Massacre (Wing)"},
{"Mission_OnFoot_Assassination_MB_name", "On Foot Assassination"},
{"Mission_OnFoot_AssassinationIllegal_MB_name", "On Foot Assassination (Illegal)"},
{"Mission_OnFoot_AssassinationIllegal_NCD_MB_name", "On Foot Assassination (Illegal)" },
{"Mission_OnFoot_Collect_Contact_MB_name", "On Foot Collect"},
{"Mission_OnFoot_Collect_MB_name", "On Foot Collection"},
{"Mission_OnFoot_Delivery_Contact_MB_name", "On Foot Delivery (Contact)"},
{"Mission_OnFoot_Hack_Upload_Covert_MB_name", "On Foot Hack (Covert Upload)"},
{"Mission_OnFoot_Hack_Upload_MB_name", "On Foot Hack (Upload)"},
{"Mission_OnFoot_Heist_MB_name", "On Foot Heist" },
{"Mission_OnFoot_Heist_POI_MB_name", "On Foot Heist (POI)"},
{"Mission_OnFoot_Massacre_MB_name", "On Foot Massacre" },
{"Mission_OnFoot_MassacreIllegal_MB_name", "On Foot Massacre (Illegal)" },
{"Mission_OnFoot_Onslaught_MB_name", "On Foot Onslaught"},
{"Mission_OnFoot_Onslaught_Offline_MB_name", "On Foot Onslaught (Offline)"},
{"Mission_OnFoot_ProductionHeist_Covert_MB_name", "On Foot Production Heist (Covert)"},
@ -93,14 +87,14 @@ public class EnglishMissionNames {
{"MISSION_Scan_name", "Scan"},
{"Mission_Sightseeing_Criminal_FAMINE_name", "Sightseeing (Criminal) (Famine)"},
{"Mission_Sightseeing_name", "Sightseeing"},
{"Mission_TW_Massacre_Basilisk_Plural_name", "Kill Basilisk" },
{"Mission_TW_Massacre_Basilisk_Singular_name", "Kill Basilisk" },
{"Mission_TW_Massacre_Cyclops_Plural_name", "Kill Cyclops" },
{"Mission_TW_Massacre_Cyclops_Singular_name", "Kill Cyclops" },
{"Mission_TW_Massacre_Scout_Plural_name", "Kill Scouts (Wing)" },
{"Mission_TW_PassengerEvacuation_Burning_name", "Passenger Evacuation (Significant Damage)" },
{"Mission_TW_PassengerEvacuation_UnderAttack_name", "Passenger Evacuation (Thargoid Invasion)" },
{"Mission_TW_Rescue_UnderAttack_name", "Rescue (Thargoid Attack)" },
{"Mission_TW_Massacre_Cyclops_Singular_name", "Kill Cyclops" },
{"Mission_TW_Massacre_Basilisk_Singular_name", "Kill Basilisk" },
{"Mission_TW_Massacre_Cyclops_Plural_name", "Kill Cyclops" },
{"Mission_TW_Massacre_Basilisk_Plural_name", "Kill Basilisk" },
};
public static string? Translate(string name) {

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>net7.0-windows</TargetFramework>
<OutputType>WinExe</OutputType>
<Version>0.2.4</Version>
<Version>0.2.5</Version>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<UseWindowsForms>true</UseWindowsForms>
<UseWPF>true</UseWPF>

View File

@ -14,13 +14,23 @@ public class FailedMissionFormat : LogFormatter {
return "";
}
foreach (MissionFailed failed in missions) {
foreach (var failed in missions) {
MissionFailedEntry f = failed.Failed;
builder.AppendFormat("Failed {0} mission(s) \"{1}\" targeting {2}\n",
failed.Amount,
string.IsNullOrEmpty(f.Mission.LocalisedName) ? f.Mission.Name : f.Mission.LocalisedName,
failed.Faction
);
string name;
if (!string.IsNullOrEmpty(f.Mission.FriendlyName)) {
name = f.Mission.FriendlyName;
} else if (!string.IsNullOrEmpty(f.Mission.LocalisedName)) {
name = f.Mission.LocalisedName;
} else {
name = f.Mission.Name;
}
if (!string.IsNullOrEmpty(failed.Faction)) {
builder.AppendFormat("Failed mission \"{0}\" targeting {1}\n", name, failed.Faction);
} else {
builder.AppendFormat("Failed mission \"{0}\"\n", name);
}
}
return builder.ToString().Trim();

View File

@ -1,5 +1,10 @@
# EliteBGS changelog
## 0.2.5 on ??.12.2022
* Repaired mission fails.
* Added support for Missions entry.
## 0.2.4 on 18.12.2022
* Fixed bug with organic data.