change abandoned and failed towards newest Mission
This commit is contained in:
parent
1d19a8f73c
commit
ce54430137
@ -28,8 +28,9 @@ public class MissionFailed : Transaction {
|
||||
}
|
||||
|
||||
/* if it is the same mission name, the same faction and the same system,
|
||||
* collate mission failures together */
|
||||
if (failed.Failed?.HumanReadableName == Failed?.HumanReadableName &&
|
||||
* collate mission failures together
|
||||
*/
|
||||
if (string.Compare(failed.Failed?.Mission?.Name, Failed?.Mission?.Name) == 0 &&
|
||||
failed.Faction == Faction &&
|
||||
failed.System == System) {
|
||||
return 0;
|
||||
@ -50,7 +51,8 @@ public class MissionFailed : Transaction {
|
||||
|
||||
builder.AppendFormat("{0}x Mission failed: \"{1}\"",
|
||||
Amount,
|
||||
Failed.HumanReadableName != null ? Failed.HumanReadableName : Failed.Name
|
||||
Failed?.Mission?.LocalisedName != null ?
|
||||
Failed?.Mission?.LocalisedName : Failed?.Mission?.Name
|
||||
);
|
||||
|
||||
return builder.ToString();
|
||||
|
@ -423,11 +423,11 @@ public class Report {
|
||||
string? accepted_system;
|
||||
string? accepted_station;
|
||||
|
||||
if (failed == null) {
|
||||
if (failed == null || failed.Mission == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!acceptedMissions.TryGetValue(failed.MissionID, out accepted)) {
|
||||
if (!acceptedMissions.TryGetValue(failed.Mission.MissionID, out accepted)) {
|
||||
OnLog?.Invoke("A mission failed which wasn't accepted in the given time frame. " +
|
||||
"Please adjust start date to when the mission was accepted to include it in the list.");
|
||||
continue;
|
||||
@ -437,7 +437,7 @@ public class Report {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!acceptedSystems.TryGetValue(failed.MissionID, out accepted_address)) {
|
||||
if (!acceptedSystems.TryGetValue(failed.Mission.MissionID, out accepted_address)) {
|
||||
OnLog?.Invoke(string.Format(
|
||||
"Unable to figure out in which system mission \"{0}\" was accepted.", accepted.Mission.Name
|
||||
));
|
||||
@ -451,7 +451,7 @@ public class Report {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!acceptedStations.TryGetValue(failed.MissionID, out accepted_station)) {
|
||||
if (!acceptedStations.TryGetValue(failed.Mission.MissionID, out accepted_station)) {
|
||||
OnLog?.Invoke(string.Format(
|
||||
"Unable to figure out in which station mission \"{0}\" was accepted.", accepted.Mission.Name
|
||||
));
|
||||
@ -466,12 +466,6 @@ public class Report {
|
||||
SystemAddress = accepted_address,
|
||||
});
|
||||
|
||||
if (failed.HumanReadableName == null) {
|
||||
OnLog?.Invoke("Human readable name for mission \"" +
|
||||
failed.Name +
|
||||
"\" was not recognised");
|
||||
}
|
||||
|
||||
/* Mission failed should be collated if they are in the same system/station
|
||||
*/
|
||||
collate = true;
|
||||
|
@ -389,14 +389,18 @@ internal class MissionFailedParser : TransactionParserPart {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
if (!context.AcceptedMissions.TryGetValue(entry.MissionID, out accepted)) {
|
||||
if (entry.Mission == null) {
|
||||
throw new InvalidJournalEntryException("No mission specified in mission failure");
|
||||
}
|
||||
|
||||
if (!context.AcceptedMissions.TryGetValue(entry.Mission.MissionID, out accepted)) {
|
||||
transactions.AddIncomplete(new MissionFailed(),
|
||||
"Mission acceptance was not found"
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!context.AcceptedMissionLocation.TryGetValue(entry.MissionID, out accepted_location)) {
|
||||
if (!context.AcceptedMissionLocation.TryGetValue(entry.Mission.MissionID, out accepted_location)) {
|
||||
transactions.AddIncomplete(new MissionFailed(),
|
||||
"Unable to figure out where failed mission was accepted"
|
||||
);
|
||||
|
@ -1,7 +1,9 @@
|
||||
namespace EDPlayerJournal.Entries;
|
||||
|
||||
public class MissionAbandonedEntry : Entry {
|
||||
public ulong MissionID { get; set; }
|
||||
public Mission? Mission { get; set; }
|
||||
|
||||
protected override void Initialise() {
|
||||
MissionID = JSON.Value<ulong?>("MissionID") ?? 0;
|
||||
Mission = Mission.FromMissionAbandoned(JSON);
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +1,15 @@
|
||||
namespace EDPlayerJournal.Entries;
|
||||
namespace EDPlayerJournal.Entries;
|
||||
|
||||
public class MissionFailedEntry : Entry {
|
||||
public string? Name { get; set; }
|
||||
public ulong MissionID { get; set; }
|
||||
/// <summary>
|
||||
/// Fine imposed for mission failure.
|
||||
/// </summary>
|
||||
public int Fine { get; set; }
|
||||
|
||||
public string? HumanReadableName {
|
||||
get {
|
||||
if (Name == null) return null;
|
||||
return HumanReadableMissionName.MakeHumanReadableName(Name);
|
||||
}
|
||||
}
|
||||
public Mission? Mission { get; set; }
|
||||
|
||||
protected override void Initialise() {
|
||||
Name = JSON.Value<string>("Name");
|
||||
MissionID = JSON.Value<ulong?>("MissionID") ?? 0;
|
||||
Mission = Mission.FromMissionFailed(JSON);
|
||||
Fine = JSON.Value<int?>("Fine") ?? 0;
|
||||
}
|
||||
}
|
||||
|
@ -186,4 +186,16 @@ public class Mission : IComparable<Mission> {
|
||||
public static Mission FromMissionAccepted(JObject o) {
|
||||
return FromJSON(o);
|
||||
}
|
||||
|
||||
public static Mission FromMissionAbandoned(JObject o) {
|
||||
return FromJSON(o);
|
||||
}
|
||||
|
||||
public static Mission FromMissionFailed(JObject o) {
|
||||
return FromJSON(o);
|
||||
}
|
||||
|
||||
public static Mission FromMissionCompleted(JObject o) {
|
||||
return FromJSON(o);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user