refactor missions a bit
This commit is contained in:
parent
ac3d1cd8b9
commit
8d72808fbf
@ -10,8 +10,17 @@ namespace EDPlayerJournal.BGS;
|
||||
/// </summary>
|
||||
public class InfluenceSupport : Transaction {
|
||||
public string Influence { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Relevant mission completed entry
|
||||
/// </summary>
|
||||
public MissionCompletedEntry? RelevantMission { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Mission accepted entry
|
||||
/// </summary>
|
||||
public MissionAcceptedEntry? AcceptedEntry { get; set; }
|
||||
|
||||
public override string CompletedAt {
|
||||
get {
|
||||
if (RelevantMission == null) {
|
||||
|
@ -1,50 +1,52 @@
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using EDPlayerJournal.Entries;
|
||||
|
||||
namespace EDPlayerJournal.BGS;
|
||||
|
||||
public class MissionCompleted : Transaction {
|
||||
public MissionCompletedEntry? CompletedEntry { get; set; }
|
||||
|
||||
public MissionAcceptedEntry? AcceptedEntry { get; set; }
|
||||
|
||||
public MissionCompleted() { }
|
||||
public MissionCompleted(MissionCompletedEntry e) {
|
||||
Entries.Add(e);
|
||||
|
||||
public override string CompletedAt {
|
||||
get {
|
||||
if (CompletedEntry == null) {
|
||||
return "";
|
||||
}
|
||||
return CompletedEntry.Timestamp.ToString("dd.MM.yyyy HH:mm UTC");
|
||||
}
|
||||
}
|
||||
|
||||
public string MissionName {
|
||||
get {
|
||||
MissionCompletedEntry? c = Entries[0] as MissionCompletedEntry;
|
||||
if (c == null || c.Mission == null) {
|
||||
if (CompletedEntry == null || CompletedEntry.Mission == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return c.Mission.FriendlyName;
|
||||
return CompletedEntry.Mission.FriendlyName;
|
||||
}
|
||||
}
|
||||
|
||||
public string Influence {
|
||||
get {
|
||||
MissionCompletedEntry? e = (Entries[0] as MissionCompletedEntry);
|
||||
|
||||
if (e == null || Faction == null || e.Mission == null) {
|
||||
if (CompletedEntry == null || Faction == null || CompletedEntry.Mission == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return (e.Mission.GetInfluenceForFaction(Faction, SystemAddress) ?? "");
|
||||
return (CompletedEntry.Mission.GetInfluenceForFaction(Faction, SystemAddress) ?? "");
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
if (Faction == null || Entries.Count <= 0) {
|
||||
if (Faction == null || CompletedEntry == null || CompletedEntry.Mission == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
var entry = Entries[0] as MissionCompletedEntry;
|
||||
|
||||
if (entry == null || entry.Mission == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
var influence = entry.Mission.GetInfluenceForFaction(Faction, SystemAddress);
|
||||
var influence = CompletedEntry.Mission.GetInfluenceForFaction(Faction, SystemAddress);
|
||||
|
||||
builder.AppendFormat("{0}", MissionName);
|
||||
if (influence != "") {
|
||||
|
@ -360,7 +360,9 @@ public class Report {
|
||||
if (faction.Equals(source_faction_name) && system_address == accepted_address) {
|
||||
/* This is the influence block for the origin of the mission.
|
||||
*/
|
||||
main_mission = new MissionCompleted(completed) {
|
||||
main_mission = new MissionCompleted() {
|
||||
CompletedEntry = completed,
|
||||
AcceptedEntry = accepted,
|
||||
System = accepted_system,
|
||||
Faction = source_faction_name,
|
||||
SystemAddress = accepted_address,
|
||||
|
@ -499,7 +499,9 @@ internal class MissionCompletedParser : TransactionParserPart {
|
||||
system_address == accepted_location.SystemAddress) {
|
||||
// Source and target faction are the same, and this is the block
|
||||
// for the source system. So we make a full mission completed entry.
|
||||
transactions.Add(new MissionCompleted(entry) {
|
||||
transactions.Add(new MissionCompleted() {
|
||||
CompletedEntry = entry,
|
||||
AcceptedEntry = accepted,
|
||||
System = accepted_location.StarSystem,
|
||||
Faction = source_faction_name,
|
||||
SystemAddress = accepted_location.SystemAddress,
|
||||
@ -513,6 +515,7 @@ internal class MissionCompletedParser : TransactionParserPart {
|
||||
// differs. Sometimes missions go to different systems but to
|
||||
// the same faction.
|
||||
transactions.Add(new InfluenceSupport() {
|
||||
AcceptedEntry = accepted,
|
||||
Faction = faction,
|
||||
Influence = influences.Value,
|
||||
System = system,
|
||||
|
@ -109,6 +109,11 @@ public class MissionFactionEffects {
|
||||
}
|
||||
|
||||
public class Mission : IComparable<Mission> {
|
||||
/// <summary>
|
||||
/// Passenger type for refugees
|
||||
/// </summary>
|
||||
public static readonly string PassengerTypeRefugee = "PassengerRefugee";
|
||||
|
||||
public ulong MissionID { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
@ -250,6 +255,31 @@ public class Mission : IComparable<Mission> {
|
||||
/// </summary>
|
||||
public List<MissionFactionEffects> FactionEffects { get; set; } = new List<MissionFactionEffects>();
|
||||
|
||||
|
||||
public bool IsPassengerMission {
|
||||
get {
|
||||
if (PassengerCount == null || PassengerCount == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsRescueMission {
|
||||
get {
|
||||
if (!IsPassengerMission) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (string.Compare(PassengerType, PassengerTypeRefugee) == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a friendly human-readable name for the mission. If a localised name is available
|
||||
/// it will use that, baring that it will check EnglishMissionNames for a translation, and
|
||||
|
Loading…
Reference in New Issue
Block a user