implement failed missions which give negative INF
This commit is contained in:
parent
ee9f7ea4cd
commit
6dda7cfde4
@ -103,6 +103,24 @@ namespace EliteBGS.BGS {
|
|||||||
return builder.ToString();
|
return builder.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string BuildFailedMissions(Objective objective) {
|
||||||
|
MissionFailed[] missions = objective.LogEntries.OfType<MissionFailed>().ToArray();
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
|
if (missions.Length <= 0) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (MissionFailed failed in missions) {
|
||||||
|
MissionFailedEntry f = failed.Failed;
|
||||||
|
builder.AppendFormat("Failed mission \"{0}\"\n",
|
||||||
|
f.HumanReadableName == null ? f.Name : f.HumanReadableName
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return builder.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
private string BuildMissionList(Objective objective) {
|
private string BuildMissionList(Objective objective) {
|
||||||
Dictionary<string, Dictionary<string, int>> collated = new Dictionary<string, Dictionary<string, int>>();
|
Dictionary<string, Dictionary<string, int>> collated = new Dictionary<string, Dictionary<string, int>>();
|
||||||
StringBuilder output = new StringBuilder();
|
StringBuilder output = new StringBuilder();
|
||||||
@ -190,6 +208,9 @@ namespace EliteBGS.BGS {
|
|||||||
var missions = BuildMissionList(objective);
|
var missions = BuildMissionList(objective);
|
||||||
entries.Append(missions);
|
entries.Append(missions);
|
||||||
|
|
||||||
|
var failed = BuildFailedMissions(objective);
|
||||||
|
entries.Append(failed);
|
||||||
|
|
||||||
var vouchers = BuildVouchers(objective);
|
var vouchers = BuildVouchers(objective);
|
||||||
entries.Append(vouchers);
|
entries.Append(vouchers);
|
||||||
|
|
||||||
|
@ -3,11 +3,9 @@ using EDJournal;
|
|||||||
|
|
||||||
namespace EliteBGS.BGS {
|
namespace EliteBGS.BGS {
|
||||||
public class MissionCompleted : LogEntry {
|
public class MissionCompleted : LogEntry {
|
||||||
public MissionCompleted(MissionCompletedEntry e, string system, string station) {
|
public MissionCompleted(MissionCompletedEntry e) {
|
||||||
this.Entries.Add(e);
|
Entries.Add(e);
|
||||||
this.Faction = e.JSON.GetValue("Faction").ToString();
|
Faction = e.JSON.GetValue("Faction").ToString();
|
||||||
this.System = system;
|
|
||||||
this.Station = station;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string MissionName {
|
public string MissionName {
|
||||||
|
28
BGS/MissionFailed.cs
Normal file
28
BGS/MissionFailed.cs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
using System.Text;
|
||||||
|
using EDJournal;
|
||||||
|
|
||||||
|
namespace EliteBGS.BGS {
|
||||||
|
public class MissionFailed : LogEntry {
|
||||||
|
public MissionFailedEntry Failed { get; set; }
|
||||||
|
public MissionAcceptedEntry Accepted { get; set; }
|
||||||
|
|
||||||
|
public MissionFailed(MissionAcceptedEntry accepted) {
|
||||||
|
Accepted = accepted;
|
||||||
|
Faction = accepted.Faction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
|
if (Failed == null || Accepted == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.AppendFormat("Mission failed: \"{0}\"",
|
||||||
|
Failed.HumanReadableName != null ? Failed.HumanReadableName : Failed.Name
|
||||||
|
);
|
||||||
|
|
||||||
|
return builder.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -30,6 +30,8 @@ namespace EliteBGS.BGS {
|
|||||||
|
|
||||||
private bool IsRelevant(Entry e) {
|
private bool IsRelevant(Entry e) {
|
||||||
return e.Is(Events.MissionCompleted) ||
|
return e.Is(Events.MissionCompleted) ||
|
||||||
|
e.Is(Events.MissionFailed) ||
|
||||||
|
e.Is(Events.MissionAccepted) ||
|
||||||
e.Is(Events.Docked) ||
|
e.Is(Events.Docked) ||
|
||||||
e.Is(Events.FSDJump) ||
|
e.Is(Events.FSDJump) ||
|
||||||
e.Is(Events.MultiSellExplorationData) ||
|
e.Is(Events.MultiSellExplorationData) ||
|
||||||
@ -50,6 +52,8 @@ namespace EliteBGS.BGS {
|
|||||||
select log
|
select log
|
||||||
;
|
;
|
||||||
|
|
||||||
|
Dictionary<int, MissionAcceptedEntry> acceptedMissions = new Dictionary<int, MissionAcceptedEntry>();
|
||||||
|
|
||||||
string current_system = null;
|
string current_system = null;
|
||||||
string current_station = null;
|
string current_station = null;
|
||||||
string controlling_faction = null;
|
string controlling_faction = null;
|
||||||
@ -71,7 +75,7 @@ namespace EliteBGS.BGS {
|
|||||||
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) { System = current_system, Station = current_station };
|
||||||
if (completed.HumanReadableNameWasGenerated) {
|
if (completed.HumanReadableNameWasGenerated) {
|
||||||
/* If the human readable name was generated, we send a log message. Because the
|
/* 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
|
* generated names all sort of suck, we should have more human readable names in
|
||||||
@ -81,6 +85,22 @@ namespace EliteBGS.BGS {
|
|||||||
completed.Name +
|
completed.Name +
|
||||||
"\" was generated, please report this.");
|
"\" was generated, please report this.");
|
||||||
}
|
}
|
||||||
|
} else if (e.Is(Events.MissionAccepted)) {
|
||||||
|
MissionAcceptedEntry accepted = e as MissionAcceptedEntry;
|
||||||
|
acceptedMissions[accepted.MissionID] = accepted;
|
||||||
|
} else if (e.Is(Events.MissionFailed)) {
|
||||||
|
var failed = e as MissionFailedEntry;
|
||||||
|
var accepted = acceptedMissions[failed.MissionID];
|
||||||
|
if (accepted == null) {
|
||||||
|
OnLog?.Invoke("Mission failed that wasn't accepted, please adjust time frame.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
entry = new MissionFailed(accepted) { Failed = failed, System = current_system };
|
||||||
|
if (failed.HumanReadableName == null) {
|
||||||
|
OnLog?.Invoke("Human readable name for mission \"" +
|
||||||
|
failed.Name +
|
||||||
|
"\" was not recognised");
|
||||||
|
}
|
||||||
} 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.
|
/* For multi-sell-exploraton-data only the controlling faction of the station sold to matters.
|
||||||
*/
|
*/
|
||||||
|
@ -79,6 +79,7 @@
|
|||||||
</ApplicationDefinition>
|
</ApplicationDefinition>
|
||||||
<Compile Include="BGS\DiscordLogGenerator.cs" />
|
<Compile Include="BGS\DiscordLogGenerator.cs" />
|
||||||
<Compile Include="BGS\GenericDiscordLog.cs" />
|
<Compile Include="BGS\GenericDiscordLog.cs" />
|
||||||
|
<Compile Include="BGS\MissionFailed.cs" />
|
||||||
<Compile Include="BGS\NonaDiscordLog.cs" />
|
<Compile Include="BGS\NonaDiscordLog.cs" />
|
||||||
<Compile Include="BGS\SellCargo.cs" />
|
<Compile Include="BGS\SellCargo.cs" />
|
||||||
<Compile Include="BGS\SellMicroResources.cs" />
|
<Compile Include="BGS\SellMicroResources.cs" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user