# EliteBGS

This tool is meant to help people contributing to the BGS effort to create BGS reports.
The tool allows you to configure BGS objectives, and will then parse your player journal
for tasks you completed relating to that BGS objective. Once the JSON player journal has
been parsed, you may then generate a BGS report you can copy/paste into Discord.

Source code is available [here](https://git.aror.org/florian/elitebgs).

Binary downloads can be found here: [https://bgs.n0la.org/](https://bgs.n0la.org/).

## How To

Press "Parse Journal", which will check your Elite Dangerous player journal for completed
missions. Currently the tool recognises the following completed tasks:

* Buying of cargo from stations (new in Update 10)
* Completed missions
* Failed missions
* Murders
* Search and Rescue contributions
* Selling cartography data
* Selling of cargo to stations
* Selling of micro resources (Odyssey only)
* Selling of organic data (Odyssey only)
* Vouchers, including bounty vouchers, combat bonds, and settlement vouchers (aka intel packages)
* Thargoid kills
* Combat zones (experimental)

Combat zone detection is highly wonky at this time. There is no direct event for detecting
combat zones, and so the tool makes a few assumptions and goes from there. If you disembark
it will assume on foot combat zones, and if you don't, it will assume a ship CZ. This
detection can, and will be wrong, so caution is advised.

Vouchers help the faction that is listed for them. If said faction is not present in the
current system, then there is no BGS impact. So the tool looks for all system factions, and
makes sure that your vouchers actually have a BGS impact, otherwise it won't list them.

Selling cargo attempts to discern the profit and/or loss, which is helpful to gauge BGS
impact. But the player journal does not tell the amount of profit in the sell message.
So the tool looks for a buy a message related to the same commodity, and calculates loss
and/or profit from that. If the buy of the commodity is not within the time and date range,
or some other shenanigans happen that the tool does not yet support, the profit/loss could 
be wrong. You can use the "Adjust Trade Profit" button to manually adjust the trade profit,
or you could simply edit the discord log manually.

Please note that cartography data, and micro resources only help the controlling faction
of a station. The tool is clever enough to exclude these if the station you turn them in at, is not
controlled by the faction you specified in the objective.

Some missions may show up having zero influence for the given faction. This happens if you do
missions for a faction which is currently in an election state. You do not gain influence for
the faction so the influence reads as zero. But you contribute towards the election, so the
missions are selected anyway.

There is no entry in the journal if you win a combat zone. So you have to add those manually. Select
an objective for which you wish to log a combat zone. The faction in the objective, must be the
faction you fought for in the combat zone. Then click "Add Combat Zone Win". Select type,
either "On Foot" for Odyssey, or "Ship" for regular ones. Then select the grade (low, medium or
high), and how many you won. Then press "Accept". Select "Cancel" to abort. You can of course remove
the combat zone entries by selecting them, and pressing "DEL".

If you deliberately fail a mission (to log negative INF towards a faction), the tool cannot detect
it, if the day you accepted the mission is outside of the given date range. It needs the journal
entry where you accept the mission to connect the mission to a faction, system and station. The tool
will warn you if this happens, with a message in the error log in the fourth tab.

When committing murder, the journal entry contains the faction information of the faction that gave
you the bounty. And not the faction of the victim. The tool will look for an event in which you
scanned your victim, and gleem the victim's faction from that. If you did not scan your victim, then
sadly the tool cannot connect the victim's faction to the victim.

![Main Window with entries](main-page.png)

The window will then list all the journal entries it has found, and group them by objectives. You
can select which objectives you wish to report, by using the checkmarks.

You can exclude a specific entry within an objective by deselecting the checkbox next to them.
This way said entry will not appear in the final log. You can also remove individual entries
(if you think the tool detected something you thought was wrong), by selecting the entry,
and pressing the "DEL" key. 

Once you are satisfied with the result, you can copy and paste the final report to the discord
server of your choice. Before you copy/paste it into the discord of your squadron, you should
check the log. You can of course also edit it, either if something is wrong because the tool
missed something, or you just wish to add a note the report itself.

If you wish to regenerate the discord log, simply click "Generate Log".

## Known Issues and Bugs

### Settlement Vouchers

Settlement vouchers (aka Intel Packages) help every faction aligned with the given superpower.
So if you turn in an Imperial intel package on an imperial station, all factions aligned with
the Empire will gain a bit of INF boost. The tool currently cannot handle that. All intel packages
are displayed instead.

### Bugged bounty vouchers

Sometimes bounty vouchers are not properly recognised. This is a bug in the player journal, where
the faction information is not properly written out in the journal:

```
{ 
  "timestamp":"2021-10-07T14:57:50Z", "event":"RedeemVoucher", 
  "Type":"bounty", "Amount":20750, 
  "Factions":[ { "Faction":"", "Amount":500 }, { "Faction":"", "Amount":20250 }]
}
```

Since the tool does not know for which faction these bounties were redeemed for, it cannot assign
it to an objective.

### Combat Zones

The player journal currently does not make an entry when you win or lose a combat zone. This is a
an ommission from FDev:

* [https://issues.frontierstore.net/issue-detail/43509](https://issues.frontierstore.net/issue-detail/43509)

Please upvote the issue to get it fixed. Until then, you have to add combat zone wins manually.

### On-Foot NPC givers

Up until update 13 missions accepted from NPCs in Odyssey concourses do not get a player journal entry.
This has been fixed in update 13. Any on foot missions from NPCs accepted before update 13, do not have
an entry in the player journal.

### Failed vs. Abandoned Missions

The tool also currently cannot differentiate between missions you have abandoned in the transaction
tab before it was completed, and those that you have failed - either delibaretly or by time-out. So
it will find and add them all, and you simply can remove those that you have abandoned manually.

### Influence given to empty/non-existent faction

Sometimes the log will state that it gave positive or negative influence to a faction, but the
faction name is empty:

```
 "FactionEffects": [
    {
      "Faction": "",
      "Effects": [
        {
          "Effect": "$MISSIONUTIL_Interaction_Summary_EP_down;",
          "Effect_Localised": "The economic status of $#MinorFaction; has declined in the $#System; system.",
          "Trend": "DownBad"
        }
      ],
      "Influence": [
        {
          "SystemAddress": 251012319587,
          "Trend": "DownBad",
          "Influence": "+"
        }
      ],
      "ReputationTrend": "DownBad",
      "Reputation": "+"
    }
]
```
This happens for example if you do a scan/heist mission from a surface POI, but no one owns said
surface POI. Randomly generated surface POIs sometimes have no owner, and said non-existant owner
then gets the negative influence.

### Mission Completed but no one gains influence

Sometimes missions are completed but no one gains any influence:

```
{
  "timestamp": "2022-02-25T21:30:45Z",
  "event": "MissionCompleted",
  "Faction": "Social LHS 6103 Confederation",
  "Name": "Mission_Courier_Elections_name",
  "MissionID": 850025233,
  "TargetFaction": "Delphin Blue Federal PLC",
  "DestinationSystem": "Delphin",
  "DestinationStation": "Aristotle Orbital",
  "Reward": 122300,
  "FactionEffects": [
    {
      "Faction": "Social LHS 6103 Confederation",
      "Effects": [
        {
          "Effect": "$MISSIONUTIL_Interaction_Summary_EP_up;",
          "Effect_Localised": "The economic status of $#MinorFaction; has improved in the $#System; system.",
          "Trend": "UpGood"
        }
      ],
      "Influence": [],
      "ReputationTrend": "UpGood",
      "Reputation": "+"
    },
    {
      "Faction": "Delphin Blue Federal PLC",
      "Effects": [],
      "Influence": [],
      "ReputationTrend": "UpGood",
      "Reputation": "+"
    }
  ]
}
```

Here the is known that at the time of completion the Confederation was in an Election and could not
have gained any influence regardless. It is unclear whether this also holds true for Delphin Blue
Federal PLC. So to be save, the tool assumes that if no influence was gained for the source faction,
it still has to make an entry for the source system. The same applies for the target faction: if no
influence is gained for the target faction, still add an entry for the target faction in the missions
target system.

Since it is not possible to differentiate between missions that give no influence no matter what, and
no influence gained because of an election, we have to assume it *gave* influence and let the user
decide whether it was because of an election, or not.

Future tool versions should probably take faction states into account in such matters.

## Nothing's Perfect

The tool itself is still a work in progress, and it might miss something. If you think the tool
missed a task you have done, please contact `Hekateh` on the Elite Dangerous community discord. 
It would be helpful if you included the JSON player journal. This player journal can be found here:

```
%userprofile%\saved Games\Frontier Developments\Elite Dangerous\
```

## Build Dependencies

The project also requires `Ookii.Dialogs.WPF` controls, which contains the auto complete text box.

And of course, `Newtonsoft.Json` as the JSON parser.