2022-11-24 19:38:19 +01:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using EDPlayerJournal.BGS;
|
|
|
|
|
using System.Linq;
|
2022-11-26 17:09:01 +01:00
|
|
|
|
using System.Windows;
|
2022-12-03 14:47:31 +01:00
|
|
|
|
using EDPlayerJournal;
|
2022-12-14 19:28:23 +01:00
|
|
|
|
using System.ComponentModel;
|
2022-11-24 19:38:19 +01:00
|
|
|
|
|
|
|
|
|
namespace EliteBGS;
|
|
|
|
|
|
2022-12-14 19:28:23 +01:00
|
|
|
|
public class UITransaction : INotifyPropertyChanged {
|
|
|
|
|
private bool isenabled = true;
|
|
|
|
|
|
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
|
|
|
|
|
|
public bool IsEnabled {
|
|
|
|
|
get { return isenabled; }
|
|
|
|
|
set {
|
|
|
|
|
isenabled = value;
|
|
|
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IsEnabled"));
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-11-24 19:38:19 +01:00
|
|
|
|
|
|
|
|
|
public bool IsExpanded { get; set; } = true;
|
|
|
|
|
|
2022-11-26 17:09:01 +01:00
|
|
|
|
public Visibility IsCombatZone {
|
|
|
|
|
get {
|
|
|
|
|
return (Transaction != null && Transaction.GetType() == typeof(CombatZone)) ? Visibility.Visible : Visibility.Hidden;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Visibility IsSellCargo {
|
|
|
|
|
get {
|
|
|
|
|
return (Transaction != null && Transaction.GetType() == typeof(SellCargo)) ? Visibility.Visible : Visibility.Hidden;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-03 14:47:31 +01:00
|
|
|
|
public Visibility IsGroundCombatZone {
|
|
|
|
|
get {
|
|
|
|
|
CombatZone combat = Transaction as CombatZone;
|
|
|
|
|
if (combat == null) {
|
|
|
|
|
return Visibility.Hidden;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.Compare(combat.Type, CombatZones.GroundCombatZone) == 0) {
|
|
|
|
|
return Visibility.Visible;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Visibility.Hidden;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-28 20:06:14 +01:00
|
|
|
|
public Visibility IsShipCombatZone {
|
|
|
|
|
get {
|
2022-11-29 16:39:20 +01:00
|
|
|
|
CombatZone combat = Transaction as CombatZone;
|
2022-11-28 20:06:14 +01:00
|
|
|
|
if (combat == null) {
|
|
|
|
|
return Visibility.Hidden;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-03 14:47:31 +01:00
|
|
|
|
if (string.Compare(combat.Type, CombatZones.ShipCombatZone) == 0) {
|
|
|
|
|
return Visibility.Visible;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Visibility.Hidden;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-03 20:42:38 +01:00
|
|
|
|
public Visibility IsAXCombatZone {
|
2022-12-03 14:47:31 +01:00
|
|
|
|
get {
|
|
|
|
|
CombatZone combat = Transaction as CombatZone;
|
|
|
|
|
if (combat == null) {
|
|
|
|
|
return Visibility.Hidden;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-03 20:42:38 +01:00
|
|
|
|
if (string.Compare(combat.Type, CombatZones.AXCombatZone) == 0) {
|
2022-11-28 20:06:14 +01:00
|
|
|
|
return Visibility.Visible;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Visibility.Hidden;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-29 16:39:20 +01:00
|
|
|
|
public bool HasSpecOps {
|
2022-11-28 20:06:14 +01:00
|
|
|
|
get {
|
2022-11-29 16:39:20 +01:00
|
|
|
|
CombatZone combat = Transaction as CombatZone;
|
2022-11-28 20:06:14 +01:00
|
|
|
|
if (combat == null) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return combat.SpecOps ?? false;
|
|
|
|
|
}
|
|
|
|
|
set {
|
2022-11-29 16:39:20 +01:00
|
|
|
|
CombatZone combat = Transaction as CombatZone;
|
2022-11-28 20:06:14 +01:00
|
|
|
|
if (combat == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
combat.SpecOps = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-29 16:39:20 +01:00
|
|
|
|
public bool HasCapitalShip {
|
2022-11-28 20:06:14 +01:00
|
|
|
|
get {
|
2022-11-29 16:39:20 +01:00
|
|
|
|
CombatZone combat = Transaction as CombatZone;
|
2022-11-28 20:06:14 +01:00
|
|
|
|
if (combat == null) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return combat.CapitalShip ?? false;
|
|
|
|
|
}
|
|
|
|
|
set {
|
2022-11-29 16:39:20 +01:00
|
|
|
|
CombatZone combat = Transaction as CombatZone;
|
2022-11-28 20:06:14 +01:00
|
|
|
|
if (combat == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
combat.CapitalShip = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-18 14:55:22 +02:00
|
|
|
|
public bool HasEnemyCaptain {
|
2022-11-28 20:06:14 +01:00
|
|
|
|
get {
|
2022-11-29 16:39:20 +01:00
|
|
|
|
CombatZone combat = Transaction as CombatZone;
|
2022-11-28 20:06:14 +01:00
|
|
|
|
if (combat == null) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-18 14:55:22 +02:00
|
|
|
|
return combat.EnemyCaptain ?? false;
|
2022-11-28 20:06:14 +01:00
|
|
|
|
}
|
|
|
|
|
set {
|
2022-11-29 16:39:20 +01:00
|
|
|
|
CombatZone combat = Transaction as CombatZone;
|
2022-11-28 20:06:14 +01:00
|
|
|
|
if (combat == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-18 14:55:22 +02:00
|
|
|
|
combat.EnemyCaptain = value;
|
2022-11-28 20:06:14 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-18 14:55:22 +02:00
|
|
|
|
public bool HasAlliedCaptain {
|
2022-11-28 20:06:14 +01:00
|
|
|
|
get {
|
2022-11-29 16:39:20 +01:00
|
|
|
|
CombatZone combat = Transaction as CombatZone;
|
2022-11-28 20:06:14 +01:00
|
|
|
|
if (combat == null) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-18 14:55:22 +02:00
|
|
|
|
return combat.AlliedCaptain ?? false;
|
2022-11-28 20:06:14 +01:00
|
|
|
|
}
|
|
|
|
|
set {
|
2022-11-29 16:39:20 +01:00
|
|
|
|
CombatZone combat = Transaction as CombatZone;
|
2022-11-28 20:06:14 +01:00
|
|
|
|
if (combat == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-18 14:55:22 +02:00
|
|
|
|
combat.AlliedCaptain = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool HasEnemyCorrespondent {
|
|
|
|
|
get {
|
|
|
|
|
CombatZone combat = Transaction as CombatZone;
|
|
|
|
|
if (combat == null) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return combat.EnemyCorrespondent ?? false;
|
|
|
|
|
}
|
|
|
|
|
set {
|
|
|
|
|
CombatZone combat = Transaction as CombatZone;
|
|
|
|
|
if (combat == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
combat.EnemyCorrespondent = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool HasAlliedCorrespondent {
|
|
|
|
|
get {
|
|
|
|
|
CombatZone combat = Transaction as CombatZone;
|
|
|
|
|
if (combat == null) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return combat.AlliedCorrespondent ?? false;
|
|
|
|
|
}
|
|
|
|
|
set {
|
|
|
|
|
CombatZone combat = Transaction as CombatZone;
|
|
|
|
|
if (combat == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
combat.AlliedCorrespondent = value;
|
2022-11-28 20:06:14 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-26 17:09:01 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Profit from selling, used in the XAML ui for binding
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Profit {
|
|
|
|
|
get {
|
|
|
|
|
SellCargo cargo = Transaction as SellCargo;
|
|
|
|
|
if (cargo == null) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
return cargo.Profit.ToString();
|
|
|
|
|
}
|
|
|
|
|
set {
|
|
|
|
|
SellCargo cargo = Transaction as SellCargo;
|
|
|
|
|
if (cargo == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
long profit_as_number = Convert.ToInt64(value);
|
|
|
|
|
cargo.Profit = profit_as_number;
|
|
|
|
|
} catch (FormatException) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-24 19:38:19 +01:00
|
|
|
|
public Transaction Transaction { get; set; }
|
|
|
|
|
|
|
|
|
|
public UITransaction() { }
|
|
|
|
|
|
|
|
|
|
public UITransaction(Transaction transaction) {
|
|
|
|
|
Transaction = transaction;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Name {
|
|
|
|
|
get { return ToString(); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string CompletedAt {
|
|
|
|
|
get { return Transaction.CompletedAt; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string ToString() {
|
|
|
|
|
return Transaction.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class Objective : IComparable<Objective> {
|
2024-04-11 16:25:20 +02:00
|
|
|
|
public bool IsEnabled { get; set; } = true;
|
2022-11-24 19:38:19 +01:00
|
|
|
|
|
|
|
|
|
public List<UITransaction> UITransactions { get; } = new List<UITransaction>();
|
|
|
|
|
|
|
|
|
|
public List<Transaction> Transactions {
|
|
|
|
|
get { return UITransactions.Select(x => x.Transaction).ToList<Transaction>(); }
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-26 17:39:31 +01:00
|
|
|
|
public Visibility HasSystem {
|
|
|
|
|
get { return string.IsNullOrEmpty(System) ? Visibility.Hidden : Visibility.Visible; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Visibility HasFaction {
|
|
|
|
|
get { return string.IsNullOrEmpty(Faction) ? Visibility.Hidden : Visibility.Visible; }
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-24 19:38:19 +01:00
|
|
|
|
public string Name {
|
|
|
|
|
get { return this.ToString(); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsExpanded { get; set; }
|
|
|
|
|
|
|
|
|
|
public void Clear() {
|
|
|
|
|
if (Transactions == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Transactions.Clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool Matches(string system, string faction) {
|
|
|
|
|
return string.Compare(system, System) == 0 &&
|
|
|
|
|
string.Compare(faction, Faction) == 0;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-03 15:01:46 +01:00
|
|
|
|
public bool Matches(string system) {
|
|
|
|
|
return string.Compare(system, System) == 0;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-24 19:38:19 +01:00
|
|
|
|
public int CompareTo(Objective other) {
|
|
|
|
|
return (other.System == System &&
|
|
|
|
|
other.Faction == Faction) ? 0 : -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsValid {
|
|
|
|
|
get { return !string.IsNullOrEmpty(System) && !string.IsNullOrEmpty(Faction); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string System { get; set; }
|
|
|
|
|
|
|
|
|
|
public string Faction { get; set; }
|
|
|
|
|
|
|
|
|
|
public override string ToString() {
|
|
|
|
|
StringBuilder str = new StringBuilder();
|
|
|
|
|
if (!string.IsNullOrEmpty(System)) {
|
|
|
|
|
str.AppendFormat("System: {0}", System);
|
2022-11-25 14:39:45 +01:00
|
|
|
|
} else {
|
|
|
|
|
str.AppendFormat("System: Unknown");
|
2022-11-24 19:38:19 +01:00
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(Faction)) {
|
|
|
|
|
if (str.Length > 0) {
|
|
|
|
|
str.Append(", ");
|
|
|
|
|
}
|
|
|
|
|
str.AppendFormat("Faction: {0}", Faction);
|
|
|
|
|
}
|
|
|
|
|
return str.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Type> EnabledOfType<Type>() where Type : Transaction {
|
|
|
|
|
return UITransactions
|
|
|
|
|
.Where(x => x.IsEnabled)
|
|
|
|
|
.Select(x => x.Transaction)
|
|
|
|
|
.OfType<Type>()
|
|
|
|
|
.ToList()
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
}
|