public ShipModule(string s, string sfd, string i, string ifd, bool?e, int?prior, int?ac, int?ah, double?health, long?value, double?power, JournalEngineerCraftBase.EngineeringData engineering) { Slot = s; SlotFD = sfd; Item = i; ItemFD = ifd; Enabled = e; Priority = prior; AmmoClip = ac; AmmoHopper = ah; if (health.HasValue) { Health = (int)(health * 100.0); } Value = value; Power = power; Engineering = engineering; }
public JournalLoadout(JObject evt) : base(evt, JournalTypeEnum.Loadout) { Ship = JournalFieldNaming.GetBetterShipName(evt["Ship"].Str()); ShipFD = JournalFieldNaming.NormaliseFDShipName(evt["Ship"].Str()); ShipId = evt["ShipID"].Int(); ShipName = evt["ShipName"].Str(); ShipIdent = evt["ShipIdent"].Str(); HullValue = evt["HullValue"].LongNull(); ModulesValue = evt["ModulesValue"].LongNull(); Rebuy = evt["Rebuy"].LongNull(); ShipModules = new List <ShipModule>(); JArray jmodules = (JArray)evt["Modules"]; if (jmodules != null) // paranoia { foreach (JObject jo in jmodules) { JournalEngineerCraftBase.EngineeringData engineering = null; JObject jeng = (JObject)jo["Engineering"]; if (jeng != null) { engineering = new JournalEngineerCraftBase.EngineeringData(jeng); } ShipModule module = new ShipModule(JournalFieldNaming.GetBetterSlotName(jo["Slot"].Str()), JournalFieldNaming.NormaliseFDSlotName(jo["Slot"].Str()), JournalFieldNaming.GetBetterItemNameEvents(jo["Item"].Str()), JournalFieldNaming.NormaliseFDItemName(jo["Item"].Str()), jo["On"].BoolNull(), jo["Priority"].IntNull(), jo["AmmoInClip"].IntNull(), jo["AmmoInHopper"].IntNull(), jo["Health"].DoubleNull(), jo["Value"].IntNull(), null, //power not received here engineering); ShipModules.Add(module); } ShipModules = ShipModules.OrderBy(x => x.Slot).ToList(); // sort for presentation.. } }