extract influence support for missions that affect more than one faction

This commit is contained in:
Florian Stinglmayr 2022-01-21 20:34:56 +01:00
parent ceaf8035e9
commit 8f40c1d75e
3 changed files with 36 additions and 0 deletions

24
BGS/InfluenceSupport.cs Normal file
View File

@ -0,0 +1,24 @@
using System.Text;
namespace EliteBGS.BGS {
/// <summary>
/// This class is used when a completed mission gives influence to another
/// faction as well. This happens, for example, when you deliver cargo from one
/// faction to another. Both sometimes gain influence.
/// </summary>
public class InfluenceSupport : LogEntry {
public string Influence { get; set; }
public MissionCompleted RelevantMission { get; set; }
public override string ToString() {
StringBuilder builder = new StringBuilder();
builder.AppendFormat("Influence gained from \"{0}\": \"{1}\"",
RelevantMission.MissionName,
string.IsNullOrEmpty(Influence) ? "NONE" : Influence
);
return builder.ToString();
}
}
}

View File

@ -107,6 +107,17 @@ namespace EliteBGS.BGS {
completed.Name +
"\" 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);
results.Add(new InfluenceSupport() {
Faction = faction,
Influence = influence,
RelevantMission = results[0] as MissionCompleted
});
}
} else if (e.Is(Events.MissionAccepted)) {
MissionAcceptedEntry accepted = e as MissionAcceptedEntry;
acceptedMissions[accepted.MissionID] = accepted;

View File

@ -82,6 +82,7 @@
</Compile>
<Compile Include="BGS\DiscordLogGenerator.cs" />
<Compile Include="BGS\GenericDiscordLog.cs" />
<Compile Include="BGS\InfluenceSupport.cs" />
<Compile Include="BGS\MissionFailed.cs" />
<Compile Include="BGS\NonaDiscordLog.cs" />
<Compile Include="BGS\SellCargo.cs" />