using System;
using System.Linq;
namespace EDPlayerJournal.BGS;
public class CombatZone : Transaction {
///
/// Type, either on foot or ship
///
public string Type { get; set; } = CombatZones.ShipCombatZone;
///
/// Difficulty type, low, medium or high. Null means unknown.
///
public string? Grade { get; set; }
///
/// Whether spec ops were won.
///
public bool? SpecOps { get; set; }
///
/// Whether allied captain objective was won
///
public bool? AlliedCaptain { get; set; }
///
/// Whether enemy captain objective was won
///
public bool? EnemyCaptain { get; set; }
///
/// Whether the allied correspondent objective was won
///
public bool? AlliedCorrespondent { get; set; }
///
/// Whether the enemy correspondent objective was won
///
public bool? EnemyCorrespondent { get; set; }
///
/// Whether cap ship objective was won
///
public bool? CapitalShip { get; set; }
///
/// If we have a combat zone, this might point to the settlement
/// in question.
///
public string? Settlement { get; set; }
///
/// How many optional objectives were completed?
///
public int OptionalObjectivesCompleted {
get {
if (IsGround) {
return 0;
}
return new List() {
SpecOps,
AlliedCaptain,
EnemyCaptain,
AlliedCorrespondent,
EnemyCorrespondent,
CapitalShip
}
.Where(x => x != null && x == true)
.Count()
;
}
}
///
/// Returns true if it is an on foot/ground combat zone
///
public bool IsGround {
get { return string.Compare(Type, CombatZones.GroundCombatZone) == 0; }
}
///
/// Returns true if it is an on foot combat zone
///
public bool IsShip {
get { return string.Compare(Type, CombatZones.ShipCombatZone) == 0; }
}
///
/// Returns true if it is a thargoid combat zone
///
public bool IsThargoid {
get { return string.Compare(Type, CombatZones.AXCombatZone) == 0; }
}
public override int CompareTo(Transaction? obj) {
if (obj == null || obj.GetType() != typeof(CombatZone)) {
return -1;
}
CombatZone? b = obj as CombatZone;
if (b == null) {
return -1;
}
if (b.Faction != Faction || b.System != System) {
return -1; // System and faction don't match
}
if (b.Type != b.Type || b.Grade != b.Grade) {
return -1; // grade and type don't match
}
return 0;
}
public override string ToString() {
if (!string.IsNullOrEmpty(Grade)) {
return string.Format("Won {0} {1} Combat Zone", Grade, Type);
} else {
return string.Format("Won {0} Combat Zone", Type);
}
}
}