parse faction for vouchers
This commit is contained in:
parent
afcbea9ad1
commit
e26ccf51f8
@ -1,13 +1,33 @@
|
|||||||
namespace EDJournal {
|
using Newtonsoft.Json.Linq;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace EDJournal {
|
||||||
public class RedeemVoucherEntry : Entry {
|
public class RedeemVoucherEntry : Entry {
|
||||||
private int amount = 0;
|
|
||||||
private string type = null;
|
|
||||||
protected override void Initialise() {
|
protected override void Initialise() {
|
||||||
amount = JSON.Value<int>("Amount");
|
Amount = JSON.Value<int>("Amount");
|
||||||
type = JSON.Value<string>("Type");
|
Type = JSON.Value<string>("Type");
|
||||||
|
|
||||||
|
/* according to API, there should be a Factions structure */
|
||||||
|
JToken factions = JSON.GetValue("Factions");
|
||||||
|
if (factions != null) {
|
||||||
|
foreach (JObject faction in factions.Children<JObject>()) {
|
||||||
|
string faction_name = faction.Value<string>("Faction");
|
||||||
|
if (faction_name == null || faction_name.Length <= 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Factions.Add(faction_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* but there also might be just a Faction entry */
|
||||||
|
string single_faction = JSON.Value<string>("Faction");
|
||||||
|
if (single_faction != null) {
|
||||||
|
Factions.Add(single_faction);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Amount => amount;
|
public int Amount { get; set; } = 0;
|
||||||
public string Type => type;
|
public string Type { get; set; } = "Bounty";
|
||||||
|
public List<string> Factions { get; set; } = new List<string>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user