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,
|
/* if it is the same mission name, the same faction and the same system,
|
||||||
* collate mission failures together */
|
* collate mission failures together
|
||||||
if (failed.Failed?.HumanReadableName == Failed?.HumanReadableName &&
|
*/
|
||||||
|
if (string.Compare(failed.Failed?.Mission?.Name, Failed?.Mission?.Name) == 0 &&
|
||||||
failed.Faction == Faction &&
|
failed.Faction == Faction &&
|
||||||
failed.System == System) {
|
failed.System == System) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -50,7 +51,8 @@ public class MissionFailed : Transaction {
|
|||||||
|
|
||||||
builder.AppendFormat("{0}x Mission failed: \"{1}\"",
|
builder.AppendFormat("{0}x Mission failed: \"{1}\"",
|
||||||
Amount,
|
Amount,
|
||||||
Failed.HumanReadableName != null ? Failed.HumanReadableName : Failed.Name
|
Failed?.Mission?.LocalisedName != null ?
|
||||||
|
Failed?.Mission?.LocalisedName : Failed?.Mission?.Name
|
||||||
);
|
);
|
||||||
|
|
||||||
return builder.ToString();
|
return builder.ToString();
|
||||||
|
@ -423,11 +423,11 @@ public class Report {
|
|||||||
string? accepted_system;
|
string? accepted_system;
|
||||||
string? accepted_station;
|
string? accepted_station;
|
||||||
|
|
||||||
if (failed == null) {
|
if (failed == null || failed.Mission == null) {
|
||||||
continue;
|
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. " +
|
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.");
|
"Please adjust start date to when the mission was accepted to include it in the list.");
|
||||||
continue;
|
continue;
|
||||||
@ -437,7 +437,7 @@ public class Report {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!acceptedSystems.TryGetValue(failed.MissionID, out accepted_address)) {
|
if (!acceptedSystems.TryGetValue(failed.Mission.MissionID, out accepted_address)) {
|
||||||
OnLog?.Invoke(string.Format(
|
OnLog?.Invoke(string.Format(
|
||||||
"Unable to figure out in which system mission \"{0}\" was accepted.", accepted.Mission.Name
|
"Unable to figure out in which system mission \"{0}\" was accepted.", accepted.Mission.Name
|
||||||
));
|
));
|
||||||
@ -451,7 +451,7 @@ public class Report {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!acceptedStations.TryGetValue(failed.MissionID, out accepted_station)) {
|
if (!acceptedStations.TryGetValue(failed.Mission.MissionID, out accepted_station)) {
|
||||||
OnLog?.Invoke(string.Format(
|
OnLog?.Invoke(string.Format(
|
||||||
"Unable to figure out in which station mission \"{0}\" was accepted.", accepted.Mission.Name
|
"Unable to figure out in which station mission \"{0}\" was accepted.", accepted.Mission.Name
|
||||||
));
|
));
|
||||||
@ -466,12 +466,6 @@ public class Report {
|
|||||||
SystemAddress = accepted_address,
|
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
|
/* Mission failed should be collated if they are in the same system/station
|
||||||
*/
|
*/
|
||||||
collate = true;
|
collate = true;
|
||||||
|
@ -389,14 +389,18 @@ internal class MissionFailedParser : TransactionParserPart {
|
|||||||
throw new NotImplementedException();
|
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(),
|
transactions.AddIncomplete(new MissionFailed(),
|
||||||
"Mission acceptance was not found"
|
"Mission acceptance was not found"
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!context.AcceptedMissionLocation.TryGetValue(entry.MissionID, out accepted_location)) {
|
if (!context.AcceptedMissionLocation.TryGetValue(entry.Mission.MissionID, out accepted_location)) {
|
||||||
transactions.AddIncomplete(new MissionFailed(),
|
transactions.AddIncomplete(new MissionFailed(),
|
||||||
"Unable to figure out where failed mission was accepted"
|
"Unable to figure out where failed mission was accepted"
|
||||||
);
|
);
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
namespace EDPlayerJournal.Entries;
|
namespace EDPlayerJournal.Entries;
|
||||||
|
|
||||||
public class MissionAbandonedEntry : Entry {
|
public class MissionAbandonedEntry : Entry {
|
||||||
public ulong MissionID { get; set; }
|
public Mission? Mission { get; set; }
|
||||||
|
|
||||||
protected override void Initialise() {
|
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 class MissionFailedEntry : Entry {
|
||||||
public string? Name { get; set; }
|
/// <summary>
|
||||||
public ulong MissionID { get; set; }
|
/// Fine imposed for mission failure.
|
||||||
|
/// </summary>
|
||||||
public int Fine { get; set; }
|
public int Fine { get; set; }
|
||||||
|
|
||||||
public string? HumanReadableName {
|
public Mission? Mission { get; set; }
|
||||||
get {
|
|
||||||
if (Name == null) return null;
|
|
||||||
return HumanReadableMissionName.MakeHumanReadableName(Name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Initialise() {
|
protected override void Initialise() {
|
||||||
Name = JSON.Value<string>("Name");
|
Mission = Mission.FromMissionFailed(JSON);
|
||||||
MissionID = JSON.Value<ulong?>("MissionID") ?? 0;
|
|
||||||
Fine = JSON.Value<int?>("Fine") ?? 0;
|
Fine = JSON.Value<int?>("Fine") ?? 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -186,4 +186,16 @@ public class Mission : IComparable<Mission> {
|
|||||||
public static Mission FromMissionAccepted(JObject o) {
|
public static Mission FromMissionAccepted(JObject o) {
|
||||||
return FromJSON(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