add a few comments to the code for explanation

This commit is contained in:
Florian Stinglmayr 2021-07-09 11:39:09 +02:00
parent 0346b8e7e7
commit fca1e607ec
2 changed files with 17 additions and 1 deletions

View File

@ -66,20 +66,30 @@ namespace NonaBGS.BGS {
*/ */
current_station = (e as DockedEntry).StationName; current_station = (e as DockedEntry).StationName;
} else if (e.Is(Events.FSDJump)) { } else if (e.Is(Events.FSDJump)) {
/* Gleem current system and controlling faction from this message.
*/
current_system = (e as FSDJumpEntry).StarSystem; current_system = (e as FSDJumpEntry).StarSystem;
controlling_faction = (e as FSDJumpEntry).SystemFaction; controlling_faction = (e as FSDJumpEntry).SystemFaction;
} else if (e.Is(Events.MissionCompleted)) { } else if (e.Is(Events.MissionCompleted)) {
var completed = e as MissionCompletedEntry; var completed = e as MissionCompletedEntry;
entry = new MissionCompleted(completed, current_system, current_station); entry = new MissionCompleted(completed, current_system, current_station);
if (completed.HumanReadableNameWasGenerated) { if (completed.HumanReadableNameWasGenerated) {
/* If the human readable name was generated, we send a log message. Because the
* generated names all sort of suck, we should have more human readable names in
* in the lookup dictionary.
*/
OnLog?.Invoke("Human readable name for mission \"" + OnLog?.Invoke("Human readable name for mission \"" +
completed.Name + completed.Name +
"\" was generated, please report this."); "\" was generated, please report this.");
} }
} else if (e.Is(Events.MultiSellExplorationData)) { } else if (e.Is(Events.MultiSellExplorationData)) {
/* For multi-sell-exploraton-data only the controlling faction of the station sold to matters.
*/
entry = new Cartographics(e as MultiSellExplorationDataEntry, current_system, current_station); entry = new Cartographics(e as MultiSellExplorationDataEntry, current_system, current_station);
entry.Faction = controlling_faction; entry.Faction = controlling_faction;
} else if (e.Is(Events.RedeemVoucher)) { } else if (e.Is(Events.RedeemVoucher)) {
/* Same for selling combat vouchers. Only the current controlling faction matters here.
*/
entry = new Vouchers(); entry = new Vouchers();
entry.Entries.Add(e); entry.Entries.Add(e);
entry.System = current_system; entry.System = current_system;
@ -94,6 +104,8 @@ namespace NonaBGS.BGS {
continue; continue;
} }
/* Find all objectives that generally match.
*/
var matches = objectives var matches = objectives
.Where(x => x.Matches(entry) > 0) .Where(x => x.Matches(entry) > 0)
.OrderBy(x => x.Matches(entry)) .OrderBy(x => x.Matches(entry))
@ -102,6 +114,8 @@ namespace NonaBGS.BGS {
continue; continue;
} }
/* Then select the one that matches the most.
*/
var objective = matches var objective = matches
.OrderBy(x => x.Matches(entry)) .OrderBy(x => x.Matches(entry))
.Reverse() .Reverse()

View File

@ -16,7 +16,9 @@ namespace NonaBGS.Journal {
private int count = 0; private int count = 0;
private int donated = 0; private int donated = 0;
private readonly Dictionary<string, string> humanreadable = new Dictionary<string, string> { /* TODO: make this a file at some point for easier editing.
*/
private static readonly Dictionary<string, string> humanreadable = new Dictionary<string, string> {
{ "Mission_AltruismCredits_name", "Donate Credits" }, { "Mission_AltruismCredits_name", "Donate Credits" },
{ "Mission_Collect_name", "Collect" }, { "Mission_Collect_name", "Collect" },
{ "Mission_Courier_Elections_name", "Courier (Elections)" }, { "Mission_Courier_Elections_name", "Courier (Elections)" },