handle missions were the alternate influence gain goes towards the same faction but in a different system
This commit is contained in:
@@ -17,6 +17,7 @@ namespace EliteBGS.BGS {
|
||||
public List<Entry> Entries => entries;
|
||||
public string Station { get; set; }
|
||||
public string System { get; set; }
|
||||
public ulong SystemAddress { get; set; }
|
||||
public string Faction { get; set; }
|
||||
/// <summary>
|
||||
/// Whether this entry was manually added. Manually added entries are not deleted
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace EliteBGS.BGS {
|
||||
}
|
||||
StringBuilder builder = new StringBuilder();
|
||||
var entry = Entries[0] as MissionCompletedEntry;
|
||||
var influence = entry.GetInfluenceForFaction(Faction);
|
||||
var influence = entry.GetInfluenceForFaction(Faction, SystemAddress);
|
||||
|
||||
builder.AppendFormat("{0}", MissionName);
|
||||
if (influence != "") {
|
||||
|
||||
@@ -62,8 +62,10 @@ namespace EliteBGS.BGS {
|
||||
List<Entry> relevant = entries.Where(x => IsRelevant(x)).ToList();
|
||||
Dictionary<int, MissionAcceptedEntry> acceptedMissions = new Dictionary<int, MissionAcceptedEntry>();
|
||||
Dictionary<string, long> buyCost = new Dictionary<string, long>();
|
||||
Dictionary<ulong, string> systems = new Dictionary<ulong, string>();
|
||||
|
||||
string current_system = null;
|
||||
ulong current_system_address = 0;
|
||||
string current_station = null;
|
||||
string controlling_faction = null;
|
||||
|
||||
@@ -80,17 +82,34 @@ namespace EliteBGS.BGS {
|
||||
current_station = docked.StationName;
|
||||
current_system = docked.StarSystem;
|
||||
controlling_faction = docked.StationFaction;
|
||||
current_system_address = docked.SystemAddress;
|
||||
|
||||
if (!systems.ContainsKey(docked.SystemAddress)) {
|
||||
systems.Add(docked.SystemAddress, docked.StarSystem);
|
||||
}
|
||||
} else if (e.Is(Events.FSDJump)) {
|
||||
/* Gleem current system and controlling faction from this message.
|
||||
*/
|
||||
current_system = (e as FSDJumpEntry).StarSystem;
|
||||
controlling_faction = (e as FSDJumpEntry).SystemFaction;
|
||||
FSDJumpEntry fsd = e as FSDJumpEntry;
|
||||
current_system_address = fsd.SystemAddress;
|
||||
current_system = fsd.StarSystem;
|
||||
controlling_faction = fsd.SystemFaction;
|
||||
|
||||
if (!systems.ContainsKey(fsd.SystemAddress)) {
|
||||
systems.Add(fsd.SystemAddress, fsd.StarSystem);
|
||||
}
|
||||
} else if (e.Is(Events.Location)) {
|
||||
/* Get current system, faction name and station from Location message
|
||||
*/
|
||||
LocationEntry location = e as LocationEntry;
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -114,7 +133,8 @@ namespace EliteBGS.BGS {
|
||||
var completed = e as MissionCompletedEntry;
|
||||
results.Add(new MissionCompleted(completed) {
|
||||
System = current_system,
|
||||
Station = current_station
|
||||
Station = current_station,
|
||||
SystemAddress = current_system_address,
|
||||
});
|
||||
if (completed.HumanReadableNameWasGenerated) {
|
||||
/* If the human readable name was generated, we send a log message. Because the
|
||||
@@ -126,22 +146,27 @@ namespace EliteBGS.BGS {
|
||||
"\" was generated, please report this.");
|
||||
}
|
||||
|
||||
foreach (string other in completed.AffectedFactions.Where(x => !x.Equals(results[0].Faction))) {
|
||||
string faction = other;
|
||||
string influence = completed.GetInfluenceForFaction(faction);
|
||||
|
||||
/* ignore empty factions which can happen
|
||||
* I assume that this denotes that you are losing REP with a superpower
|
||||
*/
|
||||
if (string.IsNullOrEmpty(faction)) {
|
||||
continue;
|
||||
if (completed.Influences.Count > 1) {
|
||||
foreach (var other in completed.Influences) {
|
||||
string faction = other.Key;
|
||||
if (string.IsNullOrEmpty(faction)) {
|
||||
continue;
|
||||
}
|
||||
foreach (var influences in other.Value) {
|
||||
ulong system_address = influences.Key;
|
||||
if (!faction.Equals(results[0].Faction) ||
|
||||
(faction.Equals(results[0].Faction) && system_address != current_system_address)) {
|
||||
string system = systems.TryGetValue(system_address, out string sys) ? sys : "";
|
||||
results.Add(new InfluenceSupport() {
|
||||
Faction = faction,
|
||||
Influence = influences.Value,
|
||||
System = system,
|
||||
SystemAddress = system_address,
|
||||
RelevantMission = results[0] as MissionCompleted
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
results.Add(new InfluenceSupport() {
|
||||
Faction = faction,
|
||||
Influence = influence,
|
||||
RelevantMission = results[0] as MissionCompleted
|
||||
});
|
||||
}
|
||||
} else if (e.Is(Events.MissionAccepted)) {
|
||||
MissionAcceptedEntry accepted = e as MissionAcceptedEntry;
|
||||
|
||||
Reference in New Issue
Block a user