add a few more entries to the library

This commit is contained in:
Florian Stinglmayr 2021-09-02 16:18:02 +02:00
parent c974a9f3ac
commit 50e543d1ab
5 changed files with 102 additions and 30 deletions

20
CommitCrimeEntry.cs Normal file
View File

@ -0,0 +1,20 @@
namespace EDJournal {
public class CommitCrimeEntry : Entry {
private string crimetype = "assault";
private string faction;
private string victim;
private int bounty = 0;
public string CrimeType => crimetype;
public string Faction => faction;
public string Victim => victim;
public int Bounty => bounty;
protected override void Initialise() {
crimetype = JSON.Value<string>("CrimeType") ?? "assault";
faction = JSON.Value<string>("Faction") ?? "";
victim = JSON.Value<string>("Victim") ?? "";
bounty = JSON.Value<int?>("Bounty") ?? 0;
}
}
}

54
DiedEntry.cs Normal file
View File

@ -0,0 +1,54 @@
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
namespace EDJournal {
public class Killer {
private string name;
private string rank;
private string ship;
public string Name {
get => name;
set => name = value;
}
public string Rank {
get => rank;
set => rank = value;
}
public string Ship {
get => ship;
set => ship = value;
}
}
public class DiedEntry : Entry {
private readonly List<Killer> killers = new List<Killer>();
public List<Killer> Killers => killers;
public Killer Killer => killers.Count > 0 ? killers[0] : null;
public bool WasWing => killers.Count > 1;
protected override void Initialise() {
var wing = JSON.Value<JArray>("Killers");
if (wing != null) {
/* a wing killed us */
foreach (JObject child in wing.Children<JObject>()) {
Killer killer = new Killer {
Name = child.Value<string>("Name") ?? "",
Rank = child.Value<string>("Rank") ?? "",
Ship = child.Value<string>("Ship") ?? ""
};
killers.Add(killer);
}
} else {
/* a single ship killed us */
Killer killer = new Killer {
Name = JSON.Value<string>("KillerName") ?? "",
Rank = JSON.Value<string>("KillerRank") ?? "",
Ship = JSON.Value<string>("KillerShip") ?? ""
};
killers.Add(killer);
}
}
}
}

View File

@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
namespace EDJournal {
/// <summary>
@ -12,21 +12,23 @@ namespace EDJournal {
/// </summary>
public class Entry {
private static readonly Dictionary<string, Type> classes = new Dictionary<string, Type> {
{ Events.Bounty, typeof(BountyEntry) },
{ Events.CommitCrime, typeof(CommitCrimeEntry) },
{ Events.Died, typeof(DiedEntry) },
{ Events.Docked, typeof(DockedEntry) },
{ Events.FSDJump, typeof(FSDJumpEntry) },
{ Events.HullDamage, typeof(HullDamageEntry) },
{ Events.MarketSell, typeof(MarketSellEntry) },
{ Events.MissionAbandoned, typeof(MissionAbandonedEntry) },
{ Events.MissionAccepted, typeof(MissionAcceptedEntry) },
{ Events.MissionCompleted, typeof(MissionCompletedEntry) },
{ Events.MissionRedirected, typeof(MissionRedirectedEntry) },
{ Events.MultiSellExplorationData, typeof(MultiSellExplorationDataEntry) },
{ Events.MarketSell, typeof(MarketSellEntry) },
{ Events.SellMicroResources, typeof(SellMicroResourcesEntry) },
{ Events.RedeemVoucher, typeof(RedeemVoucherEntry) },
{ Events.Bounty, typeof(BountyEntry) },
{ Events.SellMicroResources, typeof(SellMicroResourcesEntry) },
{ Events.ShieldState, typeof(ShieldStateEntry) },
{ Events.ShipTargeted, typeof(ShipTargetedEntry) },
{ Events.UnderAttack, typeof(UnderAttackEntry) },
{ Events.ShieldState, typeof(ShieldStateEntry) },
{ Events.HullDamage, typeof(HullDamageEntry) },
};
private string eventtype = null;

View File

@ -1,23 +1,22 @@
namespace EDJournal {
public class Events {
/**
* A mission has been completed.
*/
public static readonly string MissionCompleted = "MissionCompleted";
public static readonly string MissionAccepted = "MissionAccepted";
public static readonly string MissionAbandoned = "MissionAbandoned";
public static readonly string Docked = "Docked";
public static readonly string FSDJump = "FSDJump";
public static readonly string MultiSellExplorationData = "MultiSellExplorationData";
public static readonly string MarketSell = "MarketSell";
public static readonly string SellMicroResources = "SellMicroResources";
public static readonly string RedeemVoucher = "RedeemVoucher";
public static readonly string Bounty = "Bounty";
public static readonly string ShipTargeted = "ShipTargeted";
public static readonly string ShieldState = "ShieldState";
public static readonly string MissionRedirected = "MissionRedirected";
public static readonly string UnderAttack = "UnderAttack";
public static readonly string HullDamage = "HullDamage";
public static readonly string CommitCrime = "CommitCrime";
public static readonly string Died = "Died";
public static readonly string Docked = "Docked";
public static readonly string FighterDestroyed = "FighterDestroyed";
public static readonly string FSDJump = "FSDJump";
public static readonly string HullDamage = "HullDamage";
public static readonly string MarketSell = "MarketSell";
public static readonly string MissionAbandoned = "MissionAbandoned";
public static readonly string MissionAccepted = "MissionAccepted";
public static readonly string MissionCompleted = "MissionCompleted";
public static readonly string MissionRedirected = "MissionRedirected";
public static readonly string MultiSellExplorationData = "MultiSellExplorationData";
public static readonly string RedeemVoucher = "RedeemVoucher";
public static readonly string SellMicroResources = "SellMicroResources";
public static readonly string ShieldState = "ShieldState";
public static readonly string ShipTargeted = "ShipTargeted";
public static readonly string UnderAttack = "UnderAttack";
}
}

View File

@ -36,16 +36,13 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="BountyEntry.cs" />
<Compile Include="CommitCrimeEntry.cs" />
<Compile Include="Credits.cs" />
<Compile Include="DiedEntry.cs" />
<Compile Include="DockedEntry.cs" />
<Compile Include="EliteDangerous.cs" />
<Compile Include="Entry.cs" />